Re: [HACKERS] Re: your mail - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: [HACKERS] Re: your mail
Date
Msg-id 199903160216.LAA08921@srapc451.sra.co.jp
Whole thread Raw
In response to Re: your mail  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] Re: your mail
List pgsql-hackers
>Did we reject this 'unsigned' patch, folks?  I seem to remember someone
>objecting to it.
[snip]
>> ***************
>> *** 1862,1868 ****
>>   #ifdef MULTIBYTE
>>       return (c >= 0 && c <= UCHAR_MAX && isdigit(c));
>>   #else
>> !     return (isdigit(c));
>>   #endif
>>   }
>>   
>> --- 1862,1868 ----
>>   #ifdef MULTIBYTE
>>       return (c >= 0 && c <= UCHAR_MAX && isdigit(c));
>>   #else
>> !     return (isdigit((unsigned char)c));
>>   #endif
>>   }

According to the ANSI/C standard the argument to isdigit (or some
other friends) must have the value of either an unsigned char or
*EOF*. That's why the argument is typed to int, I guess. This patch
seems to break the rule?

BTW, I would like to propose yet another patches for the problem. This 
seems to work on FreeBSD and Linux. Angelos, can you test it on your
platform (is it a BSD/OS?)?
--
Tatsuo Ishii

*** regcomp.c~    Tue Sep  1 13:31:25 1998
--- regcomp.c    Thu Mar 11 16:51:28 1999
***************
*** 95,101 ****     static void p_b_eclass(struct parse * p, cset *cs);     static pg_wchar p_b_symbol(struct parse *
p);    static char p_b_coll_elem(struct parse * p, int endc);
 
!     static char othercase(int ch);     static void bothcases(struct parse * p, int ch);     static void
ordinary(structparse * p, int ch);     static void nonnewline(struct parse * p);
 
--- 95,101 ----     static void p_b_eclass(struct parse * p, cset *cs);     static pg_wchar p_b_symbol(struct parse *
p);    static char p_b_coll_elem(struct parse * p, int endc);
 
!     static unsigned char othercase(int ch);     static void bothcases(struct parse * p, int ch);     static void
ordinary(structparse * p, int ch);     static void nonnewline(struct parse * p);
 
***************
*** 1032,1049 ****  - othercase - return the case counterpart of an alphabetic  == static char othercase(int ch);  */
! static char                        /* if no counterpart, return ch */ othercase(ch) int            ch; {
assert(pg_isalpha(ch));    if (pg_isupper(ch))
 
!         return tolower(ch);     else if (pg_islower(ch))
!         return toupper(ch);     else /* peculiar, but could happen */
!         return ch; }  /*
--- 1032,1049 ----  - othercase - return the case counterpart of an alphabetic  == static char othercase(int ch);  */
! static unsigned char        /* if no counterpart, return ch */ othercase(ch) int            ch; {
assert(pg_isalpha(ch));    if (pg_isupper(ch))
 
!         return (unsigned char)tolower(ch);     else if (pg_islower(ch))
!         return (unsigned char)toupper(ch);     else /* peculiar, but could happen */
!         return (unsigned char)ch; }  /*


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: non existing table error message changed?
Next
From: "Hiroshi Inoue"
Date:
Subject: snprintf() instead of sprintf() ?