File: wncase.c

package info (click to toggle)
libwn6 6.0-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,996 kB
  • ctags: 3,938
  • sloc: ansic: 45,083; makefile: 926; csh: 274; sh: 12
file content (104 lines) | stat: -rw-r--r-- 1,736 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/****************************************************************

wn_strupcase(s)
wn_strlowcase(s)

wn_memupcase(mem,len)
wn_memlowcase(mem,len)

wn_charupcase(&c)
wn_charlowcase(&c)

****************************************************************/
/****************************************************************************

COPYRIGHT NOTICE:

  The source code in this file is provided free of charge
  to the author's consulting clients.  It is in the
  public domain and therefore may be used by anybody for
  any purpose.

AUTHOR:

  Will Naylor

****************************************************************************/
#include <ctype.h>
#include "wnlib.h"
#include "wnmap.h"

#include "wncase.h"



local char upcase_map_array[256],lowcase_map_array[256];



local void initialize(void)
{
  static bool initialized = FALSE;

  if(!initialized)
  {
    initialized = TRUE;

    wn_load_map_array(upcase_map_array,
		      "abcdefghijklmnopqrstuvwxyz",
		      "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    wn_load_map_array(lowcase_map_array,
		      "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
		      "abcdefghijklmnopqrstuvwxyz");
  }
}


void wn_memupcase(register char *string,int len)
{
  initialize();

  wn_memmap(string,len,upcase_map_array);
}


void wn_memlowcase(register char *string,int len)
{
  initialize();

  wn_memmap(string,len,lowcase_map_array);
}


void wn_strupcase(register char *string)
{
  initialize();

  wn_strmap(string,upcase_map_array);
}


void wn_strlowcase(register char *string)
{
  initialize();

  wn_strmap(string,lowcase_map_array);
}


void wn_charupcase(char *pc)
{
  initialize();

  *pc = upcase_map_array[*pc];
}


void wn_charlowcase(char *pc)
{
  initialize();

  *pc = lowcase_map_array[*pc];
}