1 /*-------------------------------------------------------------------------
4 * support routines for the lex/flex scanner, used by both the normal
5 * backend as well as the bootstrap backend
7 * Copyright (c) 1994, Regents of the University of California
11 * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.2 1996/07/23 02:23:35 scrappy Exp $
13 *-------------------------------------------------------------------------
19 #include "miscadmin.h"
20 #include "utils/elog.h"
21 #include "parser/scansup.h"
24 * Scanner error handler.
29 elog(WARN, "*** scanner error: %s\n", str);
35 * if the string passed in has escaped codes, map the escape codes to actual
38 * also, remove leading and ending quotes '"' if any
40 * the string passed in must be non-null
42 * the string returned is a pointer to static storage and should NOT
43 * be freed by the CALLER.
50 static char newStr[MAX_PARSE_BUFFER];
54 if (s == NULL || s[0] == '\0')
60 /* remove leading and trailing quotes, if any */
61 /* the normal backend lexer only accepts single quotes, but the
62 bootstrap lexer accepts double quotes */
64 if (s[0] == '"' || s[0] == '\''){
69 if (s[len-1] == delimiter)
72 serror("mismatched quote delimiters");
75 for (i = start, j = 0; i < len ; i++) {
123 s[i+k] >= '0' && s[i+k] <= '7' && k < 3;
129 octVal = strtol(octal,0,8);
130 /* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/
131 if (octVal <= 0377) {
132 newStr[j] = ((char)octVal);
140 elog (WARN, "Bad escape sequence, s[i] = %d", s[i]);