mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
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.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.33 2006/07/14 14:52:22 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.34 2006/09/22 21:39:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -183,3 +183,26 @@ truncate_identifier(char *ident, int len, bool warn)
|
||||
ident[len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* scanner_isspace() --- return TRUE if flex scanner considers char whitespace
|
||||
*
|
||||
* This should be used instead of the potentially locale-dependent isspace()
|
||||
* function when it's important to match the lexer's behavior.
|
||||
*
|
||||
* In principle we might need similar functions for isalnum etc, but for the
|
||||
* moment only isspace seems needed.
|
||||
*/
|
||||
bool
|
||||
scanner_isspace(char ch)
|
||||
{
|
||||
/* This must match scan.l's list of {space} characters */
|
||||
/* and plpgsql's scan.l as well */
|
||||
if (ch == ' ' ||
|
||||
ch == '\t' ||
|
||||
ch == '\n' ||
|
||||
ch == '\r' ||
|
||||
ch == '\f')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user