Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb65ab31

Browse files
committed
Eliminate token length assumption in scanstr().
1 parenta7fd74e commitb65ab31

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

‎src/backend/bootstrap/bootscanner.l

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.14 1999/07/17 20:16:47 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.15 1999/09/11 22:26:41 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -98,12 +98,17 @@ insert{ return(INSERT_TUPLE); }
9898
return(ID);
9999
}
100100
{id}{
101-
yylval.ival =EnterString(scanstr((char*)yytext));
101+
char *newid =scanstr((char*)yytext);
102+
yylval.ival =EnterString(newid);
103+
pfree(newid);
102104
return(ID);
103105
}
104106
{sid}{
107+
char *newid;
105108
yytext[strlen(yytext)-1] ='\0';/* strip off quotes */
106-
yylval.ival =EnterString(scanstr((char*)yytext+1));
109+
newid =scanstr((char*)yytext+1);
110+
yylval.ival =EnterString(newid);
111+
pfree(newid);
107112
yytext[strlen(yytext)] ='"';/* restore quotes */
108113
return(ID);
109114
}

‎src/backend/parser/scan.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.53 1999/09/07 00:13:27 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.54 1999/09/11 22:26:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -246,7 +246,7 @@ other.
246246
}
247247
<xq>{xqstop}{
248248
BEGIN(INITIAL);
249-
yylval.str =pstrdup(scanstr(literal));
249+
yylval.str =scanstr(literal);
250250
return SCONST;
251251
}
252252
<xq>{xqdouble}|

‎src/backend/parser/scansup.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.16 1999/07/17 20:17:27 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.17 1999/09/11 22:26:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -25,24 +25,26 @@
2525
* if the string passed in has escaped codes, map the escape codes to actual
2626
* chars
2727
*
28-
* the string returned isa pointer to static storage and should NOT
29-
*be freed by thecaller.
28+
* the string returned ispalloc'd and should eventually be pfree'd by the
29+
* caller!
3030
* ----------------
3131
*/
3232

3333
char*
3434
scanstr(char*s)
3535
{
36-
staticcharnewStr[MAX_PARSE_BUFFER];
36+
char*newStr;
3737
intlen,
3838
i,
3939
j;
4040

4141
if (s==NULL||s[0]=='\0')
42-
returns;
42+
returnpstrdup("");
4343

4444
len=strlen(s);
4545

46+
newStr=palloc(len+1);/* string cannot get longer */
47+
4648
for (i=0,j=0;i<len;i++)
4749
{
4850
if (s[i]=='\'')

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
239239
}
240240
<xq>{xqstop}{
241241
BEGIN(SQL);
242-
/* yylval.str =mm_strdup(scanstr(literal));*/
242+
/* yylval.str = scanstr(literal);*/
243243
yylval.str =mm_strdup(literal);
244244
return SCONST;
245245
}
@@ -601,7 +601,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
601601
if (strcmp(old, ptr->old) ==0)
602602
{
603603
free(ptr->new);
604-
/* ptr->new =mm_strdup(scanstr(literal));*/
604+
/* ptr->new = scanstr(literal);*/
605605
ptr->new =mm_strdup(literal);
606606
}
607607
}
@@ -611,7 +611,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
611611

612612
/* initial definition */
613613
this->old = old;
614-
/* this->new =mm_strdup(scanstr(literal));*/
614+
/* this->new = scanstr(literal);*/
615615
this->new =mm_strdup(literal);
616616
this->next = defines;
617617
defines =this;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp