mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Tweak scanner/grammar interface so that the keyword-as-identifier rules
in gram.y can make use of the keywords.c string table, instead of having their own copies of the keyword strings. This saves a few kilobytes and more importantly eliminates an opportunity for cut-and-paste errors.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.107 2002/04/21 19:21:49 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.108 2002/05/02 18:44:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -26,7 +26,7 @@
|
||||
* !!WARNING!!: This list must be sorted, because binary
|
||||
* search is used to locate entries.
|
||||
*/
|
||||
static ScanKeyword ScanKeywords[] = {
|
||||
static const ScanKeyword ScanKeywords[] = {
|
||||
/* name, value */
|
||||
{"abort", ABORT_TRANS},
|
||||
{"absolute", ABSOLUTE},
|
||||
@@ -303,14 +303,14 @@ static ScanKeyword ScanKeywords[] = {
|
||||
* keywords are to be matched in this way even though non-keyword identifiers
|
||||
* receive a different case-normalization mapping.
|
||||
*/
|
||||
ScanKeyword *
|
||||
ScanKeywordLookup(char *text)
|
||||
const ScanKeyword *
|
||||
ScanKeywordLookup(const char *text)
|
||||
{
|
||||
int len,
|
||||
i;
|
||||
char word[NAMEDATALEN];
|
||||
ScanKeyword *low;
|
||||
ScanKeyword *high;
|
||||
const ScanKeyword *low;
|
||||
const ScanKeyword *high;
|
||||
|
||||
len = strlen(text);
|
||||
/* We assume all keywords are shorter than NAMEDATALEN. */
|
||||
@@ -342,7 +342,7 @@ ScanKeywordLookup(char *text)
|
||||
high = endof(ScanKeywords) - 1;
|
||||
while (low <= high)
|
||||
{
|
||||
ScanKeyword *middle;
|
||||
const ScanKeyword *middle;
|
||||
int difference;
|
||||
|
||||
middle = low + (high - low) / 2;
|
||||
|
||||
Reference in New Issue
Block a user