diff options
| author | Tom Lane | 2006-09-22 21:39:58 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-09-22 21:39:58 +0000 |
| commit | beca984e5f1c315d02064e69861be112f5a69b3d (patch) | |
| tree | b06b0b54e649824380e3b35822c1c054dac24608 /src/interfaces | |
| parent | 6d0efd3a092ec60c7e27b53e604cbc87ba3c8e2c (diff) | |
Fix bugs in plpgsql and ecpg caused by assuming that isspace() would only
return true for exactly the characters treated as whitespace by their flex
scanners. Per report from Victor Snezhko and subsequent investigation.
Also fix a passel of unsafe usages of <ctype.h> functions, that is, ye olde
char-vs-unsigned-char issue. I won't miss <ctype.h> when we are finally
able to stop using it.
Diffstat (limited to 'src/interfaces')
| -rw-r--r-- | src/interfaces/ecpg/preproc/pgc.l | 27 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-auth.c | 4 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index e9f87fe183b..1af79f8e9e4 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.149 2006/08/18 15:59:35 meskes Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.150 2006/09/22 21:39:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -47,6 +47,7 @@ static void addlit(char *ytext, int yleng); static void addlitchar (unsigned char); static void parse_include (void); static void check_escape_warning(void); +static bool ecpg_isspace(char ch); char *token_start; int state_before; @@ -245,6 +246,9 @@ param \${integer} * did not end with a newline. * * XXX perhaps \f (formfeed) should be treated as a newline as well? + * + * XXX if you change the set of whitespace characters, fix ecpg_isspace() + * to agree. */ ccomment "//".*\n @@ -872,7 +876,7 @@ cppline {space}*#(.*\\{space})*.*{newline} * contains at least one non-space character plus the ";" */ for (i = strlen(yytext)-2; - i > 0 && isspace((unsigned char) yytext[i]); + i > 0 && ecpg_isspace(yytext[i]); i-- ) ; yytext[i+1] = '\0'; @@ -1060,7 +1064,7 @@ cppline {space}*#(.*\\{space})*.*{newline} * contains at least one non-space character plus the ";" */ for (i = strlen(yytext)-2; - i > 0 && isspace((unsigned char) yytext[i]); + i > 0 && ecpg_isspace(yytext[i]); i-- ) ; yytext[i+1] = '\0'; @@ -1252,7 +1256,7 @@ parse_include(void) * yytext contains at least one non-space character plus the ";" */ for (i = strlen(yytext)-2; - i > 0 && isspace((unsigned char) yytext[i]); + i > 0 && ecpg_isspace(yytext[i]); i--) ; @@ -1328,3 +1332,18 @@ check_escape_warning(void) mmerror (PARSE_ERROR, ET_WARNING, "nonstandard use of escape in a string literal"); warn_on_first_escape = false; /* warn only once per string */ } + +/* + * ecpg_isspace() --- return TRUE if flex scanner considers char whitespace + */ +static bool +ecpg_isspace(char ch) +{ + if (ch == ' ' || + ch == '\t' || + ch == '\n' || + ch == '\r' || + ch == '\f') + return true; + return false; +} diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index db8bbdd78da..bcc4c570bf5 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.119 2006/07/14 14:52:27 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.120 2006/09/22 21:39:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -89,7 +89,7 @@ pg_an_to_ln(char *aname) *p = '\0'; #ifdef WIN32 for (p = aname; *p; p++) - *p = pg_tolower(*p); + *p = pg_tolower((unsigned char) *p); #endif return aname; |
