summaryrefslogtreecommitdiff
path: root/src/case.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/case.c')
-rw-r--r--src/case.c72
1 files changed, 51 insertions, 21 deletions
diff --git a/src/case.c b/src/case.c
index 47eb8ed..fa5c86b 100644
--- a/src/case.c
+++ b/src/case.c
@@ -1,4 +1,5 @@
#include "case.h"
+
#include "str.h"
/**
@@ -7,7 +8,7 @@
@brief string comparison and helper functions; case insensitive
*/
-int case_diffb(register char *s,unsigned int len,register char *t)
+int case_diffb(register char *s, unsigned int len, register char *t)
{
register unsigned char x;
register unsigned char y;
@@ -15,32 +16,43 @@ int case_diffb(register char *s,unsigned int len,register char *t)
while (len > 0) {
--len;
x = *s++ - 'A';
- if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
+ if (x <= 'Z' - 'A')
+ x += 'a';
+ else
+ x += 'A';
y = *t++ - 'A';
- if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
- if (x != y)
- return ((int)(unsigned int) x) - ((int)(unsigned int) y);
+ if (y <= 'Z' - 'A')
+ y += 'a';
+ else
+ y += 'A';
+ if (x != y) return ((int)(unsigned int)x) - ((int)(unsigned int)y);
}
return 0;
}
-int case_diffs(register char *s,register char *t)
+int case_diffs(register char *s, register char *t)
{
register unsigned char x;
register unsigned char y;
for (;;) {
x = *s++ - 'A';
- if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
+ if (x <= 'Z' - 'A')
+ x += 'a';
+ else
+ x += 'A';
y = *t++ - 'A';
- if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
+ if (y <= 'Z' - 'A')
+ y += 'a';
+ else
+ y += 'A';
if (x != y) break;
if (!x) break;
}
- return ((int)(unsigned int) x) - ((int)(unsigned int) y);
+ return ((int)(unsigned int)x) - ((int)(unsigned int)y);
}
-int case_diffrs(register char *s,register char *t)
+int case_diffrs(register char *s, register char *t)
{
register unsigned char x = 0;
register unsigned char y = 0;
@@ -49,17 +61,23 @@ int case_diffrs(register char *s,register char *t)
while (lens > 0 && lent > 0) {
x = s[--lens] - 'A';
- if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
+ if (x <= 'Z' - 'A')
+ x += 'a';
+ else
+ x += 'A';
y = t[--lent] - 'A';
- if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
+ if (y <= 'Z' - 'A')
+ y += 'a';
+ else
+ y += 'A';
if (x != y) break;
if (!x) break;
if (!y) break;
}
- return ((int)(unsigned int) x) - ((int)(unsigned int) y);
+ return ((int)(unsigned int)x) - ((int)(unsigned int)y);
}
-void case_lowerb(char *s,unsigned int len)
+void case_lowerb(char *s, unsigned int len)
{
unsigned char x;
while (len > 0) {
@@ -80,7 +98,7 @@ void case_lowers(char *s)
}
}
-void case_upperb(char *s,unsigned int len)
+void case_upperb(char *s, unsigned int len)
{
unsigned char x;
while (len > 0) {
@@ -101,33 +119,45 @@ void case_uppers(char *s)
}
}
-int case_startb(register char *s,unsigned int len,register char *t)
+int case_startb(register char *s, unsigned int len, register char *t)
{
register unsigned char x;
register unsigned char y;
for (;;) {
y = *t++ - 'A';
- if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
+ if (y <= 'Z' - 'A')
+ y += 'a';
+ else
+ y += 'A';
if (!y) return 1;
if (!len) return 0;
--len;
x = *s++ - 'A';
- if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
+ if (x <= 'Z' - 'A')
+ x += 'a';
+ else
+ x += 'A';
if (x != y) return 0;
}
}
-int case_starts(register char *s,register char *t)
+int case_starts(register char *s, register char *t)
{
register unsigned char x;
register unsigned char y;
for (;;) {
x = *s++ - 'A';
- if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
+ if (x <= 'Z' - 'A')
+ x += 'a';
+ else
+ x += 'A';
y = *t++ - 'A';
- if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
+ if (y <= 'Z' - 'A')
+ y += 'a';
+ else
+ y += 'A';
if (!y) return 1;
if (x != y) return 0;
}