summaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/scan.l5
-rw-r--r--src/backend/parser/scansup.c25
2 files changed, 28 insertions, 2 deletions
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index c97c9e6ada3..303350fac9a 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -24,7 +24,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.137 2006/09/03 03:19:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.138 2006/09/22 21:39:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -145,6 +145,9 @@ static unsigned char unescape_single_char(unsigned char c);
* 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 scanner_isspace()
+ * to agree, and see also the plpgsql lexer.
*/
space [ \t\n\r\f]
diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c
index c326ef0e3ab..807338652b4 100644
--- a/src/backend/parser/scansup.c
+++ b/src/backend/parser/scansup.c
@@ -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;
+}