1 /*-------------------------------------------------------------------------
4 * support routines for the lex/flex scanner, used by both the normal
5 * backend as well as the bootstrap backend
7 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
12 * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.23 2002/09/05 00:43:07 tgl Exp $
14 *-------------------------------------------------------------------------
20 #include "miscadmin.h"
21 #include "parser/scansup.h"
26 * if the string passed in has escaped codes, map the escape codes to actual
29 * the string returned is palloc'd and should eventually be pfree'd by the
42 if (s == NULL || s[0] == '\0')
47 newStr = palloc(len + 1); /* string cannot get longer */
49 for (i = 0, j = 0; i < len; i++)
54 * Note: if scanner is working right, unescaped quotes can
55 * only appear in pairs, so there should be another character.
60 else if (s[i] == '\\')
93 s[i + k] >= '0' && s[i + k] <= '7' && k < 3;
95 octVal = (octVal << 3) + (s[i + k] - '0');
97 newStr[j] = ((char) octVal);