Last change
on this file since 664bac3 was
6b13103,
checked in by dequis <dx@…>, at 2015-01-16T19:50:23Z
|
Replace isdigit/isalpha/.../tolower/toupper with glib variants
This fixes warnings about passing signed chars to them (apparently they
are implemented as macros that do array lookups without checks in some
platforms, yay)
Specifically:
functions=isalnum|isalpha|isdigit|isspace|isxdigit|tolower|toupper
sed -ir "s/$functions/g_ascii_&/g" /*.c
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[b7d3cc34] | 1 | #include <aim.h> |
---|
| 2 | #include <ctype.h> |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * int snlen(const char *) |
---|
| 6 | * |
---|
| 7 | * This takes a screen name and returns its length without |
---|
| 8 | * spaces. If there are no spaces in the SN, then the |
---|
| 9 | * return is equal to that of strlen(). |
---|
| 10 | * |
---|
| 11 | */ |
---|
| 12 | static int aim_snlen(const char *sn) |
---|
| 13 | { |
---|
| 14 | int i = 0; |
---|
| 15 | const char *curPtr = NULL; |
---|
| 16 | |
---|
| 17 | if (!sn) |
---|
| 18 | return 0; |
---|
| 19 | |
---|
| 20 | curPtr = sn; |
---|
[5d6c178] | 21 | while ( (*curPtr) != (char) '\0') { |
---|
[b7d3cc34] | 22 | if ((*curPtr) != ' ') |
---|
| 23 | i++; |
---|
| 24 | curPtr++; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | return i; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | /* |
---|
| 31 | * int sncmp(const char *, const char *) |
---|
| 32 | * |
---|
| 33 | * This takes two screen names and compares them using the rules |
---|
| 34 | * on screen names for AIM/AOL. Mainly, this means case and space |
---|
| 35 | * insensitivity (all case differences and spacing differences are |
---|
| 36 | * ignored). |
---|
| 37 | * |
---|
| 38 | * Return: 0 if equal |
---|
| 39 | * non-0 if different |
---|
| 40 | * |
---|
| 41 | */ |
---|
| 42 | |
---|
| 43 | int aim_sncmp(const char *sn1, const char *sn2) |
---|
| 44 | { |
---|
| 45 | const char *curPtr1 = NULL, *curPtr2 = NULL; |
---|
| 46 | |
---|
| 47 | if (aim_snlen(sn1) != aim_snlen(sn2)) |
---|
| 48 | return 1; |
---|
| 49 | |
---|
| 50 | curPtr1 = sn1; |
---|
| 51 | curPtr2 = sn2; |
---|
[5d6c178] | 52 | while ( (*curPtr1 != (char) '\0') && (*curPtr2 != (char) '\0') ) { |
---|
[b7d3cc34] | 53 | if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) { |
---|
| 54 | if (*curPtr1 == ' ') |
---|
| 55 | curPtr1++; |
---|
| 56 | if (*curPtr2 == ' ') |
---|
| 57 | curPtr2++; |
---|
| 58 | } else { |
---|
[6b13103] | 59 | if ( g_ascii_toupper(*curPtr1) != g_ascii_toupper(*curPtr2)) |
---|
[b7d3cc34] | 60 | return 1; |
---|
| 61 | curPtr1++; |
---|
| 62 | curPtr2++; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* Should both be NULL */ |
---|
| 67 | if (*curPtr1 != *curPtr2) |
---|
| 68 | return 1; |
---|
| 69 | |
---|
| 70 | return 0; |
---|
| 71 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.