mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Eliminate token length assumption in scanstr().
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.53 1999/09/07 00:13:27 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.54 1999/09/11 22:26:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -246,7 +246,7 @@ other .
|
||||
}
|
||||
<xq>{xqstop} {
|
||||
BEGIN(INITIAL);
|
||||
yylval.str = pstrdup(scanstr(literal));
|
||||
yylval.str = scanstr(literal);
|
||||
return SCONST;
|
||||
}
|
||||
<xq>{xqdouble} |
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.16 1999/07/17 20:17:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.17 1999/09/11 22:26:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -25,24 +25,26 @@
|
||||
* if the string passed in has escaped codes, map the escape codes to actual
|
||||
* chars
|
||||
*
|
||||
* the string returned is a pointer to static storage and should NOT
|
||||
* be freed by the caller.
|
||||
* the string returned is palloc'd and should eventually be pfree'd by the
|
||||
* caller!
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
char *
|
||||
scanstr(char *s)
|
||||
{
|
||||
static char newStr[MAX_PARSE_BUFFER];
|
||||
char *newStr;
|
||||
int len,
|
||||
i,
|
||||
j;
|
||||
|
||||
if (s == NULL || s[0] == '\0')
|
||||
return s;
|
||||
return pstrdup("");
|
||||
|
||||
len = strlen(s);
|
||||
|
||||
newStr = palloc(len+1); /* string cannot get longer */
|
||||
|
||||
for (i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
if (s[i] == '\'')
|
||||
|
||||
Reference in New Issue
Block a user