Change 11966 by ams@ams-lustre on 2001/09/09 21:06:13
Subject: Re: [ID 20010810.011] 'use v2b' not allowed with strict
From: Rafael Garcia-Suarez <[EMAIL PROTECTED]>
Date: Mon, 13 Aug 2001 22:51:59 +0200
Message-ID: <20010813225159.C6681@rafael>
(Applied with several tweaks.)
Affected files ...
... //depot/perl/embed.h#285 edit
... //depot/perl/embed.pl#271 edit
... //depot/perl/proto.h#330 edit
... //depot/perl/toke.c#383 edit
Differences ...
==== //depot/perl/embed.h#285 (text+w) ====
Index: perl/embed.h
--- perl/embed.h.~1~ Sun Sep 9 15:15:05 2001
+++ perl/embed.h Sun Sep 9 15:15:05 2001
@@ -2646,7 +2646,7 @@
#if defined(PERL_IN_TOKE_C) || defined(PERL_DECL_PROT)
#define check_uni() S_check_uni(aTHX)
#define force_next(a) S_force_next(aTHX_ a)
-#define force_version(a) S_force_version(aTHX_ a)
+#define force_version(a,b) S_force_version(aTHX_ a,b)
#define force_word(a,b,c,d,e) S_force_word(aTHX_ a,b,c,d,e)
#define tokeq(a) S_tokeq(aTHX_ a)
#define pending_ident() S_pending_ident(aTHX)
==== //depot/perl/embed.pl#271 (xtext) ====
Index: perl/embed.pl
--- perl/embed.pl.~1~ Sun Sep 9 15:15:05 2001
+++ perl/embed.pl Sun Sep 9 15:15:05 2001
@@ -2260,7 +2260,7 @@
#if defined(PERL_IN_TOKE_C) || defined(PERL_DECL_PROT)
s |void |check_uni
s |void |force_next |I32 type
-s |char* |force_version |char *start
+s |char* |force_version |char *start|int guessing
s |char* |force_word |char *start|int token|int check_keyword \
|int allow_pack|int allow_tick
s |SV* |tokeq |SV *sv
==== //depot/perl/proto.h#330 (text+w) ====
Index: perl/proto.h
--- perl/proto.h.~1~ Sun Sep 9 15:15:05 2001
+++ perl/proto.h Sun Sep 9 15:15:05 2001
@@ -1248,7 +1248,7 @@
#if defined(PERL_IN_TOKE_C) || defined(PERL_DECL_PROT)
STATIC void S_check_uni(pTHX);
STATIC void S_force_next(pTHX_ I32 type);
-STATIC char* S_force_version(pTHX_ char *start);
+STATIC char* S_force_version(pTHX_ char *start, int guessing);
STATIC char* S_force_word(pTHX_ char *start, int token, int check_keyword, int
allow_pack, int allow_tick);
STATIC SV* S_tokeq(pTHX_ SV *sv);
STATIC int S_pending_ident(pTHX);
==== //depot/perl/toke.c#383 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~ Sun Sep 9 15:15:05 2001
+++ perl/toke.c Sun Sep 9 15:15:05 2001
@@ -864,10 +864,13 @@
/*
* S_force_version
* Forces the next token to be a version number.
+ * If the next token appears to be an invalid version number, (e.g. "v2b"),
+ * and if "guessing" is TRUE, then no new token is created (and the caller
+ * must use an alternative parsing method).
*/
STATIC char *
-S_force_version(pTHX_ char *s)
+S_force_version(pTHX_ char *s, int guessing)
{
OP *version = Nullop;
char *d;
@@ -878,7 +881,8 @@
if (*d == 'v')
d++;
if (isDIGIT(*d)) {
- for (; isDIGIT(*d) || *d == '_' || *d == '.'; d++);
+ while (isDIGIT(*d) || *d == '_' || *d == '.')
+ d++;
if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) {
SV *ver;
s = scan_num(s, &yylval);
@@ -890,13 +894,15 @@
SvNOK_on(ver); /* hint that it is a version */
}
}
+ else if (guessing)
+ return s;
}
/* NOTE: The parser sees the package name and the VERSION swapped */
PL_nextval[PL_nexttoke].opval = version;
force_next(WORD);
- return (s);
+ return s;
}
/*
@@ -4534,7 +4540,7 @@
if (PL_expect != XSTATE)
yyerror("\"no\" not allowed in expression");
s = force_word(s,WORD,FALSE,TRUE,FALSE);
- s = force_version(s);
+ s = force_version(s, FALSE);
yylval.ival = 0;
OPERATOR(USE);
@@ -4686,10 +4692,12 @@
case KEY_require:
s = skipspace(s);
- if (isDIGIT(*s) || (*s == 'v' && isDIGIT(s[1]))) {
- s = force_version(s);
+ if (isDIGIT(*s)) {
+ s = force_version(s, FALSE);
}
- else {
+ else if (*s != 'v' || !isDIGIT(s[1])
+ || (s = force_version(s, TRUE), *s == 'v'))
+ {
*PL_tokenbuf = '\0';
s = force_word(s,WORD,TRUE,TRUE,FALSE);
if (isIDFIRST_lazy_if(PL_tokenbuf,UTF))
@@ -5049,15 +5057,19 @@
yyerror("\"use\" not allowed in expression");
s = skipspace(s);
if (isDIGIT(*s) || (*s == 'v' && isDIGIT(s[1]))) {
- s = force_version(s);
+ s = force_version(s, TRUE);
if (*s == ';' || (s = skipspace(s), *s == ';')) {
PL_nextval[PL_nexttoke].opval = Nullop;
force_next(WORD);
}
+ else if (*s == 'v') {
+ s = force_word(s,WORD,FALSE,TRUE,FALSE);
+ s = force_version(s, FALSE);
+ }
}
else {
s = force_word(s,WORD,FALSE,TRUE,FALSE);
- s = force_version(s);
+ s = force_version(s, FALSE);
}
yylval.ival = 1;
OPERATOR(USE);
End of Patch.