From: Gurusamy Sarathy Date: Wed, 26 Nov 1997 01:50:37 +0000 (+0000) Subject: [win32] Fix for C bug: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15f0808c5d67b362ecb8b59cf6a3ed61fbf51bbf;p=p5sagit%2Fp5-mst-13.2.git [win32] Fix for C bug: From: Gurusamy Sarathy Message-Id: <199711011946.OAA18882@aatma.engin.umich.edu> Subject: [PATCH] Re: Sort grammar bug Date: Sat, 01 Nov 1997 14:46:35 -0500 ------ From: Hugo van der Sanden Message-Id: <199711021247.MAA01743@crypt.compulink.co.uk> Subject: Re: Sort grammar bug Date: Sun, 02 Nov 1997 12:47:51 +0000 p4raw-id: //depot/win32/perl@312 --- diff --git a/t/op/sort.t b/t/op/sort.t index c792bbb..a6829e0 100755 --- a/t/op/sort.t +++ b/t/op/sort.t @@ -2,7 +2,7 @@ # $RCSfile: sort.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:24 $ -print "1..19\n"; +print "1..21\n"; sub backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 } @@ -91,3 +91,14 @@ print ($@ =~ /redefine active sort/ ? "ok 18\n" : "not ok 18\n"); }; eval { @b = sort twoface 4,1 }; print $@ ? "$@" : "not ok 19\n"; + +eval <<'CODE'; + my @result = sort main'backwards 'one', 'two'; +CODE +print $@ ? "not ok 20\n# $@" : "ok 20\n"; + +eval <<'CODE'; + # "sort 'one', 'two'" should not try to parse "'one" as a sort sub + my @result = sort 'one', 'two'; +CODE +print $@ ? "not ok 21\n# $@" : "ok 21\n"; diff --git a/toke.c b/toke.c index 95be7df..dbb273a 100644 --- a/toke.c +++ b/toke.c @@ -500,7 +500,7 @@ force_next(I32 type) } static char * -force_word(register char *start, int token, int check_keyword, int allow_pack, int allow_tick) +force_word(register char *start, int token, int check_keyword, int allow_pack, int allow_initial_tick) { register char *s; STRLEN len; @@ -509,7 +509,7 @@ force_word(register char *start, int token, int check_keyword, int allow_pack, i s = start; if (isIDFIRST(*s) || (allow_pack && *s == ':') || - (allow_tick && *s == '\'') ) + (allow_initial_tick && *s == '\'') ) { s = scan_word(s, tokenbuf, sizeof tokenbuf, allow_pack, &len); if (check_keyword && keyword(tokenbuf, len)) @@ -3542,7 +3542,7 @@ yylex(void) if (*s == ';' || *s == ')') /* probably a close */ croak("sort is now a reserved word"); expect = XTERM; - s = force_word(s,WORD,TRUE,TRUE,TRUE); + s = force_word(s,WORD,TRUE,TRUE,FALSE); LOP(OP_SORT,XREF); case KEY_split: