@@ -253,17 +253,18 @@ metaphone(PG_FUNCTION_ARGS)
253
253
* accesssing the array directly... */
254
254
255
255
/* Look at the next letter in the word */
256
- #define Next_Letter (toupper(word[w_idx+1]))
256
+ #define Next_Letter (toupper((unsigned char) word[w_idx+1]))
257
257
/* Look at the current letter in the word */
258
- #define Curr_Letter (toupper(word[w_idx]))
258
+ #define Curr_Letter (toupper((unsigned char) word[w_idx]))
259
259
/* Go N letters back. */
260
- #define Look_Back_Letter (n ) (w_idx >= n ? toupper(word[w_idx-n]) : '\0')
260
+ #define Look_Back_Letter (n ) \
261
+ (w_idx >= (n) ? toupper((unsigned char) word[w_idx-(n)]) : '\0')
261
262
/* Previous letter. I dunno, should this return null on failure? */
262
263
#define Prev_Letter (Look_Back_Letter(1))
263
264
/* Look two letters down. It makes sure you don't walk off the string. */
264
- #define After_Next_Letter (Next_Letter != '\0' ? toupper(word[w_idx+2]) \
265
- : '\0')
266
- #define Look_Ahead_Letter (n ) ( toupper(Lookahead(word+w_idx, n) ))
265
+ #define After_Next_Letter \
266
+ (Next_Letter != '\0' ? toupper((unsigned char) word[w_idx+2]) : '\0')
267
+ #define Look_Ahead_Letter (n ) toupper((unsigned char) Lookahead(word+w_idx, n))
267
268
268
269
269
270
/* Allows us to safely look ahead an arbitrary # of letters */
@@ -291,7 +292,7 @@ Lookahead(char *word, int how_far)
291
292
#define Phone_Len (p_idx)
292
293
293
294
/* Note is a letter is a 'break' in the word */
294
- #define Isbreak (c ) (!isalpha(c ))
295
+ #define Isbreak (c ) (!isalpha((unsigned char) (c) ))
295
296
296
297
297
298
int
@@ -336,7 +337,7 @@ _metaphone(
336
337
337
338
/*-- The first phoneme has to be processed specially. --*/
338
339
/* Find our first letter */
339
- for (; !isalpha (Curr_Letter ); w_idx ++ )
340
+ for (; !isalpha (( unsigned char ) ( Curr_Letter ) ); w_idx ++ )
340
341
{
341
342
/* On the off chance we were given nothing but crap... */
342
343
if (Curr_Letter == '\0' )
@@ -435,7 +436,7 @@ _metaphone(
435
436
*/
436
437
437
438
/* Ignore non-alphas */
438
- if (!isalpha (Curr_Letter ))
439
+ if (!isalpha (( unsigned char ) ( Curr_Letter ) ))
439
440
continue ;
440
441
441
442
/* Drop duplicates, except CC */
0 commit comments