fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
case.c
Go to the documentation of this file.
1#include "case.h"
2#include "str.h"
3
10int case_diffb(char *s,unsigned int len,char *t)
11{
12 unsigned char x;
13 unsigned char y;
14
15 while (len > 0) {
16 --len;
17 x = *s++ - 'A';
18 if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
19 y = *t++ - 'A';
20 if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
21 if (x != y)
22 return ((int)(unsigned int) x) - ((int)(unsigned int) y);
23 }
24 return 0;
25}
26
27int case_diffs(char *s,char *t)
28{
29 unsigned char x;
30 unsigned char y;
31
32 for (;;) {
33 x = *s++ - 'A';
34 if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
35 y = *t++ - 'A';
36 if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
37 if (x != y) break;
38 if (!x) break;
39 }
40 return ((int)(unsigned int) x) - ((int)(unsigned int) y);
41}
42
43int case_diffrs(char *s,char *t)
44{
45 unsigned char x = 0;
46 unsigned char y = 0;
47 unsigned int lens = str_len(s);
48 unsigned int lent = str_len(t);
49
50 while (lens > 0 && lent > 0) {
51 x = s[--lens] - 'A';
52 if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
53 y = t[--lent] - 'A';
54 if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
55 if (x != y) break;
56 if (!x) break;
57 if (!y) break;
58 }
59 return ((int)(unsigned int) x) - ((int)(unsigned int) y);
60}
61
62void case_lowerb(char *s,unsigned int len)
63{
64 unsigned char x;
65 while (len > 0) {
66 --len;
67 x = *s - 'A';
68 if (x <= 'Z' - 'A') *s = x + 'a';
69 ++s;
70 }
71}
72
73void case_lowers(char *s)
74{
75 unsigned char x;
76 while ((x = *s)) {
77 x -= 'A';
78 if (x <= 'Z' - 'A') *s = x + 'a';
79 ++s;
80 }
81}
82
83void case_upperb(char *s,unsigned int len)
84{
85 unsigned char x;
86 while (len > 0) {
87 --len;
88 x = *s - 'a';
89 if (x <= 'z' - 'a') *s = x + 'A';
90 ++s;
91 }
92}
93
94void case_uppers(char *s)
95{
96 unsigned char x;
97 while ((x = *s)) {
98 x -= 'a';
99 if (x <= 'z' - 'a') *s = x + 'A';
100 ++s;
101 }
102}
103
104int case_startb(char *s,unsigned int len,char *t)
105{
106 unsigned char x;
107 unsigned char y;
108
109 for (;;) {
110 y = *t++ - 'A';
111 if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
112 if (!y) return 1;
113 if (!len) return 0;
114 --len;
115 x = *s++ - 'A';
116 if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
117 if (x != y) return 0;
118 }
119}
120
121int case_starts(char *s,char *t)
122{
123 unsigned char x;
124 unsigned char y;
125
126 for (;;) {
127 x = *s++ - 'A';
128 if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
129 y = *t++ - 'A';
130 if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
131 if (!y) return 1;
132 if (x != y) return 0;
133 }
134}
void case_upperb(char *s, unsigned int len)
Definition: case.c:83
int case_diffs(char *s, char *t)
Definition: case.c:27
int case_starts(char *s, char *t)
Definition: case.c:121
int case_diffb(char *s, unsigned int len, char *t)
Definition: case.c:10
int case_startb(char *s, unsigned int len, char *t)
Definition: case.c:104
void case_lowers(char *s)
Definition: case.c:73
void case_lowerb(char *s, unsigned int len)
Definition: case.c:62
int case_diffrs(char *s, char *t)
Definition: case.c:43
void case_uppers(char *s)
Definition: case.c:94
unsigned int str_len(const char *)
Definition: str.c:68