summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1997-03-09 11:57:19 +1200
committerChip Salzenberg <chip@atlantic.net>1997-03-09 11:57:19 +1200
commit68dc074516a6859e3424b48d1647bcb08b1a1a7d (patch)
tree125011c6d8e4a04727ff97166dc19199809958e4 /toke.c
parent699e6cd4da8c333ef83554732e73ab6734463b5d (diff)
downloadperl-68dc074516a6859e3424b48d1647bcb08b1a1a7d.tar.gz
[inseparable changes from match from perl-5.003_93 to perl-5.003_94]
BUILD PROCESS Subject: Don't use db 2.x, we're not yet ready for it From: Paul Marquess <pmarquess@bfsec.bt.co.uk> Files: Configure Subject: Warn if #! command is longer than 32 chars From: Chip Salzenberg <chip@perl.com> Files: Configure Subject: patches re perl -wc install{perl,man} Date: Tue, 11 Mar 97 13:13:16 GMT From: Robin Barker <rmb1@cise.npl.co.uk> Files: installman installperl I got the new installhtml from CPAN (TOMC/scripts/pod2html-v2.0beta.shar.gz) I had problems getting the system call to splitpod at line 376 to work. 1. splitroot was not being found 2. splitroot was not finding its library 3. I changed htmlroot to podroot at line 175 to match the documentation. p5p-msgid: 3180.9703270906@tempest.cise.npl.co.uk private-msgid: 21544.9703111313@tempest.cise.npl.co.uk Subject: 3_93 doesn't install pods Date: Sun, 16 Mar 1997 02:21:35 -0500 From: Spider Boardman <spider@orb.nashua.nh.us> Files: installperl Msg-ID: 199703160721.CAA08339@Orb.Nashua.NH.US (applied based on p5p patch as commit 43506a616735d616e03d277d64fbae1e864024bf) Subject: When installing, use File::Copy instead of `cp` From: Chip Salzenberg <chip@perl.com> Files: installperl Subject: Make hint files' warnings more visible Date: Thu, 20 Mar 1997 23:18:03 +0100 (MET) From: Hallvard B Furuseth <h.b.furuseth@usit.uio.no> Files: hints/3b1.sh hints/apollo.sh hints/cxux.sh hints/dcosx.sh hints/dgux.sh hints/esix4.sh hints/freebsd.sh hints/hpux.sh hints/irix_4.sh hints/mips.sh hints/next_3_0.sh hints/os2.sh hints/qnx.sh hints/sco_2_3_3.sh hints/sco_2_3_4.sh hints/solaris_2.sh hints/ultrix_4.sh hints/utekv.sh private-msgid: 199703202218.XAA09041@bombur2.uio.no CORE LANGUAGE CHANGES Subject: Defer creation of array and hash elements as parameters From: Chip Salzenberg <chip@perl.com> Files: dump.c global.sym mg.c op.c op.h perl.h pp.c pp_hot.c proto.h sv.c Subject: New special literal: __PACKAGE__ From: Chip Salzenberg <chip@perl.com> Files: keywords.pl pod/perldata.pod toke.c Subject: Abort compilation at C<BEGIN{}> or C<use> after errors From: Chip Salzenberg <chip@perl.com> Files: op.c pod/perldiag.pod t/pragma/subs.t Subject: allow C<substr 'hello', -10> Date: Mon, 10 Mar 1997 15:55:44 -0800 From: David Dyck <dcd@tc.fluke.com> Files: pp.c Msg-ID: 97Mar10.155517pst.35716-2@gateway.fluke.com (applied based on p5p patch as commit 77f720bf92f3d0100352416caeedd57936807ff2) Subject: Regularize C<x % y>, esp. when y is negative From: Chip Salzenberg <chip@perl.com> Files: pp.c Subject: Flush before C<flock(FOO, LOCK_UN)> From: Chip Salzenberg <chip@perl.com> Files: pod/perldelta.pod pod/perlfunc.pod pp_sys.c Subject: Close loopholes in prototype mismatch warning From: Chip Salzenberg <chip@perl.com> Files: op.c sv.c toke.c Subject: Warn on C<while ($x = each %y) {}> From: Chip Salzenberg <chip@perl.com> Files: op.c pod/perldiag.pod Subject: Don't warn on C<print $fh func()> From: Chip Salzenberg <chip@perl.com> Files: toke.c CORE PORTABILITY Subject: Don't say 'static var = 1' Date: Sun, 9 Mar 1997 15:19:57 +0200 (EET) From: Jarkko Hietaniemi <jhi@iki.fi> Files: malloc.c private-msgid: 199703091319.PAA24714@alpha.hut.fi Subject: HP/UX hint comments Date: Fri, 21 Mar 1997 15:43:07 -0500 (EST) From: Andy Dougherty <doughera@fractal.phys.lafayette.edu> Files: hints/hpux.sh private-msgid: Pine.SOL.3.95q.970321153918.28770B-100000@fractal.lafayette. Subject: VMS update Date: Tue, 11 Mar 1997 22:00:55 -0500 (EST) From: Charles Bailey <bailey@hmivax.humgen.upenn.edu> Files: lib/ExtUtils/MM_VMS.pm lib/Test/Harness.pm t/op/taint.t utils/perlbug.PL vms/descrip.mms Msg-ID: 1997Mar11.220056.1873182@hmivax.humgen.upenn.edu (applied based on p5p patch as commit 2b5725676da60b49978f38b85bb7f8ee20b4cb55) Subject: vmsish.t and related patches Date: Fri, 21 Mar 1997 01:32:47 -0500 (EST) From: Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU> Files: MANIFEST perl.h vms/descrip.mms vms/ext/vmsish.t vms/vms.c private-msgid: 01IGQW3IP1KK005VFB@hmivax.humgen.upenn.edu Subject: Win32 update (four patches) From: Gurusamy Sarathy <gsar@engin.umich.edu> Files: MANIFEST README.win32 lib/AutoSplit.pm lib/Cwd.pm lib/ExtUtils/Command.pm lib/ExtUtils/Install.pm lib/ExtUtils/MM_OS2.pm lib/ExtUtils/MM_Unix.pm lib/ExtUtils/MM_Win32.pm lib/ExtUtils/MakeMaker.pm lib/ExtUtils/Mksymlists.pm lib/File/Basename.pm lib/File/Path.pm mg.c t/comp/cpp.t t/comp/script.t t/harness t/io/argv.t t/io/dup.t t/io/fs.t t/io/inplace.t t/lib/filehand.t t/lib/io_dup.t t/lib/io_sel.t t/lib/io_taint.t t/op/closure.t t/op/exec.t t/op/glob.t t/op/goto.t t/op/magic.t t/op/misc.t t/op/rand.t t/op/split.t t/op/stat.t t/op/sysio.t t/op/taint.t t/pragma/strict.t t/pragma/subs.t t/pragma/warning.t util.c win32/* DOCUMENTATION Subject: perlfaq.pod Date: Mon, 17 Mar 1997 16:01:40 -0700 From: Tom Christiansen <tchrist@jhereg.perl.com> Files: MANIFEST pod/Makefile pod/buildtoc pod/perl.pod pod/perlfaq*.pod pod/roffitall private-msgid: 199703172301.QAA12566@jhereg.perl.com Subject: *.pod changes based on the FAQ Date: Mon, 17 Mar 1997 09:50:14 -0700 (MST) From: Nat Torkington <gnat@frii.com> Files: pod/perldata.pod pod/perlfunc.pod pod/perlipc.pod pod/perlop.pod pod/perlre.pod pod/perlrun.pod pod/perlsec.pod pod/perlvar.pod Msg-ID: 199703171650.JAA02655@elara.frii.com (applied based on p5p patch as commit 3c10ad8e31f7d77e71c048b1746912f41cb540f0) Subject: Document that $. is not reset on implicit open From: Chip Salzenberg <chip@perl.com> Files: pod/perldelta.pod Subject: Re: Embedding success with _93 Date: Tue, 11 Mar 1997 17:55:05 -0500 From: Doug MacEachern <dougm@opengroup.org> Files: pod/perldelta.pod Msg-ID: 199703112255.RAA22775@postman.osf.org (applied based on p5p patch as commit 63a6ff3a1dc8d86edb4d8a7ec1548205e32a7114) Subject: Patch to document illegal characters Date: Fri, 14 Mar 1997 09:08:10 -0800 (PST) From: Tom Phoenix <rootbeer@teleport.com> Files: pod/perldiag.pod pod/perltrap.pod private-msgid: Pine.GSO.3.96.970314090558.15346J-100000@kelly.teleport.com Subject: Document trap with //o and closures Date: Mon, 10 Mar 1997 18:08:08 -0500 (EST) From: Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU> Files: pod/perltrap.pod Msg-ID: 01IGCHWRNSEU00661G@hmivax.humgen.upenn.edu (applied based on p5p patch as commit a54cb1465fdb400848f23705a6f130bb5c34ab70) Subject: Illegal character in input Date: Mon, 10 Mar 1997 15:21:21 -0800 (PST) From: Tom Phoenix <rootbeer@teleport.com> Files: pod/perldiag.pod private-msgid: Pine.GSO.3.95q.970310151512.22489a-100000@kelly.teleport.com Subject: Patch for docs Re: Lost backslash Date: Wed, 19 Mar 1997 07:28:57 -0800 (PST) From: Tom Phoenix <rootbeer@teleport.com> Files: pod/perlop.pod private-msgid: Pine.GSO.3.96.970319071438.24834G-100000@kelly.teleport.com Subject: XSUB's doc fix Date: Mon, 10 Mar 1997 11:42:06 -0500 From: Roderick Schertler <roderick@argon.org> Files: pod/perlcall.pod pod/perlguts.pod pod/perlxstut.pod Msg-ID: 28804.858012126@eeyore.ibcinc.com (applied based on p5p patch as commit 5f43237038ea7a4151d3bf65aeeecd56ceb78a6a) Subject: Document return from do FILE Date: Tue, 18 Mar 1997 14:50:10 +0000 From: "M.J.T. Guy" <mjtg@cus.cam.ac.uk> Files: pod/perlfunc.pod Msg-ID: E0w70DK-0001yJ-00@ursa.cus.cam.ac.uk (applied based on p5p patch as commit ba8d5fb439878113de8abc9b52d2af237d30fb3c) Subject: Document $^M in perlvar Date: Thu, 20 Mar 97 21:08:33 GMT From: Robin Barker <rmb1@cise.npl.co.uk> Files: pod/perlvar.pod private-msgid: 6153.9703202108@tempest.cise.npl.co.uk Subject: typos in pods of 5.003_93 Date: 19 Mar 1997 10:39:38 -0600 From: Jim Meyering <meyering@asic.sc.ti.com> Files: pod/perlfunc.pod pod/perlguts.pod pod/perlre.pod pod/perltoot.pod pod/perlxs.pod Msg-ID: wpgendbzvhx.fsf@asic.sc.ti.com (applied based on p5p patch as commit 76a9873e006cf8f48f57062b2a0dd40b5ed45a95) Subject: Re: Updates to pod punctuations Date: Fri, 14 Mar 1997 17:00:12 -0500 From: Larry W. Virden <lvirden@cas.org> Files: pod/*.pod private-msgid: 9703141700.AA22911@cas.org Subject: clarify example in perlfunc Date: Thu, 20 Mar 1997 19:46:01 +0200 (EET) From: Jarkko Hietaniemi <jhi@iki.fi> Files: pod/perlfunc.pod private-msgid: 199703201746.TAA25195@alpha.hut.fi Subject: Regularize headings in DB_File documentation From: Chip Salzenberg <chip@perl.com> Files: ext/DB_File/DB_File.pm LIBRARY AND EXTENSIONS Subject: New module: autouse.pm Date: Thu, 20 Mar 1997 19:34:30 -0500 (EST) From: Ilya Zakharevich <ilya@math.ohio-state.edu> Files: MANIFEST lib/autouse.pm Msg-ID: 199703210034.TAA13469@monk.mps.ohio-state.edu (applied based on p5p patch as commit 6757905eccb6dd0440ef65e8128a277a20f7d943) Subject: Refresh DB_File to 1.12 Date: Wed, 12 Mar 97 15:51:14 GMT From: Paul Marquess <pmarquess@bfsec.bt.co.uk> Files: ext/DB_File/DB_File.pm ext/DB_File/DB_File.xs Msg-ID: 9703121551.AA07435@claudius.bfsec.bt.co.uk (applied based on p5p patch as commit b3deed9189f963e9994815307931f9084f60d1d9) Subject: In File::Path, some systems can't remove read-only files From: Chip Salzenberg <chip@perl.com> Files: lib/File/Path.pm Subject: Fix bugs revealed by prototype warnings From: Chip Salzenberg <chip@perl.com> Files: ext/Opcode/Opcode.pm lib/ExtUtils/MakeMaker.pm lib/Getopt/Long.pm Subject: Problems with SKIP in makemaker Date: Thu, 20 Mar 1997 23:13:31 -0500 (EST) From: Ilya Zakharevich <ilya@math.ohio-state.edu> Files: lib/ExtUtils/MM_Unix.pm Msg-ID: 199703210413.XAA21601@monk.mps.ohio-state.edu (applied based on p5p patch as commit 970322a2e8024294ada6e8d1a027cb98f1f48ee3) Subject: In Exporter, don't C<require Carp> at file scope From: Chip Salzenberg <chip@perl.com> Files: lib/Exporter.pm Subject: fix for Exporter's $SIG{__WARN__} handler Date: Thu, 13 Mar 1997 18:40:51 -0500 From: Roderick Schertler <roderick@argon.org> Files: lib/Exporter.pm Msg-ID: 2282.858296451@eeyore.ibcinc.com (applied based on p5p patch as commit 2768ea1aeef34f42d096f198fbe629c8374ca429) Subject: Don't try to substr() refs in Carp From: Chip Salzenberg <chip@perl.com> Files: lib/Carp.pm Subject: Re: NUL in die and other messages Date: Fri, 21 Mar 1997 09:58:17 +0000 From: "M.J.T. Guy" <mjtg@cus.cam.ac.uk> Files: lib/Carp.pm Msg-ID: E0w815V-0005xs-00@ursa.cus.cam.ac.uk (applied based on p5p patch as commit 52a267c574cb66c4bc35601dcf148a1d7a3bc557) OTHER CORE CHANGES Subject: Guard against buffer overflow in yyerror() and related funcs From: Chip Salzenberg <chip@perl.com> Files: toke.c Subject: For bin compat, rename calllist() and he_{,delay}free From: Chip Salzenberg <chip@perl.com> Files: global.sym hv.c op.c perl.c pod/perlguts.pod proto.h Subject: Fix C<print> on tied default handle From: Chip Salzenberg <chip@perl.com> Files: pp_hot.c Subject: Fix C<local($a, undef, $b) = (1,2,3)> From: Chip Salzenberg <chip@perl.com> Files: op.c Subject: Improve diagnostic on C<@a++>, C<--%a>, @a =~ s/a/b/ From: Chip Salzenberg <chip@perl.com> Files: pp.c pp_hot.c Subject: Don't warn on C<$x{y} .= "z"> when %x is tied From: Chip Salzenberg <chip@perl.com> Files: pp_hot.c Subject: Eliminate 'unreachable code' warnings From: Chip Salzenberg <chip@perl.com> Files: ext/POSIX/POSIX.xs mg.c pp_ctl.c toke.c Subject: printf format corrections for -DDEBUGGING Date: Wed, 19 Mar 1997 12:42:50 -0500 From: Roderick Schertler <roderick@argon.org> Files: doop.c malloc.c op.c pp_ctl.c regexec.c sv.c x2p/str.c x2p/util.c Msg-ID: 26592.858793370@eeyore.ibcinc.com (applied based on p5p patch as commit e125f273e351a19a92b69d6244af55abbbf0a26d) Subject: Warn about missing -DMULTIPLICITY if likely a problem Date: Wed, 19 Mar 1997 18:45:53 -0500 From: Doug MacEachern <dougm@opengroup.org> Files: perl.c Msg-ID: 199703192345.SAA15070@postman.osf.org (applied based on p5p patch as commit 71aeea1753924e6e19c2461e241e3f7d8a570e90)
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c88
1 files changed, 65 insertions, 23 deletions
diff --git a/toke.c b/toke.c
index 8c3454a23e..f9e3b07af3 100644
--- a/toke.c
+++ b/toke.c
@@ -157,12 +157,15 @@ no_op(what, s)
char *what;
char *s;
{
- char tmpbuf[128];
char *oldbp = bufptr;
bool is_first = (oldbufptr == linestart);
+ char *msg;
+
bufptr = s;
- sprintf(tmpbuf, "%s found where operator expected", what);
- yywarn(tmpbuf);
+ New(890, msg, strlen(what) + 40, char);
+ sprintf(msg, "%s found where operator expected", what);
+ yywarn(msg);
+ Safefree(msg);
if (is_first)
warn("\t(Missing semicolon on previous line?)\n");
else if (oldoldbufptr && isIDFIRST(*oldoldbufptr)) {
@@ -1385,9 +1388,7 @@ yylex()
s = bufptr;
Aop(OP_CONCAT);
}
- else
- return yylex();
- break;
+ return yylex();
case LEX_INTERPENDMAYBE:
if (intuit_more(bufptr)) {
@@ -1920,7 +1921,6 @@ yylex()
else
lex_brackstack[lex_brackets++] = XOPERATOR;
OPERATOR(HASHBRACK);
- break;
case XOPERATOR:
while (s < bufend && (*s == ' ' || *s == '\t'))
s++;
@@ -2233,6 +2233,17 @@ yylex()
expect = XTERM; /* e.g. print $fh "foo" */
else if (strchr("&*<%", *s) && isIDFIRST(s[1]))
expect = XTERM; /* e.g. print $fh &sub */
+ else if (isIDFIRST(*s)) {
+ char tmpbuf[1024];
+ scan_word(s, tmpbuf, TRUE, &len);
+ if (keyword(tmpbuf, len))
+ expect = XTERM; /* e.g. print $fh length() */
+ else {
+ GV *gv = gv_fetchpv(tmpbuf, FALSE, SVt_PVCV);
+ if (gv && GvCVu(gv))
+ expect = XTERM; /* e.g. print $fh subr() */
+ }
+ }
else if (isDIGIT(*s))
expect = XTERM; /* e.g. print $fh 3 */
else if (*s == '.' && isDIGIT(s[1]))
@@ -2641,15 +2652,21 @@ yylex()
TOKEN(WORD);
}
+ case KEY___FILE__:
case KEY___LINE__:
- case KEY___FILE__: {
if (tokenbuf[2] == 'L')
(void)sprintf(tokenbuf,"%ld",(long)curcop->cop_line);
else
strcpy(tokenbuf, SvPVX(GvSV(curcop->cop_filegv)));
yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(tokenbuf,0));
TERM(THING);
- }
+
+ case KEY___PACKAGE__:
+ yylval.opval = (OP*)newSVOP(OP_CONST, 0,
+ (curstash
+ ? newSVsv(curstname)
+ : &sv_undef));
+ TERM(THING);
case KEY___DATA__:
case KEY___END__: {
@@ -3432,6 +3449,8 @@ yylex()
/* Look for a prototype */
if (*s == '(') {
+ char *p;
+
s = scan_str(s);
if (!s) {
if (lex_stuff)
@@ -3439,6 +3458,16 @@ yylex()
lex_stuff = Nullsv;
croak("Prototype not terminated");
}
+ /* strip spaces */
+ d = SvPVX(lex_stuff);
+ tmp = 0;
+ for (p = d; *p; ++p) {
+ if (!isSPACE(*p))
+ d[tmp++] = *p;
+ }
+ d[tmp] = '\0';
+ SvCUR(lex_stuff) = tmp;
+
nexttoke++;
nextval[1] = nextval[0];
nexttype[1] = nexttype[0];
@@ -3613,8 +3642,9 @@ I32 len;
switch (*d) {
case '_':
if (d[1] == '_') {
- if (strEQ(d,"__LINE__")) return -KEY___LINE__;
if (strEQ(d,"__FILE__")) return -KEY___FILE__;
+ if (strEQ(d,"__LINE__")) return -KEY___LINE__;
+ if (strEQ(d,"__PACKAGE__")) return -KEY___PACKAGE__;
if (strEQ(d,"__DATA__")) return KEY___DATA__;
if (strEQ(d,"__END__")) return KEY___END__;
}
@@ -5136,40 +5166,52 @@ int
yyerror(s)
char *s;
{
- char tmpbuf[258];
- char *tname = tmpbuf;
+ char wbuf[40];
+ char *where = NULL;
+ char *context = NULL;
+ int contlen = -1;
if (bufptr > oldoldbufptr && bufptr - oldoldbufptr < 200 &&
oldoldbufptr != oldbufptr && oldbufptr != bufptr) {
while (isSPACE(*oldoldbufptr))
oldoldbufptr++;
- sprintf(tname,"near \"%.*s\"",bufptr - oldoldbufptr, oldoldbufptr);
+ context = oldoldbufptr;
+ contlen = bufptr - oldoldbufptr;
}
else if (bufptr > oldbufptr && bufptr - oldbufptr < 200 &&
oldbufptr != bufptr) {
while (isSPACE(*oldbufptr))
oldbufptr++;
- sprintf(tname,"near \"%.*s\"",bufptr - oldbufptr, oldbufptr);
+ context = oldbufptr;
+ contlen = bufptr - oldbufptr;
}
else if (yychar > 255)
- tname = "next token ???";
+ where = "next token ???";
else if (!yychar || (yychar == ';' && !rsfp))
- (void)strcpy(tname,"at EOF");
+ where = "at EOF";
else if ((yychar & 127) == 127) {
if (lex_state == LEX_NORMAL ||
(lex_state == LEX_KNOWNEXT && lex_defer == LEX_NORMAL))
- (void)strcpy(tname,"at end of line");
+ where = "at end of line";
else if (lex_inpat)
- (void)strcpy(tname,"within pattern");
+ where = "within pattern";
else
- (void)strcpy(tname,"within string");
+ where = "within string";
}
else if (yychar < 32)
- (void)sprintf(tname,"next char ^%c",toCTRL(yychar));
+ (void)sprintf(where = wbuf, "next char ^%c", toCTRL(yychar));
+ else if (isPRINT_LC(yychar))
+ (void)sprintf(where = wbuf, "next char %c", yychar);
+ else
+ (void)sprintf(where = wbuf, "next char \\%03o", yychar & 255);
+ if (contlen == -1)
+ contlen = strlen(where);
+ (void)sprintf(buf, "%s at %s line %d, ",
+ s, SvPVX(GvSV(curcop->cop_filegv)), curcop->cop_line);
+ if (context)
+ (void)sprintf(buf+strlen(buf), "near \"%.*s\"\n", contlen, context);
else
- (void)sprintf(tname,"next char %c",yychar);
- (void)sprintf(buf, "%s at %s line %d, %s\n",
- s,SvPVX(GvSV(curcop->cop_filegv)),curcop->cop_line,tname);
+ (void)sprintf(buf+strlen(buf), "%s\n", where);
if (multi_start < multi_end && (U32)(curcop->cop_line - multi_end) <= 1) {
sprintf(buf+strlen(buf),
" (Might be a runaway multi-line %c%c string starting on line %ld)\n",