summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorRoca, Ignasi <ignasi.roca@fujitsu.siemens.es>2000-10-20 15:17:27 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2000-10-20 20:44:31 +0000
commitb73d6f5067e468c85b81d9c800ab577f770b45b3 (patch)
tree26fbd8edbcc23dfd82cd6a2bf06816b43348391c /toke.c
parent20141f0ebfa7c09c3e5e502bba1c4e6e40b3072c (diff)
downloadperl-b73d6f5067e468c85b81d9c800ab577f770b45b3.tar.gz
Make scan_num() reëntrant, as suggested in
Subject: [PATCH perl@7229] Rentrant parser and yylex() Message-ID: <5930DC161690D211966700902715754702DA09CD@madt009a.siemens.es> p4raw-id: //depot/perl@7382
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/toke.c b/toke.c
index 2f8f015788..2ec1f8cb30 100644
--- a/toke.c
+++ b/toke.c
@@ -848,7 +848,7 @@ S_force_version(pTHX_ char *s)
for (; isDIGIT(*d) || *d == '_' || *d == '.'; d++);
if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) {
SV *ver;
- s = scan_num(s);
+ s = scan_num(s, &yylval);
version = yylval.opval;
ver = cSVOPx(version)->op_sv;
if (SvPOK(ver) && !SvNIOK(ver)) {
@@ -2071,20 +2071,15 @@ Perl_yylex(pTHX_ YYSTYPE *lvalp, int *lcharp)
Perl_yylex(pTHX)
#endif
{
-
+ dTHR;
int r;
#ifdef USE_PURE_BISON
-/* increment level and store the argument pointers */
- yyactlevel++;
- if (yyactlevel >= YYMAXLEVEL) {
-/* What to do ??? */
- }
yylval_pointer[yyactlevel] = lvalp;
yychar_pointer[yyactlevel] = lcharp;
- /* Save last pointer at the bottom */
- yylval_pointer[0] = lvalp;
- yychar_pointer[0] = lcharp;
+ yyactlevel++;
+ if (yyactlevel >= YYMAXLEVEL)
+ Perl_croak(aTHX_ "panic: YYMAXLEVEL");
#endif
r = S_syylex(aTHX);
@@ -3549,7 +3544,7 @@ S_syylex(pTHX) /* need to be separate from yylex for reentrancy */
/* FALL THROUGH */
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- s = scan_num(s);
+ s = scan_num(s, &yylval);
if (PL_expect == XOPERATOR)
no_op("Number",s);
TERM(THING);
@@ -3619,7 +3614,7 @@ S_syylex(pTHX) /* need to be separate from yylex for reentrancy */
while (isDIGIT(*start) || *start == '_')
start++;
if (*start == '.' && isDIGIT(start[1])) {
- s = scan_num(s);
+ s = scan_num(s, &yylval);
TERM(THING);
}
/* avoid v123abc() or $h{v1}, allow C<print v10;> */
@@ -3630,7 +3625,7 @@ S_syylex(pTHX) /* need to be separate from yylex for reentrancy */
gv = gv_fetchpv(s, FALSE, SVt_PVCV);
*start = c;
if (!gv) {
- s = scan_num(s);
+ s = scan_num(s, &yylval);
TERM(THING);
}
}
@@ -6739,7 +6734,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
*/
char *
-Perl_scan_num(pTHX_ char *start)
+Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
{
register char *s = start; /* current position in buffer */
register char *d; /* destination in temp buffer */
@@ -7152,9 +7147,9 @@ vstring:
/* make the op for the constant and return */
if (sv)
- yylval.opval = newSVOP(OP_CONST, 0, sv);
+ lvalp->opval = newSVOP(OP_CONST, 0, sv);
else
- yylval.opval = Nullop;
+ lvalp->opval = Nullop;
return s;
}