diff options
| author | Tom Lane | 2001-12-30 23:09:42 +0000 |
|---|---|---|
| committer | Tom Lane | 2001-12-30 23:09:42 +0000 |
| commit | ee051baeac9dce2dbfd5da50da21ae425b548c43 (patch) | |
| tree | e1e24cb9f15642b9359eaf9bf6f8940bf9f76efc /contrib/fuzzystrmatch | |
| parent | e7d9a6bf630e8784fc1723d138e4e4e973550017 (diff) | |
Make sure that all <ctype.h> routines are called with unsigned char
values; it's not portable to call them with signed chars. I recall doing
this for the last release, but a few more uncasted calls have snuck in.
Diffstat (limited to 'contrib/fuzzystrmatch')
| -rw-r--r-- | contrib/fuzzystrmatch/fuzzystrmatch.c | 19 | ||||
| -rw-r--r-- | contrib/fuzzystrmatch/fuzzystrmatch.h | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c index 3f863a4fa9..fbb16f66b3 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.c +++ b/contrib/fuzzystrmatch/fuzzystrmatch.c @@ -253,17 +253,18 @@ metaphone(PG_FUNCTION_ARGS) * accesssing the array directly... */ /* Look at the next letter in the word */ -#define Next_Letter (toupper(word[w_idx+1])) +#define Next_Letter (toupper((unsigned char) word[w_idx+1])) /* Look at the current letter in the word */ -#define Curr_Letter (toupper(word[w_idx])) +#define Curr_Letter (toupper((unsigned char) word[w_idx])) /* Go N letters back. */ -#define Look_Back_Letter(n) (w_idx >= n ? toupper(word[w_idx-n]) : '\0') +#define Look_Back_Letter(n) \ + (w_idx >= (n) ? toupper((unsigned char) word[w_idx-(n)]) : '\0') /* Previous letter. I dunno, should this return null on failure? */ #define Prev_Letter (Look_Back_Letter(1)) /* Look two letters down. It makes sure you don't walk off the string. */ -#define After_Next_Letter (Next_Letter != '\0' ? toupper(word[w_idx+2]) \ - : '\0') -#define Look_Ahead_Letter(n) (toupper(Lookahead(word+w_idx, n))) +#define After_Next_Letter \ + (Next_Letter != '\0' ? toupper((unsigned char) word[w_idx+2]) : '\0') +#define Look_Ahead_Letter(n) toupper((unsigned char) Lookahead(word+w_idx, n)) /* Allows us to safely look ahead an arbitrary # of letters */ @@ -291,7 +292,7 @@ Lookahead(char *word, int how_far) #define Phone_Len (p_idx) /* Note is a letter is a 'break' in the word */ -#define Isbreak(c) (!isalpha(c)) +#define Isbreak(c) (!isalpha((unsigned char) (c))) int @@ -336,7 +337,7 @@ _metaphone( /*-- The first phoneme has to be processed specially. --*/ /* Find our first letter */ - for (; !isalpha(Curr_Letter); w_idx++) + for (; !isalpha((unsigned char) (Curr_Letter)); w_idx++) { /* On the off chance we were given nothing but crap... */ if (Curr_Letter == '\0') @@ -435,7 +436,7 @@ _metaphone( */ /* Ignore non-alphas */ - if (!isalpha(Curr_Letter)) + if (!isalpha((unsigned char) (Curr_Letter))) continue; /* Drop duplicates, except CC */ diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.h b/contrib/fuzzystrmatch/fuzzystrmatch.h index 23e5e57d92..59e0d9258c 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.h +++ b/contrib/fuzzystrmatch/fuzzystrmatch.h @@ -153,7 +153,7 @@ char _codes[26] = { }; -#define ENCODE(c) (isalpha(c) ? _codes[((toupper(c)) - 'A')] : 0) +#define ENCODE(c) (isalpha((unsigned char) (c)) ? _codes[((toupper((unsigned char) (c))) - 'A')] : 0) #define isvowel(c) (ENCODE(c) & 1) /* AEIOU */ |
