Commit | Line | Data |
---|---|---|
a0d0e21e | 1 | /* toke.c |
a687059c | 2 | * |
4bb101f2 | 3 | * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
b94e2f88 | 4 | * 2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others |
a687059c | 5 | * |
d48672a2 LW |
6 | * You may distribute under the terms of either the GNU General Public |
7 | * License or the Artistic License, as specified in the README file. | |
378cc40b | 8 | * |
a0d0e21e LW |
9 | */ |
10 | ||
11 | /* | |
12 | * "It all comes from here, the stench and the peril." --Frodo | |
378cc40b LW |
13 | */ |
14 | ||
9cbb5ea2 GS |
15 | /* |
16 | * This file is the lexer for Perl. It's closely linked to the | |
4e553d73 | 17 | * parser, perly.y. |
ffb4593c NT |
18 | * |
19 | * The main routine is yylex(), which returns the next token. | |
20 | */ | |
21 | ||
378cc40b | 22 | #include "EXTERN.h" |
864dbfa3 | 23 | #define PERL_IN_TOKE_C |
378cc40b | 24 | #include "perl.h" |
378cc40b | 25 | |
12fbd33b DM |
26 | #define yychar (*PL_yycharp) |
27 | #define yylval (*PL_yylvalp) | |
d3b6f988 | 28 | |
0bd48802 | 29 | static const char ident_too_long[] = "Identifier too long"; |
c445ea15 | 30 | static const char commaless_variable_list[] = "comma-less variable list"; |
8903cb82 | 31 | |
acfe0abc | 32 | static void restore_rsfp(pTHX_ void *f); |
6e3aabd6 | 33 | #ifndef PERL_NO_UTF16_FILTER |
acfe0abc GS |
34 | static I32 utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen); |
35 | static I32 utf16rev_textfilter(pTHX_ int idx, SV *sv, int maxlen); | |
6e3aabd6 | 36 | #endif |
51371543 | 37 | |
9059aa12 LW |
38 | #define XFAKEBRACK 128 |
39 | #define XENUMMASK 127 | |
40 | ||
39e02b42 JH |
41 | #ifdef USE_UTF8_SCRIPTS |
42 | # define UTF (!IN_BYTES) | |
2b9d42f0 | 43 | #else |
746b446a | 44 | # define UTF ((PL_linestr && DO_UTF8(PL_linestr)) || (PL_hints & HINT_UTF8)) |
2b9d42f0 | 45 | #endif |
a0ed51b3 | 46 | |
61f0cdd9 | 47 | /* In variables named $^X, these are the legal values for X. |
2b92dfce GS |
48 | * 1999-02-27 mjd-perl-patch@plover.com */ |
49 | #define isCONTROLVAR(x) (isUPPER(x) || strchr("[\\]^_?", (x))) | |
50 | ||
bf4acbe4 GS |
51 | /* On MacOS, respect nonbreaking spaces */ |
52 | #ifdef MACOS_TRADITIONAL | |
53 | #define SPACE_OR_TAB(c) ((c)==' '||(c)=='\312'||(c)=='\t') | |
54 | #else | |
55 | #define SPACE_OR_TAB(c) ((c)==' '||(c)=='\t') | |
56 | #endif | |
57 | ||
ffb4593c NT |
58 | /* LEX_* are values for PL_lex_state, the state of the lexer. |
59 | * They are arranged oddly so that the guard on the switch statement | |
79072805 LW |
60 | * can get by with a single comparison (if the compiler is smart enough). |
61 | */ | |
62 | ||
fb73857a | 63 | /* #define LEX_NOTPARSING 11 is done in perl.h. */ |
64 | ||
b6007c36 DM |
65 | #define LEX_NORMAL 10 /* normal code (ie not within "...") */ |
66 | #define LEX_INTERPNORMAL 9 /* code within a string, eg "$foo[$x+1]" */ | |
67 | #define LEX_INTERPCASEMOD 8 /* expecting a \U, \Q or \E etc */ | |
68 | #define LEX_INTERPPUSH 7 /* starting a new sublex parse level */ | |
69 | #define LEX_INTERPSTART 6 /* expecting the start of a $var */ | |
70 | ||
71 | /* at end of code, eg "$x" followed by: */ | |
72 | #define LEX_INTERPEND 5 /* ... eg not one of [, { or -> */ | |
73 | #define LEX_INTERPENDMAYBE 4 /* ... eg one of [, { or -> */ | |
74 | ||
75 | #define LEX_INTERPCONCAT 3 /* expecting anything, eg at start of | |
76 | string or after \E, $foo, etc */ | |
77 | #define LEX_INTERPCONST 2 /* NOT USED */ | |
78 | #define LEX_FORMLINE 1 /* expecting a format line */ | |
79 | #define LEX_KNOWNEXT 0 /* next token known; just return it */ | |
80 | ||
79072805 | 81 | |
bbf60fe6 | 82 | #ifdef DEBUGGING |
27da23d5 | 83 | static const char* const lex_state_names[] = { |
bbf60fe6 DM |
84 | "KNOWNEXT", |
85 | "FORMLINE", | |
86 | "INTERPCONST", | |
87 | "INTERPCONCAT", | |
88 | "INTERPENDMAYBE", | |
89 | "INTERPEND", | |
90 | "INTERPSTART", | |
91 | "INTERPPUSH", | |
92 | "INTERPCASEMOD", | |
93 | "INTERPNORMAL", | |
94 | "NORMAL" | |
95 | }; | |
96 | #endif | |
97 | ||
79072805 LW |
98 | #ifdef ff_next |
99 | #undef ff_next | |
d48672a2 LW |
100 | #endif |
101 | ||
79072805 | 102 | #include "keywords.h" |
fe14fcc3 | 103 | |
ffb4593c NT |
104 | /* CLINE is a macro that ensures PL_copline has a sane value */ |
105 | ||
ae986130 LW |
106 | #ifdef CLINE |
107 | #undef CLINE | |
108 | #endif | |
57843af0 | 109 | #define CLINE (PL_copline = (CopLINE(PL_curcop) < PL_copline ? CopLINE(PL_curcop) : PL_copline)) |
3280af22 | 110 | |
ffb4593c NT |
111 | /* |
112 | * Convenience functions to return different tokens and prime the | |
9cbb5ea2 | 113 | * lexer for the next token. They all take an argument. |
ffb4593c NT |
114 | * |
115 | * TOKEN : generic token (used for '(', DOLSHARP, etc) | |
116 | * OPERATOR : generic operator | |
117 | * AOPERATOR : assignment operator | |
118 | * PREBLOCK : beginning the block after an if, while, foreach, ... | |
119 | * PRETERMBLOCK : beginning a non-code-defining {} block (eg, hash ref) | |
120 | * PREREF : *EXPR where EXPR is not a simple identifier | |
121 | * TERM : expression term | |
122 | * LOOPX : loop exiting command (goto, last, dump, etc) | |
123 | * FTST : file test operator | |
124 | * FUN0 : zero-argument function | |
2d2e263d | 125 | * FUN1 : not used, except for not, which isn't a UNIOP |
ffb4593c NT |
126 | * BOop : bitwise or or xor |
127 | * BAop : bitwise and | |
128 | * SHop : shift operator | |
129 | * PWop : power operator | |
9cbb5ea2 | 130 | * PMop : pattern-matching operator |
ffb4593c NT |
131 | * Aop : addition-level operator |
132 | * Mop : multiplication-level operator | |
133 | * Eop : equality-testing operator | |
e5edeb50 | 134 | * Rop : relational operator <= != gt |
ffb4593c NT |
135 | * |
136 | * Also see LOP and lop() below. | |
137 | */ | |
138 | ||
998054bd | 139 | #ifdef DEBUGGING /* Serve -DT. */ |
f5bd084c | 140 | # define REPORT(retval) tokereport((I32)retval) |
998054bd | 141 | #else |
bbf60fe6 | 142 | # define REPORT(retval) (retval) |
998054bd SC |
143 | #endif |
144 | ||
bbf60fe6 DM |
145 | #define TOKEN(retval) return ( PL_bufptr = s, REPORT(retval)) |
146 | #define OPERATOR(retval) return (PL_expect = XTERM, PL_bufptr = s, REPORT(retval)) | |
147 | #define AOPERATOR(retval) return ao((PL_expect = XTERM, PL_bufptr = s, REPORT(retval))) | |
148 | #define PREBLOCK(retval) return (PL_expect = XBLOCK,PL_bufptr = s, REPORT(retval)) | |
149 | #define PRETERMBLOCK(retval) return (PL_expect = XTERMBLOCK,PL_bufptr = s, REPORT(retval)) | |
150 | #define PREREF(retval) return (PL_expect = XREF,PL_bufptr = s, REPORT(retval)) | |
151 | #define TERM(retval) return (CLINE, PL_expect = XOPERATOR, PL_bufptr = s, REPORT(retval)) | |
152 | #define LOOPX(f) return (yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)LOOPEX)) | |
153 | #define FTST(f) return (yylval.ival=f, PL_expect=XTERMORDORDOR, PL_bufptr=s, REPORT((int)UNIOP)) | |
154 | #define FUN0(f) return (yylval.ival=f, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC0)) | |
155 | #define FUN1(f) return (yylval.ival=f, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC1)) | |
156 | #define BOop(f) return ao((yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)BITOROP))) | |
157 | #define BAop(f) return ao((yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)BITANDOP))) | |
158 | #define SHop(f) return ao((yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)SHIFTOP))) | |
159 | #define PWop(f) return ao((yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)POWOP))) | |
160 | #define PMop(f) return(yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)MATCHOP)) | |
161 | #define Aop(f) return ao((yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)ADDOP))) | |
162 | #define Mop(f) return ao((yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)MULOP))) | |
163 | #define Eop(f) return (yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)EQOP)) | |
164 | #define Rop(f) return (yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)RELOP)) | |
2f3197b3 | 165 | |
a687059c LW |
166 | /* This bit of chicanery makes a unary function followed by |
167 | * a parenthesis into a function with one argument, highest precedence. | |
6f33ba73 RGS |
168 | * The UNIDOR macro is for unary functions that can be followed by the // |
169 | * operator (such as C<shift // 0>). | |
a687059c | 170 | */ |
376fcdbf AL |
171 | #define UNI2(f,x) { \ |
172 | yylval.ival = f; \ | |
173 | PL_expect = x; \ | |
174 | PL_bufptr = s; \ | |
175 | PL_last_uni = PL_oldbufptr; \ | |
176 | PL_last_lop_op = f; \ | |
177 | if (*s == '(') \ | |
178 | return REPORT( (int)FUNC1 ); \ | |
179 | s = skipspace(s); \ | |
180 | return REPORT( *s=='(' ? (int)FUNC1 : (int)UNIOP ); \ | |
181 | } | |
6f33ba73 RGS |
182 | #define UNI(f) UNI2(f,XTERM) |
183 | #define UNIDOR(f) UNI2(f,XTERMORDORDOR) | |
a687059c | 184 | |
376fcdbf AL |
185 | #define UNIBRACK(f) { \ |
186 | yylval.ival = f; \ | |
187 | PL_bufptr = s; \ | |
188 | PL_last_uni = PL_oldbufptr; \ | |
189 | if (*s == '(') \ | |
190 | return REPORT( (int)FUNC1 ); \ | |
191 | s = skipspace(s); \ | |
192 | return REPORT( (*s == '(') ? (int)FUNC1 : (int)UNIOP ); \ | |
193 | } | |
79072805 | 194 | |
9f68db38 | 195 | /* grandfather return to old style */ |
3280af22 | 196 | #define OLDLOP(f) return(yylval.ival=f,PL_expect = XTERM,PL_bufptr = s,(int)LSTOP) |
79072805 | 197 | |
8fa7f367 JH |
198 | #ifdef DEBUGGING |
199 | ||
bbf60fe6 DM |
200 | /* how to interpret the yylval associated with the token */ |
201 | enum token_type { | |
202 | TOKENTYPE_NONE, | |
203 | TOKENTYPE_IVAL, | |
204 | TOKENTYPE_OPNUM, /* yylval.ival contains an opcode number */ | |
205 | TOKENTYPE_PVAL, | |
206 | TOKENTYPE_OPVAL, | |
207 | TOKENTYPE_GVVAL | |
208 | }; | |
209 | ||
27da23d5 JH |
210 | static struct debug_tokens { const int token, type; const char *name; } |
211 | const debug_tokens[] = | |
9041c2e3 | 212 | { |
bbf60fe6 DM |
213 | { ADDOP, TOKENTYPE_OPNUM, "ADDOP" }, |
214 | { ANDAND, TOKENTYPE_NONE, "ANDAND" }, | |
215 | { ANDOP, TOKENTYPE_NONE, "ANDOP" }, | |
216 | { ANONSUB, TOKENTYPE_IVAL, "ANONSUB" }, | |
217 | { ARROW, TOKENTYPE_NONE, "ARROW" }, | |
218 | { ASSIGNOP, TOKENTYPE_OPNUM, "ASSIGNOP" }, | |
219 | { BITANDOP, TOKENTYPE_OPNUM, "BITANDOP" }, | |
220 | { BITOROP, TOKENTYPE_OPNUM, "BITOROP" }, | |
221 | { COLONATTR, TOKENTYPE_NONE, "COLONATTR" }, | |
222 | { CONTINUE, TOKENTYPE_NONE, "CONTINUE" }, | |
0d863452 | 223 | { DEFAULT, TOKENTYPE_NONE, "DEFAULT" }, |
bbf60fe6 DM |
224 | { DO, TOKENTYPE_NONE, "DO" }, |
225 | { DOLSHARP, TOKENTYPE_NONE, "DOLSHARP" }, | |
226 | { DORDOR, TOKENTYPE_NONE, "DORDOR" }, | |
227 | { DOROP, TOKENTYPE_OPNUM, "DOROP" }, | |
228 | { DOTDOT, TOKENTYPE_IVAL, "DOTDOT" }, | |
229 | { ELSE, TOKENTYPE_NONE, "ELSE" }, | |
230 | { ELSIF, TOKENTYPE_IVAL, "ELSIF" }, | |
231 | { EQOP, TOKENTYPE_OPNUM, "EQOP" }, | |
232 | { FOR, TOKENTYPE_IVAL, "FOR" }, | |
233 | { FORMAT, TOKENTYPE_NONE, "FORMAT" }, | |
234 | { FUNC, TOKENTYPE_OPNUM, "FUNC" }, | |
235 | { FUNC0, TOKENTYPE_OPNUM, "FUNC0" }, | |
236 | { FUNC0SUB, TOKENTYPE_OPVAL, "FUNC0SUB" }, | |
237 | { FUNC1, TOKENTYPE_OPNUM, "FUNC1" }, | |
238 | { FUNCMETH, TOKENTYPE_OPVAL, "FUNCMETH" }, | |
0d863452 | 239 | { GIVEN, TOKENTYPE_IVAL, "GIVEN" }, |
bbf60fe6 DM |
240 | { HASHBRACK, TOKENTYPE_NONE, "HASHBRACK" }, |
241 | { IF, TOKENTYPE_IVAL, "IF" }, | |
242 | { LABEL, TOKENTYPE_PVAL, "LABEL" }, | |
243 | { LOCAL, TOKENTYPE_IVAL, "LOCAL" }, | |
244 | { LOOPEX, TOKENTYPE_OPNUM, "LOOPEX" }, | |
245 | { LSTOP, TOKENTYPE_OPNUM, "LSTOP" }, | |
246 | { LSTOPSUB, TOKENTYPE_OPVAL, "LSTOPSUB" }, | |
247 | { MATCHOP, TOKENTYPE_OPNUM, "MATCHOP" }, | |
248 | { METHOD, TOKENTYPE_OPVAL, "METHOD" }, | |
249 | { MULOP, TOKENTYPE_OPNUM, "MULOP" }, | |
250 | { MY, TOKENTYPE_IVAL, "MY" }, | |
251 | { MYSUB, TOKENTYPE_NONE, "MYSUB" }, | |
252 | { NOAMP, TOKENTYPE_NONE, "NOAMP" }, | |
253 | { NOTOP, TOKENTYPE_NONE, "NOTOP" }, | |
254 | { OROP, TOKENTYPE_IVAL, "OROP" }, | |
255 | { OROR, TOKENTYPE_NONE, "OROR" }, | |
256 | { PACKAGE, TOKENTYPE_NONE, "PACKAGE" }, | |
257 | { PMFUNC, TOKENTYPE_OPVAL, "PMFUNC" }, | |
258 | { POSTDEC, TOKENTYPE_NONE, "POSTDEC" }, | |
259 | { POSTINC, TOKENTYPE_NONE, "POSTINC" }, | |
260 | { POWOP, TOKENTYPE_OPNUM, "POWOP" }, | |
261 | { PREDEC, TOKENTYPE_NONE, "PREDEC" }, | |
262 | { PREINC, TOKENTYPE_NONE, "PREINC" }, | |
263 | { PRIVATEREF, TOKENTYPE_OPVAL, "PRIVATEREF" }, | |
264 | { REFGEN, TOKENTYPE_NONE, "REFGEN" }, | |
265 | { RELOP, TOKENTYPE_OPNUM, "RELOP" }, | |
266 | { SHIFTOP, TOKENTYPE_OPNUM, "SHIFTOP" }, | |
267 | { SUB, TOKENTYPE_NONE, "SUB" }, | |
268 | { THING, TOKENTYPE_OPVAL, "THING" }, | |
269 | { UMINUS, TOKENTYPE_NONE, "UMINUS" }, | |
270 | { UNIOP, TOKENTYPE_OPNUM, "UNIOP" }, | |
271 | { UNIOPSUB, TOKENTYPE_OPVAL, "UNIOPSUB" }, | |
272 | { UNLESS, TOKENTYPE_IVAL, "UNLESS" }, | |
273 | { UNTIL, TOKENTYPE_IVAL, "UNTIL" }, | |
274 | { USE, TOKENTYPE_IVAL, "USE" }, | |
0d863452 | 275 | { WHEN, TOKENTYPE_IVAL, "WHEN" }, |
bbf60fe6 DM |
276 | { WHILE, TOKENTYPE_IVAL, "WHILE" }, |
277 | { WORD, TOKENTYPE_OPVAL, "WORD" }, | |
278 | { 0, TOKENTYPE_NONE, 0 } | |
279 | }; | |
280 | ||
281 | /* dump the returned token in rv, plus any optional arg in yylval */ | |
998054bd | 282 | |
bbf60fe6 | 283 | STATIC int |
f5bd084c | 284 | S_tokereport(pTHX_ I32 rv) |
bbf60fe6 DM |
285 | { |
286 | if (DEBUG_T_TEST) { | |
bfed75c6 | 287 | const char *name = Nullch; |
bbf60fe6 | 288 | enum token_type type = TOKENTYPE_NONE; |
f54cb97a | 289 | const struct debug_tokens *p; |
396482e1 | 290 | SV* const report = newSVpvs("<== "); |
bbf60fe6 | 291 | |
f54cb97a | 292 | for (p = debug_tokens; p->token; p++) { |
bbf60fe6 DM |
293 | if (p->token == (int)rv) { |
294 | name = p->name; | |
295 | type = p->type; | |
296 | break; | |
297 | } | |
298 | } | |
299 | if (name) | |
54667de8 | 300 | Perl_sv_catpv(aTHX_ report, name); |
bbf60fe6 DM |
301 | else if ((char)rv > ' ' && (char)rv < '~') |
302 | Perl_sv_catpvf(aTHX_ report, "'%c'", (char)rv); | |
303 | else if (!rv) | |
396482e1 | 304 | sv_catpvs(report, "EOF"); |
bbf60fe6 DM |
305 | else |
306 | Perl_sv_catpvf(aTHX_ report, "?? %"IVdf, (IV)rv); | |
307 | switch (type) { | |
308 | case TOKENTYPE_NONE: | |
309 | case TOKENTYPE_GVVAL: /* doesn't appear to be used */ | |
310 | break; | |
311 | case TOKENTYPE_IVAL: | |
e4584336 | 312 | Perl_sv_catpvf(aTHX_ report, "(ival=%"IVdf")", (IV)yylval.ival); |
bbf60fe6 DM |
313 | break; |
314 | case TOKENTYPE_OPNUM: | |
315 | Perl_sv_catpvf(aTHX_ report, "(ival=op_%s)", | |
316 | PL_op_name[yylval.ival]); | |
317 | break; | |
318 | case TOKENTYPE_PVAL: | |
319 | Perl_sv_catpvf(aTHX_ report, "(pval=\"%s\")", yylval.pval); | |
320 | break; | |
321 | case TOKENTYPE_OPVAL: | |
b6007c36 | 322 | if (yylval.opval) { |
401441c0 | 323 | Perl_sv_catpvf(aTHX_ report, "(opval=op_%s)", |
bbf60fe6 | 324 | PL_op_name[yylval.opval->op_type]); |
b6007c36 DM |
325 | if (yylval.opval->op_type == OP_CONST) { |
326 | Perl_sv_catpvf(aTHX_ report, " %s", | |
327 | SvPEEK(cSVOPx_sv(yylval.opval))); | |
328 | } | |
329 | ||
330 | } | |
401441c0 | 331 | else |
396482e1 | 332 | sv_catpvs(report, "(opval=null)"); |
bbf60fe6 DM |
333 | break; |
334 | } | |
b6007c36 | 335 | PerlIO_printf(Perl_debug_log, "### %s\n\n", SvPV_nolen_const(report)); |
bbf60fe6 DM |
336 | }; |
337 | return (int)rv; | |
998054bd SC |
338 | } |
339 | ||
b6007c36 DM |
340 | |
341 | /* print the buffer with suitable escapes */ | |
342 | ||
343 | STATIC void | |
344 | S_printbuf(pTHX_ const char* fmt, const char* s) | |
345 | { | |
396482e1 | 346 | SV* const tmp = newSVpvs(""); |
b6007c36 DM |
347 | PerlIO_printf(Perl_debug_log, fmt, pv_display(tmp, s, strlen(s), 0, 60)); |
348 | SvREFCNT_dec(tmp); | |
349 | } | |
350 | ||
8fa7f367 JH |
351 | #endif |
352 | ||
ffb4593c NT |
353 | /* |
354 | * S_ao | |
355 | * | |
c963b151 BD |
356 | * This subroutine detects &&=, ||=, and //= and turns an ANDAND, OROR or DORDOR |
357 | * into an OP_ANDASSIGN, OP_ORASSIGN, or OP_DORASSIGN | |
ffb4593c NT |
358 | */ |
359 | ||
76e3520e | 360 | STATIC int |
cea2e8a9 | 361 | S_ao(pTHX_ int toketype) |
a0d0e21e | 362 | { |
3280af22 NIS |
363 | if (*PL_bufptr == '=') { |
364 | PL_bufptr++; | |
a0d0e21e LW |
365 | if (toketype == ANDAND) |
366 | yylval.ival = OP_ANDASSIGN; | |
367 | else if (toketype == OROR) | |
368 | yylval.ival = OP_ORASSIGN; | |
c963b151 BD |
369 | else if (toketype == DORDOR) |
370 | yylval.ival = OP_DORASSIGN; | |
a0d0e21e LW |
371 | toketype = ASSIGNOP; |
372 | } | |
373 | return toketype; | |
374 | } | |
375 | ||
ffb4593c NT |
376 | /* |
377 | * S_no_op | |
378 | * When Perl expects an operator and finds something else, no_op | |
379 | * prints the warning. It always prints "<something> found where | |
380 | * operator expected. It prints "Missing semicolon on previous line?" | |
381 | * if the surprise occurs at the start of the line. "do you need to | |
382 | * predeclare ..." is printed out for code like "sub bar; foo bar $x" | |
383 | * where the compiler doesn't know if foo is a method call or a function. | |
384 | * It prints "Missing operator before end of line" if there's nothing | |
385 | * after the missing operator, or "... before <...>" if there is something | |
386 | * after the missing operator. | |
387 | */ | |
388 | ||
76e3520e | 389 | STATIC void |
bfed75c6 | 390 | S_no_op(pTHX_ const char *what, char *s) |
463ee0b2 | 391 | { |
9d4ba2ae AL |
392 | char * const oldbp = PL_bufptr; |
393 | const bool is_first = (PL_oldbufptr == PL_linestart); | |
68dc0745 | 394 | |
1189a94a GS |
395 | if (!s) |
396 | s = oldbp; | |
07c798fb | 397 | else |
1189a94a | 398 | PL_bufptr = s; |
cea2e8a9 | 399 | yywarn(Perl_form(aTHX_ "%s found where operator expected", what)); |
56da5a46 RGS |
400 | if (ckWARN_d(WARN_SYNTAX)) { |
401 | if (is_first) | |
402 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), | |
403 | "\t(Missing semicolon on previous line?)\n"); | |
404 | else if (PL_oldoldbufptr && isIDFIRST_lazy_if(PL_oldoldbufptr,UTF)) { | |
f54cb97a | 405 | const char *t; |
56da5a46 RGS |
406 | for (t = PL_oldoldbufptr; *t && (isALNUM_lazy_if(t,UTF) || *t == ':'); t++) ; |
407 | if (t < PL_bufptr && isSPACE(*t)) | |
408 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), | |
409 | "\t(Do you need to predeclare %.*s?)\n", | |
551405c4 | 410 | (int)(t - PL_oldoldbufptr), PL_oldoldbufptr); |
56da5a46 RGS |
411 | } |
412 | else { | |
413 | assert(s >= oldbp); | |
414 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), | |
551405c4 | 415 | "\t(Missing operator before %.*s?)\n", (int)(s - oldbp), oldbp); |
56da5a46 | 416 | } |
07c798fb | 417 | } |
3280af22 | 418 | PL_bufptr = oldbp; |
8990e307 LW |
419 | } |
420 | ||
ffb4593c NT |
421 | /* |
422 | * S_missingterm | |
423 | * Complain about missing quote/regexp/heredoc terminator. | |
424 | * If it's called with (char *)NULL then it cauterizes the line buffer. | |
425 | * If we're in a delimited string and the delimiter is a control | |
426 | * character, it's reformatted into a two-char sequence like ^C. | |
427 | * This is fatal. | |
428 | */ | |
429 | ||
76e3520e | 430 | STATIC void |
cea2e8a9 | 431 | S_missingterm(pTHX_ char *s) |
8990e307 LW |
432 | { |
433 | char tmpbuf[3]; | |
434 | char q; | |
435 | if (s) { | |
9d4ba2ae | 436 | char * const nl = strrchr(s,'\n'); |
d2719217 | 437 | if (nl) |
8990e307 LW |
438 | *nl = '\0'; |
439 | } | |
9d116dd7 JH |
440 | else if ( |
441 | #ifdef EBCDIC | |
442 | iscntrl(PL_multi_close) | |
443 | #else | |
444 | PL_multi_close < 32 || PL_multi_close == 127 | |
445 | #endif | |
446 | ) { | |
8990e307 | 447 | *tmpbuf = '^'; |
585ec06d | 448 | tmpbuf[1] = (char)toCTRL(PL_multi_close); |
8990e307 LW |
449 | tmpbuf[2] = '\0'; |
450 | s = tmpbuf; | |
451 | } | |
452 | else { | |
eb160463 | 453 | *tmpbuf = (char)PL_multi_close; |
8990e307 LW |
454 | tmpbuf[1] = '\0'; |
455 | s = tmpbuf; | |
456 | } | |
457 | q = strchr(s,'"') ? '\'' : '"'; | |
cea2e8a9 | 458 | Perl_croak(aTHX_ "Can't find string terminator %c%s%c anywhere before EOF",q,s,q); |
463ee0b2 | 459 | } |
79072805 | 460 | |
ef89dcc3 | 461 | #define FEATURE_IS_ENABLED(name) \ |
0d863452 | 462 | ((0 != (PL_hints & HINT_LOCALIZE_HH)) \ |
89529cee | 463 | && S_feature_is_enabled(aTHX_ STR_WITH_LEN(name))) |
0d863452 RH |
464 | /* |
465 | * S_feature_is_enabled | |
466 | * Check whether the named feature is enabled. | |
467 | */ | |
468 | STATIC bool | |
469 | S_feature_is_enabled(pTHX_ char *name, STRLEN namelen) | |
470 | { | |
471 | HV * const hinthv = GvHV(PL_hintgv); | |
7b9ef140 RH |
472 | char he_name[32] = "feature_"; |
473 | (void) strncpy(&he_name[8], name, 24); | |
474 | ||
475 | return (hinthv && hv_exists(hinthv, he_name, 8 + namelen)); | |
0d863452 RH |
476 | } |
477 | ||
ffb4593c NT |
478 | /* |
479 | * Perl_deprecate | |
ffb4593c NT |
480 | */ |
481 | ||
79072805 | 482 | void |
bfed75c6 | 483 | Perl_deprecate(pTHX_ const char *s) |
a0d0e21e | 484 | { |
599cee73 | 485 | if (ckWARN(WARN_DEPRECATED)) |
9014280d | 486 | Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), "Use of %s is deprecated", s); |
a0d0e21e LW |
487 | } |
488 | ||
12bcd1a6 | 489 | void |
bfed75c6 | 490 | Perl_deprecate_old(pTHX_ const char *s) |
12bcd1a6 PM |
491 | { |
492 | /* This function should NOT be called for any new deprecated warnings */ | |
493 | /* Use Perl_deprecate instead */ | |
494 | /* */ | |
495 | /* It is here to maintain backward compatibility with the pre-5.8 */ | |
496 | /* warnings category hierarchy. The "deprecated" category used to */ | |
497 | /* live under the "syntax" category. It is now a top-level category */ | |
498 | /* in its own right. */ | |
499 | ||
500 | if (ckWARN2(WARN_DEPRECATED, WARN_SYNTAX)) | |
bfed75c6 | 501 | Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), |
12bcd1a6 PM |
502 | "Use of %s is deprecated", s); |
503 | } | |
504 | ||
ffb4593c | 505 | /* |
9cbb5ea2 GS |
506 | * experimental text filters for win32 carriage-returns, utf16-to-utf8 and |
507 | * utf16-to-utf8-reversed. | |
ffb4593c NT |
508 | */ |
509 | ||
c39cd008 GS |
510 | #ifdef PERL_CR_FILTER |
511 | static void | |
512 | strip_return(SV *sv) | |
513 | { | |
95a20fc0 | 514 | register const char *s = SvPVX_const(sv); |
9d4ba2ae | 515 | register const char * const e = s + SvCUR(sv); |
c39cd008 GS |
516 | /* outer loop optimized to do nothing if there are no CR-LFs */ |
517 | while (s < e) { | |
518 | if (*s++ == '\r' && *s == '\n') { | |
519 | /* hit a CR-LF, need to copy the rest */ | |
520 | register char *d = s - 1; | |
521 | *d++ = *s++; | |
522 | while (s < e) { | |
523 | if (*s == '\r' && s[1] == '\n') | |
524 | s++; | |
525 | *d++ = *s++; | |
526 | } | |
527 | SvCUR(sv) -= s - d; | |
528 | return; | |
529 | } | |
530 | } | |
531 | } | |
a868473f | 532 | |
76e3520e | 533 | STATIC I32 |
c39cd008 | 534 | S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen) |
a868473f | 535 | { |
f54cb97a | 536 | const I32 count = FILTER_READ(idx+1, sv, maxlen); |
c39cd008 GS |
537 | if (count > 0 && !maxlen) |
538 | strip_return(sv); | |
539 | return count; | |
a868473f NIS |
540 | } |
541 | #endif | |
542 | ||
ffb4593c NT |
543 | /* |
544 | * Perl_lex_start | |
9cbb5ea2 GS |
545 | * Initialize variables. Uses the Perl save_stack to save its state (for |
546 | * recursive calls to the parser). | |
ffb4593c NT |
547 | */ |
548 | ||
a0d0e21e | 549 | void |
864dbfa3 | 550 | Perl_lex_start(pTHX_ SV *line) |
79072805 | 551 | { |
cfd0369c | 552 | const char *s; |
8990e307 LW |
553 | STRLEN len; |
554 | ||
3280af22 NIS |
555 | SAVEI32(PL_lex_dojoin); |
556 | SAVEI32(PL_lex_brackets); | |
3280af22 NIS |
557 | SAVEI32(PL_lex_casemods); |
558 | SAVEI32(PL_lex_starts); | |
559 | SAVEI32(PL_lex_state); | |
7766f137 | 560 | SAVEVPTR(PL_lex_inpat); |
3280af22 | 561 | SAVEI32(PL_lex_inwhat); |
18b09519 GS |
562 | if (PL_lex_state == LEX_KNOWNEXT) { |
563 | I32 toke = PL_nexttoke; | |
564 | while (--toke >= 0) { | |
565 | SAVEI32(PL_nexttype[toke]); | |
566 | SAVEVPTR(PL_nextval[toke]); | |
567 | } | |
568 | SAVEI32(PL_nexttoke); | |
18b09519 | 569 | } |
57843af0 | 570 | SAVECOPLINE(PL_curcop); |
3280af22 NIS |
571 | SAVEPPTR(PL_bufptr); |
572 | SAVEPPTR(PL_bufend); | |
573 | SAVEPPTR(PL_oldbufptr); | |
574 | SAVEPPTR(PL_oldoldbufptr); | |
207e3d1a JH |
575 | SAVEPPTR(PL_last_lop); |
576 | SAVEPPTR(PL_last_uni); | |
3280af22 NIS |
577 | SAVEPPTR(PL_linestart); |
578 | SAVESPTR(PL_linestr); | |
8edd5f42 RGS |
579 | SAVEGENERICPV(PL_lex_brackstack); |
580 | SAVEGENERICPV(PL_lex_casestack); | |
c76ac1ee | 581 | SAVEDESTRUCTOR_X(restore_rsfp, PL_rsfp); |
3280af22 NIS |
582 | SAVESPTR(PL_lex_stuff); |
583 | SAVEI32(PL_lex_defer); | |
09bef843 | 584 | SAVEI32(PL_sublex_info.sub_inwhat); |
3280af22 | 585 | SAVESPTR(PL_lex_repl); |
bebdddfc GS |
586 | SAVEINT(PL_expect); |
587 | SAVEINT(PL_lex_expect); | |
3280af22 NIS |
588 | |
589 | PL_lex_state = LEX_NORMAL; | |
590 | PL_lex_defer = 0; | |
591 | PL_expect = XSTATE; | |
592 | PL_lex_brackets = 0; | |
a02a5408 JC |
593 | Newx(PL_lex_brackstack, 120, char); |
594 | Newx(PL_lex_casestack, 12, char); | |
3280af22 NIS |
595 | PL_lex_casemods = 0; |
596 | *PL_lex_casestack = '\0'; | |
597 | PL_lex_dojoin = 0; | |
598 | PL_lex_starts = 0; | |
599 | PL_lex_stuff = Nullsv; | |
600 | PL_lex_repl = Nullsv; | |
601 | PL_lex_inpat = 0; | |
76be56bc | 602 | PL_nexttoke = 0; |
3280af22 | 603 | PL_lex_inwhat = 0; |
09bef843 | 604 | PL_sublex_info.sub_inwhat = 0; |
3280af22 NIS |
605 | PL_linestr = line; |
606 | if (SvREADONLY(PL_linestr)) | |
607 | PL_linestr = sv_2mortal(newSVsv(PL_linestr)); | |
cfd0369c | 608 | s = SvPV_const(PL_linestr, len); |
6f27f9a7 | 609 | if (!len || s[len-1] != ';') { |
3280af22 NIS |
610 | if (!(SvFLAGS(PL_linestr) & SVs_TEMP)) |
611 | PL_linestr = sv_2mortal(newSVsv(PL_linestr)); | |
396482e1 | 612 | sv_catpvs(PL_linestr, "\n;"); |
8990e307 | 613 | } |
3280af22 NIS |
614 | SvTEMP_off(PL_linestr); |
615 | PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr); | |
616 | PL_bufend = PL_bufptr + SvCUR(PL_linestr); | |
207e3d1a | 617 | PL_last_lop = PL_last_uni = Nullch; |
3280af22 | 618 | PL_rsfp = 0; |
79072805 | 619 | } |
a687059c | 620 | |
ffb4593c NT |
621 | /* |
622 | * Perl_lex_end | |
9cbb5ea2 GS |
623 | * Finalizer for lexing operations. Must be called when the parser is |
624 | * done with the lexer. | |
ffb4593c NT |
625 | */ |
626 | ||
463ee0b2 | 627 | void |
864dbfa3 | 628 | Perl_lex_end(pTHX) |
463ee0b2 | 629 | { |
3280af22 | 630 | PL_doextract = FALSE; |
463ee0b2 LW |
631 | } |
632 | ||
ffb4593c NT |
633 | /* |
634 | * S_incline | |
635 | * This subroutine has nothing to do with tilting, whether at windmills | |
636 | * or pinball tables. Its name is short for "increment line". It | |
57843af0 | 637 | * increments the current line number in CopLINE(PL_curcop) and checks |
ffb4593c | 638 | * to see whether the line starts with a comment of the form |
9cbb5ea2 GS |
639 | * # line 500 "foo.pm" |
640 | * If so, it sets the current line number and file to the values in the comment. | |
ffb4593c NT |
641 | */ |
642 | ||
76e3520e | 643 | STATIC void |
cea2e8a9 | 644 | S_incline(pTHX_ char *s) |
463ee0b2 LW |
645 | { |
646 | char *t; | |
647 | char *n; | |
73659bf1 | 648 | char *e; |
463ee0b2 | 649 | char ch; |
463ee0b2 | 650 | |
57843af0 | 651 | CopLINE_inc(PL_curcop); |
463ee0b2 LW |
652 | if (*s++ != '#') |
653 | return; | |
bf4acbe4 | 654 | while (SPACE_OR_TAB(*s)) s++; |
73659bf1 GS |
655 | if (strnEQ(s, "line", 4)) |
656 | s += 4; | |
657 | else | |
658 | return; | |
084592ab | 659 | if (SPACE_OR_TAB(*s)) |
73659bf1 | 660 | s++; |
4e553d73 | 661 | else |
73659bf1 | 662 | return; |
bf4acbe4 | 663 | while (SPACE_OR_TAB(*s)) s++; |
463ee0b2 LW |
664 | if (!isDIGIT(*s)) |
665 | return; | |
666 | n = s; | |
667 | while (isDIGIT(*s)) | |
668 | s++; | |
bf4acbe4 | 669 | while (SPACE_OR_TAB(*s)) |
463ee0b2 | 670 | s++; |
73659bf1 | 671 | if (*s == '"' && (t = strchr(s+1, '"'))) { |
463ee0b2 | 672 | s++; |
73659bf1 GS |
673 | e = t + 1; |
674 | } | |
463ee0b2 | 675 | else { |
463ee0b2 | 676 | for (t = s; !isSPACE(*t); t++) ; |
73659bf1 | 677 | e = t; |
463ee0b2 | 678 | } |
bf4acbe4 | 679 | while (SPACE_OR_TAB(*e) || *e == '\r' || *e == '\f') |
73659bf1 GS |
680 | e++; |
681 | if (*e != '\n' && *e != '\0') | |
682 | return; /* false alarm */ | |
683 | ||
463ee0b2 LW |
684 | ch = *t; |
685 | *t = '\0'; | |
f4dd75d9 | 686 | if (t - s > 0) { |
8a5ee598 | 687 | #ifndef USE_ITHREADS |
c4420975 | 688 | const char * const cf = CopFILE(PL_curcop); |
42d9b98d NC |
689 | STRLEN tmplen = cf ? strlen(cf) : 0; |
690 | if (tmplen > 7 && strnEQ(cf, "(eval ", 6)) { | |
e66cf94c RGS |
691 | /* must copy *{"::_<(eval N)[oldfilename:L]"} |
692 | * to *{"::_<newfilename"} */ | |
693 | char smallbuf[256], smallbuf2[256]; | |
694 | char *tmpbuf, *tmpbuf2; | |
8a5ee598 | 695 | GV **gvp, *gv2; |
e66cf94c RGS |
696 | STRLEN tmplen2 = strlen(s); |
697 | if (tmplen + 3 < sizeof smallbuf) | |
698 | tmpbuf = smallbuf; | |
699 | else | |
700 | Newx(tmpbuf, tmplen + 3, char); | |
701 | if (tmplen2 + 3 < sizeof smallbuf2) | |
702 | tmpbuf2 = smallbuf2; | |
703 | else | |
704 | Newx(tmpbuf2, tmplen2 + 3, char); | |
705 | tmpbuf[0] = tmpbuf2[0] = '_'; | |
706 | tmpbuf[1] = tmpbuf2[1] = '<'; | |
707 | memcpy(tmpbuf + 2, cf, ++tmplen); | |
708 | memcpy(tmpbuf2 + 2, s, ++tmplen2); | |
709 | ++tmplen; ++tmplen2; | |
8a5ee598 RGS |
710 | gvp = (GV**)hv_fetch(PL_defstash, tmpbuf, tmplen, FALSE); |
711 | if (gvp) { | |
712 | gv2 = *(GV**)hv_fetch(PL_defstash, tmpbuf2, tmplen2, TRUE); | |
713 | if (!isGV(gv2)) | |
714 | gv_init(gv2, PL_defstash, tmpbuf2, tmplen2, FALSE); | |
715 | /* adjust ${"::_<newfilename"} to store the new file name */ | |
716 | GvSV(gv2) = newSVpvn(tmpbuf2 + 2, tmplen2 - 2); | |
717 | GvHV(gv2) = (HV*)SvREFCNT_inc(GvHV(*gvp)); | |
718 | GvAV(gv2) = (AV*)SvREFCNT_inc(GvAV(*gvp)); | |
719 | } | |
e66cf94c RGS |
720 | if (tmpbuf != smallbuf) Safefree(tmpbuf); |
721 | if (tmpbuf2 != smallbuf2) Safefree(tmpbuf2); | |
722 | } | |
8a5ee598 | 723 | #endif |
05ec9bb3 | 724 | CopFILE_free(PL_curcop); |
57843af0 | 725 | CopFILE_set(PL_curcop, s); |
f4dd75d9 | 726 | } |
463ee0b2 | 727 | *t = ch; |
57843af0 | 728 | CopLINE_set(PL_curcop, atoi(n)-1); |
463ee0b2 LW |
729 | } |
730 | ||
ffb4593c NT |
731 | /* |
732 | * S_skipspace | |
733 | * Called to gobble the appropriate amount and type of whitespace. | |
734 | * Skips comments as well. | |
735 | */ | |
736 | ||
76e3520e | 737 | STATIC char * |
cea2e8a9 | 738 | S_skipspace(pTHX_ register char *s) |
a687059c | 739 | { |
3280af22 | 740 | if (PL_lex_formbrack && PL_lex_brackets <= PL_lex_formbrack) { |
bf4acbe4 | 741 | while (s < PL_bufend && SPACE_OR_TAB(*s)) |
463ee0b2 LW |
742 | s++; |
743 | return s; | |
744 | } | |
745 | for (;;) { | |
fd049845 | 746 | STRLEN prevlen; |
09bef843 | 747 | SSize_t oldprevlen, oldoldprevlen; |
9c5ffd7c | 748 | SSize_t oldloplen = 0, oldunilen = 0; |
60e6418e GS |
749 | while (s < PL_bufend && isSPACE(*s)) { |
750 | if (*s++ == '\n' && PL_in_eval && !PL_rsfp) | |
751 | incline(s); | |
752 | } | |
ffb4593c NT |
753 | |
754 | /* comment */ | |
3280af22 NIS |
755 | if (s < PL_bufend && *s == '#') { |
756 | while (s < PL_bufend && *s != '\n') | |
463ee0b2 | 757 | s++; |
60e6418e | 758 | if (s < PL_bufend) { |
463ee0b2 | 759 | s++; |
60e6418e GS |
760 | if (PL_in_eval && !PL_rsfp) { |
761 | incline(s); | |
762 | continue; | |
763 | } | |
764 | } | |
463ee0b2 | 765 | } |
ffb4593c NT |
766 | |
767 | /* only continue to recharge the buffer if we're at the end | |
768 | * of the buffer, we're not reading from a source filter, and | |
769 | * we're in normal lexing mode | |
770 | */ | |
09bef843 SB |
771 | if (s < PL_bufend || !PL_rsfp || PL_sublex_info.sub_inwhat || |
772 | PL_lex_state == LEX_FORMLINE) | |
463ee0b2 | 773 | return s; |
ffb4593c NT |
774 | |
775 | /* try to recharge the buffer */ | |
9cbb5ea2 GS |
776 | if ((s = filter_gets(PL_linestr, PL_rsfp, |
777 | (prevlen = SvCUR(PL_linestr)))) == Nullch) | |
778 | { | |
779 | /* end of file. Add on the -p or -n magic */ | |
01a19ab0 NC |
780 | if (PL_minus_p) { |
781 | sv_setpv(PL_linestr, | |
782 | ";}continue{print or die qq(-p destination: $!\\n);}"); | |
3280af22 | 783 | PL_minus_n = PL_minus_p = 0; |
a0d0e21e | 784 | } |
01a19ab0 NC |
785 | else if (PL_minus_n) { |
786 | sv_setpvn(PL_linestr, ";}", 2); | |
787 | PL_minus_n = 0; | |
788 | } | |
a0d0e21e | 789 | else |
4147a61b | 790 | sv_setpvn(PL_linestr,";", 1); |
ffb4593c NT |
791 | |
792 | /* reset variables for next time we lex */ | |
9cbb5ea2 GS |
793 | PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = s = PL_linestart |
794 | = SvPVX(PL_linestr); | |
3280af22 | 795 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); |
207e3d1a | 796 | PL_last_lop = PL_last_uni = Nullch; |
ffb4593c NT |
797 | |
798 | /* Close the filehandle. Could be from -P preprocessor, | |
799 | * STDIN, or a regular file. If we were reading code from | |
800 | * STDIN (because the commandline held no -e or filename) | |
801 | * then we don't close it, we reset it so the code can | |
802 | * read from STDIN too. | |
803 | */ | |
804 | ||
3280af22 NIS |
805 | if (PL_preprocess && !PL_in_eval) |
806 | (void)PerlProc_pclose(PL_rsfp); | |
807 | else if ((PerlIO*)PL_rsfp == PerlIO_stdin()) | |
808 | PerlIO_clearerr(PL_rsfp); | |
8990e307 | 809 | else |
3280af22 NIS |
810 | (void)PerlIO_close(PL_rsfp); |
811 | PL_rsfp = Nullfp; | |
463ee0b2 LW |
812 | return s; |
813 | } | |
ffb4593c NT |
814 | |
815 | /* not at end of file, so we only read another line */ | |
09bef843 SB |
816 | /* make corresponding updates to old pointers, for yyerror() */ |
817 | oldprevlen = PL_oldbufptr - PL_bufend; | |
818 | oldoldprevlen = PL_oldoldbufptr - PL_bufend; | |
819 | if (PL_last_uni) | |
820 | oldunilen = PL_last_uni - PL_bufend; | |
821 | if (PL_last_lop) | |
822 | oldloplen = PL_last_lop - PL_bufend; | |
3280af22 NIS |
823 | PL_linestart = PL_bufptr = s + prevlen; |
824 | PL_bufend = s + SvCUR(PL_linestr); | |
825 | s = PL_bufptr; | |
09bef843 SB |
826 | PL_oldbufptr = s + oldprevlen; |
827 | PL_oldoldbufptr = s + oldoldprevlen; | |
828 | if (PL_last_uni) | |
829 | PL_last_uni = s + oldunilen; | |
830 | if (PL_last_lop) | |
831 | PL_last_lop = s + oldloplen; | |
a0d0e21e | 832 | incline(s); |
ffb4593c NT |
833 | |
834 | /* debugger active and we're not compiling the debugger code, | |
835 | * so store the line into the debugger's array of lines | |
836 | */ | |
3280af22 | 837 | if (PERLDB_LINE && PL_curstash != PL_debstash) { |
9d4ba2ae | 838 | SV * const sv = NEWSV(85,0); |
8990e307 LW |
839 | |
840 | sv_upgrade(sv, SVt_PVMG); | |
3280af22 | 841 | sv_setpvn(sv,PL_bufptr,PL_bufend-PL_bufptr); |
0ac0412a | 842 | (void)SvIOK_on(sv); |
45977657 | 843 | SvIV_set(sv, 0); |
36c7798d | 844 | av_store(CopFILEAVx(PL_curcop),(I32)CopLINE(PL_curcop),sv); |
8990e307 | 845 | } |
463ee0b2 | 846 | } |
a687059c | 847 | } |
378cc40b | 848 | |
ffb4593c NT |
849 | /* |
850 | * S_check_uni | |
851 | * Check the unary operators to ensure there's no ambiguity in how they're | |
852 | * used. An ambiguous piece of code would be: | |
853 | * rand + 5 | |
854 | * This doesn't mean rand() + 5. Because rand() is a unary operator, | |
855 | * the +5 is its argument. | |
856 | */ | |
857 | ||
76e3520e | 858 | STATIC void |
cea2e8a9 | 859 | S_check_uni(pTHX) |
ba106d47 | 860 | { |
2f3197b3 | 861 | char *s; |
a0d0e21e | 862 | char *t; |
2f3197b3 | 863 | |
3280af22 | 864 | if (PL_oldoldbufptr != PL_last_uni) |
2f3197b3 | 865 | return; |
3280af22 NIS |
866 | while (isSPACE(*PL_last_uni)) |
867 | PL_last_uni++; | |
7e2040f0 | 868 | for (s = PL_last_uni; isALNUM_lazy_if(s,UTF) || *s == '-'; s++) ; |
3280af22 | 869 | if ((t = strchr(s, '(')) && t < PL_bufptr) |
a0d0e21e | 870 | return; |
0453d815 | 871 | if (ckWARN_d(WARN_AMBIGUOUS)){ |
9d4ba2ae | 872 | const char ch = *s; |
0453d815 | 873 | *s = '\0'; |
9014280d | 874 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
2d5ccbba | 875 | "Warning: Use of \"%s\" without parentheses is ambiguous", |
0453d815 PM |
876 | PL_last_uni); |
877 | *s = ch; | |
878 | } | |
2f3197b3 LW |
879 | } |
880 | ||
ffb4593c NT |
881 | /* |
882 | * LOP : macro to build a list operator. Its behaviour has been replaced | |
883 | * with a subroutine, S_lop() for which LOP is just another name. | |
884 | */ | |
885 | ||
a0d0e21e LW |
886 | #define LOP(f,x) return lop(f,x,s) |
887 | ||
ffb4593c NT |
888 | /* |
889 | * S_lop | |
890 | * Build a list operator (or something that might be one). The rules: | |
891 | * - if we have a next token, then it's a list operator [why?] | |
892 | * - if the next thing is an opening paren, then it's a function | |
893 | * - else it's a list operator | |
894 | */ | |
895 | ||
76e3520e | 896 | STATIC I32 |
a0be28da | 897 | S_lop(pTHX_ I32 f, int x, char *s) |
ffed7fef | 898 | { |
79072805 | 899 | yylval.ival = f; |
35c8bce7 | 900 | CLINE; |
3280af22 NIS |
901 | PL_expect = x; |
902 | PL_bufptr = s; | |
903 | PL_last_lop = PL_oldbufptr; | |
eb160463 | 904 | PL_last_lop_op = (OPCODE)f; |
3280af22 | 905 | if (PL_nexttoke) |
bbf60fe6 | 906 | return REPORT(LSTOP); |
79072805 | 907 | if (*s == '(') |
bbf60fe6 | 908 | return REPORT(FUNC); |
79072805 LW |
909 | s = skipspace(s); |
910 | if (*s == '(') | |
bbf60fe6 | 911 | return REPORT(FUNC); |
79072805 | 912 | else |
bbf60fe6 | 913 | return REPORT(LSTOP); |
79072805 LW |
914 | } |
915 | ||
ffb4593c NT |
916 | /* |
917 | * S_force_next | |
9cbb5ea2 | 918 | * When the lexer realizes it knows the next token (for instance, |
ffb4593c | 919 | * it is reordering tokens for the parser) then it can call S_force_next |
9cbb5ea2 GS |
920 | * to know what token to return the next time the lexer is called. Caller |
921 | * will need to set PL_nextval[], and possibly PL_expect to ensure the lexer | |
922 | * handles the token correctly. | |
ffb4593c NT |
923 | */ |
924 | ||
4e553d73 | 925 | STATIC void |
cea2e8a9 | 926 | S_force_next(pTHX_ I32 type) |
79072805 | 927 | { |
3280af22 NIS |
928 | PL_nexttype[PL_nexttoke] = type; |
929 | PL_nexttoke++; | |
930 | if (PL_lex_state != LEX_KNOWNEXT) { | |
931 | PL_lex_defer = PL_lex_state; | |
932 | PL_lex_expect = PL_expect; | |
933 | PL_lex_state = LEX_KNOWNEXT; | |
79072805 LW |
934 | } |
935 | } | |
936 | ||
d0a148a6 NC |
937 | STATIC SV * |
938 | S_newSV_maybe_utf8(pTHX_ const char *start, STRLEN len) | |
939 | { | |
9d4ba2ae | 940 | SV * const sv = newSVpvn(start,len); |
bfed75c6 | 941 | if (UTF && !IN_BYTES && is_utf8_string((const U8*)start, len)) |
d0a148a6 NC |
942 | SvUTF8_on(sv); |
943 | return sv; | |
944 | } | |
945 | ||
ffb4593c NT |
946 | /* |
947 | * S_force_word | |
948 | * When the lexer knows the next thing is a word (for instance, it has | |
949 | * just seen -> and it knows that the next char is a word char, then | |
950 | * it calls S_force_word to stick the next word into the PL_next lookahead. | |
951 | * | |
952 | * Arguments: | |
b1b65b59 | 953 | * char *start : buffer position (must be within PL_linestr) |
ffb4593c NT |
954 | * int token : PL_next will be this type of bare word (e.g., METHOD,WORD) |
955 | * int check_keyword : if true, Perl checks to make sure the word isn't | |
956 | * a keyword (do this if the word is a label, e.g. goto FOO) | |
957 | * int allow_pack : if true, : characters will also be allowed (require, | |
958 | * use, etc. do this) | |
9cbb5ea2 | 959 | * int allow_initial_tick : used by the "sub" lexer only. |
ffb4593c NT |
960 | */ |
961 | ||
76e3520e | 962 | STATIC char * |
cea2e8a9 | 963 | S_force_word(pTHX_ register char *start, int token, int check_keyword, int allow_pack, int allow_initial_tick) |
79072805 | 964 | { |
463ee0b2 LW |
965 | register char *s; |
966 | STRLEN len; | |
4e553d73 | 967 | |
463ee0b2 LW |
968 | start = skipspace(start); |
969 | s = start; | |
7e2040f0 | 970 | if (isIDFIRST_lazy_if(s,UTF) || |
a0d0e21e | 971 | (allow_pack && *s == ':') || |
15f0808c | 972 | (allow_initial_tick && *s == '\'') ) |
a0d0e21e | 973 | { |
3280af22 NIS |
974 | s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, allow_pack, &len); |
975 | if (check_keyword && keyword(PL_tokenbuf, len)) | |
463ee0b2 LW |
976 | return start; |
977 | if (token == METHOD) { | |
978 | s = skipspace(s); | |
979 | if (*s == '(') | |
3280af22 | 980 | PL_expect = XTERM; |
463ee0b2 | 981 | else { |
3280af22 | 982 | PL_expect = XOPERATOR; |
463ee0b2 | 983 | } |
79072805 | 984 | } |
d0a148a6 NC |
985 | PL_nextval[PL_nexttoke].opval |
986 | = (OP*)newSVOP(OP_CONST,0, | |
987 | S_newSV_maybe_utf8(aTHX_ PL_tokenbuf, len)); | |
3280af22 | 988 | PL_nextval[PL_nexttoke].opval->op_private |= OPpCONST_BARE; |
79072805 LW |
989 | force_next(token); |
990 | } | |
991 | return s; | |
992 | } | |
993 | ||
ffb4593c NT |
994 | /* |
995 | * S_force_ident | |
9cbb5ea2 | 996 | * Called when the lexer wants $foo *foo &foo etc, but the program |
ffb4593c NT |
997 | * text only contains the "foo" portion. The first argument is a pointer |
998 | * to the "foo", and the second argument is the type symbol to prefix. | |
999 | * Forces the next token to be a "WORD". | |
9cbb5ea2 | 1000 | * Creates the symbol if it didn't already exist (via gv_fetchpv()). |
ffb4593c NT |
1001 | */ |
1002 | ||
76e3520e | 1003 | STATIC void |
bfed75c6 | 1004 | S_force_ident(pTHX_ register const char *s, int kind) |
79072805 LW |
1005 | { |
1006 | if (s && *s) { | |
bfed75c6 | 1007 | OP* const o = (OP*)newSVOP(OP_CONST, 0, newSVpv(s,0)); |
3280af22 | 1008 | PL_nextval[PL_nexttoke].opval = o; |
79072805 | 1009 | force_next(WORD); |
748a9306 | 1010 | if (kind) { |
11343788 | 1011 | o->op_private = OPpCONST_ENTERED; |
55497cff | 1012 | /* XXX see note in pp_entereval() for why we forgo typo |
1013 | warnings if the symbol must be introduced in an eval. | |
1014 | GSAR 96-10-12 */ | |
f776e3cd | 1015 | gv_fetchpv(s, PL_in_eval ? (GV_ADDMULTI | GV_ADDINEVAL) : GV_ADD, |
a0d0e21e LW |
1016 | kind == '$' ? SVt_PV : |
1017 | kind == '@' ? SVt_PVAV : | |
1018 | kind == '%' ? SVt_PVHV : | |
1019 | SVt_PVGV | |
1020 | ); | |
748a9306 | 1021 | } |
79072805 LW |
1022 | } |
1023 | } | |
1024 | ||
1571675a GS |
1025 | NV |
1026 | Perl_str_to_version(pTHX_ SV *sv) | |
1027 | { | |
1028 | NV retval = 0.0; | |
1029 | NV nshift = 1.0; | |
1030 | STRLEN len; | |
cfd0369c | 1031 | const char *start = SvPV_const(sv,len); |
9d4ba2ae | 1032 | const char * const end = start + len; |
504618e9 | 1033 | const bool utf = SvUTF8(sv) ? TRUE : FALSE; |
1571675a | 1034 | while (start < end) { |
ba210ebe | 1035 | STRLEN skip; |
1571675a GS |
1036 | UV n; |
1037 | if (utf) | |
9041c2e3 | 1038 | n = utf8n_to_uvchr((U8*)start, len, &skip, 0); |
1571675a GS |
1039 | else { |
1040 | n = *(U8*)start; | |
1041 | skip = 1; | |
1042 | } | |
1043 | retval += ((NV)n)/nshift; | |
1044 | start += skip; | |
1045 | nshift *= 1000; | |
1046 | } | |
1047 | return retval; | |
1048 | } | |
1049 | ||
4e553d73 | 1050 | /* |
ffb4593c NT |
1051 | * S_force_version |
1052 | * Forces the next token to be a version number. | |
e759cc13 RGS |
1053 | * If the next token appears to be an invalid version number, (e.g. "v2b"), |
1054 | * and if "guessing" is TRUE, then no new token is created (and the caller | |
1055 | * must use an alternative parsing method). | |
ffb4593c NT |
1056 | */ |
1057 | ||
76e3520e | 1058 | STATIC char * |
e759cc13 | 1059 | S_force_version(pTHX_ char *s, int guessing) |
89bfa8cd | 1060 | { |
1061 | OP *version = Nullop; | |
44dcb63b | 1062 | char *d; |
89bfa8cd | 1063 | |
1064 | s = skipspace(s); | |
1065 | ||
44dcb63b | 1066 | d = s; |
dd629d5b | 1067 | if (*d == 'v') |
44dcb63b | 1068 | d++; |
44dcb63b | 1069 | if (isDIGIT(*d)) { |
e759cc13 RGS |
1070 | while (isDIGIT(*d) || *d == '_' || *d == '.') |
1071 | d++; | |
9f3d182e | 1072 | if (*d == ';' || isSPACE(*d) || *d == '}' || !*d) { |
dd629d5b | 1073 | SV *ver; |
b73d6f50 | 1074 | s = scan_num(s, &yylval); |
89bfa8cd | 1075 | version = yylval.opval; |
dd629d5b GS |
1076 | ver = cSVOPx(version)->op_sv; |
1077 | if (SvPOK(ver) && !SvNIOK(ver)) { | |
862a34c6 | 1078 | SvUPGRADE(ver, SVt_PVNV); |
9d6ce603 | 1079 | SvNV_set(ver, str_to_version(ver)); |
1571675a | 1080 | SvNOK_on(ver); /* hint that it is a version */ |
44dcb63b | 1081 | } |
89bfa8cd | 1082 | } |
e759cc13 RGS |
1083 | else if (guessing) |
1084 | return s; | |
89bfa8cd | 1085 | } |
1086 | ||
1087 | /* NOTE: The parser sees the package name and the VERSION swapped */ | |
3280af22 | 1088 | PL_nextval[PL_nexttoke].opval = version; |
4e553d73 | 1089 | force_next(WORD); |
89bfa8cd | 1090 | |
e759cc13 | 1091 | return s; |
89bfa8cd | 1092 | } |
1093 | ||
ffb4593c NT |
1094 | /* |
1095 | * S_tokeq | |
1096 | * Tokenize a quoted string passed in as an SV. It finds the next | |
1097 | * chunk, up to end of string or a backslash. It may make a new | |
1098 | * SV containing that chunk (if HINT_NEW_STRING is on). It also | |
1099 | * turns \\ into \. | |
1100 | */ | |
1101 | ||
76e3520e | 1102 | STATIC SV * |
cea2e8a9 | 1103 | S_tokeq(pTHX_ SV *sv) |
79072805 LW |
1104 | { |
1105 | register char *s; | |
1106 | register char *send; | |
1107 | register char *d; | |
b3ac6de7 IZ |
1108 | STRLEN len = 0; |
1109 | SV *pv = sv; | |
79072805 LW |
1110 | |
1111 | if (!SvLEN(sv)) | |
b3ac6de7 | 1112 | goto finish; |
79072805 | 1113 | |
a0d0e21e | 1114 | s = SvPV_force(sv, len); |
21a311ee | 1115 | if (SvTYPE(sv) >= SVt_PVIV && SvIVX(sv) == -1) |
b3ac6de7 | 1116 | goto finish; |
463ee0b2 | 1117 | send = s + len; |
79072805 LW |
1118 | while (s < send && *s != '\\') |
1119 | s++; | |
1120 | if (s == send) | |
b3ac6de7 | 1121 | goto finish; |
79072805 | 1122 | d = s; |
be4731d2 | 1123 | if ( PL_hints & HINT_NEW_STRING ) { |
95a20fc0 | 1124 | pv = sv_2mortal(newSVpvn(SvPVX_const(pv), len)); |
be4731d2 NIS |
1125 | if (SvUTF8(sv)) |
1126 | SvUTF8_on(pv); | |
1127 | } | |
79072805 LW |
1128 | while (s < send) { |
1129 | if (*s == '\\') { | |
a0d0e21e | 1130 | if (s + 1 < send && (s[1] == '\\')) |
79072805 LW |
1131 | s++; /* all that, just for this */ |
1132 | } | |
1133 | *d++ = *s++; | |
1134 | } | |
1135 | *d = '\0'; | |
95a20fc0 | 1136 | SvCUR_set(sv, d - SvPVX_const(sv)); |
b3ac6de7 | 1137 | finish: |
3280af22 | 1138 | if ( PL_hints & HINT_NEW_STRING ) |
b3ac6de7 | 1139 | return new_constant(NULL, 0, "q", sv, pv, "q"); |
79072805 LW |
1140 | return sv; |
1141 | } | |
1142 | ||
ffb4593c NT |
1143 | /* |
1144 | * Now come three functions related to double-quote context, | |
1145 | * S_sublex_start, S_sublex_push, and S_sublex_done. They're used when | |
1146 | * converting things like "\u\Lgnat" into ucfirst(lc("gnat")). They | |
1147 | * interact with PL_lex_state, and create fake ( ... ) argument lists | |
1148 | * to handle functions and concatenation. | |
1149 | * They assume that whoever calls them will be setting up a fake | |
1150 | * join call, because each subthing puts a ',' after it. This lets | |
1151 | * "lower \luPpEr" | |
1152 | * become | |
1153 | * join($, , 'lower ', lcfirst( 'uPpEr', ) ,) | |
1154 | * | |
1155 | * (I'm not sure whether the spurious commas at the end of lcfirst's | |
1156 | * arguments and join's arguments are created or not). | |
1157 | */ | |
1158 | ||
1159 | /* | |
1160 | * S_sublex_start | |
1161 | * Assumes that yylval.ival is the op we're creating (e.g. OP_LCFIRST). | |
1162 | * | |
1163 | * Pattern matching will set PL_lex_op to the pattern-matching op to | |
1164 | * make (we return THING if yylval.ival is OP_NULL, PMFUNC otherwise). | |
1165 | * | |
1166 | * OP_CONST and OP_READLINE are easy--just make the new op and return. | |
1167 | * | |
1168 | * Everything else becomes a FUNC. | |
1169 | * | |
1170 | * Sets PL_lex_state to LEX_INTERPPUSH unless (ival was OP_NULL or we | |
1171 | * had an OP_CONST or OP_READLINE). This just sets us up for a | |
1172 | * call to S_sublex_push(). | |
1173 | */ | |
1174 | ||
76e3520e | 1175 | STATIC I32 |
cea2e8a9 | 1176 | S_sublex_start(pTHX) |
79072805 | 1177 | { |
0d46e09a | 1178 | register const I32 op_type = yylval.ival; |
79072805 LW |
1179 | |
1180 | if (op_type == OP_NULL) { | |
3280af22 NIS |
1181 | yylval.opval = PL_lex_op; |
1182 | PL_lex_op = Nullop; | |
79072805 LW |
1183 | return THING; |
1184 | } | |
1185 | if (op_type == OP_CONST || op_type == OP_READLINE) { | |
3280af22 | 1186 | SV *sv = tokeq(PL_lex_stuff); |
b3ac6de7 IZ |
1187 | |
1188 | if (SvTYPE(sv) == SVt_PVIV) { | |
1189 | /* Overloaded constants, nothing fancy: Convert to SVt_PV: */ | |
1190 | STRLEN len; | |
cfd0369c | 1191 | const char *p = SvPV_const(sv, len); |
f54cb97a | 1192 | SV * const nsv = newSVpvn(p, len); |
01ec43d0 GS |
1193 | if (SvUTF8(sv)) |
1194 | SvUTF8_on(nsv); | |
b3ac6de7 IZ |
1195 | SvREFCNT_dec(sv); |
1196 | sv = nsv; | |
4e553d73 | 1197 | } |
b3ac6de7 | 1198 | yylval.opval = (OP*)newSVOP(op_type, 0, sv); |
3280af22 | 1199 | PL_lex_stuff = Nullsv; |
6f33ba73 RGS |
1200 | /* Allow <FH> // "foo" */ |
1201 | if (op_type == OP_READLINE) | |
1202 | PL_expect = XTERMORDORDOR; | |
79072805 LW |
1203 | return THING; |
1204 | } | |
1205 | ||
3280af22 NIS |
1206 | PL_sublex_info.super_state = PL_lex_state; |
1207 | PL_sublex_info.sub_inwhat = op_type; | |
1208 | PL_sublex_info.sub_op = PL_lex_op; | |
1209 | PL_lex_state = LEX_INTERPPUSH; | |
55497cff | 1210 | |
3280af22 NIS |
1211 | PL_expect = XTERM; |
1212 | if (PL_lex_op) { | |
1213 | yylval.opval = PL_lex_op; | |
1214 | PL_lex_op = Nullop; | |
55497cff | 1215 | return PMFUNC; |
1216 | } | |
1217 | else | |
1218 | return FUNC; | |
1219 | } | |
1220 | ||
ffb4593c NT |
1221 | /* |
1222 | * S_sublex_push | |
1223 | * Create a new scope to save the lexing state. The scope will be | |
1224 | * ended in S_sublex_done. Returns a '(', starting the function arguments | |
1225 | * to the uc, lc, etc. found before. | |
1226 | * Sets PL_lex_state to LEX_INTERPCONCAT. | |
1227 | */ | |
1228 | ||
76e3520e | 1229 | STATIC I32 |
cea2e8a9 | 1230 | S_sublex_push(pTHX) |
55497cff | 1231 | { |
27da23d5 | 1232 | dVAR; |
f46d017c | 1233 | ENTER; |
55497cff | 1234 | |
3280af22 NIS |
1235 | PL_lex_state = PL_sublex_info.super_state; |
1236 | SAVEI32(PL_lex_dojoin); | |
1237 | SAVEI32(PL_lex_brackets); | |
3280af22 NIS |
1238 | SAVEI32(PL_lex_casemods); |
1239 | SAVEI32(PL_lex_starts); | |
1240 | SAVEI32(PL_lex_state); | |
7766f137 | 1241 | SAVEVPTR(PL_lex_inpat); |
3280af22 | 1242 | SAVEI32(PL_lex_inwhat); |
57843af0 | 1243 | SAVECOPLINE(PL_curcop); |
3280af22 | 1244 | SAVEPPTR(PL_bufptr); |
8452ff4b | 1245 | SAVEPPTR(PL_bufend); |
3280af22 NIS |
1246 | SAVEPPTR(PL_oldbufptr); |
1247 | SAVEPPTR(PL_oldoldbufptr); | |
207e3d1a JH |
1248 | SAVEPPTR(PL_last_lop); |
1249 | SAVEPPTR(PL_last_uni); | |
3280af22 NIS |
1250 | SAVEPPTR(PL_linestart); |
1251 | SAVESPTR(PL_linestr); | |
8edd5f42 RGS |
1252 | SAVEGENERICPV(PL_lex_brackstack); |
1253 | SAVEGENERICPV(PL_lex_casestack); | |
3280af22 NIS |
1254 | |
1255 | PL_linestr = PL_lex_stuff; | |
1256 | PL_lex_stuff = Nullsv; | |
1257 | ||
9cbb5ea2 GS |
1258 | PL_bufend = PL_bufptr = PL_oldbufptr = PL_oldoldbufptr = PL_linestart |
1259 | = SvPVX(PL_linestr); | |
3280af22 | 1260 | PL_bufend += SvCUR(PL_linestr); |
207e3d1a | 1261 | PL_last_lop = PL_last_uni = Nullch; |
3280af22 NIS |
1262 | SAVEFREESV(PL_linestr); |
1263 | ||
1264 | PL_lex_dojoin = FALSE; | |
1265 | PL_lex_brackets = 0; | |
a02a5408 JC |
1266 | Newx(PL_lex_brackstack, 120, char); |
1267 | Newx(PL_lex_casestack, 12, char); | |
3280af22 NIS |
1268 | PL_lex_casemods = 0; |
1269 | *PL_lex_casestack = '\0'; | |
1270 | PL_lex_starts = 0; | |
1271 | PL_lex_state = LEX_INTERPCONCAT; | |
eb160463 | 1272 | CopLINE_set(PL_curcop, (line_t)PL_multi_start); |
3280af22 NIS |
1273 | |
1274 | PL_lex_inwhat = PL_sublex_info.sub_inwhat; | |
1275 | if (PL_lex_inwhat == OP_MATCH || PL_lex_inwhat == OP_QR || PL_lex_inwhat == OP_SUBST) | |
1276 | PL_lex_inpat = PL_sublex_info.sub_op; | |
79072805 | 1277 | else |
3280af22 | 1278 | PL_lex_inpat = Nullop; |
79072805 | 1279 | |
55497cff | 1280 | return '('; |
79072805 LW |
1281 | } |
1282 | ||
ffb4593c NT |
1283 | /* |
1284 | * S_sublex_done | |
1285 | * Restores lexer state after a S_sublex_push. | |
1286 | */ | |
1287 | ||
76e3520e | 1288 | STATIC I32 |
cea2e8a9 | 1289 | S_sublex_done(pTHX) |
79072805 | 1290 | { |
27da23d5 | 1291 | dVAR; |
3280af22 | 1292 | if (!PL_lex_starts++) { |
396482e1 | 1293 | SV * const sv = newSVpvs(""); |
9aa983d2 JH |
1294 | if (SvUTF8(PL_linestr)) |
1295 | SvUTF8_on(sv); | |
3280af22 | 1296 | PL_expect = XOPERATOR; |
9aa983d2 | 1297 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv); |
79072805 LW |
1298 | return THING; |
1299 | } | |
1300 | ||
3280af22 NIS |
1301 | if (PL_lex_casemods) { /* oops, we've got some unbalanced parens */ |
1302 | PL_lex_state = LEX_INTERPCASEMOD; | |
cea2e8a9 | 1303 | return yylex(); |
79072805 LW |
1304 | } |
1305 | ||
ffb4593c | 1306 | /* Is there a right-hand side to take care of? (s//RHS/ or tr//RHS/) */ |
3280af22 NIS |
1307 | if (PL_lex_repl && (PL_lex_inwhat == OP_SUBST || PL_lex_inwhat == OP_TRANS)) { |
1308 | PL_linestr = PL_lex_repl; | |
1309 | PL_lex_inpat = 0; | |
1310 | PL_bufend = PL_bufptr = PL_oldbufptr = PL_oldoldbufptr = PL_linestart = SvPVX(PL_linestr); | |
1311 | PL_bufend += SvCUR(PL_linestr); | |
207e3d1a | 1312 | PL_last_lop = PL_last_uni = Nullch; |
3280af22 NIS |
1313 | SAVEFREESV(PL_linestr); |
1314 | PL_lex_dojoin = FALSE; | |
1315 | PL_lex_brackets = 0; | |
3280af22 NIS |
1316 | PL_lex_casemods = 0; |
1317 | *PL_lex_casestack = '\0'; | |
1318 | PL_lex_starts = 0; | |
25da4f38 | 1319 | if (SvEVALED(PL_lex_repl)) { |
3280af22 NIS |
1320 | PL_lex_state = LEX_INTERPNORMAL; |
1321 | PL_lex_starts++; | |
e9fa98b2 HS |
1322 | /* we don't clear PL_lex_repl here, so that we can check later |
1323 | whether this is an evalled subst; that means we rely on the | |
1324 | logic to ensure sublex_done() is called again only via the | |
1325 | branch (in yylex()) that clears PL_lex_repl, else we'll loop */ | |
79072805 | 1326 | } |
e9fa98b2 | 1327 | else { |
3280af22 | 1328 | PL_lex_state = LEX_INTERPCONCAT; |
e9fa98b2 HS |
1329 | PL_lex_repl = Nullsv; |
1330 | } | |
79072805 | 1331 | return ','; |
ffed7fef LW |
1332 | } |
1333 | else { | |
f46d017c | 1334 | LEAVE; |
3280af22 NIS |
1335 | PL_bufend = SvPVX(PL_linestr); |
1336 | PL_bufend += SvCUR(PL_linestr); | |
1337 | PL_expect = XOPERATOR; | |
09bef843 | 1338 | PL_sublex_info.sub_inwhat = 0; |
79072805 | 1339 | return ')'; |
ffed7fef LW |
1340 | } |
1341 | } | |
1342 | ||
02aa26ce NT |
1343 | /* |
1344 | scan_const | |
1345 | ||
1346 | Extracts a pattern, double-quoted string, or transliteration. This | |
1347 | is terrifying code. | |
1348 | ||
3280af22 NIS |
1349 | It looks at lex_inwhat and PL_lex_inpat to find out whether it's |
1350 | processing a pattern (PL_lex_inpat is true), a transliteration | |
02aa26ce NT |
1351 | (lex_inwhat & OP_TRANS is true), or a double-quoted string. |
1352 | ||
9b599b2a GS |
1353 | Returns a pointer to the character scanned up to. Iff this is |
1354 | advanced from the start pointer supplied (ie if anything was | |
1355 | successfully parsed), will leave an OP for the substring scanned | |
1356 | in yylval. Caller must intuit reason for not parsing further | |
1357 | by looking at the next characters herself. | |
1358 | ||
02aa26ce NT |
1359 | In patterns: |
1360 | backslashes: | |
1361 | double-quoted style: \r and \n | |
1362 | regexp special ones: \D \s | |
1363 | constants: \x3 | |
1364 | backrefs: \1 (deprecated in substitution replacements) | |
1365 | case and quoting: \U \Q \E | |
1366 | stops on @ and $, but not for $ as tail anchor | |
1367 | ||
1368 | In transliterations: | |
1369 | characters are VERY literal, except for - not at the start or end | |
1370 | of the string, which indicates a range. scan_const expands the | |
1371 | range to the full set of intermediate characters. | |
1372 | ||
1373 | In double-quoted strings: | |
1374 | backslashes: | |
1375 | double-quoted style: \r and \n | |
1376 | constants: \x3 | |
1377 | backrefs: \1 (deprecated) | |
1378 | case and quoting: \U \Q \E | |
1379 | stops on @ and $ | |
1380 | ||
1381 | scan_const does *not* construct ops to handle interpolated strings. | |
1382 | It stops processing as soon as it finds an embedded $ or @ variable | |
1383 | and leaves it to the caller to work out what's going on. | |
1384 | ||
da6eedaa | 1385 | @ in pattern could be: @foo, @{foo}, @$foo, @'foo, @::foo. |
02aa26ce NT |
1386 | |
1387 | $ in pattern could be $foo or could be tail anchor. Assumption: | |
1388 | it's a tail anchor if $ is the last thing in the string, or if it's | |
1389 | followed by one of ")| \n\t" | |
1390 | ||
1391 | \1 (backreferences) are turned into $1 | |
1392 | ||
1393 | The structure of the code is | |
1394 | while (there's a character to process) { | |
1395 | handle transliteration ranges | |
1396 | skip regexp comments | |
1397 | skip # initiated comments in //x patterns | |
1398 | check for embedded @foo | |
1399 | check for embedded scalars | |
1400 | if (backslash) { | |
1401 | leave intact backslashes from leave (below) | |
1402 | deprecate \1 in strings and sub replacements | |
1403 | handle string-changing backslashes \l \U \Q \E, etc. | |
1404 | switch (what was escaped) { | |
1405 | handle - in a transliteration (becomes a literal -) | |
1406 | handle \132 octal characters | |
1407 | handle 0x15 hex characters | |
1408 | handle \cV (control V) | |
1409 | handle printf backslashes (\f, \r, \n, etc) | |
1410 | } (end switch) | |
1411 | } (end if backslash) | |
1412 | } (end while character to read) | |
4e553d73 | 1413 | |
02aa26ce NT |
1414 | */ |
1415 | ||
76e3520e | 1416 | STATIC char * |
cea2e8a9 | 1417 | S_scan_const(pTHX_ char *start) |
79072805 | 1418 | { |
3280af22 | 1419 | register char *send = PL_bufend; /* end of the constant */ |
02aa26ce NT |
1420 | SV *sv = NEWSV(93, send - start); /* sv for the constant */ |
1421 | register char *s = start; /* start of the constant */ | |
1422 | register char *d = SvPVX(sv); /* destination for copies */ | |
1423 | bool dorange = FALSE; /* are we in a translit range? */ | |
c2e66d9e | 1424 | bool didrange = FALSE; /* did we just finish a range? */ |
2b9d42f0 NIS |
1425 | I32 has_utf8 = FALSE; /* Output constant is UTF8 */ |
1426 | I32 this_utf8 = UTF; /* The source string is assumed to be UTF8 */ | |
012bcf8d | 1427 | UV uv; |
4c3a8340 TS |
1428 | #ifdef EBCDIC |
1429 | UV literal_endpoint = 0; | |
1430 | #endif | |
012bcf8d | 1431 | |
dff6d3cd | 1432 | const char *leaveit = /* set of acceptably-backslashed characters */ |
3280af22 | 1433 | PL_lex_inpat |
b6d5fef8 | 1434 | ? "\\.^$@AGZdDwWsSbBpPXC+*?|()-nrtfeaxz0123456789[{]} \t\n\r\f\v#" |
9b599b2a | 1435 | : ""; |
79072805 | 1436 | |
2b9d42f0 NIS |
1437 | if (PL_lex_inwhat == OP_TRANS && PL_sublex_info.sub_op) { |
1438 | /* If we are doing a trans and we know we want UTF8 set expectation */ | |
1439 | has_utf8 = PL_sublex_info.sub_op->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF); | |
1440 | this_utf8 = PL_sublex_info.sub_op->op_private & (PL_lex_repl ? OPpTRANS_FROM_UTF : OPpTRANS_TO_UTF); | |
1441 | } | |
1442 | ||
1443 | ||
79072805 | 1444 | while (s < send || dorange) { |
02aa26ce | 1445 | /* get transliterations out of the way (they're most literal) */ |
3280af22 | 1446 | if (PL_lex_inwhat == OP_TRANS) { |
02aa26ce | 1447 | /* expand a range A-Z to the full set of characters. AIE! */ |
79072805 | 1448 | if (dorange) { |
1ba5c669 JH |
1449 | I32 i; /* current expanded character */ |
1450 | I32 min; /* first character in range */ | |
1451 | I32 max; /* last character in range */ | |
02aa26ce | 1452 | |
2b9d42f0 | 1453 | if (has_utf8) { |
9d4ba2ae | 1454 | char * const c = (char*)utf8_hop((U8*)d, -1); |
8973db79 JH |
1455 | char *e = d++; |
1456 | while (e-- > c) | |
1457 | *(e + 1) = *e; | |
25716404 | 1458 | *c = (char)UTF_TO_NATIVE(0xff); |
8973db79 JH |
1459 | /* mark the range as done, and continue */ |
1460 | dorange = FALSE; | |
1461 | didrange = TRUE; | |
1462 | continue; | |
1463 | } | |
2b9d42f0 | 1464 | |
95a20fc0 | 1465 | i = d - SvPVX_const(sv); /* remember current offset */ |
9cbb5ea2 GS |
1466 | SvGROW(sv, SvLEN(sv) + 256); /* never more than 256 chars in a range */ |
1467 | d = SvPVX(sv) + i; /* refresh d after realloc */ | |
02aa26ce NT |
1468 | d -= 2; /* eat the first char and the - */ |
1469 | ||
8ada0baa JH |
1470 | min = (U8)*d; /* first char in range */ |
1471 | max = (U8)d[1]; /* last char in range */ | |
1472 | ||
c2e66d9e | 1473 | if (min > max) { |
01ec43d0 | 1474 | Perl_croak(aTHX_ |
d1573ac7 | 1475 | "Invalid range \"%c-%c\" in transliteration operator", |
1ba5c669 | 1476 | (char)min, (char)max); |
c2e66d9e GS |
1477 | } |
1478 | ||
c7f1f016 | 1479 | #ifdef EBCDIC |
4c3a8340 TS |
1480 | if (literal_endpoint == 2 && |
1481 | ((isLOWER(min) && isLOWER(max)) || | |
1482 | (isUPPER(min) && isUPPER(max)))) { | |
8ada0baa JH |
1483 | if (isLOWER(min)) { |
1484 | for (i = min; i <= max; i++) | |
1485 | if (isLOWER(i)) | |
db42d148 | 1486 | *d++ = NATIVE_TO_NEED(has_utf8,i); |
8ada0baa JH |
1487 | } else { |
1488 | for (i = min; i <= max; i++) | |
1489 | if (isUPPER(i)) | |
db42d148 | 1490 | *d++ = NATIVE_TO_NEED(has_utf8,i); |
8ada0baa JH |
1491 | } |
1492 | } | |
1493 | else | |
1494 | #endif | |
1495 | for (i = min; i <= max; i++) | |
eb160463 | 1496 | *d++ = (char)i; |
02aa26ce NT |
1497 | |
1498 | /* mark the range as done, and continue */ | |
79072805 | 1499 | dorange = FALSE; |
01ec43d0 | 1500 | didrange = TRUE; |
4c3a8340 TS |
1501 | #ifdef EBCDIC |
1502 | literal_endpoint = 0; | |
1503 | #endif | |
79072805 | 1504 | continue; |
4e553d73 | 1505 | } |
02aa26ce NT |
1506 | |
1507 | /* range begins (ignore - as first or last char) */ | |
79072805 | 1508 | else if (*s == '-' && s+1 < send && s != start) { |
4e553d73 | 1509 | if (didrange) { |
1fafa243 | 1510 | Perl_croak(aTHX_ "Ambiguous range in transliteration operator"); |
01ec43d0 | 1511 | } |
2b9d42f0 | 1512 | if (has_utf8) { |
25716404 | 1513 | *d++ = (char)UTF_TO_NATIVE(0xff); /* use illegal utf8 byte--see pmtrans */ |
a0ed51b3 LW |
1514 | s++; |
1515 | continue; | |
1516 | } | |
79072805 LW |
1517 | dorange = TRUE; |
1518 | s++; | |
01ec43d0 GS |
1519 | } |
1520 | else { | |
1521 | didrange = FALSE; | |
4c3a8340 TS |
1522 | #ifdef EBCDIC |
1523 | literal_endpoint = 0; | |
1524 | #endif | |
01ec43d0 | 1525 | } |
79072805 | 1526 | } |
02aa26ce NT |
1527 | |
1528 | /* if we get here, we're not doing a transliteration */ | |
1529 | ||
0f5d15d6 IZ |
1530 | /* skip for regexp comments /(?#comment)/ and code /(?{code})/, |
1531 | except for the last char, which will be done separately. */ | |
3280af22 | 1532 | else if (*s == '(' && PL_lex_inpat && s[1] == '?') { |
cc6b7395 | 1533 | if (s[2] == '#') { |
e994fd66 | 1534 | while (s+1 < send && *s != ')') |
db42d148 | 1535 | *d++ = NATIVE_TO_NEED(has_utf8,*s++); |
155aba94 GS |
1536 | } |
1537 | else if (s[2] == '{' /* This should match regcomp.c */ | |
1538 | || ((s[2] == 'p' || s[2] == '?') && s[3] == '{')) | |
1539 | { | |
cc6b7395 | 1540 | I32 count = 1; |
0f5d15d6 | 1541 | char *regparse = s + (s[2] == '{' ? 3 : 4); |
cc6b7395 IZ |
1542 | char c; |
1543 | ||
d9f97599 GS |
1544 | while (count && (c = *regparse)) { |
1545 | if (c == '\\' && regparse[1]) | |
1546 | regparse++; | |
4e553d73 | 1547 | else if (c == '{') |
cc6b7395 | 1548 | count++; |
4e553d73 | 1549 | else if (c == '}') |
cc6b7395 | 1550 | count--; |
d9f97599 | 1551 | regparse++; |
cc6b7395 | 1552 | } |
e994fd66 | 1553 | if (*regparse != ')') |
5bdf89e7 | 1554 | regparse--; /* Leave one char for continuation. */ |
0f5d15d6 | 1555 | while (s < regparse) |
db42d148 | 1556 | *d++ = NATIVE_TO_NEED(has_utf8,*s++); |
cc6b7395 | 1557 | } |
748a9306 | 1558 | } |
02aa26ce NT |
1559 | |
1560 | /* likewise skip #-initiated comments in //x patterns */ | |
3280af22 NIS |
1561 | else if (*s == '#' && PL_lex_inpat && |
1562 | ((PMOP*)PL_lex_inpat)->op_pmflags & PMf_EXTENDED) { | |
748a9306 | 1563 | while (s+1 < send && *s != '\n') |
db42d148 | 1564 | *d++ = NATIVE_TO_NEED(has_utf8,*s++); |
748a9306 | 1565 | } |
02aa26ce | 1566 | |
5d1d4326 | 1567 | /* check for embedded arrays |
da6eedaa | 1568 | (@foo, @::foo, @'foo, @{foo}, @$foo, @+, @-) |
5d1d4326 | 1569 | */ |
7e2040f0 | 1570 | else if (*s == '@' && s[1] |
5d1d4326 | 1571 | && (isALNUM_lazy_if(s+1,UTF) || strchr(":'{$+-", s[1]))) |
79072805 | 1572 | break; |
02aa26ce NT |
1573 | |
1574 | /* check for embedded scalars. only stop if we're sure it's a | |
1575 | variable. | |
1576 | */ | |
79072805 | 1577 | else if (*s == '$') { |
3280af22 | 1578 | if (!PL_lex_inpat) /* not a regexp, so $ must be var */ |
79072805 | 1579 | break; |
6002328a | 1580 | if (s + 1 < send && !strchr("()| \r\n\t", s[1])) |
79072805 LW |
1581 | break; /* in regexp, $ might be tail anchor */ |
1582 | } | |
02aa26ce | 1583 | |
2b9d42f0 NIS |
1584 | /* End of else if chain - OP_TRANS rejoin rest */ |
1585 | ||
02aa26ce | 1586 | /* backslashes */ |
79072805 LW |
1587 | if (*s == '\\' && s+1 < send) { |
1588 | s++; | |
02aa26ce NT |
1589 | |
1590 | /* some backslashes we leave behind */ | |
c9f97d15 | 1591 | if (*leaveit && *s && strchr(leaveit, *s)) { |
db42d148 NIS |
1592 | *d++ = NATIVE_TO_NEED(has_utf8,'\\'); |
1593 | *d++ = NATIVE_TO_NEED(has_utf8,*s++); | |
79072805 LW |
1594 | continue; |
1595 | } | |
02aa26ce NT |
1596 | |
1597 | /* deprecate \1 in strings and substitution replacements */ | |
3280af22 | 1598 | if (PL_lex_inwhat == OP_SUBST && !PL_lex_inpat && |
a0d0e21e | 1599 | isDIGIT(*s) && *s != '0' && !isDIGIT(s[1])) |
79072805 | 1600 | { |
599cee73 | 1601 | if (ckWARN(WARN_SYNTAX)) |
9014280d | 1602 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "\\%c better written as $%c", *s, *s); |
79072805 LW |
1603 | *--s = '$'; |
1604 | break; | |
1605 | } | |
02aa26ce NT |
1606 | |
1607 | /* string-change backslash escapes */ | |
3280af22 | 1608 | if (PL_lex_inwhat != OP_TRANS && *s && strchr("lLuUEQ", *s)) { |
79072805 LW |
1609 | --s; |
1610 | break; | |
1611 | } | |
02aa26ce NT |
1612 | |
1613 | /* if we get here, it's either a quoted -, or a digit */ | |
79072805 | 1614 | switch (*s) { |
02aa26ce NT |
1615 | |
1616 | /* quoted - in transliterations */ | |
79072805 | 1617 | case '-': |
3280af22 | 1618 | if (PL_lex_inwhat == OP_TRANS) { |
79072805 LW |
1619 | *d++ = *s++; |
1620 | continue; | |
1621 | } | |
1622 | /* FALL THROUGH */ | |
1623 | default: | |
11b8faa4 | 1624 | { |
041457d9 DM |
1625 | if (isALNUM(*s) && |
1626 | *s != '_' && | |
1627 | ckWARN(WARN_MISC)) | |
9014280d | 1628 | Perl_warner(aTHX_ packWARN(WARN_MISC), |
11b8faa4 JH |
1629 | "Unrecognized escape \\%c passed through", |
1630 | *s); | |
1631 | /* default action is to copy the quoted character */ | |
f9a63242 | 1632 | goto default_action; |
11b8faa4 | 1633 | } |
02aa26ce NT |
1634 | |
1635 | /* \132 indicates an octal constant */ | |
79072805 LW |
1636 | case '0': case '1': case '2': case '3': |
1637 | case '4': case '5': case '6': case '7': | |
ba210ebe | 1638 | { |
53305cf1 NC |
1639 | I32 flags = 0; |
1640 | STRLEN len = 3; | |
1641 | uv = grok_oct(s, &len, &flags, NULL); | |
ba210ebe JH |
1642 | s += len; |
1643 | } | |
012bcf8d | 1644 | goto NUM_ESCAPE_INSERT; |
02aa26ce NT |
1645 | |
1646 | /* \x24 indicates a hex constant */ | |
79072805 | 1647 | case 'x': |
a0ed51b3 LW |
1648 | ++s; |
1649 | if (*s == '{') { | |
9d4ba2ae | 1650 | char* const e = strchr(s, '}'); |
a4c04bdc NC |
1651 | I32 flags = PERL_SCAN_ALLOW_UNDERSCORES | |
1652 | PERL_SCAN_DISALLOW_PREFIX; | |
53305cf1 | 1653 | STRLEN len; |
355860ce | 1654 | |
53305cf1 | 1655 | ++s; |
adaeee49 | 1656 | if (!e) { |
a0ed51b3 | 1657 | yyerror("Missing right brace on \\x{}"); |
355860ce | 1658 | continue; |
ba210ebe | 1659 | } |
53305cf1 NC |
1660 | len = e - s; |
1661 | uv = grok_hex(s, &len, &flags, NULL); | |
ba210ebe | 1662 | s = e + 1; |
a0ed51b3 LW |
1663 | } |
1664 | else { | |
ba210ebe | 1665 | { |
53305cf1 | 1666 | STRLEN len = 2; |
a4c04bdc | 1667 | I32 flags = PERL_SCAN_DISALLOW_PREFIX; |
53305cf1 | 1668 | uv = grok_hex(s, &len, &flags, NULL); |
ba210ebe JH |
1669 | s += len; |
1670 | } | |
012bcf8d GS |
1671 | } |
1672 | ||
1673 | NUM_ESCAPE_INSERT: | |
1674 | /* Insert oct or hex escaped character. | |
301d3d20 | 1675 | * There will always enough room in sv since such |
db42d148 | 1676 | * escapes will be longer than any UTF-8 sequence |
301d3d20 | 1677 | * they can end up as. */ |
ba7cea30 | 1678 | |
c7f1f016 NIS |
1679 | /* We need to map to chars to ASCII before doing the tests |
1680 | to cover EBCDIC | |
1681 | */ | |
c4d5f83a | 1682 | if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(uv))) { |
9aa983d2 | 1683 | if (!has_utf8 && uv > 255) { |
301d3d20 JH |
1684 | /* Might need to recode whatever we have |
1685 | * accumulated so far if it contains any | |
1686 | * hibit chars. | |
1687 | * | |
1688 | * (Can't we keep track of that and avoid | |
1689 | * this rescan? --jhi) | |
012bcf8d | 1690 | */ |
c7f1f016 | 1691 | int hicount = 0; |
63cd0674 NIS |
1692 | U8 *c; |
1693 | for (c = (U8 *) SvPVX(sv); c < (U8 *)d; c++) { | |
c4d5f83a | 1694 | if (!NATIVE_IS_INVARIANT(*c)) { |
012bcf8d | 1695 | hicount++; |
db42d148 | 1696 | } |
012bcf8d | 1697 | } |
63cd0674 | 1698 | if (hicount) { |
9d4ba2ae | 1699 | const STRLEN offset = d - SvPVX_const(sv); |
db42d148 NIS |
1700 | U8 *src, *dst; |
1701 | d = SvGROW(sv, SvLEN(sv) + hicount + 1) + offset; | |
1702 | src = (U8 *)d - 1; | |
1703 | dst = src+hicount; | |
1704 | d += hicount; | |
cfd0369c | 1705 | while (src >= (const U8 *)SvPVX_const(sv)) { |
c4d5f83a | 1706 | if (!NATIVE_IS_INVARIANT(*src)) { |
9d4ba2ae | 1707 | const U8 ch = NATIVE_TO_ASCII(*src); |
eb160463 GS |
1708 | *dst-- = (U8)UTF8_EIGHT_BIT_LO(ch); |
1709 | *dst-- = (U8)UTF8_EIGHT_BIT_HI(ch); | |
012bcf8d GS |
1710 | } |
1711 | else { | |
63cd0674 | 1712 | *dst-- = *src; |
012bcf8d | 1713 | } |
c7f1f016 | 1714 | src--; |
012bcf8d GS |
1715 | } |
1716 | } | |
1717 | } | |
1718 | ||
9aa983d2 | 1719 | if (has_utf8 || uv > 255) { |
9041c2e3 | 1720 | d = (char*)uvchr_to_utf8((U8*)d, uv); |
4e553d73 | 1721 | has_utf8 = TRUE; |
f9a63242 JH |
1722 | if (PL_lex_inwhat == OP_TRANS && |
1723 | PL_sublex_info.sub_op) { | |
1724 | PL_sublex_info.sub_op->op_private |= | |
1725 | (PL_lex_repl ? OPpTRANS_FROM_UTF | |
1726 | : OPpTRANS_TO_UTF); | |
f9a63242 | 1727 | } |
012bcf8d | 1728 | } |
a0ed51b3 | 1729 | else { |
012bcf8d | 1730 | *d++ = (char)uv; |
a0ed51b3 | 1731 | } |
012bcf8d GS |
1732 | } |
1733 | else { | |
c4d5f83a | 1734 | *d++ = (char) uv; |
a0ed51b3 | 1735 | } |
79072805 | 1736 | continue; |
02aa26ce | 1737 | |
b239daa5 | 1738 | /* \N{LATIN SMALL LETTER A} is a named character */ |
4a2d328f | 1739 | case 'N': |
55eda711 | 1740 | ++s; |
423cee85 JH |
1741 | if (*s == '{') { |
1742 | char* e = strchr(s, '}'); | |
155aba94 | 1743 | SV *res; |
423cee85 | 1744 | STRLEN len; |
cfd0369c | 1745 | const char *str; |
4e553d73 | 1746 | |
423cee85 | 1747 | if (!e) { |
5777a3f7 | 1748 | yyerror("Missing right brace on \\N{}"); |
423cee85 JH |
1749 | e = s - 1; |
1750 | goto cont_scan; | |
1751 | } | |
dbc0d4f2 JH |
1752 | if (e > s + 2 && s[1] == 'U' && s[2] == '+') { |
1753 | /* \N{U+...} */ | |
1754 | I32 flags = PERL_SCAN_ALLOW_UNDERSCORES | | |
1755 | PERL_SCAN_DISALLOW_PREFIX; | |
1756 | s += 3; | |
1757 | len = e - s; | |
1758 | uv = grok_hex(s, &len, &flags, NULL); | |
1759 | s = e + 1; | |
1760 | goto NUM_ESCAPE_INSERT; | |
1761 | } | |
55eda711 JH |
1762 | res = newSVpvn(s + 1, e - s - 1); |
1763 | res = new_constant( Nullch, 0, "charnames", | |
1764 | res, Nullsv, "\\N{...}" ); | |
f9a63242 JH |
1765 | if (has_utf8) |
1766 | sv_utf8_upgrade(res); | |
cfd0369c | 1767 | str = SvPV_const(res,len); |
1c47067b JH |
1768 | #ifdef EBCDIC_NEVER_MIND |
1769 | /* charnames uses pack U and that has been | |
1770 | * recently changed to do the below uni->native | |
1771 | * mapping, so this would be redundant (and wrong, | |
1772 | * the code point would be doubly converted). | |
1773 | * But leave this in just in case the pack U change | |
1774 | * gets revoked, but the semantics is still | |
1775 | * desireable for charnames. --jhi */ | |
cddc7ef4 | 1776 | { |
cfd0369c | 1777 | UV uv = utf8_to_uvchr((const U8*)str, 0); |
cddc7ef4 JH |
1778 | |
1779 | if (uv < 0x100) { | |
89ebb4a3 | 1780 | U8 tmpbuf[UTF8_MAXBYTES+1], *d; |
cddc7ef4 JH |
1781 | |
1782 | d = uvchr_to_utf8(tmpbuf, UNI_TO_NATIVE(uv)); | |
1783 | sv_setpvn(res, (char *)tmpbuf, d - tmpbuf); | |
cfd0369c | 1784 | str = SvPV_const(res, len); |
cddc7ef4 JH |
1785 | } |
1786 | } | |
1787 | #endif | |
89491803 | 1788 | if (!has_utf8 && SvUTF8(res)) { |
9d4ba2ae | 1789 | const char * const ostart = SvPVX_const(sv); |
f08d6ad9 GS |
1790 | SvCUR_set(sv, d - ostart); |
1791 | SvPOK_on(sv); | |
e4f3eed8 | 1792 | *d = '\0'; |
f08d6ad9 | 1793 | sv_utf8_upgrade(sv); |
d2f449dd | 1794 | /* this just broke our allocation above... */ |
eb160463 | 1795 | SvGROW(sv, (STRLEN)(send - start)); |
f08d6ad9 | 1796 | d = SvPVX(sv) + SvCUR(sv); |
89491803 | 1797 | has_utf8 = TRUE; |
f08d6ad9 | 1798 | } |
eb160463 | 1799 | if (len > (STRLEN)(e - s + 4)) { /* I _guess_ 4 is \N{} --jhi */ |
9d4ba2ae | 1800 | const char * const odest = SvPVX_const(sv); |
423cee85 | 1801 | |
8973db79 | 1802 | SvGROW(sv, (SvLEN(sv) + len - (e - s + 4))); |
423cee85 JH |
1803 | d = SvPVX(sv) + (d - odest); |
1804 | } | |
1805 | Copy(str, d, len, char); | |
1806 | d += len; | |
1807 | SvREFCNT_dec(res); | |
1808 | cont_scan: | |
1809 | s = e + 1; | |
1810 | } | |
1811 | else | |
5777a3f7 | 1812 | yyerror("Missing braces on \\N{}"); |
423cee85 JH |
1813 | continue; |
1814 | ||
02aa26ce | 1815 | /* \c is a control character */ |
79072805 LW |
1816 | case 'c': |
1817 | s++; | |
961ce445 | 1818 | if (s < send) { |
ba210ebe | 1819 | U8 c = *s++; |
c7f1f016 NIS |
1820 | #ifdef EBCDIC |
1821 | if (isLOWER(c)) | |
1822 | c = toUPPER(c); | |
1823 | #endif | |
db42d148 | 1824 | *d++ = NATIVE_TO_NEED(has_utf8,toCTRL(c)); |
ba210ebe | 1825 | } |
961ce445 RGS |
1826 | else { |
1827 | yyerror("Missing control char name in \\c"); | |
1828 | } | |
79072805 | 1829 | continue; |
02aa26ce NT |
1830 | |
1831 | /* printf-style backslashes, formfeeds, newlines, etc */ | |
79072805 | 1832 | case 'b': |
db42d148 | 1833 | *d++ = NATIVE_TO_NEED(has_utf8,'\b'); |
79072805 LW |
1834 | break; |
1835 | case 'n': | |
db42d148 | 1836 | *d++ = NATIVE_TO_NEED(has_utf8,'\n'); |
79072805 LW |
1837 | break; |
1838 | case 'r': | |
db42d148 | 1839 | *d++ = NATIVE_TO_NEED(has_utf8,'\r'); |
79072805 LW |
1840 | break; |
1841 | case 'f': | |
db42d148 | 1842 | *d++ = NATIVE_TO_NEED(has_utf8,'\f'); |
79072805 LW |
1843 | break; |
1844 | case 't': | |
db42d148 | 1845 | *d++ = NATIVE_TO_NEED(has_utf8,'\t'); |
79072805 | 1846 | break; |
34a3fe2a | 1847 | case 'e': |
db42d148 | 1848 | *d++ = ASCII_TO_NEED(has_utf8,'\033'); |
34a3fe2a PP |
1849 | break; |
1850 | case 'a': | |
db42d148 | 1851 | *d++ = ASCII_TO_NEED(has_utf8,'\007'); |
79072805 | 1852 | break; |
02aa26ce NT |
1853 | } /* end switch */ |
1854 | ||
79072805 LW |
1855 | s++; |
1856 | continue; | |
02aa26ce | 1857 | } /* end if (backslash) */ |
4c3a8340 TS |
1858 | #ifdef EBCDIC |
1859 | else | |
1860 | literal_endpoint++; | |
1861 | #endif | |
02aa26ce | 1862 | |
f9a63242 | 1863 | default_action: |
2b9d42f0 NIS |
1864 | /* If we started with encoded form, or already know we want it |
1865 | and then encode the next character */ | |
1866 | if ((has_utf8 || this_utf8) && !NATIVE_IS_INVARIANT((U8)(*s))) { | |
1867 | STRLEN len = 1; | |
9d4ba2ae AL |
1868 | const UV uv = (this_utf8) ? utf8n_to_uvchr((U8*)s, send - s, &len, 0) : (UV) ((U8) *s); |
1869 | const STRLEN need = UNISKIP(NATIVE_TO_UNI(uv)); | |
2b9d42f0 NIS |
1870 | s += len; |
1871 | if (need > len) { | |
1872 | /* encoded value larger than old, need extra space (NOTE: SvCUR() not set here) */ | |
9d4ba2ae | 1873 | const STRLEN off = d - SvPVX_const(sv); |
2b9d42f0 NIS |
1874 | d = SvGROW(sv, SvLEN(sv) + (need-len)) + off; |
1875 | } | |
1876 | d = (char*)uvchr_to_utf8((U8*)d, uv); | |
1877 | has_utf8 = TRUE; | |
1878 | } | |
1879 | else { | |
1880 | *d++ = NATIVE_TO_NEED(has_utf8,*s++); | |
1881 | } | |
02aa26ce NT |
1882 | } /* while loop to process each character */ |
1883 | ||
1884 | /* terminate the string and set up the sv */ | |
79072805 | 1885 | *d = '\0'; |
95a20fc0 | 1886 | SvCUR_set(sv, d - SvPVX_const(sv)); |
2b9d42f0 | 1887 | if (SvCUR(sv) >= SvLEN(sv)) |
d0063567 | 1888 | Perl_croak(aTHX_ "panic: constant overflowed allocated space"); |
2b9d42f0 | 1889 | |
79072805 | 1890 | SvPOK_on(sv); |
9f4817db | 1891 | if (PL_encoding && !has_utf8) { |
d0063567 DK |
1892 | sv_recode_to_utf8(sv, PL_encoding); |
1893 | if (SvUTF8(sv)) | |
1894 | has_utf8 = TRUE; | |
9f4817db | 1895 | } |
2b9d42f0 | 1896 | if (has_utf8) { |
7e2040f0 | 1897 | SvUTF8_on(sv); |
2b9d42f0 | 1898 | if (PL_lex_inwhat == OP_TRANS && PL_sublex_info.sub_op) { |
d0063567 | 1899 | PL_sublex_info.sub_op->op_private |= |
2b9d42f0 NIS |
1900 | (PL_lex_repl ? OPpTRANS_FROM_UTF : OPpTRANS_TO_UTF); |
1901 | } | |
1902 | } | |
79072805 | 1903 | |
02aa26ce | 1904 | /* shrink the sv if we allocated more than we used */ |
79072805 | 1905 | if (SvCUR(sv) + 5 < SvLEN(sv)) { |
1da4ca5f | 1906 | SvPV_shrink_to_cur(sv); |
79072805 | 1907 | } |
02aa26ce | 1908 | |
9b599b2a | 1909 | /* return the substring (via yylval) only if we parsed anything */ |
3280af22 NIS |
1910 | if (s > PL_bufptr) { |
1911 | if ( PL_hints & ( PL_lex_inpat ? HINT_NEW_RE : HINT_NEW_STRING ) ) | |
4e553d73 | 1912 | sv = new_constant(start, s - start, (PL_lex_inpat ? "qr" : "q"), |
b3ac6de7 | 1913 | sv, Nullsv, |
4e553d73 | 1914 | ( PL_lex_inwhat == OP_TRANS |
b3ac6de7 | 1915 | ? "tr" |
3280af22 | 1916 | : ( (PL_lex_inwhat == OP_SUBST && !PL_lex_inpat) |
b3ac6de7 IZ |
1917 | ? "s" |
1918 | : "qq"))); | |
79072805 | 1919 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv); |
b3ac6de7 | 1920 | } else |
8990e307 | 1921 | SvREFCNT_dec(sv); |
79072805 LW |
1922 | return s; |
1923 | } | |
1924 | ||
ffb4593c NT |
1925 | /* S_intuit_more |
1926 | * Returns TRUE if there's more to the expression (e.g., a subscript), | |
1927 | * FALSE otherwise. | |
ffb4593c NT |
1928 | * |
1929 | * It deals with "$foo[3]" and /$foo[3]/ and /$foo[0123456789$]+/ | |
1930 | * | |
1931 | * ->[ and ->{ return TRUE | |
1932 | * { and [ outside a pattern are always subscripts, so return TRUE | |
1933 | * if we're outside a pattern and it's not { or [, then return FALSE | |
1934 | * if we're in a pattern and the first char is a { | |
1935 | * {4,5} (any digits around the comma) returns FALSE | |
1936 | * if we're in a pattern and the first char is a [ | |
1937 | * [] returns FALSE | |
1938 | * [SOMETHING] has a funky algorithm to decide whether it's a | |
1939 | * character class or not. It has to deal with things like | |
1940 | * /$foo[-3]/ and /$foo[$bar]/ as well as /$foo[$\d]+/ | |
1941 | * anything else returns TRUE | |
1942 | */ | |
1943 | ||
9cbb5ea2 GS |
1944 | /* This is the one truly awful dwimmer necessary to conflate C and sed. */ |
1945 | ||
76e3520e | 1946 | STATIC int |
cea2e8a9 | 1947 | S_intuit_more(pTHX_ register char *s) |
79072805 | 1948 | { |
3280af22 | 1949 | if (PL_lex_brackets) |
79072805 LW |
1950 | return TRUE; |
1951 | if (*s == '-' && s[1] == '>' && (s[2] == '[' || s[2] == '{')) | |
1952 | return TRUE; | |
1953 | if (*s != '{' && *s != '[') | |
1954 | return FALSE; | |
3280af22 | 1955 | if (!PL_lex_inpat) |
79072805 LW |
1956 | return TRUE; |
1957 | ||
1958 | /* In a pattern, so maybe we have {n,m}. */ | |
1959 | if (*s == '{') { | |
1960 | s++; | |
1961 | if (!isDIGIT(*s)) | |
1962 | return TRUE; | |
1963 | while (isDIGIT(*s)) | |
1964 | s++; | |
1965 | if (*s == ',') | |
1966 | s++; | |
1967 | while (isDIGIT(*s)) | |
1968 | s++; | |
1969 | if (*s == '}') | |
1970 | return FALSE; | |
1971 | return TRUE; | |
1972 | ||
1973 | } | |
1974 | ||
1975 | /* On the other hand, maybe we have a character class */ | |
1976 | ||
1977 | s++; | |
1978 | if (*s == ']' || *s == '^') | |
1979 | return FALSE; | |
1980 | else { | |
ffb4593c | 1981 | /* this is terrifying, and it works */ |
79072805 LW |
1982 | int weight = 2; /* let's weigh the evidence */ |
1983 | char seen[256]; | |
f27ffc4a | 1984 | unsigned char un_char = 255, last_un_char; |
9d4ba2ae | 1985 | const char * const send = strchr(s,']'); |
3280af22 | 1986 | char tmpbuf[sizeof PL_tokenbuf * 4]; |
79072805 LW |
1987 | |
1988 | if (!send) /* has to be an expression */ | |
1989 | return TRUE; | |
1990 | ||
1991 | Zero(seen,256,char); | |
1992 | if (*s == '$') | |
1993 | weight -= 3; | |
1994 | else if (isDIGIT(*s)) { | |
1995 | if (s[1] != ']') { | |
1996 | if (isDIGIT(s[1]) && s[2] == ']') | |
1997 | weight -= 10; | |
1998 | } | |
1999 | else | |
2000 | weight -= 100; | |
2001 | } | |
2002 | for (; s < send; s++) { | |
2003 | last_un_char = un_char; | |
2004 | un_char = (unsigned char)*s; | |
2005 | switch (*s) { | |
2006 | case '@': | |
2007 | case '&': | |
2008 | case '$': | |
2009 | weight -= seen[un_char] * 10; | |
7e2040f0 | 2010 | if (isALNUM_lazy_if(s+1,UTF)) { |
8903cb82 | 2011 | scan_ident(s, send, tmpbuf, sizeof tmpbuf, FALSE); |
f776e3cd NC |
2012 | if ((int)strlen(tmpbuf) > 1 |
2013 | && gv_fetchpv(tmpbuf, 0, SVt_PV)) | |
79072805 LW |
2014 | weight -= 100; |
2015 | else | |
2016 | weight -= 10; | |
2017 | } | |
2018 | else if (*s == '$' && s[1] && | |
93a17b20 LW |
2019 | strchr("[#!%*<>()-=",s[1])) { |
2020 | if (/*{*/ strchr("])} =",s[2])) | |
79072805 LW |
2021 | weight -= 10; |
2022 | else | |
2023 | weight -= 1; | |
2024 | } | |
2025 | break; | |
2026 | case '\\': | |
2027 | un_char = 254; | |
2028 | if (s[1]) { | |
93a17b20 | 2029 | if (strchr("wds]",s[1])) |
79072805 LW |
2030 | weight += 100; |
2031 | else if (seen['\''] || seen['"']) | |
2032 | weight += 1; | |
93a17b20 | 2033 | else if (strchr("rnftbxcav",s[1])) |
79072805 LW |
2034 | weight += 40; |
2035 | else if (isDIGIT(s[1])) { | |
2036 | weight += 40; | |
2037 | while (s[1] && isDIGIT(s[1])) | |
2038 | s++; | |
2039 | } | |
2040 | } | |
2041 | else | |
2042 | weight += 100; | |
2043 | break; | |
2044 | case '-': | |
2045 | if (s[1] == '\\') | |
2046 | weight += 50; | |
93a17b20 | 2047 | if (strchr("aA01! ",last_un_char)) |
79072805 | 2048 | weight += 30; |
93a17b20 | 2049 | if (strchr("zZ79~",s[1])) |
79072805 | 2050 | weight += 30; |
f27ffc4a GS |
2051 | if (last_un_char == 255 && (isDIGIT(s[1]) || s[1] == '$')) |
2052 | weight -= 5; /* cope with negative subscript */ | |
79072805 LW |
2053 | break; |
2054 | default: | |
3792a11b NC |
2055 | if (!isALNUM(last_un_char) |
2056 | && !(last_un_char == '$' || last_un_char == '@' | |
2057 | || last_un_char == '&') | |
2058 | && isALPHA(*s) && s[1] && isALPHA(s[1])) { | |
79072805 LW |
2059 | char *d = tmpbuf; |
2060 | while (isALPHA(*s)) | |
2061 | *d++ = *s++; | |
2062 | *d = '\0'; | |
2063 | if (keyword(tmpbuf, d - tmpbuf)) | |
2064 | weight -= 150; | |
2065 | } | |
2066 | if (un_char == last_un_char + 1) | |
2067 | weight += 5; | |
2068 | weight -= seen[un_char]; | |
2069 | break; | |
2070 | } | |
2071 | seen[un_char]++; | |
2072 | } | |
2073 | if (weight >= 0) /* probably a character class */ | |
2074 | return FALSE; | |
2075 | } | |
2076 | ||
2077 | return TRUE; | |
2078 | } | |
ffed7fef | 2079 | |
ffb4593c NT |
2080 | /* |
2081 | * S_intuit_method | |
2082 | * | |
2083 | * Does all the checking to disambiguate | |
2084 | * foo bar | |
2085 | * between foo(bar) and bar->foo. Returns 0 if not a method, otherwise | |
2086 | * FUNCMETH (bar->foo(args)) or METHOD (bar->foo args). | |
2087 | * | |
2088 | * First argument is the stuff after the first token, e.g. "bar". | |
2089 | * | |
2090 | * Not a method if bar is a filehandle. | |
2091 | * Not a method if foo is a subroutine prototyped to take a filehandle. | |
2092 | * Not a method if it's really "Foo $bar" | |
2093 | * Method if it's "foo $bar" | |
2094 | * Not a method if it's really "print foo $bar" | |
2095 | * Method if it's really "foo package::" (interpreted as package->foo) | |
8f8cf39c | 2096 | * Not a method if bar is known to be a subroutine ("sub bar; foo bar") |
3cb0bbe5 | 2097 | * Not a method if bar is a filehandle or package, but is quoted with |
ffb4593c NT |
2098 | * => |
2099 | */ | |
2100 | ||
76e3520e | 2101 | STATIC int |
62d55b22 | 2102 | S_intuit_method(pTHX_ char *start, GV *gv, CV *cv) |
a0d0e21e LW |
2103 | { |
2104 | char *s = start + (*start == '$'); | |
3280af22 | 2105 | char tmpbuf[sizeof PL_tokenbuf]; |
a0d0e21e LW |
2106 | STRLEN len; |
2107 | GV* indirgv; | |
2108 | ||
2109 | if (gv) { | |
62d55b22 | 2110 | if (SvTYPE(gv) == SVt_PVGV && GvIO(gv)) |
a0d0e21e | 2111 | return 0; |
62d55b22 NC |
2112 | if (cv) { |
2113 | if (SvPOK(cv)) { | |
2114 | const char *proto = SvPVX_const(cv); | |
2115 | if (proto) { | |
2116 | if (*proto == ';') | |
2117 | proto++; | |
2118 | if (*proto == '*') | |
2119 | return 0; | |
2120 | } | |
b6c543e3 IZ |
2121 | } |
2122 | } else | |
a0d0e21e LW |
2123 | gv = 0; |
2124 | } | |
8903cb82 | 2125 | s = scan_word(s, tmpbuf, sizeof tmpbuf, TRUE, &len); |
ffb4593c NT |
2126 | /* start is the beginning of the possible filehandle/object, |
2127 | * and s is the end of it | |
2128 | * tmpbuf is a copy of it | |
2129 | */ | |
2130 | ||
a0d0e21e | 2131 | if (*start == '$') { |
3280af22 | 2132 | if (gv || PL_last_lop_op == OP_PRINT || isUPPER(*PL_tokenbuf)) |
a0d0e21e LW |
2133 | return 0; |
2134 | s = skipspace(s); | |
3280af22 NIS |
2135 | PL_bufptr = start; |
2136 | PL_expect = XREF; | |
a0d0e21e LW |
2137 | return *s == '(' ? FUNCMETH : METHOD; |
2138 | } | |
2139 | if (!keyword(tmpbuf, len)) { | |
c3e0f903 GS |
2140 | if (len > 2 && tmpbuf[len - 2] == ':' && tmpbuf[len - 1] == ':') { |
2141 | len -= 2; | |
2142 | tmpbuf[len] = '\0'; | |
2143 | goto bare_package; | |
2144 | } | |
f776e3cd | 2145 | indirgv = gv_fetchpv(tmpbuf, 0, SVt_PVCV); |
8ebc5c01 | 2146 | if (indirgv && GvCVu(indirgv)) |
a0d0e21e LW |
2147 | return 0; |
2148 | /* filehandle or package name makes it a method */ | |
89bfa8cd | 2149 | if (!gv || GvIO(indirgv) || gv_stashpvn(tmpbuf, len, FALSE)) { |
a0d0e21e | 2150 | s = skipspace(s); |
3280af22 | 2151 | if ((PL_bufend - s) >= 2 && *s == '=' && *(s+1) == '>') |
55497cff | 2152 | return 0; /* no assumptions -- "=>" quotes bearword */ |
c3e0f903 | 2153 | bare_package: |
3280af22 | 2154 | PL_nextval[PL_nexttoke].opval = (OP*)newSVOP(OP_CONST, 0, |
79cb57f6 | 2155 | newSVpvn(tmpbuf,len)); |
3280af22 NIS |
2156 | PL_nextval[PL_nexttoke].opval->op_private = OPpCONST_BARE; |
2157 | PL_expect = XTERM; | |
a0d0e21e | 2158 | force_next(WORD); |
3280af22 | 2159 | PL_bufptr = s; |
a0d0e21e LW |
2160 | return *s == '(' ? FUNCMETH : METHOD; |
2161 | } | |
2162 | } | |
2163 | return 0; | |
2164 | } | |
2165 | ||
ffb4593c NT |
2166 | /* |
2167 | * S_incl_perldb | |
2168 | * Return a string of Perl code to load the debugger. If PERL5DB | |
2169 | * is set, it will return the contents of that, otherwise a | |
2170 | * compile-time require of perl5db.pl. | |
2171 | */ | |
2172 | ||
bfed75c6 | 2173 | STATIC const char* |
cea2e8a9 | 2174 | S_incl_perldb(pTHX) |
a0d0e21e | 2175 | { |
3280af22 | 2176 | if (PL_perldb) { |
9d4ba2ae | 2177 | const char * const pdb = PerlEnv_getenv("PERL5DB"); |
a0d0e21e LW |
2178 | |
2179 | if (pdb) | |
2180 | return pdb; | |
93189314 | 2181 | SETERRNO(0,SS_NORMAL); |
a0d0e21e LW |
2182 | return "BEGIN { require 'perl5db.pl' }"; |
2183 | } | |
2184 | return ""; | |
2185 | } | |
2186 | ||
2187 | ||
16d20bd9 | 2188 | /* Encoded script support. filter_add() effectively inserts a |
4e553d73 | 2189 | * 'pre-processing' function into the current source input stream. |
16d20bd9 AD |
2190 | * Note that the filter function only applies to the current source file |
2191 | * (e.g., it will not affect files 'require'd or 'use'd by this one). | |
2192 | * | |
2193 | * The datasv parameter (which may be NULL) can be used to pass | |
2194 | * private data to this instance of the filter. The filter function | |
2195 | * can recover the SV using the FILTER_DATA macro and use it to | |
2196 | * store private buffers and state information. | |
2197 | * | |
2198 | * The supplied datasv parameter is upgraded to a PVIO type | |
4755096e | 2199 | * and the IoDIRP/IoANY field is used to store the function pointer, |
e0c19803 | 2200 | * and IOf_FAKE_DIRP is enabled on datasv to mark this as such. |
16d20bd9 AD |
2201 | * Note that IoTOP_NAME, IoFMT_NAME, IoBOTTOM_NAME, if set for |
2202 | * private use must be set using malloc'd pointers. | |
2203 | */ | |
16d20bd9 AD |
2204 | |
2205 | SV * | |
864dbfa3 | 2206 | Perl_filter_add(pTHX_ filter_t funcp, SV *datasv) |
16d20bd9 | 2207 | { |
f4c556ac GS |
2208 | if (!funcp) |
2209 | return Nullsv; | |
2210 | ||
3280af22 NIS |
2211 | if (!PL_rsfp_filters) |
2212 | PL_rsfp_filters = newAV(); | |
16d20bd9 | 2213 | if (!datasv) |
8c52afec | 2214 | datasv = NEWSV(255,0); |
862a34c6 | 2215 | SvUPGRADE(datasv, SVt_PVIO); |
8141890a | 2216 | IoANY(datasv) = FPTR2DPTR(void *, funcp); /* stash funcp into spare field */ |
e0c19803 | 2217 | IoFLAGS(datasv) |= IOf_FAKE_DIRP; |
f4c556ac | 2218 | DEBUG_P(PerlIO_printf(Perl_debug_log, "filter_add func %p (%s)\n", |
8141890a | 2219 | IoANY(datasv), SvPV_nolen(datasv))); |
3280af22 NIS |
2220 | av_unshift(PL_rsfp_filters, 1); |
2221 | av_store(PL_rsfp_filters, 0, datasv) ; | |
16d20bd9 AD |
2222 | return(datasv); |
2223 | } | |
4e553d73 | 2224 | |
16d20bd9 AD |
2225 | |
2226 | /* Delete most recently added instance of this filter function. */ | |
a0d0e21e | 2227 | void |
864dbfa3 | 2228 | Perl_filter_del(pTHX_ filter_t funcp) |
16d20bd9 | 2229 | { |
e0c19803 | 2230 | SV *datasv; |
24801a4b | 2231 | |
33073adb | 2232 | #ifdef DEBUGGING |
8141890a | 2233 | DEBUG_P(PerlIO_printf(Perl_debug_log, "filter_del func %p", FPTR2DPTR(XPVIO *, funcp))); |
33073adb | 2234 | #endif |
3280af22 | 2235 | if (!PL_rsfp_filters || AvFILLp(PL_rsfp_filters)<0) |
16d20bd9 AD |
2236 | return; |
2237 | /* if filter is on top of stack (usual case) just pop it off */ | |
e0c19803 | 2238 | datasv = FILTER_DATA(AvFILLp(PL_rsfp_filters)); |
8141890a | 2239 | if (IoANY(datasv) == FPTR2DPTR(void *, funcp)) { |
e0c19803 | 2240 | IoFLAGS(datasv) &= ~IOf_FAKE_DIRP; |
4755096e | 2241 | IoANY(datasv) = (void *)NULL; |
3280af22 | 2242 | sv_free(av_pop(PL_rsfp_filters)); |
e50aee73 | 2243 | |
16d20bd9 AD |
2244 | return; |
2245 | } | |
2246 | /* we need to search for the correct entry and clear it */ | |
cea2e8a9 | 2247 | Perl_die(aTHX_ "filter_del can only delete in reverse order (currently)"); |
16d20bd9 AD |
2248 | } |
2249 | ||
2250 | ||
1de9afcd RGS |
2251 | /* Invoke the idxth filter function for the current rsfp. */ |
2252 | /* maxlen 0 = read one text line */ | |
16d20bd9 | 2253 | I32 |
864dbfa3 | 2254 | Perl_filter_read(pTHX_ int idx, SV *buf_sv, int maxlen) |
a0d0e21e | 2255 | { |
16d20bd9 AD |
2256 | filter_t funcp; |
2257 | SV *datasv = NULL; | |
e50aee73 | 2258 | |
3280af22 | 2259 | if (!PL_rsfp_filters) |
16d20bd9 | 2260 | return -1; |
1de9afcd | 2261 | if (idx > AvFILLp(PL_rsfp_filters)) { /* Any more filters? */ |
16d20bd9 AD |
2262 | /* Provide a default input filter to make life easy. */ |
2263 | /* Note that we append to the line. This is handy. */ | |
f4c556ac GS |
2264 | DEBUG_P(PerlIO_printf(Perl_debug_log, |
2265 | "filter_read %d: from rsfp\n", idx)); | |
4e553d73 | 2266 | if (maxlen) { |
16d20bd9 AD |
2267 | /* Want a block */ |
2268 | int len ; | |
f54cb97a | 2269 | const int old_len = SvCUR(buf_sv); |
16d20bd9 AD |
2270 | |
2271 | /* ensure buf_sv is large enough */ | |
eb160463 | 2272 | SvGROW(buf_sv, (STRLEN)(old_len + maxlen)) ; |
3280af22 NIS |
2273 | if ((len = PerlIO_read(PL_rsfp, SvPVX(buf_sv) + old_len, maxlen)) <= 0){ |
2274 | if (PerlIO_error(PL_rsfp)) | |
37120919 AD |
2275 | return -1; /* error */ |
2276 | else | |
2277 | return 0 ; /* end of file */ | |
2278 | } | |
16d20bd9 AD |
2279 | SvCUR_set(buf_sv, old_len + len) ; |
2280 | } else { | |
2281 | /* Want a line */ | |
3280af22 NIS |
2282 | if (sv_gets(buf_sv, PL_rsfp, SvCUR(buf_sv)) == NULL) { |
2283 | if (PerlIO_error(PL_rsfp)) | |
37120919 AD |
2284 | return -1; /* error */ |
2285 | else | |
2286 | return 0 ; /* end of file */ | |
2287 | } | |
16d20bd9 AD |
2288 | } |
2289 | return SvCUR(buf_sv); | |
2290 | } | |
2291 | /* Skip this filter slot if filter has been deleted */ | |
1de9afcd | 2292 | if ( (datasv = FILTER_DATA(idx)) == &PL_sv_undef) { |
f4c556ac GS |
2293 | DEBUG_P(PerlIO_printf(Perl_debug_log, |
2294 | "filter_read %d: skipped (filter deleted)\n", | |
2295 | idx)); | |
16d20bd9 AD |
2296 | return FILTER_READ(idx+1, buf_sv, maxlen); /* recurse */ |
2297 | } | |
2298 | /* Get function pointer hidden within datasv */ | |
8141890a | 2299 | funcp = DPTR2FPTR(filter_t, IoANY(datasv)); |
f4c556ac GS |
2300 | DEBUG_P(PerlIO_printf(Perl_debug_log, |
2301 | "filter_read %d: via function %p (%s)\n", | |
cfd0369c | 2302 | idx, datasv, SvPV_nolen_const(datasv))); |
16d20bd9 AD |
2303 | /* Call function. The function is expected to */ |
2304 | /* call "FILTER_READ(idx+1, buf_sv)" first. */ | |
37120919 | 2305 | /* Return: <0:error, =0:eof, >0:not eof */ |
acfe0abc | 2306 | return (*funcp)(aTHX_ idx, buf_sv, maxlen); |
16d20bd9 AD |
2307 | } |
2308 | ||
76e3520e | 2309 | STATIC char * |
cea2e8a9 | 2310 | S_filter_gets(pTHX_ register SV *sv, register PerlIO *fp, STRLEN append) |
16d20bd9 | 2311 | { |
c39cd008 | 2312 | #ifdef PERL_CR_FILTER |
3280af22 | 2313 | if (!PL_rsfp_filters) { |
c39cd008 | 2314 | filter_add(S_cr_textfilter,NULL); |
a868473f NIS |
2315 | } |
2316 | #endif | |
3280af22 | 2317 | if (PL_rsfp_filters) { |
55497cff | 2318 | if (!append) |
2319 | SvCUR_set(sv, 0); /* start with empty line */ | |
16d20bd9 AD |
2320 | if (FILTER_READ(0, sv, 0) > 0) |
2321 | return ( SvPVX(sv) ) ; | |
2322 | else | |
2323 | return Nullch ; | |
2324 | } | |
9d116dd7 | 2325 | else |
fd049845 | 2326 | return (sv_gets(sv, fp, append)); |
a0d0e21e LW |
2327 | } |
2328 | ||
01ec43d0 | 2329 | STATIC HV * |
7fc63493 | 2330 | S_find_in_my_stash(pTHX_ const char *pkgname, I32 len) |
def3634b GS |
2331 | { |
2332 | GV *gv; | |
2333 | ||
01ec43d0 | 2334 | if (len == 11 && *pkgname == '_' && strEQ(pkgname, "__PACKAGE__")) |
def3634b GS |
2335 | return PL_curstash; |
2336 | ||
2337 | if (len > 2 && | |
2338 | (pkgname[len - 2] == ':' && pkgname[len - 1] == ':') && | |
f776e3cd | 2339 | (gv = gv_fetchpv(pkgname, 0, SVt_PVHV))) |
01ec43d0 GS |
2340 | { |
2341 | return GvHV(gv); /* Foo:: */ | |
def3634b GS |
2342 | } |
2343 | ||
2344 | /* use constant CLASS => 'MyClass' */ | |
f776e3cd | 2345 | if ((gv = gv_fetchpv(pkgname, 0, SVt_PVCV))) { |
def3634b GS |
2346 | SV *sv; |
2347 | if (GvCV(gv) && (sv = cv_const_sv(GvCV(gv)))) { | |
83003860 | 2348 | pkgname = SvPV_nolen_const(sv); |
def3634b GS |
2349 | } |
2350 | } | |
2351 | ||
2352 | return gv_stashpv(pkgname, FALSE); | |
2353 | } | |
a0d0e21e | 2354 | |
468aa647 | 2355 | STATIC char * |
cc6ed77d | 2356 | S_tokenize_use(pTHX_ int is_use, char *s) { |
468aa647 RGS |
2357 | if (PL_expect != XSTATE) |
2358 | yyerror(Perl_form(aTHX_ "\"%s\" not allowed in expression", | |
2359 | is_use ? "use" : "no")); | |
2360 | s = skipspace(s); | |
2361 | if (isDIGIT(*s) || (*s == 'v' && isDIGIT(s[1]))) { | |
2362 | s = force_version(s, TRUE); | |
2363 | if (*s == ';' || (s = skipspace(s), *s == ';')) { | |
2364 | PL_nextval[PL_nexttoke].opval = Nullop; | |
2365 | force_next(WORD); | |
2366 | } | |
2367 | else if (*s == 'v') { | |
2368 | s = force_word(s,WORD,FALSE,TRUE,FALSE); | |
2369 | s = force_version(s, FALSE); | |
2370 | } | |
2371 | } | |
2372 | else { | |
2373 | s = force_word(s,WORD,FALSE,TRUE,FALSE); | |
2374 | s = force_version(s, FALSE); | |
2375 | } | |
2376 | yylval.ival = is_use; | |
2377 | return s; | |
2378 | } | |
748a9306 | 2379 | #ifdef DEBUGGING |
27da23d5 | 2380 | static const char* const exp_name[] = |
09bef843 | 2381 | { "OPERATOR", "TERM", "REF", "STATE", "BLOCK", "ATTRBLOCK", |
27308ded | 2382 | "ATTRTERM", "TERMBLOCK", "TERMORDORDOR" |
09bef843 | 2383 | }; |
748a9306 | 2384 | #endif |
463ee0b2 | 2385 | |
02aa26ce NT |
2386 | /* |
2387 | yylex | |
2388 | ||
2389 | Works out what to call the token just pulled out of the input | |
2390 | stream. The yacc parser takes care of taking the ops we return and | |
2391 | stitching them into a tree. | |
2392 | ||
2393 | Returns: | |
2394 | PRIVATEREF | |
2395 | ||
2396 | Structure: | |
2397 | if read an identifier | |
2398 | if we're in a my declaration | |
2399 | croak if they tried to say my($foo::bar) | |
2400 | build the ops for a my() declaration | |
2401 | if it's an access to a my() variable | |
2402 | are we in a sort block? | |
2403 | croak if my($a); $a <=> $b | |
2404 | build ops for access to a my() variable | |
2405 | if in a dq string, and they've said @foo and we can't find @foo | |
2406 | croak | |
2407 | build ops for a bareword | |
2408 | if we already built the token before, use it. | |
2409 | */ | |
2410 | ||
20141f0e | 2411 | |
dba4d153 JH |
2412 | #ifdef __SC__ |
2413 | #pragma segment Perl_yylex | |
2414 | #endif | |
dba4d153 | 2415 | int |
dba4d153 | 2416 | Perl_yylex(pTHX) |
20141f0e | 2417 | { |
3afc138a | 2418 | register char *s = PL_bufptr; |
378cc40b | 2419 | register char *d; |
463ee0b2 | 2420 | STRLEN len; |
aa7440fb | 2421 | bool bof = FALSE; |
a687059c | 2422 | |
bbf60fe6 | 2423 | DEBUG_T( { |
396482e1 | 2424 | SV* tmp = newSVpvs(""); |
b6007c36 DM |
2425 | PerlIO_printf(Perl_debug_log, "### %"IVdf":LEX_%s/X%s %s\n", |
2426 | (IV)CopLINE(PL_curcop), | |
2427 | lex_state_names[PL_lex_state], | |
2428 | exp_name[PL_expect], | |
2429 | pv_display(tmp, s, strlen(s), 0, 60)); | |
2430 | SvREFCNT_dec(tmp); | |
bbf60fe6 | 2431 | } ); |
02aa26ce | 2432 | /* check if there's an identifier for us to look at */ |
ba979b31 | 2433 | if (PL_pending_ident) |
bbf60fe6 | 2434 | return REPORT(S_pending_ident(aTHX)); |
bbce6d69 | 2435 | |
02aa26ce NT |
2436 | /* no identifier pending identification */ |
2437 | ||
3280af22 | 2438 | switch (PL_lex_state) { |
79072805 LW |
2439 | #ifdef COMMENTARY |
2440 | case LEX_NORMAL: /* Some compilers will produce faster */ | |
2441 | case LEX_INTERPNORMAL: /* code if we comment these out. */ | |
2442 | break; | |
2443 | #endif | |
2444 | ||
09bef843 | 2445 | /* when we've already built the next token, just pull it out of the queue */ |
79072805 | 2446 | case LEX_KNOWNEXT: |
3280af22 NIS |
2447 | PL_nexttoke--; |
2448 | yylval = PL_nextval[PL_nexttoke]; | |
2449 | if (!PL_nexttoke) { | |
2450 | PL_lex_state = PL_lex_defer; | |
2451 | PL_expect = PL_lex_expect; | |
2452 | PL_lex_defer = LEX_NORMAL; | |
463ee0b2 | 2453 | } |
bbf60fe6 | 2454 | return REPORT(PL_nexttype[PL_nexttoke]); |
79072805 | 2455 | |
02aa26ce | 2456 | /* interpolated case modifiers like \L \U, including \Q and \E. |
3280af22 | 2457 | when we get here, PL_bufptr is at the \ |
02aa26ce | 2458 | */ |
79072805 LW |
2459 | case LEX_INTERPCASEMOD: |
2460 | #ifdef DEBUGGING | |
3280af22 | 2461 | if (PL_bufptr != PL_bufend && *PL_bufptr != '\\') |
cea2e8a9 | 2462 | Perl_croak(aTHX_ "panic: INTERPCASEMOD"); |
79072805 | 2463 | #endif |
02aa26ce | 2464 | /* handle \E or end of string */ |
3280af22 | 2465 | if (PL_bufptr == PL_bufend || PL_bufptr[1] == 'E') { |
02aa26ce | 2466 | /* if at a \E */ |
3280af22 | 2467 | if (PL_lex_casemods) { |
f54cb97a | 2468 | const char oldmod = PL_lex_casestack[--PL_lex_casemods]; |
3280af22 | 2469 | PL_lex_casestack[PL_lex_casemods] = '\0'; |
02aa26ce | 2470 | |
3792a11b NC |
2471 | if (PL_bufptr != PL_bufend |
2472 | && (oldmod == 'L' || oldmod == 'U' || oldmod == 'Q')) { | |
3280af22 NIS |
2473 | PL_bufptr += 2; |
2474 | PL_lex_state = LEX_INTERPCONCAT; | |
a0d0e21e | 2475 | } |
bbf60fe6 | 2476 | return REPORT(')'); |
79072805 | 2477 | } |
3280af22 NIS |
2478 | if (PL_bufptr != PL_bufend) |
2479 | PL_bufptr += 2; | |
2480 | PL_lex_state = LEX_INTERPCONCAT; | |
cea2e8a9 | 2481 | return yylex(); |
79072805 LW |
2482 | } |
2483 | else { | |
607df283 | 2484 | DEBUG_T({ PerlIO_printf(Perl_debug_log, |
b6007c36 | 2485 | "### Saw case modifier\n"); }); |
3280af22 | 2486 | s = PL_bufptr + 1; |
6e909404 JH |
2487 | if (s[1] == '\\' && s[2] == 'E') { |
2488 | PL_bufptr = s + 3; | |
2489 | PL_lex_state = LEX_INTERPCONCAT; | |
2490 | return yylex(); | |
a0d0e21e | 2491 | } |
6e909404 | 2492 | else { |
90771dc0 | 2493 | I32 tmp; |
6e909404 JH |
2494 | if (strnEQ(s, "L\\u", 3) || strnEQ(s, "U\\l", 3)) |
2495 | tmp = *s, *s = s[2], s[2] = (char)tmp; /* misordered... */ | |
3792a11b | 2496 | if ((*s == 'L' || *s == 'U') && |
6e909404 JH |
2497 | (strchr(PL_lex_casestack, 'L') || strchr(PL_lex_casestack, 'U'))) { |
2498 | PL_lex_casestack[--PL_lex_casemods] = '\0'; | |
bbf60fe6 | 2499 | return REPORT(')'); |
6e909404 JH |
2500 | } |
2501 | if (PL_lex_casemods > 10) | |
2502 | Renew(PL_lex_casestack, PL_lex_casemods + 2, char); | |
2503 | PL_lex_casestack[PL_lex_casemods++] = *s; | |
2504 | PL_lex_casestack[PL_lex_casemods] = '\0'; | |
2505 | PL_lex_state = LEX_INTERPCONCAT; | |
2506 | PL_nextval[PL_nexttoke].ival = 0; | |
2507 | force_next('('); | |
2508 | if (*s == 'l') | |
2509 | PL_nextval[PL_nexttoke].ival = OP_LCFIRST; | |
2510 | else if (*s == 'u') | |
2511 | PL_nextval[PL_nexttoke].ival = OP_UCFIRST; | |
2512 | else if (*s == 'L') | |
2513 | PL_nextval[PL_nexttoke].ival = OP_LC; | |
2514 | else if (*s == 'U') | |
2515 | PL_nextval[PL_nexttoke].ival = OP_UC; | |
2516 | else if (*s == 'Q') | |
2517 | PL_nextval[PL_nexttoke].ival = OP_QUOTEMETA; | |
2518 | else | |
2519 | Perl_croak(aTHX_ "panic: yylex"); | |
2520 | PL_bufptr = s + 1; | |
a0d0e21e | 2521 | } |
79072805 | 2522 | force_next(FUNC); |
3280af22 NIS |
2523 | if (PL_lex_starts) { |
2524 | s = PL_bufptr; | |
2525 | PL_lex_starts = 0; | |
131b3ad0 DM |
2526 | /* commas only at base level: /$a\Ub$c/ => ($a,uc(b.$c)) */ |
2527 | if (PL_lex_casemods == 1 && PL_lex_inpat) | |
2528 | OPERATOR(','); | |
2529 | else | |
2530 | Aop(OP_CONCAT); | |
79072805 LW |
2531 | } |
2532 | else | |
cea2e8a9 | 2533 | return yylex(); |
79072805 LW |
2534 | } |
2535 | ||
55497cff | 2536 | case LEX_INTERPPUSH: |
bbf60fe6 | 2537 | return REPORT(sublex_push()); |
55497cff | 2538 | |
79072805 | 2539 | case LEX_INTERPSTART: |
3280af22 | 2540 | if (PL_bufptr == PL_bufend) |
bbf60fe6 | 2541 | return REPORT(sublex_done()); |
607df283 | 2542 | DEBUG_T({ PerlIO_printf(Perl_debug_log, |
b6007c36 | 2543 | "### Interpolated variable\n"); }); |
3280af22 NIS |
2544 | PL_expect = XTERM; |
2545 | PL_lex_dojoin = (*PL_bufptr == '@'); | |
2546 | PL_lex_state = LEX_INTERPNORMAL; | |
2547 | if (PL_lex_dojoin) { | |
2548 | PL_nextval[PL_nexttoke].ival = 0; | |
79072805 | 2549 | force_next(','); |
a0d0e21e | 2550 | force_ident("\"", '$'); |
3280af22 | 2551 | PL_nextval[PL_nexttoke].ival = 0; |
79072805 | 2552 | force_next('$'); |
3280af22 | 2553 | PL_nextval[PL_nexttoke].ival = 0; |
79072805 | 2554 | force_next('('); |
3280af22 | 2555 | PL_nextval[PL_nexttoke].ival = OP_JOIN; /* emulate join($", ...) */ |
79072805 LW |
2556 | force_next(FUNC); |
2557 | } | |
3280af22 NIS |
2558 | if (PL_lex_starts++) { |
2559 | s = PL_bufptr; | |
131b3ad0 DM |
2560 | /* commas only at base level: /$a\Ub$c/ => ($a,uc(b.$c)) */ |
2561 | if (!PL_lex_casemods && PL_lex_inpat) | |
2562 | OPERATOR(','); | |
2563 | else | |
2564 | Aop(OP_CONCAT); | |
79072805 | 2565 | } |
cea2e8a9 | 2566 | return yylex(); |
79072805 LW |
2567 | |
2568 | case LEX_INTERPENDMAYBE: | |
3280af22 NIS |
2569 | if (intuit_more(PL_bufptr)) { |
2570 | PL_lex_state = LEX_INTERPNORMAL; /* false alarm, more expr */ | |
79072805 LW |
2571 | break; |
2572 | } | |
2573 | /* FALL THROUGH */ | |
2574 | ||
2575 | case LEX_INTERPEND: | |
3280af22 NIS |
2576 | if (PL_lex_dojoin) { |
2577 | PL_lex_dojoin = FALSE; | |
2578 | PL_lex_state = LEX_INTERPCONCAT; | |
bbf60fe6 | 2579 | return REPORT(')'); |
79072805 | 2580 | } |
43a16006 | 2581 | if (PL_lex_inwhat == OP_SUBST && PL_linestr == PL_lex_repl |
25da4f38 | 2582 | && SvEVALED(PL_lex_repl)) |
43a16006 | 2583 | { |
e9fa98b2 | 2584 | if (PL_bufptr != PL_bufend) |
cea2e8a9 | 2585 | Perl_croak(aTHX_ "Bad evalled substitution pattern"); |
e9fa98b2 HS |
2586 | PL_lex_repl = Nullsv; |
2587 | } | |
79072805 LW |
2588 | /* FALLTHROUGH */ |
2589 | case LEX_INTERPCONCAT: | |
2590 | #ifdef DEBUGGING | |
3280af22 | 2591 | if (PL_lex_brackets) |
cea2e8a9 | 2592 | Perl_croak(aTHX_ "panic: INTERPCONCAT"); |
79072805 | 2593 | #endif |
3280af22 | 2594 | if (PL_bufptr == PL_bufend) |
bbf60fe6 | 2595 | return REPORT(sublex_done()); |
79072805 | 2596 | |
3280af22 NIS |
2597 | if (SvIVX(PL_linestr) == '\'') { |
2598 | SV *sv = newSVsv(PL_linestr); | |
2599 | if (!PL_lex_inpat) | |
76e3520e | 2600 | sv = tokeq(sv); |
3280af22 | 2601 | else if ( PL_hints & HINT_NEW_RE ) |
b3ac6de7 | 2602 | sv = new_constant(NULL, 0, "qr", sv, sv, "q"); |
79072805 | 2603 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv); |
3280af22 | 2604 | s = PL_bufend; |
79072805 LW |
2605 | } |
2606 | else { | |
3280af22 | 2607 | s = scan_const(PL_bufptr); |
79072805 | 2608 | if (*s == '\\') |
3280af22 | 2609 | PL_lex_state = LEX_INTERPCASEMOD; |
79072805 | 2610 | else |
3280af22 | 2611 | PL_lex_state = LEX_INTERPSTART; |
79072805 LW |
2612 | } |
2613 | ||
3280af22 NIS |
2614 | if (s != PL_bufptr) { |
2615 | PL_nextval[PL_nexttoke] = yylval; | |
2616 | PL_expect = XTERM; | |
79072805 | 2617 | force_next(THING); |
131b3ad0 DM |
2618 | if (PL_lex_starts++) { |
2619 | /* commas only at base level: /$a\Ub$c/ => ($a,uc(b.$c)) */ | |
2620 | if (!PL_lex_casemods && PL_lex_inpat) | |
2621 | OPERATOR(','); | |
2622 | else | |
2623 | Aop(OP_CONCAT); | |
2624 | } | |
79072805 | 2625 | else { |
3280af22 | 2626 | PL_bufptr = s; |
cea2e8a9 | 2627 | return yylex(); |
79072805 LW |
2628 | } |
2629 | } | |
2630 | ||
cea2e8a9 | 2631 | return yylex(); |
a0d0e21e | 2632 | case LEX_FORMLINE: |
3280af22 NIS |
2633 | PL_lex_state = LEX_NORMAL; |
2634 | s = scan_formline(PL_bufptr); | |
2635 | if (!PL_lex_formbrack) | |
a0d0e21e LW |
2636 | goto rightbracket; |
2637 | OPERATOR(';'); | |
79072805 LW |
2638 | } |
2639 | ||
3280af22 NIS |
2640 | s = PL_bufptr; |
2641 | PL_oldoldbufptr = PL_oldbufptr; | |
2642 | PL_oldbufptr = s; | |
463ee0b2 LW |
2643 | |
2644 | retry: | |
378cc40b LW |
2645 | switch (*s) { |
2646 | default: | |
7e2040f0 | 2647 | if (isIDFIRST_lazy_if(s,UTF)) |
834a4ddd | 2648 | goto keylookup; |
cea2e8a9 | 2649 | Perl_croak(aTHX_ "Unrecognized character \\x%02X", *s & 255); |
e929a76b LW |
2650 | case 4: |
2651 | case 26: | |
2652 | goto fake_eof; /* emulate EOF on ^D or ^Z */ | |
378cc40b | 2653 | case 0: |
3280af22 NIS |
2654 | if (!PL_rsfp) { |
2655 | PL_last_uni = 0; | |
2656 | PL_last_lop = 0; | |
c5ee2135 | 2657 | if (PL_lex_brackets) { |
0bd48802 AL |
2658 | yyerror(PL_lex_formbrack |
2659 | ? "Format not terminated" | |
2660 | : "Missing right curly or square bracket"); | |
c5ee2135 | 2661 | } |
4e553d73 | 2662 | DEBUG_T( { PerlIO_printf(Perl_debug_log, |
607df283 | 2663 | "### Tokener got EOF\n"); |
5f80b19c | 2664 | } ); |
79072805 | 2665 | TOKEN(0); |
463ee0b2 | 2666 | } |
3280af22 | 2667 | if (s++ < PL_bufend) |
a687059c | 2668 | goto retry; /* ignore stray nulls */ |
3280af22 NIS |
2669 | PL_last_uni = 0; |
2670 | PL_last_lop = 0; | |
2671 | if (!PL_in_eval && !PL_preambled) { | |
2672 | PL_preambled = TRUE; | |
2673 | sv_setpv(PL_linestr,incl_perldb()); | |
2674 | if (SvCUR(PL_linestr)) | |
396482e1 | 2675 | sv_catpvs(PL_linestr,";"); |
3280af22 NIS |
2676 | if (PL_preambleav){ |
2677 | while(AvFILLp(PL_preambleav) >= 0) { | |
2678 | SV *tmpsv = av_shift(PL_preambleav); | |
2679 | sv_catsv(PL_linestr, tmpsv); | |
396482e1 | 2680 | sv_catpvs(PL_linestr, ";"); |
91b7def8 | 2681 | sv_free(tmpsv); |
2682 | } | |
3280af22 NIS |
2683 | sv_free((SV*)PL_preambleav); |
2684 | PL_preambleav = NULL; | |
91b7def8 | 2685 | } |
3280af22 | 2686 | if (PL_minus_n || PL_minus_p) { |
396482e1 | 2687 | sv_catpvs(PL_linestr, "LINE: while (<>) {"); |
3280af22 | 2688 | if (PL_minus_l) |
396482e1 | 2689 | sv_catpvs(PL_linestr,"chomp;"); |
3280af22 | 2690 | if (PL_minus_a) { |
3280af22 | 2691 | if (PL_minus_F) { |
3792a11b NC |
2692 | if ((*PL_splitstr == '/' || *PL_splitstr == '\'' |
2693 | || *PL_splitstr == '"') | |
3280af22 | 2694 | && strchr(PL_splitstr + 1, *PL_splitstr)) |
3db68c4c | 2695 | Perl_sv_catpvf(aTHX_ PL_linestr, "our @F=split(%s);", PL_splitstr); |
54310121 | 2696 | else { |
c8ef6a4b NC |
2697 | /* "q\0${splitstr}\0" is legal perl. Yes, even NUL |
2698 | bytes can be used as quoting characters. :-) */ | |
dd374669 | 2699 | const char *splits = PL_splitstr; |
91d456ae | 2700 | sv_catpvs(PL_linestr, "our @F=split(q\0"); |
48c4c863 NC |
2701 | do { |
2702 | /* Need to \ \s */ | |
dd374669 AL |
2703 | if (*splits == '\\') |
2704 | sv_catpvn(PL_linestr, splits, 1); | |
2705 | sv_catpvn(PL_linestr, splits, 1); | |
2706 | } while (*splits++); | |
48c4c863 NC |
2707 | /* This loop will embed the trailing NUL of |
2708 | PL_linestr as the last thing it does before | |
2709 | terminating. */ | |
396482e1 | 2710 | sv_catpvs(PL_linestr, ");"); |
54310121 | 2711 | } |
2304df62 AD |
2712 | } |
2713 | else | |
396482e1 | 2714 | sv_catpvs(PL_linestr,"our @F=split(' ');"); |
2304df62 | 2715 | } |
79072805 | 2716 | } |
bc9b29db | 2717 | if (PL_minus_E) |
396482e1 GA |
2718 | sv_catpvs(PL_linestr,"use feature ':5.10';"); |
2719 | sv_catpvs(PL_linestr, "\n"); | |
3280af22 NIS |
2720 | PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); |
2721 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
207e3d1a | 2722 | PL_last_lop = PL_last_uni = Nullch; |
3280af22 | 2723 | if (PERLDB_LINE && PL_curstash != PL_debstash) { |
9d4ba2ae | 2724 | SV * const sv = NEWSV(85,0); |
a0d0e21e LW |
2725 | |
2726 | sv_upgrade(sv, SVt_PVMG); | |
3280af22 | 2727 | sv_setsv(sv,PL_linestr); |
0ac0412a | 2728 | (void)SvIOK_on(sv); |
45977657 | 2729 | SvIV_set(sv, 0); |
36c7798d | 2730 | av_store(CopFILEAVx(PL_curcop),(I32)CopLINE(PL_curcop),sv); |
a0d0e21e | 2731 | } |
79072805 | 2732 | goto retry; |
a687059c | 2733 | } |
e929a76b | 2734 | do { |
aa7440fb | 2735 | bof = PL_rsfp ? TRUE : FALSE; |
7e28d3af JH |
2736 | if ((s = filter_gets(PL_linestr, PL_rsfp, 0)) == Nullch) { |
2737 | fake_eof: | |
2738 | if (PL_rsfp) { | |
2739 | if (PL_preprocess && !PL_in_eval) | |
2740 | (void)PerlProc_pclose(PL_rsfp); | |
2741 | else if ((PerlIO *)PL_rsfp == PerlIO_stdin()) | |
2742 | PerlIO_clearerr(PL_rsfp); | |
2743 | else | |
2744 | (void)PerlIO_close(PL_rsfp); | |
2745 | PL_rsfp = Nullfp; | |
2746 | PL_doextract = FALSE; | |
2747 | } | |
2748 | if (!PL_in_eval && (PL_minus_n || PL_minus_p)) { | |
a23c4656 NC |
2749 | sv_setpv(PL_linestr,PL_minus_p |
2750 | ? ";}continue{print;}" : ";}"); | |
7e28d3af JH |
2751 | PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); |
2752 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
207e3d1a | 2753 | PL_last_lop = PL_last_uni = Nullch; |
7e28d3af JH |
2754 | PL_minus_n = PL_minus_p = 0; |
2755 | goto retry; | |
2756 | } | |
2757 | PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); | |
207e3d1a | 2758 | PL_last_lop = PL_last_uni = Nullch; |
c69006e4 | 2759 | sv_setpvn(PL_linestr,"",0); |
7e28d3af JH |
2760 | TOKEN(';'); /* not infinite loop because rsfp is NULL now */ |
2761 | } | |
7aa207d6 JH |
2762 | /* If it looks like the start of a BOM or raw UTF-16, |
2763 | * check if it in fact is. */ | |
2764 | else if (bof && | |
2765 | (*s == 0 || | |
2766 | *(U8*)s == 0xEF || | |
2767 | *(U8*)s >= 0xFE || | |
2768 | s[1] == 0)) { | |
226017aa | 2769 | #ifdef PERLIO_IS_STDIO |
e3f494f1 JH |
2770 | # ifdef __GNU_LIBRARY__ |
2771 | # if __GNU_LIBRARY__ == 1 /* Linux glibc5 */ | |
226017aa DD |
2772 | # define FTELL_FOR_PIPE_IS_BROKEN |
2773 | # endif | |
e3f494f1 JH |
2774 | # else |
2775 | # ifdef __GLIBC__ | |
2776 | # if __GLIBC__ == 1 /* maybe some glibc5 release had it like this? */ | |
2777 | # define FTELL_FOR_PIPE_IS_BROKEN | |
2778 | # endif | |
2779 | # endif | |
226017aa DD |
2780 | # endif |
2781 | #endif | |
2782 | #ifdef FTELL_FOR_PIPE_IS_BROKEN | |
2783 | /* This loses the possibility to detect the bof | |
2784 | * situation on perl -P when the libc5 is being used. | |
2785 | * Workaround? Maybe attach some extra state to PL_rsfp? | |
2786 | */ | |
2787 | if (!PL_preprocess) | |
7e28d3af | 2788 | bof = PerlIO_tell(PL_rsfp) == SvCUR(PL_linestr); |
226017aa | 2789 | #else |
eb160463 | 2790 | bof = PerlIO_tell(PL_rsfp) == (Off_t)SvCUR(PL_linestr); |
226017aa | 2791 | #endif |
7e28d3af | 2792 | if (bof) { |
3280af22 | 2793 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); |
7e28d3af | 2794 | s = swallow_bom((U8*)s); |
e929a76b | 2795 | } |
378cc40b | 2796 | } |
3280af22 | 2797 | if (PL_doextract) { |
a0d0e21e LW |
2798 | /* Incest with pod. */ |
2799 | if (*s == '=' && strnEQ(s, "=cut", 4)) { | |
c69006e4 | 2800 | sv_setpvn(PL_linestr, "", 0); |
3280af22 NIS |
2801 | PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); |
2802 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
207e3d1a | 2803 | PL_last_lop = PL_last_uni = Nullch; |
3280af22 | 2804 | PL_doextract = FALSE; |
a0d0e21e | 2805 | } |
4e553d73 | 2806 | } |
463ee0b2 | 2807 | incline(s); |
3280af22 NIS |
2808 | } while (PL_doextract); |
2809 | PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = s; | |
2810 | if (PERLDB_LINE && PL_curstash != PL_debstash) { | |
9d4ba2ae | 2811 | SV * const sv = NEWSV(85,0); |
a687059c | 2812 | |
93a17b20 | 2813 | sv_upgrade(sv, SVt_PVMG); |
3280af22 | 2814 | sv_setsv(sv,PL_linestr); |
0ac0412a | 2815 | (void)SvIOK_on(sv); |
45977657 | 2816 | SvIV_set(sv, 0); |
36c7798d | 2817 | av_store(CopFILEAVx(PL_curcop),(I32)CopLINE(PL_curcop),sv); |
a687059c | 2818 | } |
3280af22 | 2819 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); |
207e3d1a | 2820 | PL_last_lop = PL_last_uni = Nullch; |
57843af0 | 2821 | if (CopLINE(PL_curcop) == 1) { |
3280af22 | 2822 | while (s < PL_bufend && isSPACE(*s)) |
79072805 | 2823 | s++; |
a0d0e21e | 2824 | if (*s == ':' && s[1] != ':') /* for csh execing sh scripts */ |
79072805 | 2825 | s++; |
44a8e56a | 2826 | d = Nullch; |
3280af22 | 2827 | if (!PL_in_eval) { |
44a8e56a | 2828 | if (*s == '#' && *(s+1) == '!') |
2829 | d = s + 2; | |
2830 | #ifdef ALTERNATE_SHEBANG | |
2831 | else { | |
bfed75c6 | 2832 | static char const as[] = ALTERNATE_SHEBANG; |
44a8e56a | 2833 | if (*s == as[0] && strnEQ(s, as, sizeof(as) - 1)) |
2834 | d = s + (sizeof(as) - 1); | |
2835 | } | |
2836 | #endif /* ALTERNATE_SHEBANG */ | |
2837 | } | |
2838 | if (d) { | |
b8378b72 | 2839 | char *ipath; |
774d564b | 2840 | char *ipathend; |
b8378b72 | 2841 | |
774d564b | 2842 | while (isSPACE(*d)) |
b8378b72 CS |
2843 | d++; |
2844 | ipath = d; | |
774d564b | 2845 | while (*d && !isSPACE(*d)) |
2846 | d++; | |
2847 | ipathend = d; | |
2848 | ||
2849 | #ifdef ARG_ZERO_IS_SCRIPT | |
2850 | if (ipathend > ipath) { | |
2851 | /* | |
2852 | * HP-UX (at least) sets argv[0] to the script name, | |
2853 | * which makes $^X incorrect. And Digital UNIX and Linux, | |
2854 | * at least, set argv[0] to the basename of the Perl | |
2855 | * interpreter. So, having found "#!", we'll set it right. | |
2856 | */ | |
f776e3cd NC |
2857 | SV * const x |
2858 | = GvSV(gv_fetchpv("\030", GV_ADD, SVt_PV)); /* $^X */ | |
774d564b | 2859 | assert(SvPOK(x) || SvGMAGICAL(x)); |
cc49e20b | 2860 | if (sv_eq(x, CopFILESV(PL_curcop))) { |
774d564b | 2861 | sv_setpvn(x, ipath, ipathend - ipath); |
9607fc9c | 2862 | SvSETMAGIC(x); |
2863 | } | |
556c1dec JH |
2864 | else { |
2865 | STRLEN blen; | |
2866 | STRLEN llen; | |
cfd0369c | 2867 | const char *bstart = SvPV_const(CopFILESV(PL_curcop),blen); |
9d4ba2ae | 2868 | const char * const lstart = SvPV_const(x,llen); |
556c1dec JH |
2869 | if (llen < blen) { |
2870 | bstart += blen - llen; | |
2871 | if (strnEQ(bstart, lstart, llen) && bstart[-1] == '/') { | |
2872 | sv_setpvn(x, ipath, ipathend - ipath); | |
2873 | SvSETMAGIC(x); | |
2874 | } | |
2875 | } | |
2876 | } | |
774d564b | 2877 | TAINT_NOT; /* $^X is always tainted, but that's OK */ |
8ebc5c01 | 2878 | } |
774d564b | 2879 | #endif /* ARG_ZERO_IS_SCRIPT */ |
b8378b72 CS |
2880 | |
2881 | /* | |
2882 | * Look for options. | |
2883 | */ | |
748a9306 | 2884 | d = instr(s,"perl -"); |
84e30d1a | 2885 | if (!d) { |
748a9306 | 2886 | d = instr(s,"perl"); |
84e30d1a GS |
2887 | #if defined(DOSISH) |
2888 | /* avoid getting into infinite loops when shebang | |
2889 | * line contains "Perl" rather than "perl" */ | |
2890 | if (!d) { | |
2891 | for (d = ipathend-4; d >= ipath; --d) { | |
2892 | if ((*d == 'p' || *d == 'P') | |
2893 | && !ibcmp(d, "perl", 4)) | |
2894 | { | |
2895 | break; | |
2896 | } | |
2897 | } | |
2898 | if (d < ipath) | |
2899 | d = Nullch; | |
2900 | } | |
2901 | #endif | |
2902 | } | |
44a8e56a | 2903 | #ifdef ALTERNATE_SHEBANG |
2904 | /* | |
2905 | * If the ALTERNATE_SHEBANG on this system starts with a | |
2906 | * character that can be part of a Perl expression, then if | |
2907 | * we see it but not "perl", we're probably looking at the | |
2908 | * start of Perl code, not a request to hand off to some | |
2909 | * other interpreter. Similarly, if "perl" is there, but | |
2910 | * not in the first 'word' of the line, we assume the line | |
2911 | * contains the start of the Perl program. | |
44a8e56a | 2912 | */ |
2913 | if (d && *s != '#') { | |
f54cb97a | 2914 | const char *c = ipath; |
44a8e56a | 2915 | while (*c && !strchr("; \t\r\n\f\v#", *c)) |
2916 | c++; | |
2917 | if (c < d) | |
2918 | d = Nullch; /* "perl" not in first word; ignore */ | |
2919 | else | |
2920 | *s = '#'; /* Don't try to parse shebang line */ | |
2921 | } | |
774d564b | 2922 | #endif /* ALTERNATE_SHEBANG */ |
bf4acbe4 | 2923 | #ifndef MACOS_TRADITIONAL |
748a9306 | 2924 | if (!d && |
44a8e56a | 2925 | *s == '#' && |
774d564b | 2926 | ipathend > ipath && |
3280af22 | 2927 | !PL_minus_c && |
748a9306 | 2928 | !instr(s,"indir") && |
3280af22 | 2929 | instr(PL_origargv[0],"perl")) |
748a9306 | 2930 | { |
27da23d5 | 2931 | dVAR; |
9f68db38 | 2932 | char **newargv; |
9f68db38 | 2933 | |
774d564b | 2934 | *ipathend = '\0'; |
2935 | s = ipathend + 1; | |
3280af22 | 2936 | while (s < PL_bufend && isSPACE(*s)) |
9f68db38 | 2937 | s++; |
3280af22 | 2938 | if (s < PL_bufend) { |
a02a5408 | 2939 | Newxz(newargv,PL_origargc+3,char*); |
9f68db38 | 2940 | newargv[1] = s; |
3280af22 | 2941 | while (s < PL_bufend && !isSPACE(*s)) |
9f68db38 LW |
2942 | s++; |
2943 | *s = '\0'; | |
3280af22 | 2944 | Copy(PL_origargv+1, newargv+2, PL_origargc+1, char*); |
9f68db38 LW |
2945 | } |
2946 | else | |
3280af22 | 2947 | newargv = PL_origargv; |
774d564b | 2948 | newargv[0] = ipath; |
b35112e7 | 2949 | PERL_FPU_PRE_EXEC |
b4748376 | 2950 | PerlProc_execv(ipath, EXEC_ARGV_CAST(newargv)); |
b35112e7 | 2951 | PERL_FPU_POST_EXEC |
cea2e8a9 | 2952 | Perl_croak(aTHX_ "Can't exec %s", ipath); |
9f68db38 | 2953 | } |
bf4acbe4 | 2954 | #endif |
748a9306 | 2955 | if (d) { |
f54cb97a AL |
2956 | const U32 oldpdb = PL_perldb; |
2957 | const bool oldn = PL_minus_n; | |
2958 | const bool oldp = PL_minus_p; | |
748a9306 LW |
2959 | |
2960 | while (*d && !isSPACE(*d)) d++; | |
bf4acbe4 | 2961 | while (SPACE_OR_TAB(*d)) d++; |
748a9306 LW |
2962 | |
2963 | if (*d++ == '-') { | |
f54cb97a | 2964 | const bool switches_done = PL_doswitches; |
8cc95fdb | 2965 | do { |
3ffe3ee4 | 2966 | if (*d == 'M' || *d == 'm' || *d == 'C') { |
9d4ba2ae | 2967 | const char * const m = d; |
8cc95fdb | 2968 | while (*d && !isSPACE(*d)) d++; |
cea2e8a9 | 2969 | Perl_croak(aTHX_ "Too late for \"-%.*s\" option", |
8cc95fdb | 2970 | (int)(d - m), m); |
2971 | } | |
2972 | d = moreswitches(d); | |
2973 | } while (d); | |
f0b2cf55 YST |
2974 | if (PL_doswitches && !switches_done) { |
2975 | int argc = PL_origargc; | |
2976 | char **argv = PL_origargv; | |
2977 | do { | |
2978 | argc--,argv++; | |
2979 | } while (argc && argv[0][0] == '-' && argv[0][1]); | |
2980 | init_argv_symbols(argc,argv); | |
2981 | } | |
155aba94 GS |
2982 | if ((PERLDB_LINE && !oldpdb) || |
2983 | ((PL_minus_n || PL_minus_p) && !(oldn || oldp))) | |
b084f20b | 2984 | /* if we have already added "LINE: while (<>) {", |
2985 | we must not do it again */ | |
748a9306 | 2986 | { |
c69006e4 | 2987 | sv_setpvn(PL_linestr, "", 0); |
3280af22 NIS |
2988 | PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); |
2989 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
207e3d1a | 2990 | PL_last_lop = PL_last_uni = Nullch; |
3280af22 | 2991 | PL_preambled = FALSE; |
84902520 | 2992 | if (PERLDB_LINE) |
3280af22 | 2993 | (void)gv_fetchfile(PL_origfilename); |
748a9306 LW |
2994 | goto retry; |
2995 | } | |
a11ec5a9 RGS |
2996 | if (PL_doswitches && !switches_done) { |
2997 | int argc = PL_origargc; | |
2998 | char **argv = PL_origargv; | |
2999 | do { | |
3000 | argc--,argv++; | |
3001 | } while (argc && argv[0][0] == '-' && argv[0][1]); | |
3002 | init_argv_symbols(argc,argv); | |
3003 | } | |
a0d0e21e | 3004 | } |
79072805 | 3005 | } |
9f68db38 | 3006 | } |
79072805 | 3007 | } |
3280af22 NIS |
3008 | if (PL_lex_formbrack && PL_lex_brackets <= PL_lex_formbrack) { |
3009 | PL_bufptr = s; | |
3010 | PL_lex_state = LEX_FORMLINE; | |
cea2e8a9 | 3011 | return yylex(); |
ae986130 | 3012 | } |
378cc40b | 3013 | goto retry; |
4fdae800 | 3014 | case '\r': |
6a27c188 | 3015 | #ifdef PERL_STRICT_CR |
cea2e8a9 | 3016 | Perl_warn(aTHX_ "Illegal character \\%03o (carriage return)", '\r'); |
4e553d73 | 3017 | Perl_croak(aTHX_ |
cc507455 | 3018 | "\t(Maybe you didn't strip carriage returns after a network transfer?)\n"); |
a868473f | 3019 | #endif |
4fdae800 | 3020 | case ' ': case '\t': case '\f': case 013: |
bf4acbe4 GS |
3021 | #ifdef MACOS_TRADITIONAL |
3022 | case '\312': | |
3023 | #endif | |
378cc40b LW |
3024 | s++; |
3025 | goto retry; | |
378cc40b | 3026 | case '#': |
e929a76b | 3027 | case '\n': |
3280af22 | 3028 | if (PL_lex_state != LEX_NORMAL || (PL_in_eval && !PL_rsfp)) { |
df0deb90 GS |
3029 | if (*s == '#' && s == PL_linestart && PL_in_eval && !PL_rsfp) { |
3030 | /* handle eval qq[#line 1 "foo"\n ...] */ | |
3031 | CopLINE_dec(PL_curcop); | |
3032 | incline(s); | |
3033 | } | |
3280af22 | 3034 | d = PL_bufend; |
a687059c | 3035 | while (s < d && *s != '\n') |
378cc40b | 3036 | s++; |
0f85fab0 | 3037 | if (s < d) |
378cc40b | 3038 | s++; |
78c267c1 | 3039 | else if (s > d) /* Found by Ilya: feed random input to Perl. */ |
a8406387 | 3040 | Perl_croak(aTHX_ "panic: input overflow"); |
463ee0b2 | 3041 | incline(s); |
3280af22 NIS |
3042 | if (PL_lex_formbrack && PL_lex_brackets <= PL_lex_formbrack) { |
3043 | PL_bufptr = s; | |
3044 | PL_lex_state = LEX_FORMLINE; | |
cea2e8a9 | 3045 | return yylex(); |
a687059c | 3046 | } |
378cc40b | 3047 | } |
a687059c | 3048 | else { |
378cc40b | 3049 | *s = '\0'; |
3280af22 | 3050 | PL_bufend = s; |
a687059c | 3051 | } |
378cc40b LW |
3052 | goto retry; |
3053 | case '-': | |
79072805 | 3054 | if (s[1] && isALPHA(s[1]) && !isALNUM(s[2])) { |
e5edeb50 | 3055 | I32 ftst = 0; |
90771dc0 | 3056 | char tmp; |
e5edeb50 | 3057 | |
378cc40b | 3058 | s++; |
3280af22 | 3059 | PL_bufptr = s; |
748a9306 LW |
3060 | tmp = *s++; |
3061 | ||
bf4acbe4 | 3062 | while (s < PL_bufend && SPACE_OR_TAB(*s)) |
748a9306 LW |
3063 | s++; |
3064 | ||
3065 | if (strnEQ(s,"=>",2)) { | |
3280af22 | 3066 | s = force_word(PL_bufptr,WORD,FALSE,FALSE,FALSE); |
b6007c36 DM |
3067 | DEBUG_T( { S_printbuf(aTHX_ |
3068 | "### Saw unary minus before =>, forcing word %s\n", s); | |
5f80b19c | 3069 | } ); |
748a9306 LW |
3070 | OPERATOR('-'); /* unary minus */ |
3071 | } | |
3280af22 | 3072 | PL_last_uni = PL_oldbufptr; |
748a9306 | 3073 | switch (tmp) { |
e5edeb50 JH |
3074 | case 'r': ftst = OP_FTEREAD; break; |
3075 | case 'w': ftst = OP_FTEWRITE; break; | |
3076 | case 'x': ftst = OP_FTEEXEC; break; | |
3077 | case 'o': ftst = OP_FTEOWNED; break; | |
3078 | case 'R': ftst = OP_FTRREAD; break; | |
3079 | case 'W': ftst = OP_FTRWRITE; break; | |
3080 | case 'X': ftst = OP_FTREXEC; break; | |
3081 | case 'O': ftst = OP_FTROWNED; break; | |
3082 | case 'e': ftst = OP_FTIS; break; | |
3083 | case 'z': ftst = OP_FTZERO; break; | |
3084 | case 's': ftst = OP_FTSIZE; break; | |
3085 | case 'f': ftst = OP_FTFILE; break; | |
3086 | case 'd': ftst = OP_FTDIR; break; | |
3087 | case 'l': ftst = OP_FTLINK; break; | |
3088 | case 'p': ftst = OP_FTPIPE; break; | |
3089 | case 'S': ftst = OP_FTSOCK; break; | |
3090 | case 'u': ftst = OP_FTSUID; break; | |
3091 | case 'g': ftst = OP_FTSGID; break; | |
3092 | case 'k': ftst = OP_FTSVTX; break; | |
3093 | case 'b': ftst = OP_FTBLK; break; | |
3094 | case 'c': ftst = OP_FTCHR; break; | |
3095 | case 't': ftst = OP_FTTTY; break; | |
3096 | case 'T': ftst = OP_FTTEXT; break; | |
3097 | case 'B': ftst = OP_FTBINARY; break; | |
3098 | case 'M': case 'A': case 'C': | |
f776e3cd | 3099 | gv_fetchpv("\024",GV_ADD, SVt_PV); |
e5edeb50 JH |
3100 | switch (tmp) { |
3101 | case 'M': ftst = OP_FTMTIME; break; | |
3102 | case 'A': ftst = OP_FTATIME; break; | |
3103 | case 'C': ftst = OP_FTCTIME; break; | |
3104 | default: break; | |
3105 | } | |
3106 | break; | |
378cc40b | 3107 | default: |
378cc40b LW |
3108 | break; |
3109 | } | |
e5edeb50 | 3110 | if (ftst) { |
eb160463 | 3111 | PL_last_lop_op = (OPCODE)ftst; |
4e553d73 | 3112 | DEBUG_T( { PerlIO_printf(Perl_debug_log, |
a18d764d | 3113 | "### Saw file test %c\n", (int)tmp); |
5f80b19c | 3114 | } ); |
e5edeb50 JH |
3115 | FTST(ftst); |
3116 | } | |
3117 | else { | |
3118 | /* Assume it was a minus followed by a one-letter named | |
3119 | * subroutine call (or a -bareword), then. */ | |
95c31fe3 | 3120 | DEBUG_T( { PerlIO_printf(Perl_debug_log, |
17ad61e0 | 3121 | "### '-%c' looked like a file test but was not\n", |
4fccd7c6 | 3122 | (int) tmp); |
5f80b19c | 3123 | } ); |
3cf7b4c4 | 3124 | s = --PL_bufptr; |
e5edeb50 | 3125 | } |
378cc40b | 3126 | } |
90771dc0 NC |
3127 | { |
3128 | const char tmp = *s++; | |
3129 | if (*s == tmp) { | |
3130 | s++; | |
3131 | if (PL_expect == XOPERATOR) | |
3132 | TERM(POSTDEC); | |
3133 | else | |
3134 | OPERATOR(PREDEC); | |
3135 | } | |
3136 | else if (*s == '>') { | |
3137 | s++; | |
3138 | s = skipspace(s); | |
3139 | if (isIDFIRST_lazy_if(s,UTF)) { | |
3140 | s = force_word(s,METHOD,FALSE,TRUE,FALSE); | |
3141 | TOKEN(ARROW); | |
3142 | } | |
3143 | else if (*s == '$') | |
3144 | OPERATOR(ARROW); | |
3145 | else | |
3146 | TERM(ARROW); | |
3147 | } | |
3280af22 | 3148 | if (PL_expect == XOPERATOR) |
90771dc0 NC |
3149 | Aop(OP_SUBTRACT); |
3150 | else { | |
3151 | if (isSPACE(*s) || !isSPACE(*PL_bufptr)) | |
3152 | check_uni(); | |
3153 | OPERATOR('-'); /* unary minus */ | |
79072805 | 3154 | } |
2f3197b3 | 3155 | } |
79072805 | 3156 | |
378cc40b | 3157 | case '+': |
90771dc0 NC |
3158 | { |
3159 | const char tmp = *s++; | |
3160 | if (*s == tmp) { | |
3161 | s++; | |
3162 | if (PL_expect == XOPERATOR) | |
3163 | TERM(POSTINC); | |
3164 | else | |
3165 | OPERATOR(PREINC); | |
3166 | } | |
3280af22 | 3167 | if (PL_expect == XOPERATOR) |
90771dc0 NC |
3168 | Aop(OP_ADD); |
3169 | else { | |
3170 | if (isSPACE(*s) || !isSPACE(*PL_bufptr)) | |
3171 | check_uni(); | |
3172 | OPERATOR('+'); | |
3173 | } | |
2f3197b3 | 3174 | } |
a687059c | 3175 | |
378cc40b | 3176 | case '*': |
3280af22 NIS |
3177 | if (PL_expect != XOPERATOR) { |
3178 | s = scan_ident(s, PL_bufend, PL_tokenbuf, sizeof PL_tokenbuf, TRUE); | |
3179 | PL_expect = XOPERATOR; | |
3180 | force_ident(PL_tokenbuf, '*'); | |
3181 | if (!*PL_tokenbuf) | |
a0d0e21e | 3182 | PREREF('*'); |
79072805 | 3183 | TERM('*'); |
a687059c | 3184 | } |
79072805 LW |
3185 | s++; |
3186 | if (*s == '*') { | |
a687059c | 3187 | s++; |
79072805 | 3188 | PWop(OP_POW); |
a687059c | 3189 | } |
79072805 LW |
3190 | Mop(OP_MULTIPLY); |
3191 | ||
378cc40b | 3192 | case '%': |
3280af22 | 3193 | if (PL_expect == XOPERATOR) { |
bbce6d69 | 3194 | ++s; |
3195 | Mop(OP_MODULO); | |
a687059c | 3196 | } |
3280af22 NIS |
3197 | PL_tokenbuf[0] = '%'; |
3198 | s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, TRUE); | |
3199 | if (!PL_tokenbuf[1]) { | |
bbce6d69 | 3200 | PREREF('%'); |
a687059c | 3201 | } |
3280af22 | 3202 | PL_pending_ident = '%'; |
bbce6d69 | 3203 | TERM('%'); |
a687059c | 3204 | |
378cc40b | 3205 | case '^': |
79072805 | 3206 | s++; |
a0d0e21e | 3207 | BOop(OP_BIT_XOR); |
79072805 | 3208 | case '[': |
3280af22 | 3209 | PL_lex_brackets++; |
79072805 | 3210 | /* FALL THROUGH */ |
378cc40b | 3211 | case '~': |
0d863452 RH |
3212 | if (s[1] == '~' |
3213 | && (PL_expect == XOPERATOR || PL_expect == XTERMORDORDOR) | |
ef89dcc3 | 3214 | && FEATURE_IS_ENABLED("~~")) |
0d863452 RH |
3215 | { |
3216 | s += 2; | |
3217 | Eop(OP_SMARTMATCH); | |
3218 | } | |
378cc40b | 3219 | case ',': |
90771dc0 NC |
3220 | { |
3221 | const char tmp = *s++; | |
3222 | OPERATOR(tmp); | |
3223 | } | |
a0d0e21e LW |
3224 | case ':': |
3225 | if (s[1] == ':') { | |
3226 | len = 0; | |
0bfa2a8a | 3227 | goto just_a_word_zero_gv; |
a0d0e21e LW |
3228 | } |
3229 | s++; | |
09bef843 SB |
3230 | switch (PL_expect) { |
3231 | OP *attrs; | |
3232 | case XOPERATOR: | |
3233 | if (!PL_in_my || PL_lex_state != LEX_NORMAL) | |
3234 | break; | |
3235 | PL_bufptr = s; /* update in case we back off */ | |
3236 | goto grabattrs; | |
3237 | case XATTRBLOCK: | |
3238 | PL_expect = XBLOCK; | |
3239 | goto grabattrs; | |
3240 | case XATTRTERM: | |
3241 | PL_expect = XTERMBLOCK; | |
3242 | grabattrs: | |
3243 | s = skipspace(s); | |
3244 | attrs = Nullop; | |
7e2040f0 | 3245 | while (isIDFIRST_lazy_if(s,UTF)) { |
90771dc0 | 3246 | I32 tmp; |
09bef843 | 3247 | d = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &len); |
f9829d6b GS |
3248 | if (isLOWER(*s) && (tmp = keyword(PL_tokenbuf, len))) { |
3249 | if (tmp < 0) tmp = -tmp; | |
3250 | switch (tmp) { | |
3251 | case KEY_or: | |
3252 | case KEY_and: | |
c963b151 | 3253 | case KEY_err: |
f9829d6b GS |
3254 | case KEY_for: |
3255 | case KEY_unless: | |
3256 | case KEY_if: | |
3257 | case KEY_while: | |
3258 | case KEY_until: | |
3259 | goto got_attrs; | |
3260 | default: | |
3261 | break; | |
3262 | } | |
3263 | } | |
09bef843 SB |
3264 | if (*d == '(') { |
3265 | d = scan_str(d,TRUE,TRUE); | |
3266 | if (!d) { | |
09bef843 SB |
3267 | /* MUST advance bufptr here to avoid bogus |
3268 | "at end of line" context messages from yyerror(). | |
3269 | */ | |
3270 | PL_bufptr = s + len; | |
3271 | yyerror("Unterminated attribute parameter in attribute list"); | |
3272 | if (attrs) | |
3273 | op_free(attrs); | |
bbf60fe6 | 3274 | return REPORT(0); /* EOF indicator */ |
09bef843 SB |
3275 | } |
3276 | } | |
3277 | if (PL_lex_stuff) { | |
3278 | SV *sv = newSVpvn(s, len); | |
3279 | sv_catsv(sv, PL_lex_stuff); | |
3280 | attrs = append_elem(OP_LIST, attrs, | |
3281 | newSVOP(OP_CONST, 0, sv)); | |
3282 | SvREFCNT_dec(PL_lex_stuff); | |
3283 | PL_lex_stuff = Nullsv; | |
3284 | } | |
3285 | else { | |
371fce9b DM |
3286 | if (len == 6 && strnEQ(s, "unique", len)) { |
3287 | if (PL_in_my == KEY_our) | |
3288 | #ifdef USE_ITHREADS | |
3289 | GvUNIQUE_on(cGVOPx_gv(yylval.opval)); | |
3290 | #else | |
3291 | ; /* skip to avoid loading attributes.pm */ | |
3292 | #endif | |
bfed75c6 | 3293 | else |
371fce9b DM |
3294 | Perl_croak(aTHX_ "The 'unique' attribute may only be applied to 'our' variables"); |
3295 | } | |
3296 | ||
d3cea301 SB |
3297 | /* NOTE: any CV attrs applied here need to be part of |
3298 | the CVf_BUILTIN_ATTRS define in cv.h! */ | |
371fce9b | 3299 | else if (!PL_in_my && len == 6 && strnEQ(s, "lvalue", len)) |
78f9721b SM |
3300 | CvLVALUE_on(PL_compcv); |
3301 | else if (!PL_in_my && len == 6 && strnEQ(s, "locked", len)) | |
3302 | CvLOCKED_on(PL_compcv); | |
3303 | else if (!PL_in_my && len == 6 && strnEQ(s, "method", len)) | |
3304 | CvMETHOD_on(PL_compcv); | |
06492da6 SF |
3305 | else if (!PL_in_my && len == 9 && strnEQ(s, "assertion", len)) |
3306 | CvASSERTION_on(PL_compcv); | |
78f9721b SM |
3307 | /* After we've set the flags, it could be argued that |
3308 | we don't need to do the attributes.pm-based setting | |
3309 | process, and shouldn't bother appending recognized | |
d3cea301 SB |
3310 | flags. To experiment with that, uncomment the |
3311 | following "else". (Note that's already been | |
3312 | uncommented. That keeps the above-applied built-in | |
3313 | attributes from being intercepted (and possibly | |
3314 | rejected) by a package's attribute routines, but is | |
3315 | justified by the performance win for the common case | |
3316 | of applying only built-in attributes.) */ | |
0256094b | 3317 | else |
78f9721b SM |
3318 | attrs = append_elem(OP_LIST, attrs, |
3319 | newSVOP(OP_CONST, 0, | |
3320 | newSVpvn(s, len))); | |
09bef843 SB |
3321 | } |
3322 | s = skipspace(d); | |
0120eecf | 3323 | if (*s == ':' && s[1] != ':') |
09bef843 | 3324 | s = skipspace(s+1); |
0120eecf GS |
3325 | else if (s == d) |
3326 | break; /* require real whitespace or :'s */ | |
09bef843 | 3327 | } |
90771dc0 NC |
3328 | { |
3329 | const char tmp | |
3330 | = (PL_expect == XOPERATOR ? '=' : '{'); /*'}(' for vi */ | |
3331 | if (*s != ';' && *s != '}' && *s != tmp | |
3332 | && (tmp != '=' || *s != ')')) { | |
3333 | const char q = ((*s == '\'') ? '"' : '\''); | |
3334 | /* If here for an expression, and parsed no attrs, back | |
3335 | off. */ | |
3336 | if (tmp == '=' && !attrs) { | |
3337 | s = PL_bufptr; | |
3338 | break; | |
3339 | } | |
3340 | /* MUST advance bufptr here to avoid bogus "at end of line" | |
3341 | context messages from yyerror(). | |
3342 | */ | |
3343 | PL_bufptr = s; | |
3344 | yyerror( *s | |
3345 | ? Perl_form(aTHX_ "Invalid separator character " | |
3346 | "%c%c%c in attribute list", q, *s, q) | |
3347 | : "Unterminated attribute list" ); | |
3348 | if (attrs) | |
3349 | op_free(attrs); | |
3350 | OPERATOR(':'); | |
09bef843 | 3351 | } |
09bef843 | 3352 | } |
f9829d6b | 3353 | got_attrs: |
09bef843 SB |
3354 | if (attrs) { |
3355 | PL_nextval[PL_nexttoke].opval = attrs; | |
3356 | force_next(THING); | |
3357 | } | |
3358 | TOKEN(COLONATTR); | |
3359 | } | |
a0d0e21e | 3360 | OPERATOR(':'); |
8990e307 LW |
3361 | case '(': |
3362 | s++; | |
3280af22 NIS |
3363 | if (PL_last_lop == PL_oldoldbufptr || PL_last_uni == PL_oldoldbufptr) |
3364 | PL_oldbufptr = PL_oldoldbufptr; /* allow print(STDOUT 123) */ | |
a0d0e21e | 3365 | else |
3280af22 | 3366 | PL_expect = XTERM; |
4a202259 | 3367 | s = skipspace(s); |
a0d0e21e | 3368 | TOKEN('('); |
378cc40b | 3369 | case ';': |
f4dd75d9 | 3370 | CLINE; |
90771dc0 NC |
3371 | { |
3372 | const char tmp = *s++; | |
3373 | OPERATOR(tmp); | |
3374 | } | |
378cc40b | 3375 | case ')': |
90771dc0 NC |
3376 | { |
3377 | const char tmp = *s++; | |
3378 | s = skipspace(s); | |
3379 | if (*s == '{') | |
3380 | PREBLOCK(tmp); | |
3381 | TERM(tmp); | |
3382 | } | |
79072805 LW |
3383 | case ']': |
3384 | s++; | |
3280af22 | 3385 | if (PL_lex_brackets <= 0) |
d98d5fff | 3386 | yyerror("Unmatched right square bracket"); |
463ee0b2 | 3387 | else |
3280af22 NIS |
3388 | --PL_lex_brackets; |
3389 | if (PL_lex_state == LEX_INTERPNORMAL) { | |
3390 | if (PL_lex_brackets == 0) { | |
a0d0e21e | 3391 | if (*s != '[' && *s != '{' && (*s != '-' || s[1] != '>')) |
3280af22 | 3392 | PL_lex_state = LEX_INTERPEND; |
79072805 LW |
3393 | } |
3394 | } | |
4633a7c4 | 3395 | TERM(']'); |
79072805 LW |
3396 | case '{': |
3397 | leftbracket: | |
79072805 | 3398 | s++; |
3280af22 | 3399 | if (PL_lex_brackets > 100) { |
8edd5f42 | 3400 | Renew(PL_lex_brackstack, PL_lex_brackets + 10, char); |
8990e307 | 3401 | } |
3280af22 | 3402 | switch (PL_expect) { |
a0d0e21e | 3403 | case XTERM: |
3280af22 | 3404 | if (PL_lex_formbrack) { |
a0d0e21e LW |
3405 | s--; |
3406 | PRETERMBLOCK(DO); | |
3407 | } | |
3280af22 NIS |
3408 | if (PL_oldoldbufptr == PL_last_lop) |
3409 | PL_lex_brackstack[PL_lex_brackets++] = XTERM; | |
a0d0e21e | 3410 | else |
3280af22 | 3411 | PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR; |
79072805 | 3412 | OPERATOR(HASHBRACK); |
a0d0e21e | 3413 | case XOPERATOR: |
bf4acbe4 | 3414 | while (s < PL_bufend && SPACE_OR_TAB(*s)) |
748a9306 | 3415 | s++; |
44a8e56a | 3416 | d = s; |
3280af22 NIS |
3417 | PL_tokenbuf[0] = '\0'; |
3418 | if (d < PL_bufend && *d == '-') { | |
3419 | PL_tokenbuf[0] = '-'; | |
44a8e56a | 3420 | d++; |
bf4acbe4 | 3421 | while (d < PL_bufend && SPACE_OR_TAB(*d)) |
44a8e56a | 3422 | d++; |
3423 | } | |
7e2040f0 | 3424 | if (d < PL_bufend && isIDFIRST_lazy_if(d,UTF)) { |
3280af22 | 3425 | d = scan_word(d, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, |
8903cb82 | 3426 | FALSE, &len); |
bf4acbe4 | 3427 | while (d < PL_bufend && SPACE_OR_TAB(*d)) |
748a9306 LW |
3428 | d++; |
3429 | if (*d == '}') { | |
f54cb97a | 3430 | const char minus = (PL_tokenbuf[0] == '-'); |
44a8e56a | 3431 | s = force_word(s + minus, WORD, FALSE, TRUE, FALSE); |
3432 | if (minus) | |
3433 | force_next('-'); | |
748a9306 LW |
3434 | } |
3435 | } | |
3436 | /* FALL THROUGH */ | |
09bef843 | 3437 | case XATTRBLOCK: |
748a9306 | 3438 | case XBLOCK: |
3280af22 NIS |
3439 | PL_lex_brackstack[PL_lex_brackets++] = XSTATE; |
3440 | PL_expect = XSTATE; | |
a0d0e21e | 3441 | break; |
09bef843 | 3442 | case XATTRTERM: |
a0d0e21e | 3443 | case XTERMBLOCK: |
3280af22 NIS |
3444 | PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR; |
3445 | PL_expect = XSTATE; | |
a0d0e21e LW |
3446 | break; |
3447 | default: { | |
f54cb97a | 3448 | const char *t; |
3280af22 NIS |
3449 | if (PL_oldoldbufptr == PL_last_lop) |
3450 | PL_lex_brackstack[PL_lex_brackets++] = XTERM; | |
a0d0e21e | 3451 | else |
3280af22 | 3452 | PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR; |
a0d0e21e | 3453 | s = skipspace(s); |
8452ff4b SB |
3454 | if (*s == '}') { |
3455 | if (PL_expect == XREF && PL_lex_state == LEX_INTERPNORMAL) { | |
3456 | PL_expect = XTERM; | |
3457 | /* This hack is to get the ${} in the message. */ | |
3458 | PL_bufptr = s+1; | |
3459 | yyerror("syntax error"); | |
3460 | break; | |
3461 | } | |
a0d0e21e | 3462 | OPERATOR(HASHBRACK); |
8452ff4b | 3463 | } |
b8a4b1be GS |
3464 | /* This hack serves to disambiguate a pair of curlies |
3465 | * as being a block or an anon hash. Normally, expectation | |
3466 | * determines that, but in cases where we're not in a | |
3467 | * position to expect anything in particular (like inside | |
3468 | * eval"") we have to resolve the ambiguity. This code | |
3469 | * covers the case where the first term in the curlies is a | |
3470 | * quoted string. Most other cases need to be explicitly | |
a0288114 | 3471 | * disambiguated by prepending a "+" before the opening |
b8a4b1be GS |
3472 | * curly in order to force resolution as an anon hash. |
3473 | * | |
3474 | * XXX should probably propagate the outer expectation | |
3475 | * into eval"" to rely less on this hack, but that could | |
3476 | * potentially break current behavior of eval"". | |
3477 | * GSAR 97-07-21 | |
3478 | */ | |
3479 | t = s; | |
3480 | if (*s == '\'' || *s == '"' || *s == '`') { | |
3481 | /* common case: get past first string, handling escapes */ | |
3280af22 | 3482 | for (t++; t < PL_bufend && *t != *s;) |
b8a4b1be GS |
3483 | if (*t++ == '\\' && (*t == '\\' || *t == *s)) |
3484 | t++; | |
3485 | t++; | |
a0d0e21e | 3486 | } |
b8a4b1be | 3487 | else if (*s == 'q') { |
3280af22 | 3488 | if (++t < PL_bufend |
b8a4b1be | 3489 | && (!isALNUM(*t) |
3280af22 | 3490 | || ((*t == 'q' || *t == 'x') && ++t < PL_bufend |
0505442f GS |
3491 | && !isALNUM(*t)))) |
3492 | { | |
abc667d1 | 3493 | /* skip q//-like construct */ |
f54cb97a | 3494 | const char *tmps; |
b8a4b1be GS |
3495 | char open, close, term; |
3496 | I32 brackets = 1; | |
3497 | ||
3280af22 | 3498 | while (t < PL_bufend && isSPACE(*t)) |
b8a4b1be | 3499 | t++; |
abc667d1 DM |
3500 | /* check for q => */ |
3501 | if (t+1 < PL_bufend && t[0] == '=' && t[1] == '>') { | |
3502 | OPERATOR(HASHBRACK); | |
3503 | } | |
b8a4b1be GS |
3504 | term = *t; |
3505 | open = term; | |
3506 | if (term && (tmps = strchr("([{< )]}> )]}>",term))) | |
3507 | term = tmps[5]; | |
3508 | close = term; | |
3509 | if (open == close) | |
3280af22 NIS |
3510 | for (t++; t < PL_bufend; t++) { |
3511 | if (*t == '\\' && t+1 < PL_bufend && open != '\\') | |
b8a4b1be | 3512 | t++; |
6d07e5e9 | 3513 | else if (*t == open) |
b8a4b1be GS |
3514 | break; |
3515 | } | |
abc667d1 | 3516 | else { |
3280af22 NIS |
3517 | for (t++; t < PL_bufend; t++) { |
3518 | if (*t == '\\' && t+1 < PL_bufend) | |
b8a4b1be | 3519 | t++; |
6d07e5e9 | 3520 | else if (*t == close && --brackets <= 0) |
b8a4b1be GS |
3521 | break; |
3522 | else if (*t == open) | |
3523 | brackets++; | |
3524 | } | |
abc667d1 DM |
3525 | } |
3526 | t++; | |
b8a4b1be | 3527 | } |
abc667d1 DM |
3528 | else |
3529 | /* skip plain q word */ | |
3530 | while (t < PL_bufend && isALNUM_lazy_if(t,UTF)) | |
3531 | t += UTF8SKIP(t); | |
a0d0e21e | 3532 | } |
7e2040f0 | 3533 | else if (isALNUM_lazy_if(t,UTF)) { |
0505442f | 3534 | t += UTF8SKIP(t); |
7e2040f0 | 3535 | while (t < PL_bufend && isALNUM_lazy_if(t,UTF)) |
0505442f | 3536 | t += UTF8SKIP(t); |
a0d0e21e | 3537 | } |
3280af22 | 3538 | while (t < PL_bufend && isSPACE(*t)) |
a0d0e21e | 3539 | t++; |
b8a4b1be GS |
3540 | /* if comma follows first term, call it an anon hash */ |
3541 | /* XXX it could be a comma expression with loop modifiers */ | |
3280af22 | 3542 | if (t < PL_bufend && ((*t == ',' && (*s == 'q' || !isLOWER(*s))) |
b8a4b1be | 3543 | || (*t == '=' && t[1] == '>'))) |
a0d0e21e | 3544 | OPERATOR(HASHBRACK); |
3280af22 | 3545 | if (PL_expect == XREF) |
4e4e412b | 3546 | PL_expect = XTERM; |
a0d0e21e | 3547 | else { |
3280af22 NIS |
3548 | PL_lex_brackstack[PL_lex_brackets-1] = XSTATE; |
3549 | PL_expect = XSTATE; | |
a0d0e21e | 3550 | } |
8990e307 | 3551 | } |
a0d0e21e | 3552 | break; |
463ee0b2 | 3553 | } |
57843af0 | 3554 | yylval.ival = CopLINE(PL_curcop); |
79072805 | 3555 | if (isSPACE(*s) || *s == '#') |
3280af22 | 3556 | PL_copline = NOLINE; /* invalidate current command line number */ |
79072805 | 3557 | TOKEN('{'); |
378cc40b | 3558 | case '}': |
79072805 LW |
3559 | rightbracket: |
3560 | s++; | |
3280af22 | 3561 | if (PL_lex_brackets <= 0) |
d98d5fff | 3562 | yyerror("Unmatched right curly bracket"); |
463ee0b2 | 3563 | else |
3280af22 | 3564 | PL_expect = (expectation)PL_lex_brackstack[--PL_lex_brackets]; |
c2e66d9e | 3565 | if (PL_lex_brackets < PL_lex_formbrack && PL_lex_state != LEX_INTERPNORMAL) |
3280af22 NIS |
3566 | PL_lex_formbrack = 0; |
3567 | if (PL_lex_state == LEX_INTERPNORMAL) { | |
3568 | if (PL_lex_brackets == 0) { | |
9059aa12 LW |
3569 | if (PL_expect & XFAKEBRACK) { |
3570 | PL_expect &= XENUMMASK; | |
3280af22 NIS |
3571 | PL_lex_state = LEX_INTERPEND; |
3572 | PL_bufptr = s; | |
cea2e8a9 | 3573 | return yylex(); /* ignore fake brackets */ |
79072805 | 3574 | } |
fa83b5b6 | 3575 | if (*s == '-' && s[1] == '>') |
3280af22 | 3576 | PL_lex_state = LEX_INTERPENDMAYBE; |
fa83b5b6 | 3577 | else if (*s != '[' && *s != '{') |
3280af22 | 3578 | PL_lex_state = LEX_INTERPEND; |
79072805 LW |
3579 | } |
3580 | } | |
9059aa12 LW |
3581 | if (PL_expect & XFAKEBRACK) { |
3582 | PL_expect &= XENUMMASK; | |
3280af22 | 3583 | PL_bufptr = s; |
cea2e8a9 | 3584 | return yylex(); /* ignore fake brackets */ |
748a9306 | 3585 | } |
79072805 LW |
3586 | force_next('}'); |
3587 | TOKEN(';'); | |
378cc40b LW |
3588 | case '&': |
3589 | s++; | |
90771dc0 | 3590 | if (*s++ == '&') |
a0d0e21e | 3591 | AOPERATOR(ANDAND); |
378cc40b | 3592 | s--; |
3280af22 | 3593 | if (PL_expect == XOPERATOR) { |
041457d9 DM |
3594 | if (PL_bufptr == PL_linestart && ckWARN(WARN_SEMICOLON) |
3595 | && isIDFIRST_lazy_if(s,UTF)) | |
7e2040f0 | 3596 | { |
57843af0 | 3597 | CopLINE_dec(PL_curcop); |
9014280d | 3598 | Perl_warner(aTHX_ packWARN(WARN_SEMICOLON), PL_warn_nosemi); |
57843af0 | 3599 | CopLINE_inc(PL_curcop); |
463ee0b2 | 3600 | } |
79072805 | 3601 | BAop(OP_BIT_AND); |
463ee0b2 | 3602 | } |
79072805 | 3603 | |
3280af22 NIS |
3604 | s = scan_ident(s - 1, PL_bufend, PL_tokenbuf, sizeof PL_tokenbuf, TRUE); |
3605 | if (*PL_tokenbuf) { | |
3606 | PL_expect = XOPERATOR; | |
3607 | force_ident(PL_tokenbuf, '&'); | |
463ee0b2 | 3608 | } |
79072805 LW |
3609 | else |
3610 | PREREF('&'); | |
c07a80fd | 3611 | yylval.ival = (OPpENTERSUB_AMPER<<8); |
79072805 LW |
3612 | TERM('&'); |
3613 | ||
378cc40b LW |
3614 | case '|': |
3615 | s++; | |
90771dc0 | 3616 | if (*s++ == '|') |
a0d0e21e | 3617 | AOPERATOR(OROR); |
378cc40b | 3618 | s--; |
79072805 | 3619 | BOop(OP_BIT_OR); |
378cc40b LW |
3620 | case '=': |
3621 | s++; | |
748a9306 | 3622 | { |
90771dc0 NC |
3623 | const char tmp = *s++; |
3624 | if (tmp == '=') | |
3625 | Eop(OP_EQ); | |
3626 | if (tmp == '>') | |
3627 | OPERATOR(','); | |
3628 | if (tmp == '~') | |
3629 | PMop(OP_MATCH); | |
3630 | if (tmp && isSPACE(*s) && ckWARN(WARN_SYNTAX) | |
3631 | && strchr("+-*/%.^&|<",tmp)) | |
3632 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), | |
3633 | "Reversed %c= operator",(int)tmp); | |
3634 | s--; | |
3635 | if (PL_expect == XSTATE && isALPHA(tmp) && | |
3636 | (s == PL_linestart+1 || s[-2] == '\n') ) | |
3637 | { | |
3638 | if (PL_in_eval && !PL_rsfp) { | |
3639 | d = PL_bufend; | |
3640 | while (s < d) { | |
3641 | if (*s++ == '\n') { | |
3642 | incline(s); | |
3643 | if (strnEQ(s,"=cut",4)) { | |
3644 | s = strchr(s,'\n'); | |
3645 | if (s) | |
3646 | s++; | |
3647 | else | |
3648 | s = d; | |
3649 | incline(s); | |
3650 | goto retry; | |
3651 | } | |
3652 | } | |
a5f75d66 | 3653 | } |
90771dc0 | 3654 | goto retry; |
a5f75d66 | 3655 | } |
90771dc0 NC |
3656 | s = PL_bufend; |
3657 | PL_doextract = TRUE; | |
3658 | goto retry; | |
a5f75d66 | 3659 | } |
a0d0e21e | 3660 | } |
3280af22 | 3661 | if (PL_lex_brackets < PL_lex_formbrack) { |
f54cb97a | 3662 | const char *t; |
51882d45 | 3663 | #ifdef PERL_STRICT_CR |
bf4acbe4 | 3664 | for (t = s; SPACE_OR_TAB(*t); t++) ; |
51882d45 | 3665 | #else |
bf4acbe4 | 3666 | for (t = s; SPACE_OR_TAB(*t) || *t == '\r'; t++) ; |
51882d45 | 3667 | #endif |
a0d0e21e LW |
3668 | if (*t == '\n' || *t == '#') { |
3669 | s--; | |
3280af22 | 3670 | PL_expect = XBLOCK; |
a0d0e21e LW |
3671 | goto leftbracket; |
3672 | } | |
79072805 | 3673 | } |
a0d0e21e LW |
3674 | yylval.ival = 0; |
3675 | OPERATOR(ASSIGNOP); | |
378cc40b LW |
3676 | case '!': |
3677 | s++; | |
90771dc0 NC |
3678 | { |
3679 | const char tmp = *s++; | |
3680 | if (tmp == '=') { | |
3681 | /* was this !=~ where !~ was meant? | |
3682 | * warn on m:!=~\s+([/?]|[msy]\W|tr\W): */ | |
3683 | ||
3684 | if (*s == '~' && ckWARN(WARN_SYNTAX)) { | |
3685 | const char *t = s+1; | |
3686 | ||
3687 | while (t < PL_bufend && isSPACE(*t)) | |
3688 | ++t; | |
3689 | ||
3690 | if (*t == '/' || *t == '?' || | |
3691 | ((*t == 'm' || *t == 's' || *t == 'y') | |
3692 | && !isALNUM(t[1])) || | |
3693 | (*t == 't' && t[1] == 'r' && !isALNUM(t[2]))) | |
3694 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), | |
3695 | "!=~ should be !~"); | |
3696 | } | |
3697 | Eop(OP_NE); | |
3698 | } | |
3699 | if (tmp == '~') | |
3700 | PMop(OP_NOT); | |
3701 | } | |
378cc40b LW |
3702 | s--; |
3703 | OPERATOR('!'); | |
3704 | case '<': | |
3280af22 | 3705 | if (PL_expect != XOPERATOR) { |
93a17b20 | 3706 | if (s[1] != '<' && !strchr(s,'>')) |
2f3197b3 | 3707 | check_uni(); |
79072805 LW |
3708 | if (s[1] == '<') |
3709 | s = scan_heredoc(s); | |
3710 | else | |
3711 | s = scan_inputsymbol(s); | |
3712 | TERM(sublex_start()); | |
378cc40b LW |
3713 | } |
3714 | s++; | |
90771dc0 NC |
3715 | { |
3716 | char tmp = *s++; | |
3717 | if (tmp == '<') | |
3718 | SHop(OP_LEFT_SHIFT); | |
3719 | if (tmp == '=') { | |
3720 | tmp = *s++; | |
3721 | if (tmp == '>') | |
3722 | Eop(OP_NCMP); | |
3723 | s--; | |
3724 | Rop(OP_LE); | |
3725 | } | |
395c3793 | 3726 | } |
378cc40b | 3727 | s--; |
79072805 | 3728 | Rop(OP_LT); |
378cc40b LW |
3729 | case '>': |
3730 | s++; | |
90771dc0 NC |
3731 | { |
3732 | const char tmp = *s++; | |
3733 | if (tmp == '>') | |
3734 | SHop(OP_RIGHT_SHIFT); | |
3735 | if (tmp == '=') | |
3736 | Rop(OP_GE); | |
3737 | } | |
378cc40b | 3738 | s--; |
79072805 | 3739 | Rop(OP_GT); |
378cc40b LW |
3740 | |
3741 | case '$': | |
bbce6d69 | 3742 | CLINE; |
3743 | ||
3280af22 NIS |
3744 | if (PL_expect == XOPERATOR) { |
3745 | if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { | |
3746 | PL_expect = XTERM; | |
c445ea15 | 3747 | deprecate_old(commaless_variable_list); |
bbf60fe6 | 3748 | return REPORT(','); /* grandfather non-comma-format format */ |
a0d0e21e | 3749 | } |
8990e307 | 3750 | } |
a0d0e21e | 3751 | |
7e2040f0 | 3752 | if (s[1] == '#' && (isIDFIRST_lazy_if(s+2,UTF) || strchr("{$:+-", s[2]))) { |
3280af22 | 3753 | PL_tokenbuf[0] = '@'; |
376b8730 SM |
3754 | s = scan_ident(s + 1, PL_bufend, PL_tokenbuf + 1, |
3755 | sizeof PL_tokenbuf - 1, FALSE); | |
3756 | if (PL_expect == XOPERATOR) | |
3757 | no_op("Array length", s); | |
3280af22 | 3758 | if (!PL_tokenbuf[1]) |
a0d0e21e | 3759 | PREREF(DOLSHARP); |
3280af22 NIS |
3760 | PL_expect = XOPERATOR; |
3761 | PL_pending_ident = '#'; | |
463ee0b2 | 3762 | TOKEN(DOLSHARP); |
79072805 | 3763 | } |
bbce6d69 | 3764 | |
3280af22 | 3765 | PL_tokenbuf[0] = '$'; |
376b8730 SM |
3766 | s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, |
3767 | sizeof PL_tokenbuf - 1, FALSE); | |
3768 | if (PL_expect == XOPERATOR) | |
3769 | no_op("Scalar", s); | |
3280af22 NIS |
3770 | if (!PL_tokenbuf[1]) { |
3771 | if (s == PL_bufend) | |
bbce6d69 | 3772 | yyerror("Final $ should be \\$ or $name"); |
3773 | PREREF('$'); | |
8990e307 | 3774 | } |
a0d0e21e | 3775 | |
bbce6d69 | 3776 | /* This kludge not intended to be bulletproof. */ |
3280af22 | 3777 | if (PL_tokenbuf[1] == '[' && !PL_tokenbuf[2]) { |
bbce6d69 | 3778 | yylval.opval = newSVOP(OP_CONST, 0, |
b448e4fe | 3779 | newSViv(PL_compiling.cop_arybase)); |
bbce6d69 | 3780 | yylval.opval->op_private = OPpCONST_ARYBASE; |
3781 | TERM(THING); | |
3782 | } | |
3783 | ||
ff68c719 | 3784 | d = s; |
90771dc0 NC |
3785 | { |
3786 | const char tmp = *s; | |
3787 | if (PL_lex_state == LEX_NORMAL) | |
3788 | s = skipspace(s); | |
ff68c719 | 3789 | |
90771dc0 NC |
3790 | if ((PL_expect != XREF || PL_oldoldbufptr == PL_last_lop) |
3791 | && intuit_more(s)) { | |
3792 | if (*s == '[') { | |
3793 | PL_tokenbuf[0] = '@'; | |
3794 | if (ckWARN(WARN_SYNTAX)) { | |
3795 | char *t; | |
3796 | for(t = s + 1; | |
3797 | isSPACE(*t) || isALNUM_lazy_if(t,UTF) || *t == '$'; | |
3798 | t++) ; | |
3799 | if (*t++ == ',') { | |
3800 | PL_bufptr = skipspace(PL_bufptr); | |
3801 | while (t < PL_bufend && *t != ']') | |
3802 | t++; | |
9014280d | 3803 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
90771dc0 | 3804 | "Multidimensional syntax %.*s not supported", |
36c7798d | 3805 | (int)((t - PL_bufptr) + 1), PL_bufptr); |
90771dc0 | 3806 | } |
748a9306 | 3807 | } |
93a17b20 | 3808 | } |
90771dc0 NC |
3809 | else if (*s == '{') { |
3810 | char *t; | |
3811 | PL_tokenbuf[0] = '%'; | |
3812 | if (strEQ(PL_tokenbuf+1, "SIG") && ckWARN(WARN_SYNTAX) | |
3813 | && (t = strchr(s, '}')) && (t = strchr(t, '='))) | |
3814 | { | |
3815 | char tmpbuf[sizeof PL_tokenbuf]; | |
3816 | for (t++; isSPACE(*t); t++) ; | |
3817 | if (isIDFIRST_lazy_if(t,UTF)) { | |
3818 | STRLEN len; | |
3819 | t = scan_word(t, tmpbuf, sizeof tmpbuf, TRUE, | |
3820 | &len); | |
3821 | for (; isSPACE(*t); t++) ; | |
3822 | if (*t == ';' && get_cv(tmpbuf, FALSE)) | |
3823 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), | |
3824 | "You need to quote \"%s\"", | |
3825 | tmpbuf); | |
3826 | } | |
3827 | } | |
3828 | } | |
93a17b20 | 3829 | } |
bbce6d69 | 3830 | |
90771dc0 NC |
3831 | PL_expect = XOPERATOR; |
3832 | if (PL_lex_state == LEX_NORMAL && isSPACE((char)tmp)) { | |
3833 | const bool islop = (PL_last_lop == PL_oldoldbufptr); | |
3834 | if (!islop || PL_last_lop_op == OP_GREPSTART) | |
3835 | PL_expect = XOPERATOR; | |
3836 | else if (strchr("$@\"'`q", *s)) | |
3837 | PL_expect = XTERM; /* e.g. print $fh "foo" */ | |
3838 | else if (strchr("&*<%", *s) && isIDFIRST_lazy_if(s+1,UTF)) | |
3839 | PL_expect = XTERM; /* e.g. print $fh &sub */ | |
3840 | else if (isIDFIRST_lazy_if(s,UTF)) { | |
3841 | char tmpbuf[sizeof PL_tokenbuf]; | |
3842 | int t2; | |
3843 | scan_word(s, tmpbuf, sizeof tmpbuf, TRUE, &len); | |
3844 | if ((t2 = keyword(tmpbuf, len))) { | |
3845 | /* binary operators exclude handle interpretations */ | |
3846 | switch (t2) { | |
3847 | case -KEY_x: | |
3848 | case -KEY_eq: | |
3849 | case -KEY_ne: | |
3850 | case -KEY_gt: | |
3851 | case -KEY_lt: | |
3852 | case -KEY_ge: | |
3853 | case -KEY_le: | |
3854 | case -KEY_cmp: | |
3855 | break; | |
3856 | default: | |
3857 | PL_expect = XTERM; /* e.g. print $fh length() */ | |
3858 | break; | |
3859 | } | |
3860 | } | |
3861 | else { | |
3862 | PL_expect = XTERM; /* e.g. print $fh subr() */ | |
84902520 TB |
3863 | } |
3864 | } | |
90771dc0 NC |
3865 | else if (isDIGIT(*s)) |
3866 | PL_expect = XTERM; /* e.g. print $fh 3 */ | |
3867 | else if (*s == '.' && isDIGIT(s[1])) | |
3868 | PL_expect = XTERM; /* e.g. print $fh .3 */ | |
3869 | else if ((*s == '?' || *s == '-' || *s == '+') | |
3870 | && !isSPACE(s[1]) && s[1] != '=') | |
3871 | PL_expect = XTERM; /* e.g. print $fh -1 */ | |
3872 | else if (*s == '/' && !isSPACE(s[1]) && s[1] != '=' | |
3873 | && s[1] != '/') | |
3874 | PL_expect = XTERM; /* e.g. print $fh /.../ | |
3875 | XXX except DORDOR operator | |
3876 | */ | |
3877 | else if (*s == '<' && s[1] == '<' && !isSPACE(s[2]) | |
3878 | && s[2] != '=') | |
3879 | PL_expect = XTERM; /* print $fh <<"EOF" */ | |
93a17b20 | 3880 | } |
bbce6d69 | 3881 | } |
3280af22 | 3882 | PL_pending_ident = '$'; |
79072805 | 3883 | TOKEN('$'); |
378cc40b LW |
3884 | |
3885 | case '@': | |
3280af22 | 3886 | if (PL_expect == XOPERATOR) |
bbce6d69 | 3887 | no_op("Array", s); |
3280af22 NIS |
3888 | PL_tokenbuf[0] = '@'; |
3889 | s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); | |
3890 | if (!PL_tokenbuf[1]) { | |
bbce6d69 | 3891 | PREREF('@'); |
3892 | } | |
3280af22 | 3893 | if (PL_lex_state == LEX_NORMAL) |
ff68c719 | 3894 | s = skipspace(s); |
3280af22 | 3895 | if ((PL_expect != XREF || PL_oldoldbufptr == PL_last_lop) && intuit_more(s)) { |
bbce6d69 | 3896 | if (*s == '{') |
3280af22 | 3897 | PL_tokenbuf[0] = '%'; |
a0d0e21e LW |
3898 | |
3899 | /* Warn about @ where they meant $. */ | |
041457d9 DM |
3900 | if (*s == '[' || *s == '{') { |
3901 | if (ckWARN(WARN_SYNTAX)) { | |
f54cb97a | 3902 | const char *t = s + 1; |
7e2040f0 | 3903 | while (*t && (isALNUM_lazy_if(t,UTF) || strchr(" \t$#+-'\"", *t))) |
a0d0e21e LW |
3904 | t++; |
3905 | if (*t == '}' || *t == ']') { | |
3906 | t++; | |
3280af22 | 3907 | PL_bufptr = skipspace(PL_bufptr); |
9014280d | 3908 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
599cee73 | 3909 | "Scalar value %.*s better written as $%.*s", |
36c7798d DM |
3910 | (int)(t-PL_bufptr), PL_bufptr, |
3911 | (int)(t-PL_bufptr-1), PL_bufptr+1); | |
a0d0e21e | 3912 | } |
93a17b20 LW |
3913 | } |
3914 | } | |
463ee0b2 | 3915 | } |
3280af22 | 3916 | PL_pending_ident = '@'; |
79072805 | 3917 | TERM('@'); |
378cc40b | 3918 | |
c963b151 | 3919 | case '/': /* may be division, defined-or, or pattern */ |
6f33ba73 RGS |
3920 | if (PL_expect == XTERMORDORDOR && s[1] == '/') { |
3921 | s += 2; | |
3922 | AOPERATOR(DORDOR); | |
3923 | } | |
c963b151 BD |
3924 | case '?': /* may either be conditional or pattern */ |
3925 | if(PL_expect == XOPERATOR) { | |
90771dc0 | 3926 | char tmp = *s++; |
c963b151 BD |
3927 | if(tmp == '?') { |
3928 | OPERATOR('?'); | |
3929 | } | |
3930 | else { | |
3931 | tmp = *s++; | |
3932 | if(tmp == '/') { | |
3933 | /* A // operator. */ | |
3934 | AOPERATOR(DORDOR); | |
3935 | } | |
3936 | else { | |
3937 | s--; | |
3938 | Mop(OP_DIVIDE); | |
3939 | } | |
3940 | } | |
3941 | } | |
3942 | else { | |
3943 | /* Disable warning on "study /blah/" */ | |
3944 | if (PL_oldoldbufptr == PL_last_uni | |
3945 | && (*PL_last_uni != 's' || s - PL_last_uni < 5 | |
3946 | || memNE(PL_last_uni, "study", 5) | |
3947 | || isALNUM_lazy_if(PL_last_uni+5,UTF) | |
3948 | )) | |
3949 | check_uni(); | |
3950 | s = scan_pat(s,OP_MATCH); | |
3951 | TERM(sublex_start()); | |
3952 | } | |
378cc40b LW |
3953 | |
3954 | case '.': | |
51882d45 GS |
3955 | if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack |
3956 | #ifdef PERL_STRICT_CR | |
3957 | && s[1] == '\n' | |
3958 | #else | |
3959 | && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')) | |
3960 | #endif | |
3961 | && (s == PL_linestart || s[-1] == '\n') ) | |
3962 | { | |
3280af22 NIS |
3963 | PL_lex_formbrack = 0; |
3964 | PL_expect = XSTATE; | |
79072805 LW |
3965 | goto rightbracket; |
3966 | } | |
3280af22 | 3967 | if (PL_expect == XOPERATOR || !isDIGIT(s[1])) { |
90771dc0 | 3968 | char tmp = *s++; |
a687059c LW |
3969 | if (*s == tmp) { |
3970 | s++; | |
2f3197b3 LW |
3971 | if (*s == tmp) { |
3972 | s++; | |
79072805 | 3973 | yylval.ival = OPf_SPECIAL; |
2f3197b3 LW |
3974 | } |
3975 | else | |
79072805 | 3976 | yylval.ival = 0; |
378cc40b | 3977 | OPERATOR(DOTDOT); |
a687059c | 3978 | } |
3280af22 | 3979 | if (PL_expect != XOPERATOR) |
2f3197b3 | 3980 | check_uni(); |
79072805 | 3981 | Aop(OP_CONCAT); |
378cc40b LW |
3982 | } |
3983 | /* FALL THROUGH */ | |
3984 | case '0': case '1': case '2': case '3': case '4': | |
3985 | case '5': case '6': case '7': case '8': case '9': | |
b73d6f50 | 3986 | s = scan_num(s, &yylval); |
b6007c36 | 3987 | DEBUG_T( { S_printbuf(aTHX_ "### Saw number in %s\n", s); } ); |
3280af22 | 3988 | if (PL_expect == XOPERATOR) |
8990e307 | 3989 | no_op("Number",s); |
79072805 LW |
3990 | TERM(THING); |
3991 | ||
3992 | case '\'': | |
09bef843 | 3993 | s = scan_str(s,FALSE,FALSE); |
b6007c36 | 3994 | DEBUG_T( { S_printbuf(aTHX_ "### Saw string before %s\n", s); } ); |
3280af22 NIS |
3995 | if (PL_expect == XOPERATOR) { |
3996 | if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { | |
3997 | PL_expect = XTERM; | |
c445ea15 | 3998 | deprecate_old(commaless_variable_list); |
bbf60fe6 | 3999 | return REPORT(','); /* grandfather non-comma-format format */ |
a0d0e21e | 4000 | } |
463ee0b2 | 4001 | else |
8990e307 | 4002 | no_op("String",s); |
463ee0b2 | 4003 | } |
79072805 | 4004 | if (!s) |
85e6fe83 | 4005 | missingterm((char*)0); |
79072805 LW |
4006 | yylval.ival = OP_CONST; |
4007 | TERM(sublex_start()); | |
4008 | ||
4009 | case '"': | |
09bef843 | 4010 | s = scan_str(s,FALSE,FALSE); |
b6007c36 | 4011 | DEBUG_T( { S_printbuf(aTHX_ "### Saw string before %s\n", s); } ); |
3280af22 NIS |
4012 | if (PL_expect == XOPERATOR) { |
4013 | if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { | |
4014 | PL_expect = XTERM; | |
c445ea15 | 4015 | deprecate_old(commaless_variable_list); |
bbf60fe6 | 4016 | return REPORT(','); /* grandfather non-comma-format format */ |
a0d0e21e | 4017 | } |
463ee0b2 | 4018 | else |
8990e307 | 4019 | no_op("String",s); |
463ee0b2 | 4020 | } |
79072805 | 4021 | if (!s) |
85e6fe83 | 4022 | missingterm((char*)0); |
4633a7c4 | 4023 | yylval.ival = OP_CONST; |
cfd0369c NC |
4024 | /* FIXME. I think that this can be const if char *d is replaced by |
4025 | more localised variables. */ | |
3280af22 | 4026 | for (d = SvPV(PL_lex_stuff, len); len; len--, d++) { |
63cd0674 | 4027 | if (*d == '$' || *d == '@' || *d == '\\' || !UTF8_IS_INVARIANT((U8)*d)) { |
4633a7c4 LW |
4028 | yylval.ival = OP_STRINGIFY; |
4029 | break; | |
4030 | } | |
4031 | } | |
79072805 LW |
4032 | TERM(sublex_start()); |
4033 | ||
4034 | case '`': | |
09bef843 | 4035 | s = scan_str(s,FALSE,FALSE); |
b6007c36 | 4036 | DEBUG_T( { S_printbuf(aTHX_ "### Saw backtick string before %s\n", s); } ); |
3280af22 | 4037 | if (PL_expect == XOPERATOR) |
8990e307 | 4038 | no_op("Backticks",s); |
79072805 | 4039 | if (!s) |
85e6fe83 | 4040 | missingterm((char*)0); |
79072805 LW |
4041 | yylval.ival = OP_BACKTICK; |
4042 | set_csh(); | |
4043 | TERM(sublex_start()); | |
4044 | ||
4045 | case '\\': | |
4046 | s++; | |
041457d9 | 4047 | if (PL_lex_inwhat && isDIGIT(*s) && ckWARN(WARN_SYNTAX)) |
9014280d | 4048 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX),"Can't use \\%c to mean $%c in expression", |
599cee73 | 4049 | *s, *s); |
3280af22 | 4050 | if (PL_expect == XOPERATOR) |
8990e307 | 4051 | no_op("Backslash",s); |
79072805 LW |
4052 | OPERATOR(REFGEN); |
4053 | ||
a7cb1f99 | 4054 | case 'v': |
e526c9e6 | 4055 | if (isDIGIT(s[1]) && PL_expect != XOPERATOR) { |
f54cb97a | 4056 | char *start = s + 2; |
dd629d5b | 4057 | while (isDIGIT(*start) || *start == '_') |
a7cb1f99 GS |
4058 | start++; |
4059 | if (*start == '.' && isDIGIT(start[1])) { | |
b73d6f50 | 4060 | s = scan_num(s, &yylval); |
a7cb1f99 GS |
4061 | TERM(THING); |
4062 | } | |
e526c9e6 | 4063 | /* avoid v123abc() or $h{v1}, allow C<print v10;> */ |
6f33ba73 RGS |
4064 | else if (!isALPHA(*start) && (PL_expect == XTERM |
4065 | || PL_expect == XREF || PL_expect == XSTATE | |
4066 | || PL_expect == XTERMORDORDOR)) { | |
f54cb97a | 4067 | const char c = *start; |
e526c9e6 GS |
4068 | GV *gv; |
4069 | *start = '\0'; | |
f776e3cd | 4070 | gv = gv_fetchpv(s, 0, SVt_PVCV); |
e526c9e6 GS |
4071 | *start = c; |
4072 | if (!gv) { | |
b73d6f50 | 4073 | s = scan_num(s, &yylval); |
e526c9e6 GS |
4074 | TERM(THING); |
4075 | } | |
4076 | } | |
a7cb1f99 GS |
4077 | } |
4078 | goto keylookup; | |
79072805 | 4079 | case 'x': |
3280af22 | 4080 | if (isDIGIT(s[1]) && PL_expect == XOPERATOR) { |
79072805 LW |
4081 | s++; |
4082 | Mop(OP_REPEAT); | |
2f3197b3 | 4083 | } |
79072805 LW |
4084 | goto keylookup; |
4085 | ||
378cc40b | 4086 | case '_': |
79072805 LW |
4087 | case 'a': case 'A': |
4088 | case 'b': case 'B': | |
4089 | case 'c': case 'C': | |
4090 | case 'd': case 'D': | |
4091 | case 'e': case 'E': | |
4092 | case 'f': case 'F': | |
4093 | case 'g': case 'G': | |
4094 | case 'h': case 'H': | |
4095 | case 'i': case 'I': | |
4096 | case 'j': case 'J': | |
4097 | case 'k': case 'K': | |
4098 | case 'l': case 'L': | |
4099 | case 'm': case 'M': | |
4100 | case 'n': case 'N': | |
4101 | case 'o': case 'O': | |
4102 | case 'p': case 'P': | |
4103 | case 'q': case 'Q': | |
4104 | case 'r': case 'R': | |
4105 | case 's': case 'S': | |
4106 | case 't': case 'T': | |
4107 | case 'u': case 'U': | |
a7cb1f99 | 4108 | case 'V': |
79072805 LW |
4109 | case 'w': case 'W': |
4110 | case 'X': | |
4111 | case 'y': case 'Y': | |
4112 | case 'z': case 'Z': | |
4113 | ||
49dc05e3 | 4114 | keylookup: { |
90771dc0 | 4115 | I32 tmp; |
0bfa2a8a | 4116 | I32 orig_keyword = 0; |
cbbf8932 AL |
4117 | GV *gv = NULL; |
4118 | GV **gvp = NULL; | |
49dc05e3 | 4119 | |
3280af22 NIS |
4120 | PL_bufptr = s; |
4121 | s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &len); | |
8ebc5c01 | 4122 | |
4123 | /* Some keywords can be followed by any delimiter, including ':' */ | |
155aba94 GS |
4124 | tmp = ((len == 1 && strchr("msyq", PL_tokenbuf[0])) || |
4125 | (len == 2 && ((PL_tokenbuf[0] == 't' && PL_tokenbuf[1] == 'r') || | |
4126 | (PL_tokenbuf[0] == 'q' && | |
4127 | strchr("qwxr", PL_tokenbuf[1]))))); | |
8ebc5c01 | 4128 | |
4129 | /* x::* is just a word, unless x is "CORE" */ | |
3280af22 | 4130 | if (!tmp && *s == ':' && s[1] == ':' && strNE(PL_tokenbuf, "CORE")) |
4633a7c4 LW |
4131 | goto just_a_word; |
4132 | ||
3643fb5f | 4133 | d = s; |
3280af22 | 4134 | while (d < PL_bufend && isSPACE(*d)) |
3643fb5f CS |
4135 | d++; /* no comments skipped here, or s### is misparsed */ |
4136 | ||
4137 | /* Is this a label? */ | |
3280af22 NIS |
4138 | if (!tmp && PL_expect == XSTATE |
4139 | && d < PL_bufend && *d == ':' && *(d + 1) != ':') { | |
8ebc5c01 | 4140 | s = d + 1; |
3280af22 | 4141 | yylval.pval = savepv(PL_tokenbuf); |
8ebc5c01 | 4142 | CLINE; |
4143 | TOKEN(LABEL); | |
3643fb5f CS |
4144 | } |
4145 | ||
4146 | /* Check for keywords */ | |
3280af22 | 4147 | tmp = keyword(PL_tokenbuf, len); |
748a9306 LW |
4148 | |
4149 | /* Is this a word before a => operator? */ | |
1c3923b3 | 4150 | if (*d == '=' && d[1] == '>') { |
748a9306 | 4151 | CLINE; |
d0a148a6 NC |
4152 | yylval.opval |
4153 | = (OP*)newSVOP(OP_CONST, 0, | |
4154 | S_newSV_maybe_utf8(aTHX_ PL_tokenbuf, len)); | |
748a9306 LW |
4155 | yylval.opval->op_private = OPpCONST_BARE; |
4156 | TERM(WORD); | |
4157 | } | |
4158 | ||
a0d0e21e | 4159 | if (tmp < 0) { /* second-class keyword? */ |
cbbf8932 AL |
4160 | GV *ogv = NULL; /* override (winner) */ |
4161 | GV *hgv = NULL; /* hidden (loser) */ | |
3280af22 | 4162 | if (PL_expect != XOPERATOR && (*s != ':' || s[1] != ':')) { |
56f7f34b | 4163 | CV *cv; |
f776e3cd | 4164 | if ((gv = gv_fetchpv(PL_tokenbuf, 0, SVt_PVCV)) && |
56f7f34b CS |
4165 | (cv = GvCVu(gv))) |
4166 | { | |
4167 | if (GvIMPORTED_CV(gv)) | |
4168 | ogv = gv; | |
4169 | else if (! CvMETHOD(cv)) | |
4170 | hgv = gv; | |
4171 | } | |
4172 | if (!ogv && | |
3280af22 NIS |
4173 | (gvp = (GV**)hv_fetch(PL_globalstash,PL_tokenbuf,len,FALSE)) && |
4174 | (gv = *gvp) != (GV*)&PL_sv_undef && | |
56f7f34b CS |
4175 | GvCVu(gv) && GvIMPORTED_CV(gv)) |
4176 | { | |
4177 | ogv = gv; | |
4178 | } | |
4179 | } | |
4180 | if (ogv) { | |
30fe34ed | 4181 | orig_keyword = tmp; |
56f7f34b | 4182 | tmp = 0; /* overridden by import or by GLOBAL */ |
6e7b2336 GS |
4183 | } |
4184 | else if (gv && !gvp | |
4185 | && -tmp==KEY_lock /* XXX generalizable kludge */ | |
d0456cad | 4186 | && GvCVu(gv) |
3280af22 | 4187 | && !hv_fetch(GvHVn(PL_incgv), "Thread.pm", 9, FALSE)) |
6e7b2336 GS |
4188 | { |
4189 | tmp = 0; /* any sub overrides "weak" keyword */ | |
a0d0e21e | 4190 | } |
56f7f34b CS |
4191 | else { /* no override */ |
4192 | tmp = -tmp; | |
ac206dc8 | 4193 | if (tmp == KEY_dump && ckWARN(WARN_MISC)) { |
9014280d | 4194 | Perl_warner(aTHX_ packWARN(WARN_MISC), |
ac206dc8 RGS |
4195 | "dump() better written as CORE::dump()"); |
4196 | } | |
56f7f34b CS |
4197 | gv = Nullgv; |
4198 | gvp = 0; | |
041457d9 DM |
4199 | if (hgv && tmp != KEY_x && tmp != KEY_CORE |
4200 | && ckWARN(WARN_AMBIGUOUS)) /* never ambiguous */ | |
9014280d | 4201 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
599cee73 | 4202 | "Ambiguous call resolved as CORE::%s(), %s", |
2f3ca594 | 4203 | GvENAME(hgv), "qualify as such or use &"); |
49dc05e3 | 4204 | } |
a0d0e21e LW |
4205 | } |
4206 | ||
4207 | reserved_word: | |
4208 | switch (tmp) { | |
79072805 LW |
4209 | |
4210 | default: /* not a keyword */ | |
0bfa2a8a NC |
4211 | /* Trade off - by using this evil construction we can pull the |
4212 | variable gv into the block labelled keylookup. If not, then | |
4213 | we have to give it function scope so that the goto from the | |
4214 | earlier ':' case doesn't bypass the initialisation. */ | |
4215 | if (0) { | |
4216 | just_a_word_zero_gv: | |
4217 | gv = NULL; | |
4218 | gvp = NULL; | |
4219 | } | |
93a17b20 | 4220 | just_a_word: { |
96e4d5b1 | 4221 | SV *sv; |
ce29ac45 | 4222 | int pkgname = 0; |
f54cb97a | 4223 | const char lastchar = (PL_bufptr == PL_oldoldbufptr ? 0 : PL_bufptr[-1]); |
5069cc75 | 4224 | CV *cv; |
8990e307 LW |
4225 | |
4226 | /* Get the rest if it looks like a package qualifier */ | |
4227 | ||
155aba94 | 4228 | if (*s == '\'' || (*s == ':' && s[1] == ':')) { |
c3e0f903 | 4229 | STRLEN morelen; |
3280af22 | 4230 | s = scan_word(s, PL_tokenbuf + len, sizeof PL_tokenbuf - len, |
c3e0f903 GS |
4231 | TRUE, &morelen); |
4232 | if (!morelen) | |
cea2e8a9 | 4233 | Perl_croak(aTHX_ "Bad name after %s%s", PL_tokenbuf, |
ec2ab091 | 4234 | *s == '\'' ? "'" : "::"); |
c3e0f903 | 4235 | len += morelen; |
ce29ac45 | 4236 | pkgname = 1; |
a0d0e21e | 4237 | } |
8990e307 | 4238 | |
3280af22 NIS |
4239 | if (PL_expect == XOPERATOR) { |
4240 | if (PL_bufptr == PL_linestart) { | |
57843af0 | 4241 | CopLINE_dec(PL_curcop); |
9014280d | 4242 | Perl_warner(aTHX_ packWARN(WARN_SEMICOLON), PL_warn_nosemi); |
57843af0 | 4243 | CopLINE_inc(PL_curcop); |
463ee0b2 LW |
4244 | } |
4245 | else | |
54310121 | 4246 | no_op("Bareword",s); |
463ee0b2 | 4247 | } |
8990e307 | 4248 | |
c3e0f903 GS |
4249 | /* Look for a subroutine with this name in current package, |
4250 | unless name is "Foo::", in which case Foo is a bearword | |
4251 | (and a package name). */ | |
4252 | ||
4253 | if (len > 2 && | |
3280af22 | 4254 | PL_tokenbuf[len - 2] == ':' && PL_tokenbuf[len - 1] == ':') |
c3e0f903 | 4255 | { |
f776e3cd NC |
4256 | if (ckWARN(WARN_BAREWORD) |
4257 | && ! gv_fetchpv(PL_tokenbuf, 0, SVt_PVHV)) | |
9014280d | 4258 | Perl_warner(aTHX_ packWARN(WARN_BAREWORD), |
599cee73 | 4259 | "Bareword \"%s\" refers to nonexistent package", |
3280af22 | 4260 | PL_tokenbuf); |
c3e0f903 | 4261 | len -= 2; |
3280af22 | 4262 | PL_tokenbuf[len] = '\0'; |
c3e0f903 GS |
4263 | gv = Nullgv; |
4264 | gvp = 0; | |
4265 | } | |
4266 | else { | |
4267 | len = 0; | |
62d55b22 NC |
4268 | if (!gv) { |
4269 | /* Mustn't actually add anything to a symbol table. | |
4270 | But also don't want to "initialise" any placeholder | |
4271 | constants that might already be there into full | |
4272 | blown PVGVs with attached PVCV. */ | |
4273 | gv = gv_fetchpv(PL_tokenbuf, GV_NOADD_NOINIT, | |
4274 | SVt_PVCV); | |
4275 | } | |
c3e0f903 GS |
4276 | } |
4277 | ||
4278 | /* if we saw a global override before, get the right name */ | |
8990e307 | 4279 | |
49dc05e3 | 4280 | if (gvp) { |
396482e1 | 4281 | sv = newSVpvs("CORE::GLOBAL::"); |
3280af22 | 4282 | sv_catpv(sv,PL_tokenbuf); |
49dc05e3 | 4283 | } |
8a7a129d NC |
4284 | else { |
4285 | /* If len is 0, newSVpv does strlen(), which is correct. | |
4286 | If len is non-zero, then it will be the true length, | |
4287 | and so the scalar will be created correctly. */ | |
4288 | sv = newSVpv(PL_tokenbuf,len); | |
4289 | } | |
8990e307 | 4290 | |
a0d0e21e LW |
4291 | /* Presume this is going to be a bareword of some sort. */ |
4292 | ||
4293 | CLINE; | |
49dc05e3 | 4294 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv); |
a0d0e21e | 4295 | yylval.opval->op_private = OPpCONST_BARE; |
8f8cf39c JH |
4296 | /* UTF-8 package name? */ |
4297 | if (UTF && !IN_BYTES && | |
95a20fc0 | 4298 | is_utf8_string((U8*)SvPVX_const(sv), SvCUR(sv))) |
8f8cf39c | 4299 | SvUTF8_on(sv); |
a0d0e21e | 4300 | |
c3e0f903 GS |
4301 | /* And if "Foo::", then that's what it certainly is. */ |
4302 | ||
4303 | if (len) | |
4304 | goto safe_bareword; | |
4305 | ||
5069cc75 NC |
4306 | /* Do the explicit type check so that we don't need to force |
4307 | the initialisation of the symbol table to have a real GV. | |
4308 | Beware - gv may not really be a PVGV, cv may not really be | |
4309 | a PVCV, (because of the space optimisations that gv_init | |
4310 | understands) But they're true if for this symbol there is | |
4311 | respectively a typeglob and a subroutine. | |
4312 | */ | |
4313 | cv = gv ? ((SvTYPE(gv) == SVt_PVGV) | |
4314 | /* Real typeglob, so get the real subroutine: */ | |
4315 | ? GvCVu(gv) | |
4316 | /* A proxy for a subroutine in this package? */ | |
4317 | : SvOK(gv) ? (CV *) gv : NULL) | |
4318 | : NULL; | |
4319 | ||
8990e307 LW |
4320 | /* See if it's the indirect object for a list operator. */ |
4321 | ||
3280af22 NIS |
4322 | if (PL_oldoldbufptr && |
4323 | PL_oldoldbufptr < PL_bufptr && | |
65cec589 GS |
4324 | (PL_oldoldbufptr == PL_last_lop |
4325 | || PL_oldoldbufptr == PL_last_uni) && | |
a0d0e21e | 4326 | /* NO SKIPSPACE BEFORE HERE! */ |
a9ef352a GS |
4327 | (PL_expect == XREF || |
4328 | ((PL_opargs[PL_last_lop_op] >> OASHIFT)& 7) == OA_FILEREF)) | |
a0d0e21e | 4329 | { |
748a9306 LW |
4330 | bool immediate_paren = *s == '('; |
4331 | ||
a0d0e21e LW |
4332 | /* (Now we can afford to cross potential line boundary.) */ |
4333 | s = skipspace(s); | |
4334 | ||
4335 | /* Two barewords in a row may indicate method call. */ | |
4336 | ||
62d55b22 NC |
4337 | if ((isIDFIRST_lazy_if(s,UTF) || *s == '$') && |
4338 | (tmp = intuit_method(s, gv, cv))) | |
bbf60fe6 | 4339 | return REPORT(tmp); |
a0d0e21e LW |
4340 | |
4341 | /* If not a declared subroutine, it's an indirect object. */ | |
4342 | /* (But it's an indir obj regardless for sort.) */ | |
7294df96 | 4343 | /* Also, if "_" follows a filetest operator, it's a bareword */ |
a0d0e21e | 4344 | |
7294df96 RGS |
4345 | if ( |
4346 | ( !immediate_paren && (PL_last_lop_op == OP_SORT || | |
5069cc75 | 4347 | ((!gv || !cv) && |
a9ef352a | 4348 | (PL_last_lop_op != OP_MAPSTART && |
f0670693 | 4349 | PL_last_lop_op != OP_GREPSTART)))) |
7294df96 RGS |
4350 | || (PL_tokenbuf[0] == '_' && PL_tokenbuf[1] == '\0' |
4351 | && ((PL_opargs[PL_last_lop_op] & OA_CLASS_MASK) == OA_FILESTATOP)) | |
4352 | ) | |
a9ef352a | 4353 | { |
3280af22 | 4354 | PL_expect = (PL_last_lop == PL_oldoldbufptr) ? XTERM : XOPERATOR; |
748a9306 | 4355 | goto bareword; |
93a17b20 LW |
4356 | } |
4357 | } | |
8990e307 | 4358 | |
3280af22 | 4359 | PL_expect = XOPERATOR; |
8990e307 | 4360 | s = skipspace(s); |
1c3923b3 GS |
4361 | |
4362 | /* Is this a word before a => operator? */ | |
ce29ac45 | 4363 | if (*s == '=' && s[1] == '>' && !pkgname) { |
1c3923b3 GS |
4364 | CLINE; |
4365 | sv_setpv(((SVOP*)yylval.opval)->op_sv, PL_tokenbuf); | |
0064a8a9 | 4366 | if (UTF && !IN_BYTES && is_utf8_string((U8*)PL_tokenbuf, len)) |
7948272d | 4367 | SvUTF8_on(((SVOP*)yylval.opval)->op_sv); |
1c3923b3 GS |
4368 | TERM(WORD); |
4369 | } | |
4370 | ||
4371 | /* If followed by a paren, it's certainly a subroutine. */ | |
93a17b20 | 4372 | if (*s == '(') { |
79072805 | 4373 | CLINE; |
5069cc75 | 4374 | if (cv) { |
bf4acbe4 | 4375 | for (d = s + 1; SPACE_OR_TAB(*d); d++) ; |
62d55b22 | 4376 | if (*d == ')' && (sv = gv_const_sv(gv))) { |
96e4d5b1 | 4377 | s = d + 1; |
4378 | goto its_constant; | |
4379 | } | |
4380 | } | |
3280af22 NIS |
4381 | PL_nextval[PL_nexttoke].opval = yylval.opval; |
4382 | PL_expect = XOPERATOR; | |
93a17b20 | 4383 | force_next(WORD); |
c07a80fd | 4384 | yylval.ival = 0; |
463ee0b2 | 4385 | TOKEN('&'); |
79072805 | 4386 | } |
93a17b20 | 4387 | |
a0d0e21e | 4388 | /* If followed by var or block, call it a method (unless sub) */ |
8990e307 | 4389 | |
62d55b22 | 4390 | if ((*s == '$' || *s == '{') && (!gv || !cv)) { |
3280af22 NIS |
4391 | PL_last_lop = PL_oldbufptr; |
4392 | PL_last_lop_op = OP_METHOD; | |
93a17b20 | 4393 | PREBLOCK(METHOD); |
463ee0b2 LW |
4394 | } |
4395 | ||
8990e307 LW |
4396 | /* If followed by a bareword, see if it looks like indir obj. */ |
4397 | ||
30fe34ed RGS |
4398 | if (!orig_keyword |
4399 | && (isIDFIRST_lazy_if(s,UTF) || *s == '$') | |
62d55b22 | 4400 | && (tmp = intuit_method(s, gv, cv))) |
bbf60fe6 | 4401 | return REPORT(tmp); |
93a17b20 | 4402 | |
8990e307 LW |
4403 | /* Not a method, so call it a subroutine (if defined) */ |
4404 | ||
5069cc75 | 4405 | if (cv) { |
0453d815 | 4406 | if (lastchar == '-' && ckWARN_d(WARN_AMBIGUOUS)) |
9014280d | 4407 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
0453d815 | 4408 | "Ambiguous use of -%s resolved as -&%s()", |
3280af22 | 4409 | PL_tokenbuf, PL_tokenbuf); |
89bfa8cd | 4410 | /* Check for a constant sub */ |
62d55b22 | 4411 | if ((sv = gv_const_sv(gv))) { |
96e4d5b1 | 4412 | its_constant: |
4413 | SvREFCNT_dec(((SVOP*)yylval.opval)->op_sv); | |
4414 | ((SVOP*)yylval.opval)->op_sv = SvREFCNT_inc(sv); | |
4415 | yylval.opval->op_private = 0; | |
4416 | TOKEN(WORD); | |
89bfa8cd | 4417 | } |
4418 | ||
a5f75d66 | 4419 | /* Resolve to GV now. */ |
62d55b22 NC |
4420 | if (SvTYPE(gv) != SVt_PVGV) { |
4421 | gv = gv_fetchpv(PL_tokenbuf, 0, SVt_PVCV); | |
4422 | assert (SvTYPE(gv) == SVt_PVGV); | |
4423 | /* cv must have been some sort of placeholder, so | |
4424 | now needs replacing with a real code reference. */ | |
4425 | cv = GvCV(gv); | |
4426 | } | |
4427 | ||
a5f75d66 AD |
4428 | op_free(yylval.opval); |
4429 | yylval.opval = newCVREF(0, newGVOP(OP_GV, 0, gv)); | |
9675f7ac | 4430 | yylval.opval->op_private |= OPpENTERSUB_NOPAREN; |
7a52d87a | 4431 | PL_last_lop = PL_oldbufptr; |
bf848113 | 4432 | PL_last_lop_op = OP_ENTERSUB; |
4633a7c4 LW |
4433 | /* Is there a prototype? */ |
4434 | if (SvPOK(cv)) { | |
4435 | STRLEN len; | |
cfd0369c | 4436 | const char *proto = SvPV_const((SV*)cv, len); |
4633a7c4 LW |
4437 | if (!len) |
4438 | TERM(FUNC0SUB); | |
770526c1 | 4439 | if (*proto == '$' && proto[1] == '\0') |
4633a7c4 | 4440 | OPERATOR(UNIOPSUB); |
0f5d0394 AE |
4441 | while (*proto == ';') |
4442 | proto++; | |
7a52d87a | 4443 | if (*proto == '&' && *s == '{') { |
bfed75c6 | 4444 | sv_setpv(PL_subname, PL_curstash ? |
c99da370 | 4445 | "__ANON__" : "__ANON__::__ANON__"); |
4633a7c4 LW |
4446 | PREBLOCK(LSTOPSUB); |
4447 | } | |
a9ef352a | 4448 | } |
3280af22 NIS |
4449 | PL_nextval[PL_nexttoke].opval = yylval.opval; |
4450 | PL_expect = XTERM; | |
8990e307 LW |
4451 | force_next(WORD); |
4452 | TOKEN(NOAMP); | |
4453 | } | |
748a9306 | 4454 | |
8990e307 LW |
4455 | /* Call it a bare word */ |
4456 | ||
5603f27d GS |
4457 | if (PL_hints & HINT_STRICT_SUBS) |
4458 | yylval.opval->op_private |= OPpCONST_STRICT; | |
4459 | else { | |
4460 | bareword: | |
041457d9 DM |
4461 | if (lastchar != '-') { |
4462 | if (ckWARN(WARN_RESERVED)) { | |
5603f27d | 4463 | for (d = PL_tokenbuf; *d && isLOWER(*d); d++) ; |
238ae712 | 4464 | if (!*d && !gv_stashpv(PL_tokenbuf,FALSE)) |
9014280d | 4465 | Perl_warner(aTHX_ packWARN(WARN_RESERVED), PL_warn_reserved, |
5603f27d GS |
4466 | PL_tokenbuf); |
4467 | } | |
748a9306 LW |
4468 | } |
4469 | } | |
c3e0f903 GS |
4470 | |
4471 | safe_bareword: | |
3792a11b NC |
4472 | if ((lastchar == '*' || lastchar == '%' || lastchar == '&') |
4473 | && ckWARN_d(WARN_AMBIGUOUS)) { | |
9014280d | 4474 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
0453d815 | 4475 | "Operator or semicolon missing before %c%s", |
3280af22 | 4476 | lastchar, PL_tokenbuf); |
9014280d | 4477 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
0453d815 | 4478 | "Ambiguous use of %c resolved as operator %c", |
748a9306 LW |
4479 | lastchar, lastchar); |
4480 | } | |
93a17b20 | 4481 | TOKEN(WORD); |
79072805 | 4482 | } |
79072805 | 4483 | |
68dc0745 | 4484 | case KEY___FILE__: |
46fc3d4c | 4485 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, |
ed094faf | 4486 | newSVpv(CopFILE(PL_curcop),0)); |
46fc3d4c | 4487 | TERM(THING); |
4488 | ||
79072805 | 4489 | case KEY___LINE__: |
cf2093f6 | 4490 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, |
57843af0 | 4491 | Perl_newSVpvf(aTHX_ "%"IVdf, (IV)CopLINE(PL_curcop))); |
79072805 | 4492 | TERM(THING); |
68dc0745 | 4493 | |
4494 | case KEY___PACKAGE__: | |
4495 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, | |
3280af22 | 4496 | (PL_curstash |
5aaec2b4 | 4497 | ? newSVhek(HvNAME_HEK(PL_curstash)) |
3280af22 | 4498 | : &PL_sv_undef)); |
79072805 | 4499 | TERM(THING); |
79072805 | 4500 | |
e50aee73 | 4501 | case KEY___DATA__: |
79072805 LW |
4502 | case KEY___END__: { |
4503 | GV *gv; | |
3280af22 | 4504 | if (PL_rsfp && (!PL_in_eval || PL_tokenbuf[2] == 'D')) { |
bfed75c6 | 4505 | const char *pname = "main"; |
3280af22 | 4506 | if (PL_tokenbuf[2] == 'D') |
bfcb3514 | 4507 | pname = HvNAME_get(PL_curstash ? PL_curstash : PL_defstash); |
f776e3cd NC |
4508 | gv = gv_fetchpv(Perl_form(aTHX_ "%s::DATA", pname), GV_ADD, |
4509 | SVt_PVIO); | |
a5f75d66 | 4510 | GvMULTI_on(gv); |
79072805 | 4511 | if (!GvIO(gv)) |
a0d0e21e | 4512 | GvIOp(gv) = newIO(); |
3280af22 | 4513 | IoIFP(GvIOp(gv)) = PL_rsfp; |
a0d0e21e LW |
4514 | #if defined(HAS_FCNTL) && defined(F_SETFD) |
4515 | { | |
f54cb97a | 4516 | const int fd = PerlIO_fileno(PL_rsfp); |
a0d0e21e LW |
4517 | fcntl(fd,F_SETFD,fd >= 3); |
4518 | } | |
79072805 | 4519 | #endif |
fd049845 | 4520 | /* Mark this internal pseudo-handle as clean */ |
4521 | IoFLAGS(GvIOp(gv)) |= IOf_UNTAINT; | |
3280af22 | 4522 | if (PL_preprocess) |
50952442 | 4523 | IoTYPE(GvIOp(gv)) = IoTYPE_PIPE; |
3280af22 | 4524 | else if ((PerlIO*)PL_rsfp == PerlIO_stdin()) |
50952442 | 4525 | IoTYPE(GvIOp(gv)) = IoTYPE_STD; |
79072805 | 4526 | else |
50952442 | 4527 | IoTYPE(GvIOp(gv)) = IoTYPE_RDONLY; |
c39cd008 GS |
4528 | #if defined(WIN32) && !defined(PERL_TEXTMODE_SCRIPTS) |
4529 | /* if the script was opened in binmode, we need to revert | |
53129d29 | 4530 | * it to text mode for compatibility; but only iff it has CRs |
c39cd008 | 4531 | * XXX this is a questionable hack at best. */ |
53129d29 GS |
4532 | if (PL_bufend-PL_bufptr > 2 |
4533 | && PL_bufend[-1] == '\n' && PL_bufend[-2] == '\r') | |
c39cd008 GS |
4534 | { |
4535 | Off_t loc = 0; | |
50952442 | 4536 | if (IoTYPE(GvIOp(gv)) == IoTYPE_RDONLY) { |
c39cd008 GS |
4537 | loc = PerlIO_tell(PL_rsfp); |
4538 | (void)PerlIO_seek(PL_rsfp, 0L, 0); | |
4539 | } | |
2986a63f JH |
4540 | #ifdef NETWARE |
4541 | if (PerlLIO_setmode(PL_rsfp, O_TEXT) != -1) { | |
4542 | #else | |
c39cd008 | 4543 | if (PerlLIO_setmode(PerlIO_fileno(PL_rsfp), O_TEXT) != -1) { |
2986a63f | 4544 | #endif /* NETWARE */ |
1143fce0 JH |
4545 | #ifdef PERLIO_IS_STDIO /* really? */ |
4546 | # if defined(__BORLANDC__) | |
cb359b41 JH |
4547 | /* XXX see note in do_binmode() */ |
4548 | ((FILE*)PL_rsfp)->flags &= ~_F_BIN; | |
1143fce0 JH |
4549 | # endif |
4550 | #endif | |
c39cd008 GS |
4551 | if (loc > 0) |
4552 | PerlIO_seek(PL_rsfp, loc, 0); | |
4553 | } | |
4554 | } | |
4555 | #endif | |
7948272d | 4556 | #ifdef PERLIO_LAYERS |
52d2e0f4 JH |
4557 | if (!IN_BYTES) { |
4558 | if (UTF) | |
4559 | PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8"); | |
4560 | else if (PL_encoding) { | |
4561 | SV *name; | |
4562 | dSP; | |
4563 | ENTER; | |
4564 | SAVETMPS; | |
4565 | PUSHMARK(sp); | |
4566 | EXTEND(SP, 1); | |
4567 | XPUSHs(PL_encoding); | |
4568 | PUTBACK; | |
4569 | call_method("name", G_SCALAR); | |
4570 | SPAGAIN; | |
4571 | name = POPs; | |
4572 | PUTBACK; | |
bfed75c6 | 4573 | PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, |
52d2e0f4 JH |
4574 | Perl_form(aTHX_ ":encoding(%"SVf")", |
4575 | name)); | |
4576 | FREETMPS; | |
4577 | LEAVE; | |
4578 | } | |
4579 | } | |
7948272d | 4580 | #endif |
3280af22 | 4581 | PL_rsfp = Nullfp; |
79072805 LW |
4582 | } |
4583 | goto fake_eof; | |
e929a76b | 4584 | } |
de3bb511 | 4585 | |
8990e307 | 4586 | case KEY_AUTOLOAD: |
ed6116ce | 4587 | case KEY_DESTROY: |
79072805 | 4588 | case KEY_BEGIN: |
7d30b5c4 | 4589 | case KEY_CHECK: |
7d07dbc2 | 4590 | case KEY_INIT: |
7d30b5c4 | 4591 | case KEY_END: |
3280af22 NIS |
4592 | if (PL_expect == XSTATE) { |
4593 | s = PL_bufptr; | |
93a17b20 | 4594 | goto really_sub; |
79072805 LW |
4595 | } |
4596 | goto just_a_word; | |
4597 | ||
a0d0e21e LW |
4598 | case KEY_CORE: |
4599 | if (*s == ':' && s[1] == ':') { | |
4600 | s += 2; | |
748a9306 | 4601 | d = s; |
3280af22 | 4602 | s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &len); |
6798c92b GS |
4603 | if (!(tmp = keyword(PL_tokenbuf, len))) |
4604 | Perl_croak(aTHX_ "CORE::%s is not a keyword", PL_tokenbuf); | |
a0d0e21e LW |
4605 | if (tmp < 0) |
4606 | tmp = -tmp; | |
850e8516 | 4607 | else if (tmp == KEY_require || tmp == KEY_do) |
a72a1c8b | 4608 | /* that's a way to remember we saw "CORE::" */ |
850e8516 | 4609 | orig_keyword = tmp; |
a0d0e21e LW |
4610 | goto reserved_word; |
4611 | } | |
4612 | goto just_a_word; | |
4613 | ||
463ee0b2 LW |
4614 | case KEY_abs: |
4615 | UNI(OP_ABS); | |
4616 | ||
79072805 LW |
4617 | case KEY_alarm: |
4618 | UNI(OP_ALARM); | |
4619 | ||
4620 | case KEY_accept: | |
a0d0e21e | 4621 | LOP(OP_ACCEPT,XTERM); |
79072805 | 4622 | |
463ee0b2 LW |
4623 | case KEY_and: |
4624 | OPERATOR(ANDOP); | |
4625 | ||
79072805 | 4626 | case KEY_atan2: |
a0d0e21e | 4627 | LOP(OP_ATAN2,XTERM); |
85e6fe83 | 4628 | |
79072805 | 4629 | case KEY_bind: |
a0d0e21e | 4630 | LOP(OP_BIND,XTERM); |
79072805 LW |
4631 | |
4632 | case KEY_binmode: | |
1c1fc3ea | 4633 | LOP(OP_BINMODE,XTERM); |
79072805 LW |
4634 | |
4635 | case KEY_bless: | |
a0d0e21e | 4636 | LOP(OP_BLESS,XTERM); |
79072805 | 4637 | |
0d863452 RH |
4638 | case KEY_break: |
4639 | FUN0(OP_BREAK); | |
4640 | ||
79072805 LW |
4641 | case KEY_chop: |
4642 | UNI(OP_CHOP); | |
4643 | ||
4644 | case KEY_continue: | |
0d863452 RH |
4645 | /* When 'use switch' is in effect, continue has a dual |
4646 | life as a control operator. */ | |
4647 | { | |
ef89dcc3 | 4648 | if (!FEATURE_IS_ENABLED("switch")) |
0d863452 RH |
4649 | PREBLOCK(CONTINUE); |
4650 | else { | |
4651 | /* We have to disambiguate the two senses of | |
4652 | "continue". If the next token is a '{' then | |
4653 | treat it as the start of a continue block; | |
4654 | otherwise treat it as a control operator. | |
4655 | */ | |
4656 | s = skipspace(s); | |
4657 | if (*s == '{') | |
79072805 | 4658 | PREBLOCK(CONTINUE); |
0d863452 RH |
4659 | else |
4660 | FUN0(OP_CONTINUE); | |
4661 | } | |
4662 | } | |
79072805 LW |
4663 | |
4664 | case KEY_chdir: | |
f776e3cd | 4665 | (void)gv_fetchpv("ENV", GV_ADD, SVt_PVHV); /* may use HOME */ |
79072805 LW |
4666 | UNI(OP_CHDIR); |
4667 | ||
4668 | case KEY_close: | |
4669 | UNI(OP_CLOSE); | |
4670 | ||
4671 | case KEY_closedir: | |
4672 | UNI(OP_CLOSEDIR); | |
4673 | ||
4674 | case KEY_cmp: | |
4675 | Eop(OP_SCMP); | |
4676 | ||
4677 | case KEY_caller: | |
4678 | UNI(OP_CALLER); | |
4679 | ||
4680 | case KEY_crypt: | |
4681 | #ifdef FCRYPT | |
f4c556ac GS |
4682 | if (!PL_cryptseen) { |
4683 | PL_cryptseen = TRUE; | |
de3bb511 | 4684 | init_des(); |
f4c556ac | 4685 | } |
a687059c | 4686 | #endif |
a0d0e21e | 4687 | LOP(OP_CRYPT,XTERM); |
79072805 LW |
4688 | |
4689 | case KEY_chmod: | |
a0d0e21e | 4690 | LOP(OP_CHMOD,XTERM); |
79072805 LW |
4691 | |
4692 | case KEY_chown: | |
a0d0e21e | 4693 | LOP(OP_CHOWN,XTERM); |
79072805 LW |
4694 | |
4695 | case KEY_connect: | |
a0d0e21e | 4696 | LOP(OP_CONNECT,XTERM); |
79072805 | 4697 | |
463ee0b2 LW |
4698 | case KEY_chr: |
4699 | UNI(OP_CHR); | |
4700 | ||
79072805 LW |
4701 | case KEY_cos: |
4702 | UNI(OP_COS); | |
4703 | ||
4704 | case KEY_chroot: | |
4705 | UNI(OP_CHROOT); | |
4706 | ||
0d863452 RH |
4707 | case KEY_default: |
4708 | PREBLOCK(DEFAULT); | |
4709 | ||
79072805 LW |
4710 | case KEY_do: |
4711 | s = skipspace(s); | |
4712 | if (*s == '{') | |
a0d0e21e | 4713 | PRETERMBLOCK(DO); |
79072805 | 4714 | if (*s != '\'') |
89c5585f | 4715 | s = force_word(s,WORD,TRUE,TRUE,FALSE); |
850e8516 RGS |
4716 | if (orig_keyword == KEY_do) { |
4717 | orig_keyword = 0; | |
4718 | yylval.ival = 1; | |
4719 | } | |
4720 | else | |
4721 | yylval.ival = 0; | |
378cc40b | 4722 | OPERATOR(DO); |
79072805 LW |
4723 | |
4724 | case KEY_die: | |
3280af22 | 4725 | PL_hints |= HINT_BLOCK_SCOPE; |
a0d0e21e | 4726 | LOP(OP_DIE,XTERM); |
79072805 LW |
4727 | |
4728 | case KEY_defined: | |
4729 | UNI(OP_DEFINED); | |
4730 | ||
4731 | case KEY_delete: | |
a0d0e21e | 4732 | UNI(OP_DELETE); |
79072805 LW |
4733 | |
4734 | case KEY_dbmopen: | |
a0d0e21e LW |
4735 | gv_fetchpv("AnyDBM_File::ISA", GV_ADDMULTI, SVt_PVAV); |
4736 | LOP(OP_DBMOPEN,XTERM); | |
79072805 LW |
4737 | |
4738 | case KEY_dbmclose: | |
4739 | UNI(OP_DBMCLOSE); | |
4740 | ||
4741 | case KEY_dump: | |
a0d0e21e | 4742 | s = force_word(s,WORD,TRUE,FALSE,FALSE); |
79072805 LW |
4743 | LOOPX(OP_DUMP); |
4744 | ||
4745 | case KEY_else: | |
4746 | PREBLOCK(ELSE); | |
4747 | ||
4748 | case KEY_elsif: | |
57843af0 | 4749 | yylval.ival = CopLINE(PL_curcop); |
79072805 LW |
4750 | OPERATOR(ELSIF); |
4751 | ||
4752 | case KEY_eq: | |
4753 | Eop(OP_SEQ); | |
4754 | ||
a0d0e21e LW |
4755 | case KEY_exists: |
4756 | UNI(OP_EXISTS); | |
4e553d73 | 4757 | |
79072805 LW |
4758 | case KEY_exit: |
4759 | UNI(OP_EXIT); | |
4760 | ||
4761 | case KEY_eval: | |
79072805 | 4762 | s = skipspace(s); |
3280af22 | 4763 | PL_expect = (*s == '{') ? XTERMBLOCK : XTERM; |
463ee0b2 | 4764 | UNIBRACK(OP_ENTEREVAL); |
79072805 LW |
4765 | |
4766 | case KEY_eof: | |
4767 | UNI(OP_EOF); | |
4768 | ||
c963b151 BD |
4769 | case KEY_err: |
4770 | OPERATOR(DOROP); | |
4771 | ||
79072805 LW |
4772 | case KEY_exp: |
4773 | UNI(OP_EXP); | |
4774 | ||
4775 | case KEY_each: | |
4776 | UNI(OP_EACH); | |
4777 | ||
4778 | case KEY_exec: | |
4779 | set_csh(); | |
a0d0e21e | 4780 | LOP(OP_EXEC,XREF); |
79072805 LW |
4781 | |
4782 | case KEY_endhostent: | |
4783 | FUN0(OP_EHOSTENT); | |
4784 | ||
4785 | case KEY_endnetent: | |
4786 | FUN0(OP_ENETENT); | |
4787 | ||
4788 | case KEY_endservent: | |
4789 | FUN0(OP_ESERVENT); | |
4790 | ||
4791 | case KEY_endprotoent: | |
4792 | FUN0(OP_EPROTOENT); | |
4793 | ||
4794 | case KEY_endpwent: | |
4795 | FUN0(OP_EPWENT); | |
4796 | ||
4797 | case KEY_endgrent: | |
4798 | FUN0(OP_EGRENT); | |
4799 | ||
4800 | case KEY_for: | |
4801 | case KEY_foreach: | |
57843af0 | 4802 | yylval.ival = CopLINE(PL_curcop); |
55497cff | 4803 | s = skipspace(s); |
7e2040f0 | 4804 | if (PL_expect == XSTATE && isIDFIRST_lazy_if(s,UTF)) { |
55497cff | 4805 | char *p = s; |
3280af22 | 4806 | if ((PL_bufend - p) >= 3 && |
55497cff | 4807 | strnEQ(p, "my", 2) && isSPACE(*(p + 2))) |
4808 | p += 2; | |
77ca0c92 LW |
4809 | else if ((PL_bufend - p) >= 4 && |
4810 | strnEQ(p, "our", 3) && isSPACE(*(p + 3))) | |
4811 | p += 3; | |
55497cff | 4812 | p = skipspace(p); |
7e2040f0 | 4813 | if (isIDFIRST_lazy_if(p,UTF)) { |
77ca0c92 LW |
4814 | p = scan_ident(p, PL_bufend, |
4815 | PL_tokenbuf, sizeof PL_tokenbuf, TRUE); | |
4816 | p = skipspace(p); | |
4817 | } | |
4818 | if (*p != '$') | |
cea2e8a9 | 4819 | Perl_croak(aTHX_ "Missing $ on loop variable"); |
55497cff | 4820 | } |
79072805 LW |
4821 | OPERATOR(FOR); |
4822 | ||
4823 | case KEY_formline: | |
a0d0e21e | 4824 | LOP(OP_FORMLINE,XTERM); |
79072805 LW |
4825 | |
4826 | case KEY_fork: | |
4827 | FUN0(OP_FORK); | |
4828 | ||
4829 | case KEY_fcntl: | |
a0d0e21e | 4830 | LOP(OP_FCNTL,XTERM); |
79072805 LW |
4831 | |
4832 | case KEY_fileno: | |
4833 | UNI(OP_FILENO); | |
4834 | ||
4835 | case KEY_flock: | |
a0d0e21e | 4836 | LOP(OP_FLOCK,XTERM); |
79072805 LW |
4837 | |
4838 | case KEY_gt: | |
4839 | Rop(OP_SGT); | |
4840 | ||
4841 | case KEY_ge: | |
4842 | Rop(OP_SGE); | |
4843 | ||
4844 | case KEY_grep: | |
2c38e13d | 4845 | LOP(OP_GREPSTART, XREF); |
79072805 LW |
4846 | |
4847 | case KEY_goto: | |
a0d0e21e | 4848 | s = force_word(s,WORD,TRUE,FALSE,FALSE); |
79072805 LW |
4849 | LOOPX(OP_GOTO); |
4850 | ||
4851 | case KEY_gmtime: | |
4852 | UNI(OP_GMTIME); | |
4853 | ||
4854 | case KEY_getc: | |
6f33ba73 | 4855 | UNIDOR(OP_GETC); |
79072805 LW |
4856 | |
4857 | case KEY_getppid: | |
4858 | FUN0(OP_GETPPID); | |
4859 | ||
4860 | case KEY_getpgrp: | |
4861 | UNI(OP_GETPGRP); | |
4862 | ||
4863 | case KEY_getpriority: | |
a0d0e21e | 4864 | LOP(OP_GETPRIORITY,XTERM); |
79072805 LW |
4865 | |
4866 | case KEY_getprotobyname: | |
4867 | UNI(OP_GPBYNAME); | |
4868 | ||
4869 | case KEY_getprotobynumber: | |
a0d0e21e | 4870 | LOP(OP_GPBYNUMBER,XTERM); |
79072805 LW |
4871 | |
4872 | case KEY_getprotoent: | |
4873 | FUN0(OP_GPROTOENT); | |
4874 | ||
4875 | case KEY_getpwent: | |
4876 | FUN0(OP_GPWENT); | |
4877 | ||
4878 | case KEY_getpwnam: | |
ff68c719 | 4879 | UNI(OP_GPWNAM); |
79072805 LW |
4880 | |
4881 | case KEY_getpwuid: | |
ff68c719 | 4882 | UNI(OP_GPWUID); |
79072805 LW |
4883 | |
4884 | case KEY_getpeername: | |
4885 | UNI(OP_GETPEERNAME); | |
4886 | ||
4887 | case KEY_gethostbyname: | |
4888 | UNI(OP_GHBYNAME); | |
4889 | ||
4890 | case KEY_gethostbyaddr: | |
a0d0e21e | 4891 | LOP(OP_GHBYADDR,XTERM); |
79072805 LW |
4892 | |
4893 | case KEY_gethostent: | |
4894 | FUN0(OP_GHOSTENT); | |
4895 | ||
4896 | case KEY_getnetbyname: | |
4897 | UNI(OP_GNBYNAME); | |
4898 | ||
4899 | case KEY_getnetbyaddr: | |
a0d0e21e | 4900 | LOP(OP_GNBYADDR,XTERM); |
79072805 LW |
4901 | |
4902 | case KEY_getnetent: | |
4903 | FUN0(OP_GNETENT); | |
4904 | ||
4905 | case KEY_getservbyname: | |
a0d0e21e | 4906 | LOP(OP_GSBYNAME,XTERM); |
79072805 LW |
4907 | |
4908 | case KEY_getservbyport: | |
a0d0e21e | 4909 | LOP(OP_GSBYPORT,XTERM); |
79072805 LW |
4910 | |
4911 | case KEY_getservent: | |
4912 | FUN0(OP_GSERVENT); | |
4913 | ||
4914 | case KEY_getsockname: | |
4915 | UNI(OP_GETSOCKNAME); | |
4916 | ||
4917 | case KEY_getsockopt: | |
a0d0e21e | 4918 | LOP(OP_GSOCKOPT,XTERM); |
79072805 LW |
4919 | |
4920 | case KEY_getgrent: | |
4921 | FUN0(OP_GGRENT); | |
4922 | ||
4923 | case KEY_getgrnam: | |
ff68c719 | 4924 | UNI(OP_GGRNAM); |
79072805 LW |
4925 | |
4926 | case KEY_getgrgid: | |
ff68c719 | 4927 | UNI(OP_GGRGID); |
79072805 LW |
4928 | |
4929 | case KEY_getlogin: | |
4930 | FUN0(OP_GETLOGIN); | |
4931 | ||
0d863452 RH |
4932 | case KEY_given: |
4933 | yylval.ival = CopLINE(PL_curcop); | |
4934 | OPERATOR(GIVEN); | |
4935 | ||
93a17b20 | 4936 | case KEY_glob: |
a0d0e21e LW |
4937 | set_csh(); |
4938 | LOP(OP_GLOB,XTERM); | |
93a17b20 | 4939 | |
79072805 LW |
4940 | case KEY_hex: |
4941 | UNI(OP_HEX); | |
4942 | ||
4943 | case KEY_if: | |
57843af0 | 4944 | yylval.ival = CopLINE(PL_curcop); |
79072805 LW |
4945 | OPERATOR(IF); |
4946 | ||
4947 | case KEY_index: | |
a0d0e21e | 4948 | LOP(OP_INDEX,XTERM); |
79072805 LW |
4949 | |
4950 | case KEY_int: | |
4951 | UNI(OP_INT); | |
4952 | ||
4953 | case KEY_ioctl: | |
a0d0e21e | 4954 | LOP(OP_IOCTL,XTERM); |
79072805 LW |
4955 | |
4956 | case KEY_join: | |
a0d0e21e | 4957 | LOP(OP_JOIN,XTERM); |
79072805 LW |
4958 | |
4959 | case KEY_keys: | |
4960 | UNI(OP_KEYS); | |
4961 | ||
4962 | case KEY_kill: | |
a0d0e21e | 4963 | LOP(OP_KILL,XTERM); |
79072805 LW |
4964 | |
4965 | case KEY_last: | |
a0d0e21e | 4966 | s = force_word(s,WORD,TRUE,FALSE,FALSE); |
79072805 | 4967 | LOOPX(OP_LAST); |
4e553d73 | 4968 | |
79072805 LW |
4969 | case KEY_lc: |
4970 | UNI(OP_LC); | |
4971 | ||
4972 | case KEY_lcfirst: | |
4973 | UNI(OP_LCFIRST); | |
4974 | ||
4975 | case KEY_local: | |
09bef843 | 4976 | yylval.ival = 0; |
79072805 LW |
4977 | OPERATOR(LOCAL); |
4978 | ||
4979 | case KEY_length: | |
4980 | UNI(OP_LENGTH); | |
4981 | ||
4982 | case KEY_lt: | |
4983 | Rop(OP_SLT); | |
4984 | ||
4985 | case KEY_le: | |
4986 | Rop(OP_SLE); | |
4987 | ||
4988 | case KEY_localtime: | |
4989 | UNI(OP_LOCALTIME); | |
4990 | ||
4991 | case KEY_log: | |
4992 | UNI(OP_LOG); | |
4993 | ||
4994 | case KEY_link: | |
a0d0e21e | 4995 | LOP(OP_LINK,XTERM); |
79072805 LW |
4996 | |
4997 | case KEY_listen: | |
a0d0e21e | 4998 | LOP(OP_LISTEN,XTERM); |
79072805 | 4999 | |
c0329465 MB |
5000 | case KEY_lock: |
5001 | UNI(OP_LOCK); | |
5002 | ||
79072805 LW |
5003 | case KEY_lstat: |
5004 | UNI(OP_LSTAT); | |
5005 | ||
5006 | case KEY_m: | |
8782bef2 | 5007 | s = scan_pat(s,OP_MATCH); |
79072805 LW |
5008 | TERM(sublex_start()); |
5009 | ||
a0d0e21e | 5010 | case KEY_map: |
2c38e13d | 5011 | LOP(OP_MAPSTART, XREF); |
4e4e412b | 5012 | |
79072805 | 5013 | case KEY_mkdir: |
a0d0e21e | 5014 | LOP(OP_MKDIR,XTERM); |
79072805 LW |
5015 | |
5016 | case KEY_msgctl: | |
a0d0e21e | 5017 | LOP(OP_MSGCTL,XTERM); |
79072805 LW |
5018 | |
5019 | case KEY_msgget: | |
a0d0e21e | 5020 | LOP(OP_MSGGET,XTERM); |
79072805 LW |
5021 | |
5022 | case KEY_msgrcv: | |
a0d0e21e | 5023 | LOP(OP_MSGRCV,XTERM); |
79072805 LW |
5024 | |
5025 | case KEY_msgsnd: | |
a0d0e21e | 5026 | LOP(OP_MSGSND,XTERM); |
79072805 | 5027 | |
77ca0c92 | 5028 | case KEY_our: |
93a17b20 | 5029 | case KEY_my: |
77ca0c92 | 5030 | PL_in_my = tmp; |
c750a3ec | 5031 | s = skipspace(s); |
7e2040f0 | 5032 | if (isIDFIRST_lazy_if(s,UTF)) { |
3280af22 | 5033 | s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, TRUE, &len); |
09bef843 SB |
5034 | if (len == 3 && strnEQ(PL_tokenbuf, "sub", 3)) |
5035 | goto really_sub; | |
def3634b | 5036 | PL_in_my_stash = find_in_my_stash(PL_tokenbuf, len); |
3280af22 | 5037 | if (!PL_in_my_stash) { |
c750a3ec | 5038 | char tmpbuf[1024]; |
3280af22 NIS |
5039 | PL_bufptr = s; |
5040 | sprintf(tmpbuf, "No such class %.1000s", PL_tokenbuf); | |
c750a3ec MB |
5041 | yyerror(tmpbuf); |
5042 | } | |
5043 | } | |
09bef843 | 5044 | yylval.ival = 1; |
55497cff | 5045 | OPERATOR(MY); |
93a17b20 | 5046 | |
79072805 | 5047 | case KEY_next: |
a0d0e21e | 5048 | s = force_word(s,WORD,TRUE,FALSE,FALSE); |
79072805 LW |
5049 | LOOPX(OP_NEXT); |
5050 | ||
5051 | case KEY_ne: | |
5052 | Eop(OP_SNE); | |
5053 | ||
a0d0e21e | 5054 | case KEY_no: |
468aa647 | 5055 | s = tokenize_use(0, s); |
a0d0e21e LW |
5056 | OPERATOR(USE); |
5057 | ||
5058 | case KEY_not: | |
2d2e263d LW |
5059 | if (*s == '(' || (s = skipspace(s), *s == '(')) |
5060 | FUN1(OP_NOT); | |
5061 | else | |
5062 | OPERATOR(NOTOP); | |
a0d0e21e | 5063 | |
79072805 | 5064 | case KEY_open: |
93a17b20 | 5065 | s = skipspace(s); |
7e2040f0 | 5066 | if (isIDFIRST_lazy_if(s,UTF)) { |
f54cb97a | 5067 | const char *t; |
7e2040f0 | 5068 | for (d = s; isALNUM_lazy_if(d,UTF); d++) ; |
e2ab214b DM |
5069 | for (t=d; *t && isSPACE(*t); t++) ; |
5070 | if ( *t && strchr("|&*+-=!?:.", *t) && ckWARN_d(WARN_PRECEDENCE) | |
66fbe8fb HS |
5071 | /* [perl #16184] */ |
5072 | && !(t[0] == '=' && t[1] == '>') | |
5073 | ) { | |
551405c4 | 5074 | int len = (int)(d-s); |
9014280d | 5075 | Perl_warner(aTHX_ packWARN(WARN_PRECEDENCE), |
0453d815 | 5076 | "Precedence problem: open %.*s should be open(%.*s)", |
551405c4 | 5077 | len, s, len, s); |
66fbe8fb | 5078 | } |
93a17b20 | 5079 | } |
a0d0e21e | 5080 | LOP(OP_OPEN,XTERM); |
79072805 | 5081 | |
463ee0b2 | 5082 | case KEY_or: |
a0d0e21e | 5083 | yylval.ival = OP_OR; |
463ee0b2 LW |
5084 | OPERATOR(OROP); |
5085 | ||
79072805 LW |
5086 | case KEY_ord: |
5087 | UNI(OP_ORD); | |
5088 | ||
5089 | case KEY_oct: | |
5090 | UNI(OP_OCT); | |
5091 | ||
5092 | case KEY_opendir: | |
a0d0e21e | 5093 | LOP(OP_OPEN_DIR,XTERM); |
79072805 LW |
5094 | |
5095 | case KEY_print: | |
3280af22 | 5096 | checkcomma(s,PL_tokenbuf,"filehandle"); |
a0d0e21e | 5097 | LOP(OP_PRINT,XREF); |
79072805 LW |
5098 | |
5099 | case KEY_printf: | |
3280af22 | 5100 | checkcomma(s,PL_tokenbuf,"filehandle"); |
a0d0e21e | 5101 | LOP(OP_PRTF,XREF); |
79072805 | 5102 | |
c07a80fd | 5103 | case KEY_prototype: |
5104 | UNI(OP_PROTOTYPE); | |
5105 | ||
79072805 | 5106 | case KEY_push: |
a0d0e21e | 5107 | LOP(OP_PUSH,XTERM); |
79072805 LW |
5108 | |
5109 | case KEY_pop: | |
6f33ba73 | 5110 | UNIDOR(OP_POP); |
79072805 | 5111 | |
a0d0e21e | 5112 | case KEY_pos: |
6f33ba73 | 5113 | UNIDOR(OP_POS); |
4e553d73 | 5114 | |
79072805 | 5115 | case KEY_pack: |
a0d0e21e | 5116 | LOP(OP_PACK,XTERM); |
79072805 LW |
5117 | |
5118 | case KEY_package: | |
a0d0e21e | 5119 | s = force_word(s,WORD,FALSE,TRUE,FALSE); |
79072805 LW |
5120 | OPERATOR(PACKAGE); |
5121 | ||
5122 | case KEY_pipe: | |
a0d0e21e | 5123 | LOP(OP_PIPE_OP,XTERM); |
79072805 LW |
5124 | |
5125 | case KEY_q: | |
09bef843 | 5126 | s = scan_str(s,FALSE,FALSE); |
79072805 | 5127 | if (!s) |
85e6fe83 | 5128 | missingterm((char*)0); |
79072805 LW |
5129 | yylval.ival = OP_CONST; |
5130 | TERM(sublex_start()); | |
5131 | ||
a0d0e21e LW |
5132 | case KEY_quotemeta: |
5133 | UNI(OP_QUOTEMETA); | |
5134 | ||
8990e307 | 5135 | case KEY_qw: |
09bef843 | 5136 | s = scan_str(s,FALSE,FALSE); |
8990e307 | 5137 | if (!s) |
85e6fe83 | 5138 | missingterm((char*)0); |
3480a8d2 | 5139 | PL_expect = XOPERATOR; |
8127e0e3 GS |
5140 | force_next(')'); |
5141 | if (SvCUR(PL_lex_stuff)) { | |
5142 | OP *words = Nullop; | |
5143 | int warned = 0; | |
3280af22 | 5144 | d = SvPV_force(PL_lex_stuff, len); |
8127e0e3 | 5145 | while (len) { |
7948272d | 5146 | SV *sv; |
8127e0e3 GS |
5147 | for (; isSPACE(*d) && len; --len, ++d) ; |
5148 | if (len) { | |
f54cb97a | 5149 | const char *b = d; |
e476b1b5 | 5150 | if (!warned && ckWARN(WARN_QW)) { |
8127e0e3 GS |
5151 | for (; !isSPACE(*d) && len; --len, ++d) { |
5152 | if (*d == ',') { | |
9014280d | 5153 | Perl_warner(aTHX_ packWARN(WARN_QW), |
8127e0e3 GS |
5154 | "Possible attempt to separate words with commas"); |
5155 | ++warned; | |
5156 | } | |
5157 | else if (*d == '#') { | |
9014280d | 5158 | Perl_warner(aTHX_ packWARN(WARN_QW), |
8127e0e3 GS |
5159 | "Possible attempt to put comments in qw() list"); |
5160 | ++warned; | |
5161 | } | |
5162 | } | |
5163 | } | |
5164 | else { | |
5165 | for (; !isSPACE(*d) && len; --len, ++d) ; | |
5166 | } | |
7948272d NIS |
5167 | sv = newSVpvn(b, d-b); |
5168 | if (DO_UTF8(PL_lex_stuff)) | |
5169 | SvUTF8_on(sv); | |
8127e0e3 | 5170 | words = append_elem(OP_LIST, words, |
7948272d | 5171 | newSVOP(OP_CONST, 0, tokeq(sv))); |
55497cff | 5172 | } |
5173 | } | |
8127e0e3 GS |
5174 | if (words) { |
5175 | PL_nextval[PL_nexttoke].opval = words; | |
5176 | force_next(THING); | |
5177 | } | |
55497cff | 5178 | } |
37fd879b | 5179 | if (PL_lex_stuff) { |
8127e0e3 | 5180 | SvREFCNT_dec(PL_lex_stuff); |
37fd879b HS |
5181 | PL_lex_stuff = Nullsv; |
5182 | } | |
3280af22 | 5183 | PL_expect = XTERM; |
8127e0e3 | 5184 | TOKEN('('); |
8990e307 | 5185 | |
79072805 | 5186 | case KEY_qq: |
09bef843 | 5187 | s = scan_str(s,FALSE,FALSE); |
79072805 | 5188 | if (!s) |
85e6fe83 | 5189 | missingterm((char*)0); |
a0d0e21e | 5190 | yylval.ival = OP_STRINGIFY; |
3280af22 | 5191 | if (SvIVX(PL_lex_stuff) == '\'') |
45977657 | 5192 | SvIV_set(PL_lex_stuff, 0); /* qq'$foo' should intepolate */ |
79072805 LW |
5193 | TERM(sublex_start()); |
5194 | ||
8782bef2 GB |
5195 | case KEY_qr: |
5196 | s = scan_pat(s,OP_QR); | |
5197 | TERM(sublex_start()); | |
5198 | ||
79072805 | 5199 | case KEY_qx: |
09bef843 | 5200 | s = scan_str(s,FALSE,FALSE); |
79072805 | 5201 | if (!s) |
85e6fe83 | 5202 | missingterm((char*)0); |
79072805 LW |
5203 | yylval.ival = OP_BACKTICK; |
5204 | set_csh(); | |
5205 | TERM(sublex_start()); | |
5206 | ||
5207 | case KEY_return: | |
5208 | OLDLOP(OP_RETURN); | |
5209 | ||
5210 | case KEY_require: | |
a7cb1f99 | 5211 | s = skipspace(s); |
e759cc13 RGS |
5212 | if (isDIGIT(*s)) { |
5213 | s = force_version(s, FALSE); | |
a7cb1f99 | 5214 | } |
e759cc13 RGS |
5215 | else if (*s != 'v' || !isDIGIT(s[1]) |
5216 | || (s = force_version(s, TRUE), *s == 'v')) | |
5217 | { | |
a7cb1f99 GS |
5218 | *PL_tokenbuf = '\0'; |
5219 | s = force_word(s,WORD,TRUE,TRUE,FALSE); | |
7e2040f0 | 5220 | if (isIDFIRST_lazy_if(PL_tokenbuf,UTF)) |
a7cb1f99 GS |
5221 | gv_stashpvn(PL_tokenbuf, strlen(PL_tokenbuf), TRUE); |
5222 | else if (*s == '<') | |
5223 | yyerror("<> should be quotes"); | |
5224 | } | |
a72a1c8b RGS |
5225 | if (orig_keyword == KEY_require) { |
5226 | orig_keyword = 0; | |
5227 | yylval.ival = 1; | |
5228 | } | |
5229 | else | |
5230 | yylval.ival = 0; | |
5231 | PL_expect = XTERM; | |
5232 | PL_bufptr = s; | |
5233 | PL_last_uni = PL_oldbufptr; | |
5234 | PL_last_lop_op = OP_REQUIRE; | |
5235 | s = skipspace(s); | |
5236 | return REPORT( (int)REQUIRE ); | |
79072805 LW |
5237 | |
5238 | case KEY_reset: | |
5239 | UNI(OP_RESET); | |
5240 | ||
5241 | case KEY_redo: | |
a0d0e21e | 5242 | s = force_word(s,WORD,TRUE,FALSE,FALSE); |
79072805 LW |
5243 | LOOPX(OP_REDO); |
5244 | ||
5245 | case KEY_rename: | |
a0d0e21e | 5246 | LOP(OP_RENAME,XTERM); |
79072805 LW |
5247 | |
5248 | case KEY_rand: | |
5249 | UNI(OP_RAND); | |
5250 | ||
5251 | case KEY_rmdir: | |
5252 | UNI(OP_RMDIR); | |
5253 | ||
5254 | case KEY_rindex: | |
a0d0e21e | 5255 | LOP(OP_RINDEX,XTERM); |
79072805 LW |
5256 | |
5257 | case KEY_read: | |
a0d0e21e | 5258 | LOP(OP_READ,XTERM); |
79072805 LW |
5259 | |
5260 | case KEY_readdir: | |
5261 | UNI(OP_READDIR); | |
5262 | ||
93a17b20 LW |
5263 | case KEY_readline: |
5264 | set_csh(); | |
6f33ba73 | 5265 | UNIDOR(OP_READLINE); |
93a17b20 LW |
5266 | |
5267 | case KEY_readpipe: | |
5268 | set_csh(); | |
5269 | UNI(OP_BACKTICK); | |
5270 | ||
79072805 LW |
5271 | case KEY_rewinddir: |
5272 | UNI(OP_REWINDDIR); | |
5273 | ||
5274 | case KEY_recv: | |
a0d0e21e | 5275 | LOP(OP_RECV,XTERM); |
79072805 LW |
5276 | |
5277 | case KEY_reverse: | |
a0d0e21e | 5278 | LOP(OP_REVERSE,XTERM); |
79072805 LW |
5279 | |
5280 | case KEY_readlink: | |
6f33ba73 | 5281 | UNIDOR(OP_READLINK); |
79072805 LW |
5282 | |
5283 | case KEY_ref: | |
5284 | UNI(OP_REF); | |
5285 | ||
5286 | case KEY_s: | |
5287 | s = scan_subst(s); | |
5288 | if (yylval.opval) | |
5289 | TERM(sublex_start()); | |
5290 | else | |
5291 | TOKEN(1); /* force error */ | |
5292 | ||
0d863452 RH |
5293 | case KEY_say: |
5294 | checkcomma(s,PL_tokenbuf,"filehandle"); | |
5295 | LOP(OP_SAY,XREF); | |
5296 | ||
a0d0e21e LW |
5297 | case KEY_chomp: |
5298 | UNI(OP_CHOMP); | |
4e553d73 | 5299 | |
79072805 LW |
5300 | case KEY_scalar: |
5301 | UNI(OP_SCALAR); | |
5302 | ||
5303 | case KEY_select: | |
a0d0e21e | 5304 | LOP(OP_SELECT,XTERM); |
79072805 LW |
5305 | |
5306 | case KEY_seek: | |
a0d0e21e | 5307 | LOP(OP_SEEK,XTERM); |
79072805 LW |
5308 | |
5309 | case KEY_semctl: | |
a0d0e21e | 5310 | LOP(OP_SEMCTL,XTERM); |
79072805 LW |
5311 | |
5312 | case KEY_semget: | |
a0d0e21e | 5313 | LOP(OP_SEMGET,XTERM); |
79072805 LW |
5314 | |
5315 | case KEY_semop: | |
a0d0e21e | 5316 | LOP(OP_SEMOP,XTERM); |
79072805 LW |
5317 | |
5318 | case KEY_send: | |
a0d0e21e | 5319 | LOP(OP_SEND,XTERM); |
79072805 LW |
5320 | |
5321 | case KEY_setpgrp: | |
a0d0e21e | 5322 | LOP(OP_SETPGRP,XTERM); |
79072805 LW |
5323 | |
5324 | case KEY_setpriority: | |
a0d0e21e | 5325 | LOP(OP_SETPRIORITY,XTERM); |
79072805 LW |
5326 | |
5327 | case KEY_sethostent: | |
ff68c719 | 5328 | UNI(OP_SHOSTENT); |
79072805 LW |
5329 | |
5330 | case KEY_setnetent: | |
ff68c719 | 5331 | UNI(OP_SNETENT); |
79072805 LW |
5332 | |
5333 | case KEY_setservent: | |
ff68c719 | 5334 | UNI(OP_SSERVENT); |
79072805 LW |
5335 | |
5336 | case KEY_setprotoent: | |
ff68c719 | 5337 | UNI(OP_SPROTOENT); |
79072805 LW |
5338 | |
5339 | case KEY_setpwent: | |
5340 | FUN0(OP_SPWENT); | |
5341 | ||
5342 | case KEY_setgrent: | |
5343 | FUN0(OP_SGRENT); | |
5344 | ||
5345 | case KEY_seekdir: | |
a0d0e21e | 5346 | LOP(OP_SEEKDIR,XTERM); |
79072805 LW |
5347 | |
5348 | case KEY_setsockopt: | |
a0d0e21e | 5349 | LOP(OP_SSOCKOPT,XTERM); |
79072805 LW |
5350 | |
5351 | case KEY_shift: | |
6f33ba73 | 5352 | UNIDOR(OP_SHIFT); |
79072805 LW |
5353 | |
5354 | case KEY_shmctl: | |
a0d0e21e | 5355 | LOP(OP_SHMCTL,XTERM); |
79072805 LW |
5356 | |
5357 | case KEY_shmget: | |
a0d0e21e | 5358 | LOP(OP_SHMGET,XTERM); |
79072805 LW |
5359 | |
5360 | case KEY_shmread: | |
a0d0e21e | 5361 | LOP(OP_SHMREAD,XTERM); |
79072805 LW |
5362 | |
5363 | case KEY_shmwrite: | |
a0d0e21e | 5364 | LOP(OP_SHMWRITE,XTERM); |
79072805 LW |
5365 | |
5366 | case KEY_shutdown: | |
a0d0e21e | 5367 | LOP(OP_SHUTDOWN,XTERM); |
79072805 LW |
5368 | |
5369 | case KEY_sin: | |
5370 | UNI(OP_SIN); | |
5371 | ||
5372 | case KEY_sleep: | |
5373 | UNI(OP_SLEEP); | |
5374 | ||
5375 | case KEY_socket: | |
a0d0e21e | 5376 | LOP(OP_SOCKET,XTERM); |
79072805 LW |
5377 | |
5378 | case KEY_socketpair: | |
a0d0e21e | 5379 | LOP(OP_SOCKPAIR,XTERM); |
79072805 LW |
5380 | |
5381 | case KEY_sort: | |
3280af22 | 5382 | checkcomma(s,PL_tokenbuf,"subroutine name"); |
79072805 LW |
5383 | s = skipspace(s); |
5384 | if (*s == ';' || *s == ')') /* probably a close */ | |
cea2e8a9 | 5385 | Perl_croak(aTHX_ "sort is now a reserved word"); |
3280af22 | 5386 | PL_expect = XTERM; |
15f0808c | 5387 | s = force_word(s,WORD,TRUE,TRUE,FALSE); |
a0d0e21e | 5388 | LOP(OP_SORT,XREF); |
79072805 LW |
5389 | |
5390 | case KEY_split: | |
a0d0e21e | 5391 | LOP(OP_SPLIT,XTERM); |
79072805 LW |
5392 | |
5393 | case KEY_sprintf: | |
a0d0e21e | 5394 | LOP(OP_SPRINTF,XTERM); |
79072805 LW |
5395 | |
5396 | case KEY_splice: | |
a0d0e21e | 5397 | LOP(OP_SPLICE,XTERM); |
79072805 LW |
5398 | |
5399 | case KEY_sqrt: | |
5400 | UNI(OP_SQRT); | |
5401 | ||
5402 | case KEY_srand: | |
5403 | UNI(OP_SRAND); | |
5404 | ||
5405 | case KEY_stat: | |
5406 | UNI(OP_STAT); | |
5407 | ||
5408 | case KEY_study: | |
79072805 LW |
5409 | UNI(OP_STUDY); |
5410 | ||
5411 | case KEY_substr: | |
a0d0e21e | 5412 | LOP(OP_SUBSTR,XTERM); |
79072805 LW |
5413 | |
5414 | case KEY_format: | |
5415 | case KEY_sub: | |
93a17b20 | 5416 | really_sub: |
09bef843 | 5417 | { |
3280af22 | 5418 | char tmpbuf[sizeof PL_tokenbuf]; |
9c5ffd7c | 5419 | SSize_t tboffset = 0; |
09bef843 | 5420 | expectation attrful; |
d731386a | 5421 | bool have_name, have_proto, bad_proto; |
f54cb97a | 5422 | const int key = tmp; |
09bef843 SB |
5423 | |
5424 | s = skipspace(s); | |
5425 | ||
7e2040f0 | 5426 | if (isIDFIRST_lazy_if(s,UTF) || *s == '\'' || |
09bef843 SB |
5427 | (*s == ':' && s[1] == ':')) |
5428 | { | |
5429 | PL_expect = XBLOCK; | |
5430 | attrful = XATTRBLOCK; | |
b1b65b59 JH |
5431 | /* remember buffer pos'n for later force_word */ |
5432 | tboffset = s - PL_oldbufptr; | |
09bef843 SB |
5433 | d = scan_word(s, tmpbuf, sizeof tmpbuf, TRUE, &len); |
5434 | if (strchr(tmpbuf, ':')) | |
5435 | sv_setpv(PL_subname, tmpbuf); | |
5436 | else { | |
5437 | sv_setsv(PL_subname,PL_curstname); | |
396482e1 | 5438 | sv_catpvs(PL_subname,"::"); |
09bef843 SB |
5439 | sv_catpvn(PL_subname,tmpbuf,len); |
5440 | } | |
5441 | s = skipspace(d); | |
5442 | have_name = TRUE; | |
5443 | } | |
463ee0b2 | 5444 | else { |
09bef843 SB |
5445 | if (key == KEY_my) |
5446 | Perl_croak(aTHX_ "Missing name in \"my sub\""); | |
5447 | PL_expect = XTERMBLOCK; | |
5448 | attrful = XATTRTERM; | |
c69006e4 | 5449 | sv_setpvn(PL_subname,"?",1); |
09bef843 | 5450 | have_name = FALSE; |
463ee0b2 | 5451 | } |
4633a7c4 | 5452 | |
09bef843 SB |
5453 | if (key == KEY_format) { |
5454 | if (*s == '=') | |
5455 | PL_lex_formbrack = PL_lex_brackets + 1; | |
5456 | if (have_name) | |
b1b65b59 JH |
5457 | (void) force_word(PL_oldbufptr + tboffset, WORD, |
5458 | FALSE, TRUE, TRUE); | |
09bef843 SB |
5459 | OPERATOR(FORMAT); |
5460 | } | |
79072805 | 5461 | |
09bef843 SB |
5462 | /* Look for a prototype */ |
5463 | if (*s == '(') { | |
5464 | char *p; | |
5465 | ||
5466 | s = scan_str(s,FALSE,FALSE); | |
37fd879b | 5467 | if (!s) |
09bef843 | 5468 | Perl_croak(aTHX_ "Prototype not terminated"); |
2f758a16 | 5469 | /* strip spaces and check for bad characters */ |
09bef843 SB |
5470 | d = SvPVX(PL_lex_stuff); |
5471 | tmp = 0; | |
d731386a | 5472 | bad_proto = FALSE; |
09bef843 | 5473 | for (p = d; *p; ++p) { |
d37a9538 | 5474 | if (!isSPACE(*p)) { |
09bef843 | 5475 | d[tmp++] = *p; |
d37a9538 ST |
5476 | if (!strchr("$@%*;[]&\\", *p)) |
5477 | bad_proto = TRUE; | |
5478 | } | |
09bef843 SB |
5479 | } |
5480 | d[tmp] = '\0'; | |
420cdfc1 | 5481 | if (bad_proto && ckWARN(WARN_SYNTAX)) |
9014280d | 5482 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
35c1215d NC |
5483 | "Illegal character in prototype for %"SVf" : %s", |
5484 | PL_subname, d); | |
b162af07 | 5485 | SvCUR_set(PL_lex_stuff, tmp); |
09bef843 | 5486 | have_proto = TRUE; |
68dc0745 | 5487 | |
09bef843 | 5488 | s = skipspace(s); |
4633a7c4 | 5489 | } |
09bef843 SB |
5490 | else |
5491 | have_proto = FALSE; | |
5492 | ||
5493 | if (*s == ':' && s[1] != ':') | |
5494 | PL_expect = attrful; | |
8e742a20 MHM |
5495 | else if (*s != '{' && key == KEY_sub) { |
5496 | if (!have_name) | |
5497 | Perl_croak(aTHX_ "Illegal declaration of anonymous subroutine"); | |
5498 | else if (*s != ';') | |
5499 | Perl_croak(aTHX_ "Illegal declaration of subroutine %"SVf, PL_subname); | |
5500 | } | |
09bef843 SB |
5501 | |
5502 | if (have_proto) { | |
b1b65b59 JH |
5503 | PL_nextval[PL_nexttoke].opval = |
5504 | (OP*)newSVOP(OP_CONST, 0, PL_lex_stuff); | |
09bef843 SB |
5505 | PL_lex_stuff = Nullsv; |
5506 | force_next(THING); | |
68dc0745 | 5507 | } |
09bef843 | 5508 | if (!have_name) { |
c99da370 JH |
5509 | sv_setpv(PL_subname, |
5510 | PL_curstash ? "__ANON__" : "__ANON__::__ANON__"); | |
09bef843 | 5511 | TOKEN(ANONSUB); |
4633a7c4 | 5512 | } |
b1b65b59 JH |
5513 | (void) force_word(PL_oldbufptr + tboffset, WORD, |
5514 | FALSE, TRUE, TRUE); | |
09bef843 SB |
5515 | if (key == KEY_my) |
5516 | TOKEN(MYSUB); | |
5517 | TOKEN(SUB); | |
4633a7c4 | 5518 | } |
79072805 LW |
5519 | |
5520 | case KEY_system: | |
5521 | set_csh(); | |
a0d0e21e | 5522 | LOP(OP_SYSTEM,XREF); |
79072805 LW |
5523 | |
5524 | case KEY_symlink: | |
a0d0e21e | 5525 | LOP(OP_SYMLINK,XTERM); |
79072805 LW |
5526 | |
5527 | case KEY_syscall: | |
a0d0e21e | 5528 | LOP(OP_SYSCALL,XTERM); |
79072805 | 5529 | |
c07a80fd | 5530 | case KEY_sysopen: |
5531 | LOP(OP_SYSOPEN,XTERM); | |
5532 | ||
137443ea | 5533 | case KEY_sysseek: |
5534 | LOP(OP_SYSSEEK,XTERM); | |
5535 | ||
79072805 | 5536 | case KEY_sysread: |
a0d0e21e | 5537 | LOP(OP_SYSREAD,XTERM); |
79072805 LW |
5538 | |
5539 | case KEY_syswrite: | |
a0d0e21e | 5540 | LOP(OP_SYSWRITE,XTERM); |
79072805 LW |
5541 | |
5542 | case KEY_tr: | |
5543 | s = scan_trans(s); | |
5544 | TERM(sublex_start()); | |
5545 | ||
5546 | case KEY_tell: | |
5547 | UNI(OP_TELL); | |
5548 | ||
5549 | case KEY_telldir: | |
5550 | UNI(OP_TELLDIR); | |
5551 | ||
463ee0b2 | 5552 | case KEY_tie: |
a0d0e21e | 5553 | LOP(OP_TIE,XTERM); |
463ee0b2 | 5554 | |
c07a80fd | 5555 | case KEY_tied: |
5556 | UNI(OP_TIED); | |
5557 | ||
79072805 LW |
5558 | case KEY_time: |
5559 | FUN0(OP_TIME); | |
5560 | ||
5561 | case KEY_times: | |
5562 | FUN0(OP_TMS); | |
5563 | ||
5564 | case KEY_truncate: | |
a0d0e21e | 5565 | LOP(OP_TRUNCATE,XTERM); |
79072805 LW |
5566 | |
5567 | case KEY_uc: | |
5568 | UNI(OP_UC); | |
5569 | ||
5570 | case KEY_ucfirst: | |
5571 | UNI(OP_UCFIRST); | |
5572 | ||
463ee0b2 LW |
5573 | case KEY_untie: |
5574 | UNI(OP_UNTIE); | |
5575 | ||
79072805 | 5576 | case KEY_until: |
57843af0 | 5577 | yylval.ival = CopLINE(PL_curcop); |
79072805 LW |
5578 | OPERATOR(UNTIL); |
5579 | ||
5580 | case KEY_unless: | |
57843af0 | 5581 | yylval.ival = CopLINE(PL_curcop); |
79072805 LW |
5582 | OPERATOR(UNLESS); |
5583 | ||
5584 | case KEY_unlink: | |
a0d0e21e | 5585 | LOP(OP_UNLINK,XTERM); |
79072805 LW |
5586 | |
5587 | case KEY_undef: | |
6f33ba73 | 5588 | UNIDOR(OP_UNDEF); |
79072805 LW |
5589 | |
5590 | case KEY_unpack: | |
a0d0e21e | 5591 | LOP(OP_UNPACK,XTERM); |
79072805 LW |
5592 | |
5593 | case KEY_utime: | |
a0d0e21e | 5594 | LOP(OP_UTIME,XTERM); |
79072805 LW |
5595 | |
5596 | case KEY_umask: | |
6f33ba73 | 5597 | UNIDOR(OP_UMASK); |
79072805 LW |
5598 | |
5599 | case KEY_unshift: | |
a0d0e21e LW |
5600 | LOP(OP_UNSHIFT,XTERM); |
5601 | ||
5602 | case KEY_use: | |
468aa647 | 5603 | s = tokenize_use(1, s); |
a0d0e21e | 5604 | OPERATOR(USE); |
79072805 LW |
5605 | |
5606 | case KEY_values: | |
5607 | UNI(OP_VALUES); | |
5608 | ||
5609 | case KEY_vec: | |
a0d0e21e | 5610 | LOP(OP_VEC,XTERM); |
79072805 | 5611 | |
0d863452 RH |
5612 | case KEY_when: |
5613 | yylval.ival = CopLINE(PL_curcop); | |
5614 | OPERATOR(WHEN); | |
5615 | ||
79072805 | 5616 | case KEY_while: |
57843af0 | 5617 | yylval.ival = CopLINE(PL_curcop); |
79072805 LW |
5618 | OPERATOR(WHILE); |
5619 | ||
5620 | case KEY_warn: | |
3280af22 | 5621 | PL_hints |= HINT_BLOCK_SCOPE; |
a0d0e21e | 5622 | LOP(OP_WARN,XTERM); |
79072805 LW |
5623 | |
5624 | case KEY_wait: | |
5625 | FUN0(OP_WAIT); | |
5626 | ||
5627 | case KEY_waitpid: | |
a0d0e21e | 5628 | LOP(OP_WAITPID,XTERM); |
79072805 LW |
5629 | |
5630 | case KEY_wantarray: | |
5631 | FUN0(OP_WANTARRAY); | |
5632 | ||
5633 | case KEY_write: | |
9d116dd7 JH |
5634 | #ifdef EBCDIC |
5635 | { | |
df3728a2 JH |
5636 | char ctl_l[2]; |
5637 | ctl_l[0] = toCTRL('L'); | |
5638 | ctl_l[1] = '\0'; | |
f776e3cd | 5639 | gv_fetchpv(ctl_l, GV_ADD, SVt_PV); |
9d116dd7 JH |
5640 | } |
5641 | #else | |
f776e3cd | 5642 | gv_fetchpv("\f", GV_ADD, SVt_PV); /* Make sure $^L is defined */ |
9d116dd7 | 5643 | #endif |
79072805 LW |
5644 | UNI(OP_ENTERWRITE); |
5645 | ||
5646 | case KEY_x: | |
3280af22 | 5647 | if (PL_expect == XOPERATOR) |
79072805 LW |
5648 | Mop(OP_REPEAT); |
5649 | check_uni(); | |
5650 | goto just_a_word; | |
5651 | ||
a0d0e21e LW |
5652 | case KEY_xor: |
5653 | yylval.ival = OP_XOR; | |
5654 | OPERATOR(OROP); | |
5655 | ||
79072805 LW |
5656 | case KEY_y: |
5657 | s = scan_trans(s); | |
5658 | TERM(sublex_start()); | |
5659 | } | |
49dc05e3 | 5660 | }} |
79072805 | 5661 | } |
bf4acbe4 GS |
5662 | #ifdef __SC__ |
5663 | #pragma segment Main | |
5664 | #endif | |
79072805 | 5665 | |
e930465f JH |
5666 | static int |
5667 | S_pending_ident(pTHX) | |
8eceec63 SC |
5668 | { |
5669 | register char *d; | |
a55b55d8 | 5670 | register I32 tmp = 0; |
8eceec63 SC |
5671 | /* pit holds the identifier we read and pending_ident is reset */ |
5672 | char pit = PL_pending_ident; | |
5673 | PL_pending_ident = 0; | |
5674 | ||
5675 | DEBUG_T({ PerlIO_printf(Perl_debug_log, | |
b6007c36 | 5676 | "### Pending identifier '%s'\n", PL_tokenbuf); }); |
8eceec63 SC |
5677 | |
5678 | /* if we're in a my(), we can't allow dynamics here. | |
5679 | $foo'bar has already been turned into $foo::bar, so | |
5680 | just check for colons. | |
5681 | ||
5682 | if it's a legal name, the OP is a PADANY. | |
5683 | */ | |
5684 | if (PL_in_my) { | |
5685 | if (PL_in_my == KEY_our) { /* "our" is merely analogous to "my" */ | |
5686 | if (strchr(PL_tokenbuf,':')) | |
5687 | yyerror(Perl_form(aTHX_ "No package name allowed for " | |
5688 | "variable %s in \"our\"", | |
5689 | PL_tokenbuf)); | |
dd2155a4 | 5690 | tmp = allocmy(PL_tokenbuf); |
8eceec63 SC |
5691 | } |
5692 | else { | |
5693 | if (strchr(PL_tokenbuf,':')) | |
5694 | yyerror(Perl_form(aTHX_ PL_no_myglob,PL_tokenbuf)); | |
5695 | ||
5696 | yylval.opval = newOP(OP_PADANY, 0); | |
dd2155a4 | 5697 | yylval.opval->op_targ = allocmy(PL_tokenbuf); |
8eceec63 SC |
5698 | return PRIVATEREF; |
5699 | } | |
5700 | } | |
5701 | ||
5702 | /* | |
5703 | build the ops for accesses to a my() variable. | |
5704 | ||
5705 | Deny my($a) or my($b) in a sort block, *if* $a or $b is | |
5706 | then used in a comparison. This catches most, but not | |
5707 | all cases. For instance, it catches | |
5708 | sort { my($a); $a <=> $b } | |
5709 | but not | |
5710 | sort { my($a); $a < $b ? -1 : $a == $b ? 0 : 1; } | |
5711 | (although why you'd do that is anyone's guess). | |
5712 | */ | |
5713 | ||
5714 | if (!strchr(PL_tokenbuf,':')) { | |
8716503d DM |
5715 | if (!PL_in_my) |
5716 | tmp = pad_findmy(PL_tokenbuf); | |
5717 | if (tmp != NOT_IN_PAD) { | |
8eceec63 | 5718 | /* might be an "our" variable" */ |
dd2155a4 | 5719 | if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { |
8eceec63 | 5720 | /* build ops for a bareword */ |
b64e5050 AL |
5721 | HV * const stash = PAD_COMPNAME_OURSTASH(tmp); |
5722 | HEK * const stashname = HvNAME_HEK(stash); | |
5723 | SV * const sym = newSVhek(stashname); | |
396482e1 | 5724 | sv_catpvs(sym, "::"); |
8eceec63 SC |
5725 | sv_catpv(sym, PL_tokenbuf+1); |
5726 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, sym); | |
5727 | yylval.opval->op_private = OPpCONST_ENTERED; | |
7a5fd60d | 5728 | gv_fetchsv(sym, |
8eceec63 SC |
5729 | (PL_in_eval |
5730 | ? (GV_ADDMULTI | GV_ADDINEVAL) | |
700078d2 | 5731 | : GV_ADDMULTI |
8eceec63 SC |
5732 | ), |
5733 | ((PL_tokenbuf[0] == '$') ? SVt_PV | |
5734 | : (PL_tokenbuf[0] == '@') ? SVt_PVAV | |
5735 | : SVt_PVHV)); | |
5736 | return WORD; | |
5737 | } | |
5738 | ||
5739 | /* if it's a sort block and they're naming $a or $b */ | |
5740 | if (PL_last_lop_op == OP_SORT && | |
5741 | PL_tokenbuf[0] == '$' && | |
5742 | (PL_tokenbuf[1] == 'a' || PL_tokenbuf[1] == 'b') | |
5743 | && !PL_tokenbuf[2]) | |
5744 | { | |
5745 | for (d = PL_in_eval ? PL_oldoldbufptr : PL_linestart; | |
5746 | d < PL_bufend && *d != '\n'; | |
5747 | d++) | |
5748 | { | |
5749 | if (strnEQ(d,"<=>",3) || strnEQ(d,"cmp",3)) { | |
5750 | Perl_croak(aTHX_ "Can't use \"my %s\" in sort comparison", | |
5751 | PL_tokenbuf); | |
5752 | } | |
5753 | } | |
5754 | } | |
5755 | ||
5756 | yylval.opval = newOP(OP_PADANY, 0); | |
5757 | yylval.opval->op_targ = tmp; | |
5758 | return PRIVATEREF; | |
5759 | } | |
5760 | } | |
5761 | ||
5762 | /* | |
5763 | Whine if they've said @foo in a doublequoted string, | |
5764 | and @foo isn't a variable we can find in the symbol | |
5765 | table. | |
5766 | */ | |
5767 | if (pit == '@' && PL_lex_state != LEX_NORMAL && !PL_lex_brackets) { | |
f776e3cd | 5768 | GV *gv = gv_fetchpv(PL_tokenbuf+1, 0, SVt_PVAV); |
8eceec63 SC |
5769 | if ((!gv || ((PL_tokenbuf[0] == '@') ? !GvAV(gv) : !GvHV(gv))) |
5770 | && ckWARN(WARN_AMBIGUOUS)) | |
5771 | { | |
5772 | /* Downgraded from fatal to warning 20000522 mjd */ | |
9014280d | 5773 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
8eceec63 SC |
5774 | "Possible unintended interpolation of %s in string", |
5775 | PL_tokenbuf); | |
5776 | } | |
5777 | } | |
5778 | ||
5779 | /* build ops for a bareword */ | |
5780 | yylval.opval = (OP*)newSVOP(OP_CONST, 0, newSVpv(PL_tokenbuf+1, 0)); | |
5781 | yylval.opval->op_private = OPpCONST_ENTERED; | |
adc51b97 RGS |
5782 | gv_fetchpv( |
5783 | PL_tokenbuf+1, | |
5784 | PL_in_eval | |
5785 | ? (GV_ADDMULTI | GV_ADDINEVAL) | |
76138434 NC |
5786 | /* If the identifier refers to a stash, don't autovivify it. |
5787 | * Change 24660 had the side effect of causing symbol table | |
5788 | * hashes to always be defined, even if they were freshly | |
5789 | * created and the only reference in the entire program was | |
5790 | * the single statement with the defined %foo::bar:: test. | |
5791 | * It appears that all code in the wild doing this actually | |
5792 | * wants to know whether sub-packages have been loaded, so | |
5793 | * by avoiding auto-vivifying symbol tables, we ensure that | |
5794 | * defined %foo::bar:: continues to be false, and the existing | |
5795 | * tests still give the expected answers, even though what | |
5796 | * they're actually testing has now changed subtly. | |
5797 | */ | |
adc51b97 RGS |
5798 | : !(*PL_tokenbuf == '%' && *(d = PL_tokenbuf + strlen(PL_tokenbuf) - 1) == ':' && d[-1] == ':'), |
5799 | ((PL_tokenbuf[0] == '$') ? SVt_PV | |
5800 | : (PL_tokenbuf[0] == '@') ? SVt_PVAV | |
5801 | : SVt_PVHV)); | |
8eceec63 SC |
5802 | return WORD; |
5803 | } | |
5804 | ||
4c3bbe0f MHM |
5805 | /* |
5806 | * The following code was generated by perl_keyword.pl. | |
5807 | */ | |
e2e1dd5a | 5808 | |
79072805 | 5809 | I32 |
672994ce | 5810 | Perl_keyword (pTHX_ const char *name, I32 len) |
4c3bbe0f MHM |
5811 | { |
5812 | switch (len) | |
5813 | { | |
5814 | case 1: /* 5 tokens of length 1 */ | |
5815 | switch (name[0]) | |
e2e1dd5a | 5816 | { |
4c3bbe0f MHM |
5817 | case 'm': |
5818 | { /* m */ | |
5819 | return KEY_m; | |
5820 | } | |
5821 | ||
4c3bbe0f MHM |
5822 | case 'q': |
5823 | { /* q */ | |
5824 | return KEY_q; | |
5825 | } | |
5826 | ||
4c3bbe0f MHM |
5827 | case 's': |
5828 | { /* s */ | |
5829 | return KEY_s; | |
5830 | } | |
5831 | ||
4c3bbe0f MHM |
5832 | case 'x': |
5833 | { /* x */ | |
5834 | return -KEY_x; | |
5835 | } | |
5836 | ||
4c3bbe0f MHM |
5837 | case 'y': |
5838 | { /* y */ | |
5839 | return KEY_y; | |
5840 | } | |
5841 | ||
4c3bbe0f MHM |
5842 | default: |
5843 | goto unknown; | |
e2e1dd5a | 5844 | } |
4c3bbe0f MHM |
5845 | |
5846 | case 2: /* 18 tokens of length 2 */ | |
5847 | switch (name[0]) | |
e2e1dd5a | 5848 | { |
4c3bbe0f MHM |
5849 | case 'd': |
5850 | if (name[1] == 'o') | |
5851 | { /* do */ | |
5852 | return KEY_do; | |
5853 | } | |
5854 | ||
5855 | goto unknown; | |
5856 | ||
5857 | case 'e': | |
5858 | if (name[1] == 'q') | |
5859 | { /* eq */ | |
5860 | return -KEY_eq; | |
5861 | } | |
5862 | ||
5863 | goto unknown; | |
5864 | ||
5865 | case 'g': | |
5866 | switch (name[1]) | |
5867 | { | |
5868 | case 'e': | |
5869 | { /* ge */ | |
5870 | return -KEY_ge; | |
5871 | } | |
5872 | ||
4c3bbe0f MHM |
5873 | case 't': |
5874 | { /* gt */ | |
5875 | return -KEY_gt; | |
5876 | } | |
5877 | ||
4c3bbe0f MHM |
5878 | default: |
5879 | goto unknown; | |
5880 | } | |
5881 | ||
5882 | case 'i': | |
5883 | if (name[1] == 'f') | |
5884 | { /* if */ | |
5885 | return KEY_if; | |
5886 | } | |
5887 | ||
5888 | goto unknown; | |
5889 | ||
5890 | case 'l': | |
5891 | switch (name[1]) | |
5892 | { | |
5893 | case 'c': | |
5894 | { /* lc */ | |
5895 | return -KEY_lc; | |
5896 | } | |
5897 | ||
4c3bbe0f MHM |
5898 | case 'e': |
5899 | { /* le */ | |
5900 | return -KEY_le; | |
5901 | } | |
5902 | ||
4c3bbe0f MHM |
5903 | case 't': |
5904 | { /* lt */ | |
5905 | return -KEY_lt; | |
5906 | } | |
5907 | ||
4c3bbe0f MHM |
5908 | default: |
5909 | goto unknown; | |
5910 | } | |
5911 | ||
5912 | case 'm': | |
5913 | if (name[1] == 'y') | |
5914 | { /* my */ | |
5915 | return KEY_my; | |
5916 | } | |
5917 | ||
5918 | goto unknown; | |
5919 | ||
5920 | case 'n': | |
5921 | switch (name[1]) | |
5922 | { | |
5923 | case 'e': | |
5924 | { /* ne */ | |
5925 | return -KEY_ne; | |
5926 | } | |
5927 | ||
4c3bbe0f MHM |
5928 | case 'o': |
5929 | { /* no */ | |
5930 | return KEY_no; | |
5931 | } | |
5932 | ||
4c3bbe0f MHM |
5933 | default: |
5934 | goto unknown; | |
5935 | } | |
5936 | ||
5937 | case 'o': | |
5938 | if (name[1] == 'r') | |
5939 | { /* or */ | |
5940 | return -KEY_or; | |
5941 | } | |
5942 | ||
5943 | goto unknown; | |
5944 | ||
5945 | case 'q': | |
5946 | switch (name[1]) | |
5947 | { | |
5948 | case 'q': | |
5949 | { /* qq */ | |
5950 | return KEY_qq; | |
5951 | } | |
5952 | ||
4c3bbe0f MHM |
5953 | case 'r': |
5954 | { /* qr */ | |
5955 | return KEY_qr; | |
5956 | } | |
5957 | ||
4c3bbe0f MHM |
5958 | case 'w': |
5959 | { /* qw */ | |
5960 | return KEY_qw; | |
5961 | } | |
5962 | ||
4c3bbe0f MHM |
5963 | case 'x': |
5964 | { /* qx */ | |
5965 | return KEY_qx; | |
5966 | } | |
5967 | ||
4c3bbe0f MHM |
5968 | default: |
5969 | goto unknown; | |
5970 | } | |
5971 | ||
5972 | case 't': | |
5973 | if (name[1] == 'r') | |
5974 | { /* tr */ | |
5975 | return KEY_tr; | |
5976 | } | |
5977 | ||
5978 | goto unknown; | |
5979 | ||
5980 | case 'u': | |
5981 | if (name[1] == 'c') | |
5982 | { /* uc */ | |
5983 | return -KEY_uc; | |
5984 | } | |
5985 | ||
5986 | goto unknown; | |
5987 | ||
5988 | default: | |
5989 | goto unknown; | |
e2e1dd5a | 5990 | } |
4c3bbe0f | 5991 | |
0d863452 | 5992 | case 3: /* 29 tokens of length 3 */ |
4c3bbe0f | 5993 | switch (name[0]) |
e2e1dd5a | 5994 | { |
4c3bbe0f MHM |
5995 | case 'E': |
5996 | if (name[1] == 'N' && | |
5997 | name[2] == 'D') | |
5998 | { /* END */ | |
5999 | return KEY_END; | |
6000 | } | |
6001 | ||
6002 | goto unknown; | |
6003 | ||
6004 | case 'a': | |
6005 | switch (name[1]) | |
6006 | { | |
6007 | case 'b': | |
6008 | if (name[2] == 's') | |
6009 | { /* abs */ | |
6010 | return -KEY_abs; | |
6011 | } | |
6012 | ||
6013 | goto unknown; | |
6014 | ||
6015 | case 'n': | |
6016 | if (name[2] == 'd') | |
6017 | { /* and */ | |
6018 | return -KEY_and; | |
6019 | } | |
6020 | ||
6021 | goto unknown; | |
6022 | ||
6023 | default: | |
6024 | goto unknown; | |
6025 | } | |
6026 | ||
6027 | case 'c': | |
6028 | switch (name[1]) | |
6029 | { | |
6030 | case 'h': | |
6031 | if (name[2] == 'r') | |
6032 | { /* chr */ | |
6033 | return -KEY_chr; | |
6034 | } | |
6035 | ||
6036 | goto unknown; | |
6037 | ||
6038 | case 'm': | |
6039 | if (name[2] == 'p') | |
6040 | { /* cmp */ | |
6041 | return -KEY_cmp; | |
6042 | } | |
6043 | ||
6044 | goto unknown; | |
6045 | ||
6046 | case 'o': | |
6047 | if (name[2] == 's') | |
6048 | { /* cos */ | |
6049 | return -KEY_cos; | |
6050 | } | |
6051 | ||
6052 | goto unknown; | |
6053 | ||
6054 | default: | |
6055 | goto unknown; | |
6056 | } | |
6057 | ||
6058 | case 'd': | |
6059 | if (name[1] == 'i' && | |
6060 | name[2] == 'e') | |
6061 | { /* die */ | |
6062 | return -KEY_die; | |
6063 | } | |
6064 | ||
6065 | goto unknown; | |
6066 | ||
6067 | case 'e': | |
6068 | switch (name[1]) | |
6069 | { | |
6070 | case 'o': | |
6071 | if (name[2] == 'f') | |
6072 | { /* eof */ | |
6073 | return -KEY_eof; | |
6074 | } | |
6075 | ||
6076 | goto unknown; | |
6077 | ||
6078 | case 'r': | |
6079 | if (name[2] == 'r') | |
6080 | { /* err */ | |
ef89dcc3 | 6081 | return (FEATURE_IS_ENABLED("err") ? -KEY_err : 0); |
4c3bbe0f MHM |
6082 | } |
6083 | ||
6084 | goto unknown; | |
6085 | ||
6086 | case 'x': | |
6087 | if (name[2] == 'p') | |
6088 | { /* exp */ | |
6089 | return -KEY_exp; | |
6090 | } | |
6091 | ||
6092 | goto unknown; | |
6093 | ||
6094 | default: | |
6095 | goto unknown; | |
6096 | } | |
6097 | ||
6098 | case 'f': | |
6099 | if (name[1] == 'o' && | |
6100 | name[2] == 'r') | |
6101 | { /* for */ | |
6102 | return KEY_for; | |
6103 | } | |
6104 | ||
6105 | goto unknown; | |
6106 | ||
6107 | case 'h': | |
6108 | if (name[1] == 'e' && | |
6109 | name[2] == 'x') | |
6110 | { /* hex */ | |
6111 | return -KEY_hex; | |
6112 | } | |
6113 | ||
6114 | goto unknown; | |
6115 | ||
6116 | case 'i': | |
6117 | if (name[1] == 'n' && | |
6118 | name[2] == 't') | |
6119 | { /* int */ | |
6120 | return -KEY_int; | |
6121 | } | |
6122 | ||
6123 | goto unknown; | |
6124 | ||
6125 | case 'l': | |
6126 | if (name[1] == 'o' && | |
6127 | name[2] == 'g') | |
6128 | { /* log */ | |
6129 | return -KEY_log; | |
6130 | } | |
6131 | ||
6132 | goto unknown; | |
6133 | ||
6134 | case 'm': | |
6135 | if (name[1] == 'a' && | |
6136 | name[2] == 'p') | |
6137 | { /* map */ | |
6138 | return KEY_map; | |
6139 | } | |
6140 | ||
6141 | goto unknown; | |
6142 | ||
6143 | case 'n': | |
6144 | if (name[1] == 'o' && | |
6145 | name[2] == 't') | |
6146 | { /* not */ | |
6147 | return -KEY_not; | |
6148 | } | |
6149 | ||
6150 | goto unknown; | |
6151 | ||
6152 | case 'o': | |
6153 | switch (name[1]) | |
6154 | { | |
6155 | case 'c': | |
6156 | if (name[2] == 't') | |
6157 | { /* oct */ | |
6158 | return -KEY_oct; | |
6159 | } | |
6160 | ||
6161 | goto unknown; | |
6162 | ||
6163 | case 'r': | |
6164 | if (name[2] == 'd') | |
6165 | { /* ord */ | |
6166 | return -KEY_ord; | |
6167 | } | |
6168 | ||
6169 | goto unknown; | |
6170 | ||
6171 | case 'u': | |
6172 | if (name[2] == 'r') | |
6173 | { /* our */ | |
6174 | return KEY_our; | |
6175 | } | |
6176 | ||
6177 | goto unknown; | |
6178 | ||
6179 | default: | |
6180 | goto unknown; | |
6181 | } | |
6182 | ||
6183 | case 'p': | |
6184 | if (name[1] == 'o') | |
6185 | { | |
6186 | switch (name[2]) | |
6187 | { | |
6188 | case 'p': | |
6189 | { /* pop */ | |
6190 | return -KEY_pop; | |
6191 | } | |
6192 | ||
4c3bbe0f MHM |
6193 | case 's': |
6194 | { /* pos */ | |
6195 | return KEY_pos; | |
6196 | } | |
6197 | ||
4c3bbe0f MHM |
6198 | default: |
6199 | goto unknown; | |
6200 | } | |
6201 | } | |
6202 | ||
6203 | goto unknown; | |
6204 | ||
6205 | case 'r': | |
6206 | if (name[1] == 'e' && | |
6207 | name[2] == 'f') | |
6208 | { /* ref */ | |
6209 | return -KEY_ref; | |
6210 | } | |
6211 | ||
6212 | goto unknown; | |
6213 | ||
6214 | case 's': | |
6215 | switch (name[1]) | |
6216 | { | |
0d863452 RH |
6217 | case 'a': |
6218 | if (name[2] == 'y') | |
6219 | { /* say */ | |
ef89dcc3 | 6220 | return (FEATURE_IS_ENABLED("say") ? -KEY_say : 0); |
0d863452 RH |
6221 | } |
6222 | ||
6223 | goto unknown; | |
6224 | ||
4c3bbe0f MHM |
6225 | case 'i': |
6226 | if (name[2] == 'n') | |
6227 | { /* sin */ | |
6228 | return -KEY_sin; | |
6229 | } | |
6230 | ||
6231 | goto unknown; | |
6232 | ||
6233 | case 'u': | |
6234 | if (name[2] == 'b') | |
6235 | { /* sub */ | |
6236 | return KEY_sub; | |
6237 | } | |
6238 | ||
6239 | goto unknown; | |
6240 | ||
6241 | default: | |
6242 | goto unknown; | |
6243 | } | |
6244 | ||
6245 | case 't': | |
6246 | if (name[1] == 'i' && | |
6247 | name[2] == 'e') | |
6248 | { /* tie */ | |
6249 | return KEY_tie; | |
6250 | } | |
6251 | ||
6252 | goto unknown; | |
6253 | ||
6254 | case 'u': | |
6255 | if (name[1] == 's' && | |
6256 | name[2] == 'e') | |
6257 | { /* use */ | |
6258 | return KEY_use; | |
6259 | } | |
6260 | ||
6261 | goto unknown; | |
6262 | ||
6263 | case 'v': | |
6264 | if (name[1] == 'e' && | |
6265 | name[2] == 'c') | |
6266 | { /* vec */ | |
6267 | return -KEY_vec; | |
6268 | } | |
6269 | ||
6270 | goto unknown; | |
6271 | ||
6272 | case 'x': | |
6273 | if (name[1] == 'o' && | |
6274 | name[2] == 'r') | |
6275 | { /* xor */ | |
6276 | return -KEY_xor; | |
6277 | } | |
6278 | ||
6279 | goto unknown; | |
6280 | ||
6281 | default: | |
6282 | goto unknown; | |
e2e1dd5a | 6283 | } |
4c3bbe0f | 6284 | |
0d863452 | 6285 | case 4: /* 41 tokens of length 4 */ |
4c3bbe0f | 6286 | switch (name[0]) |
e2e1dd5a | 6287 | { |
4c3bbe0f MHM |
6288 | case 'C': |
6289 | if (name[1] == 'O' && | |
6290 | name[2] == 'R' && | |
6291 | name[3] == 'E') | |
6292 | { /* CORE */ | |
6293 | return -KEY_CORE; | |
6294 | } | |
6295 | ||
6296 | goto unknown; | |
6297 | ||
6298 | case 'I': | |
6299 | if (name[1] == 'N' && | |
6300 | name[2] == 'I' && | |
6301 | name[3] == 'T') | |
6302 | { /* INIT */ | |
6303 | return KEY_INIT; | |
6304 | } | |
6305 | ||
6306 | goto unknown; | |
6307 | ||
6308 | case 'b': | |
6309 | if (name[1] == 'i' && | |
6310 | name[2] == 'n' && | |
6311 | name[3] == 'd') | |
6312 | { /* bind */ | |
6313 | return -KEY_bind; | |
6314 | } | |
6315 | ||
6316 | goto unknown; | |
6317 | ||
6318 | case 'c': | |
6319 | if (name[1] == 'h' && | |
6320 | name[2] == 'o' && | |
6321 | name[3] == 'p') | |
6322 | { /* chop */ | |
6323 | return -KEY_chop; | |
6324 | } | |
6325 | ||
6326 | goto unknown; | |
6327 | ||
6328 | case 'd': | |
6329 | if (name[1] == 'u' && | |
6330 | name[2] == 'm' && | |
6331 | name[3] == 'p') | |
6332 | { /* dump */ | |
6333 | return -KEY_dump; | |
6334 | } | |
6335 | ||
6336 | goto unknown; | |
6337 | ||
6338 | case 'e': | |
6339 | switch (name[1]) | |
6340 | { | |
6341 | case 'a': | |
6342 | if (name[2] == 'c' && | |
6343 | name[3] == 'h') | |
6344 | { /* each */ | |
6345 | return -KEY_each; | |
6346 | } | |
6347 | ||
6348 | goto unknown; | |
6349 | ||
6350 | case 'l': | |
6351 | if (name[2] == 's' && | |
6352 | name[3] == 'e') | |
6353 | { /* else */ | |
6354 | return KEY_else; | |
6355 | } | |
6356 | ||
6357 | goto unknown; | |
6358 | ||
6359 | case 'v': | |
6360 | if (name[2] == 'a' && | |
6361 | name[3] == 'l') | |
6362 | { /* eval */ | |
6363 | return KEY_eval; | |
6364 | } | |
6365 | ||
6366 | goto unknown; | |
6367 | ||
6368 | case 'x': | |
6369 | switch (name[2]) | |
6370 | { | |
6371 | case 'e': | |
6372 | if (name[3] == 'c') | |
6373 | { /* exec */ | |
6374 | return -KEY_exec; | |
6375 | } | |
6376 | ||
6377 | goto unknown; | |
6378 | ||
6379 | case 'i': | |
6380 | if (name[3] == 't') | |
6381 | { /* exit */ | |
6382 | return -KEY_exit; | |
6383 | } | |
6384 | ||
6385 | goto unknown; | |
6386 | ||
6387 | default: | |
6388 | goto unknown; | |
6389 | } | |
6390 | ||
6391 | default: | |
6392 | goto unknown; | |
6393 | } | |
6394 | ||
6395 | case 'f': | |
6396 | if (name[1] == 'o' && | |
6397 | name[2] == 'r' && | |
6398 | name[3] == 'k') | |
6399 | { /* fork */ | |
6400 | return -KEY_fork; | |
6401 | } | |
6402 | ||
6403 | goto unknown; | |
6404 | ||
6405 | case 'g': | |
6406 | switch (name[1]) | |
6407 | { | |
6408 | case 'e': | |
6409 | if (name[2] == 't' && | |
6410 | name[3] == 'c') | |
6411 | { /* getc */ | |
6412 | return -KEY_getc; | |
6413 | } | |
6414 | ||
6415 | goto unknown; | |
6416 | ||
6417 | case 'l': | |
6418 | if (name[2] == 'o' && | |
6419 | name[3] == 'b') | |
6420 | { /* glob */ | |
6421 | return KEY_glob; | |
6422 | } | |
6423 | ||
6424 | goto unknown; | |
6425 | ||
6426 | case 'o': | |
6427 | if (name[2] == 't' && | |
6428 | name[3] == 'o') | |
6429 | { /* goto */ | |
6430 | return KEY_goto; | |
6431 | } | |
6432 | ||
6433 | goto unknown; | |
6434 | ||
6435 | case 'r': | |
6436 | if (name[2] == 'e' && | |
6437 | name[3] == 'p') | |
6438 | { /* grep */ | |
6439 | return KEY_grep; | |
6440 | } | |
6441 | ||
6442 | goto unknown; | |
6443 | ||
6444 | default: | |
6445 | goto unknown; | |
6446 | } | |
6447 | ||
6448 | case 'j': | |
6449 | if (name[1] == 'o' && | |
6450 | name[2] == 'i' && | |
6451 | name[3] == 'n') | |
6452 | { /* join */ | |
6453 | return -KEY_join; | |
6454 | } | |
6455 | ||
6456 | goto unknown; | |
6457 | ||
6458 | case 'k': | |
6459 | switch (name[1]) | |
6460 | { | |
6461 | case 'e': | |
6462 | if (name[2] == 'y' && | |
6463 | name[3] == 's') | |
6464 | { /* keys */ | |
6465 | return -KEY_keys; | |
6466 | } | |
6467 | ||
6468 | goto unknown; | |
6469 | ||
6470 | case 'i': | |
6471 | if (name[2] == 'l' && | |
6472 | name[3] == 'l') | |
6473 | { /* kill */ | |
6474 | return -KEY_kill; | |
6475 | } | |
6476 | ||
6477 | goto unknown; | |
6478 | ||
6479 | default: | |
6480 | goto unknown; | |
6481 | } | |
6482 | ||
6483 | case 'l': | |
6484 | switch (name[1]) | |
6485 | { | |
6486 | case 'a': | |
6487 | if (name[2] == 's' && | |
6488 | name[3] == 't') | |
6489 | { /* last */ | |
6490 | return KEY_last; | |
6491 | } | |
6492 | ||
6493 | goto unknown; | |
6494 | ||
6495 | case 'i': | |
6496 | if (name[2] == 'n' && | |
6497 | name[3] == 'k') | |
6498 | { /* link */ | |
6499 | return -KEY_link; | |
6500 | } | |
6501 | ||
6502 | goto unknown; | |
6503 | ||
6504 | case 'o': | |
6505 | if (name[2] == 'c' && | |
6506 | name[3] == 'k') | |
6507 | { /* lock */ | |
6508 | return -KEY_lock; | |
6509 | } | |
6510 | ||
6511 | goto unknown; | |
6512 | ||
6513 | default: | |
6514 | goto unknown; | |
6515 | } | |
6516 | ||
6517 | case 'n': | |
6518 | if (name[1] == 'e' && | |
6519 | name[2] == 'x' && | |
6520 | name[3] == 't') | |
6521 | { /* next */ | |
6522 | return KEY_next; | |
6523 | } | |
6524 | ||
6525 | goto unknown; | |
6526 | ||
6527 | case 'o': | |
6528 | if (name[1] == 'p' && | |
6529 | name[2] == 'e' && | |
6530 | name[3] == 'n') | |
6531 | { /* open */ | |
6532 | return -KEY_open; | |
6533 | } | |
6534 | ||
6535 | goto unknown; | |
6536 | ||
6537 | case 'p': | |
6538 | switch (name[1]) | |
6539 | { | |
6540 | case 'a': | |
6541 | if (name[2] == 'c' && | |
6542 | name[3] == 'k') | |
6543 | { /* pack */ | |
6544 | return -KEY_pack; | |
6545 | } | |
6546 | ||
6547 | goto unknown; | |
6548 | ||
6549 | case 'i': | |
6550 | if (name[2] == 'p' && | |
6551 | name[3] == 'e') | |
6552 | { /* pipe */ | |
6553 | return -KEY_pipe; | |
6554 | } | |
6555 | ||
6556 | goto unknown; | |
6557 | ||
6558 | case 'u': | |
6559 | if (name[2] == 's' && | |
6560 | name[3] == 'h') | |
6561 | { /* push */ | |
6562 | return -KEY_push; | |
6563 | } | |
6564 | ||
6565 | goto unknown; | |
6566 | ||
6567 | default: | |
6568 | goto unknown; | |
6569 | } | |
6570 | ||
6571 | case 'r': | |
6572 | switch (name[1]) | |
6573 | { | |
6574 | case 'a': | |
6575 | if (name[2] == 'n' && | |
6576 | name[3] == 'd') | |
6577 | { /* rand */ | |
6578 | return -KEY_rand; | |
6579 | } | |
6580 | ||
6581 | goto unknown; | |
6582 | ||
6583 | case 'e': | |
6584 | switch (name[2]) | |
6585 | { | |
6586 | case 'a': | |
6587 | if (name[3] == 'd') | |
6588 | { /* read */ | |
6589 | return -KEY_read; | |
6590 | } | |
6591 | ||
6592 | goto unknown; | |
6593 | ||
6594 | case 'c': | |
6595 | if (name[3] == 'v') | |
6596 | { /* recv */ | |
6597 | return -KEY_recv; | |
6598 | } | |
6599 | ||
6600 | goto unknown; | |
6601 | ||
6602 | case 'd': | |
6603 | if (name[3] == 'o') | |
6604 | { /* redo */ | |
6605 | return KEY_redo; | |
6606 | } | |
6607 | ||
6608 | goto unknown; | |
6609 | ||
6610 | default: | |
6611 | goto unknown; | |
6612 | } | |
6613 | ||
6614 | default: | |
6615 | goto unknown; | |
6616 | } | |
6617 | ||
6618 | case 's': | |
6619 | switch (name[1]) | |
6620 | { | |
6621 | case 'e': | |
6622 | switch (name[2]) | |
6623 | { | |
6624 | case 'e': | |
6625 | if (name[3] == 'k') | |
6626 | { /* seek */ | |
6627 | return -KEY_seek; | |
6628 | } | |
6629 | ||
6630 | goto unknown; | |
6631 | ||
6632 | case 'n': | |
6633 | if (name[3] == 'd') | |
6634 | { /* send */ | |
6635 | return -KEY_send; | |
6636 | } | |
6637 | ||
6638 | goto unknown; | |
6639 | ||
6640 | default: | |
6641 | goto unknown; | |
6642 | } | |
6643 | ||
6644 | case 'o': | |
6645 | if (name[2] == 'r' && | |
6646 | name[3] == 't') | |
6647 | { /* sort */ | |
6648 | return KEY_sort; | |
6649 | } | |
6650 | ||
6651 | goto unknown; | |
6652 | ||
6653 | case 'q': | |
6654 | if (name[2] == 'r' && | |
6655 | name[3] == 't') | |
6656 | { /* sqrt */ | |
6657 | return -KEY_sqrt; | |
6658 | } | |
6659 | ||
6660 | goto unknown; | |
6661 | ||
6662 | case 't': | |
6663 | if (name[2] == 'a' && | |
6664 | name[3] == 't') | |
6665 | { /* stat */ | |
6666 | return -KEY_stat; | |
6667 | } | |
6668 | ||
6669 | goto unknown; | |
6670 | ||
6671 | default: | |
6672 | goto unknown; | |
6673 | } | |
6674 | ||
6675 | case 't': | |
6676 | switch (name[1]) | |
6677 | { | |
6678 | case 'e': | |
6679 | if (name[2] == 'l' && | |
6680 | name[3] == 'l') | |
6681 | { /* tell */ | |
6682 | return -KEY_tell; | |
6683 | } | |
6684 | ||
6685 | goto unknown; | |
6686 | ||
6687 | case 'i': | |
6688 | switch (name[2]) | |
6689 | { | |
6690 | case 'e': | |
6691 | if (name[3] == 'd') | |
6692 | { /* tied */ | |
6693 | return KEY_tied; | |
6694 | } | |
6695 | ||
6696 | goto unknown; | |
6697 | ||
6698 | case 'm': | |
6699 | if (name[3] == 'e') | |
6700 | { /* time */ | |
6701 | return -KEY_time; | |
6702 | } | |
6703 | ||
6704 | goto unknown; | |
6705 | ||
6706 | default: | |
6707 | goto unknown; | |
6708 | } | |
6709 | ||
6710 | default: | |
6711 | goto unknown; | |
6712 | } | |
6713 | ||
6714 | case 'w': | |
0d863452 | 6715 | switch (name[1]) |
4c3bbe0f | 6716 | { |
0d863452 | 6717 | case 'a': |
4c3bbe0f MHM |
6718 | switch (name[2]) |
6719 | { | |
6720 | case 'i': | |
6721 | if (name[3] == 't') | |
6722 | { /* wait */ | |
6723 | return -KEY_wait; | |
6724 | } | |
6725 | ||
6726 | goto unknown; | |
6727 | ||
6728 | case 'r': | |
6729 | if (name[3] == 'n') | |
6730 | { /* warn */ | |
6731 | return -KEY_warn; | |
6732 | } | |
6733 | ||
6734 | goto unknown; | |
6735 | ||
6736 | default: | |
6737 | goto unknown; | |
6738 | } | |
0d863452 RH |
6739 | |
6740 | case 'h': | |
6741 | if (name[2] == 'e' && | |
6742 | name[3] == 'n') | |
6743 | { /* when */ | |
ef89dcc3 | 6744 | return (FEATURE_IS_ENABLED("switch") ? KEY_when : 0); |
4c3bbe0f MHM |
6745 | } |
6746 | ||
6747 | goto unknown; | |
6748 | ||
6749 | default: | |
6750 | goto unknown; | |
e2e1dd5a | 6751 | } |
4c3bbe0f | 6752 | |
0d863452 RH |
6753 | default: |
6754 | goto unknown; | |
6755 | } | |
6756 | ||
6757 | case 5: /* 38 tokens of length 5 */ | |
4c3bbe0f | 6758 | switch (name[0]) |
e2e1dd5a | 6759 | { |
4c3bbe0f MHM |
6760 | case 'B': |
6761 | if (name[1] == 'E' && | |
6762 | name[2] == 'G' && | |
6763 | name[3] == 'I' && | |
6764 | name[4] == 'N') | |
6765 | { /* BEGIN */ | |
6766 | return KEY_BEGIN; | |
6767 | } | |
6768 | ||
6769 | goto unknown; | |
6770 | ||
6771 | case 'C': | |
6772 | if (name[1] == 'H' && | |
6773 | name[2] == 'E' && | |
6774 | name[3] == 'C' && | |
6775 | name[4] == 'K') | |
6776 | { /* CHECK */ | |
6777 | return KEY_CHECK; | |
6778 | } | |
6779 | ||
6780 | goto unknown; | |
6781 | ||
6782 | case 'a': | |
6783 | switch (name[1]) | |
6784 | { | |
6785 | case 'l': | |
6786 | if (name[2] == 'a' && | |
6787 | name[3] == 'r' && | |
6788 | name[4] == 'm') | |
6789 | { /* alarm */ | |
6790 | return -KEY_alarm; | |
6791 | } | |
6792 | ||
6793 | goto unknown; | |
6794 | ||
6795 | case 't': | |
6796 | if (name[2] == 'a' && | |
6797 | name[3] == 'n' && | |
6798 | name[4] == '2') | |
6799 | { /* atan2 */ | |
6800 | return -KEY_atan2; | |
6801 | } | |
6802 | ||
6803 | goto unknown; | |
6804 | ||
6805 | default: | |
6806 | goto unknown; | |
6807 | } | |
6808 | ||
6809 | case 'b': | |
0d863452 RH |
6810 | switch (name[1]) |
6811 | { | |
6812 | case 'l': | |
6813 | if (name[2] == 'e' && | |
4c3bbe0f MHM |
6814 | name[3] == 's' && |
6815 | name[4] == 's') | |
6816 | { /* bless */ | |
6817 | return -KEY_bless; | |
6818 | } | |
6819 | ||
6820 | goto unknown; | |
6821 | ||
0d863452 RH |
6822 | case 'r': |
6823 | if (name[2] == 'e' && | |
6824 | name[3] == 'a' && | |
6825 | name[4] == 'k') | |
6826 | { /* break */ | |
ef89dcc3 | 6827 | return (FEATURE_IS_ENABLED("switch") ? -KEY_break : 0); |
0d863452 RH |
6828 | } |
6829 | ||
6830 | goto unknown; | |
6831 | ||
6832 | default: | |
6833 | goto unknown; | |
6834 | } | |
6835 | ||
4c3bbe0f MHM |
6836 | case 'c': |
6837 | switch (name[1]) | |
6838 | { | |
6839 | case 'h': | |
6840 | switch (name[2]) | |
6841 | { | |
6842 | case 'd': | |
6843 | if (name[3] == 'i' && | |
6844 | name[4] == 'r') | |
6845 | { /* chdir */ | |
6846 | return -KEY_chdir; | |
6847 | } | |
6848 | ||
6849 | goto unknown; | |
6850 | ||
6851 | case 'm': | |
6852 | if (name[3] == 'o' && | |
6853 | name[4] == 'd') | |
6854 | { /* chmod */ | |
6855 | return -KEY_chmod; | |
6856 | } | |
6857 | ||
6858 | goto unknown; | |
6859 | ||
6860 | case 'o': | |
6861 | switch (name[3]) | |
6862 | { | |
6863 | case 'm': | |
6864 | if (name[4] == 'p') | |
6865 | { /* chomp */ | |
6866 | return -KEY_chomp; | |
6867 | } | |
6868 | ||
6869 | goto unknown; | |
6870 | ||
6871 | case 'w': | |
6872 | if (name[4] == 'n') | |
6873 | { /* chown */ | |
6874 | return -KEY_chown; | |
6875 | } | |
6876 | ||
6877 | goto unknown; | |
6878 | ||
6879 | default: | |
6880 | goto unknown; | |
6881 | } | |
6882 | ||
6883 | default: | |
6884 | goto unknown; | |
6885 | } | |
6886 | ||
6887 | case 'l': | |
6888 | if (name[2] == 'o' && | |
6889 | name[3] == 's' && | |
6890 | name[4] == 'e') | |
6891 | { /* close */ | |
6892 | return -KEY_close; | |
6893 | } | |
6894 | ||
6895 | goto unknown; | |
6896 | ||
6897 | case 'r': | |
6898 | if (name[2] == 'y' && | |
6899 | name[3] == 'p' && | |
6900 | name[4] == 't') | |
6901 | { /* crypt */ | |
6902 | return -KEY_crypt; | |
6903 | } | |
6904 | ||
6905 | goto unknown; | |
6906 | ||
6907 | default: | |
6908 | goto unknown; | |
6909 | } | |
6910 | ||
6911 | case 'e': | |
6912 | if (name[1] == 'l' && | |
6913 | name[2] == 's' && | |
6914 | name[3] == 'i' && | |
6915 | name[4] == 'f') | |
6916 | { /* elsif */ | |
6917 | return KEY_elsif; | |
6918 | } | |
6919 | ||
6920 | goto unknown; | |
6921 | ||
6922 | case 'f': | |
6923 | switch (name[1]) | |
6924 | { | |
6925 | case 'c': | |
6926 | if (name[2] == 'n' && | |
6927 | name[3] == 't' && | |
6928 | name[4] == 'l') | |
6929 | { /* fcntl */ | |
6930 | return -KEY_fcntl; | |
6931 | } | |
6932 | ||
6933 | goto unknown; | |
6934 | ||
6935 | case 'l': | |
6936 | if (name[2] == 'o' && | |
6937 | name[3] == 'c' && | |
6938 | name[4] == 'k') | |
6939 | { /* flock */ | |
6940 | return -KEY_flock; | |
6941 | } | |
6942 | ||
6943 | goto unknown; | |
6944 | ||
6945 | default: | |
6946 | goto unknown; | |
6947 | } | |
6948 | ||
0d863452 RH |
6949 | case 'g': |
6950 | if (name[1] == 'i' && | |
6951 | name[2] == 'v' && | |
6952 | name[3] == 'e' && | |
6953 | name[4] == 'n') | |
6954 | { /* given */ | |
ef89dcc3 | 6955 | return (FEATURE_IS_ENABLED("switch") ? KEY_given : 0); |
0d863452 RH |
6956 | } |
6957 | ||
6958 | goto unknown; | |
6959 | ||
4c3bbe0f MHM |
6960 | case 'i': |
6961 | switch (name[1]) | |
6962 | { | |
6963 | case 'n': | |
6964 | if (name[2] == 'd' && | |
6965 | name[3] == 'e' && | |
6966 | name[4] == 'x') | |
6967 | { /* index */ | |
6968 | return -KEY_index; | |
6969 | } | |
6970 | ||
6971 | goto unknown; | |
6972 | ||
6973 | case 'o': | |
6974 | if (name[2] == 'c' && | |
6975 | name[3] == 't' && | |
6976 | name[4] == 'l') | |
6977 | { /* ioctl */ | |
6978 | return -KEY_ioctl; | |
6979 | } | |
6980 | ||
6981 | goto unknown; | |
6982 | ||
6983 | default: | |
6984 | goto unknown; | |
6985 | } | |
6986 | ||
6987 | case 'l': | |
6988 | switch (name[1]) | |
6989 | { | |
6990 | case 'o': | |
6991 | if (name[2] == 'c' && | |
6992 | name[3] == 'a' && | |
6993 | name[4] == 'l') | |
6994 | { /* local */ | |
6995 | return KEY_local; | |
6996 | } | |
6997 | ||
6998 | goto unknown; | |
6999 | ||
7000 | case 's': | |
7001 | if (name[2] == 't' && | |
7002 | name[3] == 'a' && | |
7003 | name[4] == 't') | |
7004 | { /* lstat */ | |
7005 | return -KEY_lstat; | |
7006 | } | |
7007 | ||
7008 | goto unknown; | |
7009 | ||
7010 | default: | |
7011 | goto unknown; | |
7012 | } | |
7013 | ||
7014 | case 'm': | |
7015 | if (name[1] == 'k' && | |
7016 | name[2] == 'd' && | |
7017 | name[3] == 'i' && | |
7018 | name[4] == 'r') | |
7019 | { /* mkdir */ | |
7020 | return -KEY_mkdir; | |
7021 | } | |
7022 | ||
7023 | goto unknown; | |
7024 | ||
7025 | case 'p': | |
7026 | if (name[1] == 'r' && | |
7027 | name[2] == 'i' && | |
7028 | name[3] == 'n' && | |
7029 | name[4] == 't') | |
7030 | { /* print */ | |
7031 | return KEY_print; | |
7032 | } | |
7033 | ||
7034 | goto unknown; | |
7035 | ||
7036 | case 'r': | |
7037 | switch (name[1]) | |
7038 | { | |
7039 | case 'e': | |
7040 | if (name[2] == 's' && | |
7041 | name[3] == 'e' && | |
7042 | name[4] == 't') | |
7043 | { /* reset */ | |
7044 | return -KEY_reset; | |
7045 | } | |
7046 | ||
7047 | goto unknown; | |
7048 | ||
7049 | case 'm': | |
7050 | if (name[2] == 'd' && | |
7051 | name[3] == 'i' && | |
7052 | name[4] == 'r') | |
7053 | { /* rmdir */ | |
7054 | return -KEY_rmdir; | |
7055 | } | |
7056 | ||
7057 | goto unknown; | |
7058 | ||
7059 | default: | |
7060 | goto unknown; | |
7061 | } | |
7062 | ||
7063 | case 's': | |
7064 | switch (name[1]) | |
7065 | { | |
7066 | case 'e': | |
7067 | if (name[2] == 'm' && | |
7068 | name[3] == 'o' && | |
7069 | name[4] == 'p') | |
7070 | { /* semop */ | |
7071 | return -KEY_semop; | |
7072 | } | |
7073 | ||
7074 | goto unknown; | |
7075 | ||
7076 | case 'h': | |
7077 | if (name[2] == 'i' && | |
7078 | name[3] == 'f' && | |
7079 | name[4] == 't') | |
7080 | { /* shift */ | |
7081 | return -KEY_shift; | |
7082 | } | |
7083 | ||
7084 | goto unknown; | |
7085 | ||
7086 | case 'l': | |
7087 | if (name[2] == 'e' && | |
7088 | name[3] == 'e' && | |
7089 | name[4] == 'p') | |
7090 | { /* sleep */ | |
7091 | return -KEY_sleep; | |
7092 | } | |
7093 | ||
7094 | goto unknown; | |
7095 | ||
7096 | case 'p': | |
7097 | if (name[2] == 'l' && | |
7098 | name[3] == 'i' && | |
7099 | name[4] == 't') | |
7100 | { /* split */ | |
7101 | return KEY_split; | |
7102 | } | |
7103 | ||
7104 | goto unknown; | |
7105 | ||
7106 | case 'r': | |
7107 | if (name[2] == 'a' && | |
7108 | name[3] == 'n' && | |
7109 | name[4] == 'd') | |
7110 | { /* srand */ | |
7111 | return -KEY_srand; | |
7112 | } | |
7113 | ||
7114 | goto unknown; | |
7115 | ||
7116 | case 't': | |
7117 | if (name[2] == 'u' && | |
7118 | name[3] == 'd' && | |
7119 | name[4] == 'y') | |
7120 | { /* study */ | |
7121 | return KEY_study; | |
7122 | } | |
7123 | ||
7124 | goto unknown; | |
7125 | ||
7126 | default: | |
7127 | goto unknown; | |
7128 | } | |
7129 | ||
7130 | case 't': | |
7131 | if (name[1] == 'i' && | |
7132 | name[2] == 'm' && | |
7133 | name[3] == 'e' && | |
7134 | name[4] == 's') | |
7135 | { /* times */ | |
7136 | return -KEY_times; | |
7137 | } | |
7138 | ||
7139 | goto unknown; | |
7140 | ||
7141 | case 'u': | |
7142 | switch (name[1]) | |
7143 | { | |
7144 | case 'm': | |
7145 | if (name[2] == 'a' && | |
7146 | name[3] == 's' && | |
7147 | name[4] == 'k') | |
7148 | { /* umask */ | |
7149 | return -KEY_umask; | |
7150 | } | |
7151 | ||
7152 | goto unknown; | |
7153 | ||
7154 | case 'n': | |
7155 | switch (name[2]) | |
7156 | { | |
7157 | case 'd': | |
7158 | if (name[3] == 'e' && | |
7159 | name[4] == 'f') | |
7160 | { /* undef */ | |
7161 | return KEY_undef; | |
7162 | } | |
7163 | ||
7164 | goto unknown; | |
7165 | ||
7166 | case 't': | |
7167 | if (name[3] == 'i') | |
7168 | { | |
7169 | switch (name[4]) | |
7170 | { | |
7171 | case 'e': | |
7172 | { /* untie */ | |
7173 | return KEY_untie; | |
7174 | } | |
7175 | ||
4c3bbe0f MHM |
7176 | case 'l': |
7177 | { /* until */ | |
7178 | return KEY_until; | |
7179 | } | |
7180 | ||
4c3bbe0f MHM |
7181 | default: |
7182 | goto unknown; | |
7183 | } | |
7184 | } | |
7185 | ||
7186 | goto unknown; | |
7187 | ||
7188 | default: | |
7189 | goto unknown; | |
7190 | } | |
7191 | ||
7192 | case 't': | |
7193 | if (name[2] == 'i' && | |
7194 | name[3] == 'm' && | |
7195 | name[4] == 'e') | |
7196 | { /* utime */ | |
7197 | return -KEY_utime; | |
7198 | } | |
7199 | ||
7200 | goto unknown; | |
7201 | ||
7202 | default: | |
7203 | goto unknown; | |
7204 | } | |
7205 | ||
7206 | case 'w': | |
7207 | switch (name[1]) | |
7208 | { | |
7209 | case 'h': | |
7210 | if (name[2] == 'i' && | |
7211 | name[3] == 'l' && | |
7212 | name[4] == 'e') | |
7213 | { /* while */ | |
7214 | return KEY_while; | |
7215 | } | |
7216 | ||
7217 | goto unknown; | |
7218 | ||
7219 | case 'r': | |
7220 | if (name[2] == 'i' && | |
7221 | name[3] == 't' && | |
7222 | name[4] == 'e') | |
7223 | { /* write */ | |
7224 | return -KEY_write; | |
7225 | } | |
7226 | ||
7227 | goto unknown; | |
7228 | ||
7229 | default: | |
7230 | goto unknown; | |
7231 | } | |
7232 | ||
7233 | default: | |
7234 | goto unknown; | |
e2e1dd5a | 7235 | } |
4c3bbe0f MHM |
7236 | |
7237 | case 6: /* 33 tokens of length 6 */ | |
7238 | switch (name[0]) | |
7239 | { | |
7240 | case 'a': | |
7241 | if (name[1] == 'c' && | |
7242 | name[2] == 'c' && | |
7243 | name[3] == 'e' && | |
7244 | name[4] == 'p' && | |
7245 | name[5] == 't') | |
7246 | { /* accept */ | |
7247 | return -KEY_accept; | |
7248 | } | |
7249 | ||
7250 | goto unknown; | |
7251 | ||
7252 | case 'c': | |
7253 | switch (name[1]) | |
7254 | { | |
7255 | case 'a': | |
7256 | if (name[2] == 'l' && | |
7257 | name[3] == 'l' && | |
7258 | name[4] == 'e' && | |
7259 | name[5] == 'r') | |
7260 | { /* caller */ | |
7261 | return -KEY_caller; | |
7262 | } | |
7263 | ||
7264 | goto unknown; | |
7265 | ||
7266 | case 'h': | |
7267 | if (name[2] == 'r' && | |
7268 | name[3] == 'o' && | |
7269 | name[4] == 'o' && | |
7270 | name[5] == 't') | |
7271 | { /* chroot */ | |
7272 | return -KEY_chroot; | |
7273 | } | |
7274 | ||
7275 | goto unknown; | |
7276 | ||
7277 | default: | |
7278 | goto unknown; | |
7279 | } | |
7280 | ||
7281 | case 'd': | |
7282 | if (name[1] == 'e' && | |
7283 | name[2] == 'l' && | |
7284 | name[3] == 'e' && | |
7285 | name[4] == 't' && | |
7286 | name[5] == 'e') | |
7287 | { /* delete */ | |
7288 | return KEY_delete; | |
7289 | } | |
7290 | ||
7291 | goto unknown; | |
7292 | ||
7293 | case 'e': | |
7294 | switch (name[1]) | |
7295 | { | |
7296 | case 'l': | |
7297 | if (name[2] == 's' && | |
7298 | name[3] == 'e' && | |
7299 | name[4] == 'i' && | |
7300 | name[5] == 'f') | |
7301 | { /* elseif */ | |
7302 | if(ckWARN_d(WARN_SYNTAX)) | |
7303 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "elseif should be elsif"); | |
7304 | } | |
7305 | ||
7306 | goto unknown; | |
7307 | ||
7308 | case 'x': | |
7309 | if (name[2] == 'i' && | |
7310 | name[3] == 's' && | |
7311 | name[4] == 't' && | |
7312 | name[5] == 's') | |
7313 | { /* exists */ | |
7314 | return KEY_exists; | |
7315 | } | |
7316 | ||
7317 | goto unknown; | |
7318 | ||
7319 | default: | |
7320 | goto unknown; | |
7321 | } | |
7322 | ||
7323 | case 'f': | |
7324 | switch (name[1]) | |
7325 | { | |
7326 | case 'i': | |
7327 | if (name[2] == 'l' && | |
7328 | name[3] == 'e' && | |
7329 | name[4] == 'n' && | |
7330 | name[5] == 'o') | |
7331 | { /* fileno */ | |
7332 | return -KEY_fileno; | |
7333 | } | |
7334 | ||
7335 | goto unknown; | |
7336 | ||
7337 | case 'o': | |
7338 | if (name[2] == 'r' && | |
7339 | name[3] == 'm' && | |
7340 | name[4] == 'a' && | |
7341 | name[5] == 't') | |
7342 | { /* format */ | |
7343 | return KEY_format; | |
7344 | } | |
7345 | ||
7346 | goto unknown; | |
7347 | ||
7348 | default: | |
7349 | goto unknown; | |
7350 | } | |
7351 | ||
7352 | case 'g': | |
7353 | if (name[1] == 'm' && | |
7354 | name[2] == 't' && | |
7355 | name[3] == 'i' && | |
7356 | name[4] == 'm' && | |
7357 | name[5] == 'e') | |
7358 | { /* gmtime */ | |
7359 | return -KEY_gmtime; | |
7360 | } | |
7361 | ||
7362 | goto unknown; | |
7363 | ||
7364 | case 'l': | |
7365 | switch (name[1]) | |
7366 | { | |
7367 | case 'e': | |
7368 | if (name[2] == 'n' && | |
7369 | name[3] == 'g' && | |
7370 | name[4] == 't' && | |
7371 | name[5] == 'h') | |
7372 | { /* length */ | |
7373 | return -KEY_length; | |
7374 | } | |
7375 | ||
7376 | goto unknown; | |
7377 | ||
7378 | case 'i': | |
7379 | if (name[2] == 's' && | |
7380 | name[3] == 't' && | |
7381 | name[4] == 'e' && | |
7382 | name[5] == 'n') | |
7383 | { /* listen */ | |
7384 | return -KEY_listen; | |
7385 | } | |
7386 | ||
7387 | goto unknown; | |
7388 | ||
7389 | default: | |
7390 | goto unknown; | |
7391 | } | |
7392 | ||
7393 | case 'm': | |
7394 | if (name[1] == 's' && | |
7395 | name[2] == 'g') | |
7396 | { | |
7397 | switch (name[3]) | |
7398 | { | |
7399 | case 'c': | |
7400 | if (name[4] == 't' && | |
7401 | name[5] == 'l') | |
7402 | { /* msgctl */ | |
7403 | return -KEY_msgctl; | |
7404 | } | |
7405 | ||
7406 | goto unknown; | |
7407 | ||
7408 | case 'g': | |
7409 | if (name[4] == 'e' && | |
7410 | name[5] == 't') | |
7411 | { /* msgget */ | |
7412 | return -KEY_msgget; | |
7413 | } | |
7414 | ||
7415 | goto unknown; | |
7416 | ||
7417 | case 'r': | |
7418 | if (name[4] == 'c' && | |
7419 | name[5] == 'v') | |
7420 | { /* msgrcv */ | |
7421 | return -KEY_msgrcv; | |
7422 | } | |
7423 | ||
7424 | goto unknown; | |
7425 | ||
7426 | case 's': | |
7427 | if (name[4] == 'n' && | |
7428 | name[5] == 'd') | |
7429 | { /* msgsnd */ | |
7430 | return -KEY_msgsnd; | |
7431 | } | |
7432 | ||
7433 | goto unknown; | |
7434 | ||
7435 | default: | |
7436 | goto unknown; | |
7437 | } | |
7438 | } | |
7439 | ||
7440 | goto unknown; | |
7441 | ||
7442 | case 'p': | |
7443 | if (name[1] == 'r' && | |
7444 | name[2] == 'i' && | |
7445 | name[3] == 'n' && | |
7446 | name[4] == 't' && | |
7447 | name[5] == 'f') | |
7448 | { /* printf */ | |
7449 | return KEY_printf; | |
7450 | } | |
7451 | ||
7452 | goto unknown; | |
7453 | ||
7454 | case 'r': | |
7455 | switch (name[1]) | |
7456 | { | |
7457 | case 'e': | |
7458 | switch (name[2]) | |
7459 | { | |
7460 | case 'n': | |
7461 | if (name[3] == 'a' && | |
7462 | name[4] == 'm' && | |
7463 | name[5] == 'e') | |
7464 | { /* rename */ | |
7465 | return -KEY_rename; | |
7466 | } | |
7467 | ||
7468 | goto unknown; | |
7469 | ||
7470 | case 't': | |
7471 | if (name[3] == 'u' && | |
7472 | name[4] == 'r' && | |
7473 | name[5] == 'n') | |
7474 | { /* return */ | |
7475 | return KEY_return; | |
7476 | } | |
7477 | ||
7478 | goto unknown; | |
7479 | ||
7480 | default: | |
7481 | goto unknown; | |
7482 | } | |
7483 | ||
7484 | case 'i': | |
7485 | if (name[2] == 'n' && | |
7486 | name[3] == 'd' && | |
7487 | name[4] == 'e' && | |
7488 | name[5] == 'x') | |
7489 | { /* rindex */ | |
7490 | return -KEY_rindex; | |
7491 | } | |
7492 | ||
7493 | goto unknown; | |
7494 | ||
7495 | default: | |
7496 | goto unknown; | |
7497 | } | |
7498 | ||
7499 | case 's': | |
7500 | switch (name[1]) | |
7501 | { | |
7502 | case 'c': | |
7503 | if (name[2] == 'a' && | |
7504 | name[3] == 'l' && | |
7505 | name[4] == 'a' && | |
7506 | name[5] == 'r') | |
7507 | { /* scalar */ | |
7508 | return KEY_scalar; | |
7509 | } | |
7510 | ||
7511 | goto unknown; | |
7512 | ||
7513 | case 'e': | |
7514 | switch (name[2]) | |
7515 | { | |
7516 | case 'l': | |
7517 | if (name[3] == 'e' && | |
7518 | name[4] == 'c' && | |
7519 | name[5] == 't') | |
7520 | { /* select */ | |
7521 | return -KEY_select; | |
7522 | } | |
7523 | ||
7524 | goto unknown; | |
7525 | ||
7526 | case 'm': | |
7527 | switch (name[3]) | |
7528 | { | |
7529 | case 'c': | |
7530 | if (name[4] == 't' && | |
7531 | name[5] == 'l') | |
7532 | { /* semctl */ | |
7533 | return -KEY_semctl; | |
7534 | } | |
7535 | ||
7536 | goto unknown; | |
7537 | ||
7538 | case 'g': | |
7539 | if (name[4] == 'e' && | |
7540 | name[5] == 't') | |
7541 | { /* semget */ | |
7542 | return -KEY_semget; | |
7543 | } | |
7544 | ||
7545 | goto unknown; | |
7546 | ||
7547 | default: | |
7548 | goto unknown; | |
7549 | } | |
7550 | ||
7551 | default: | |
7552 | goto unknown; | |
7553 | } | |
7554 | ||
7555 | case 'h': | |
7556 | if (name[2] == 'm') | |
7557 | { | |
7558 | switch (name[3]) | |
7559 | { | |
7560 | case 'c': | |
7561 | if (name[4] == 't' && | |
7562 | name[5] == 'l') | |
7563 | { /* shmctl */ | |
7564 | return -KEY_shmctl; | |
7565 | } | |
7566 | ||
7567 | goto unknown; | |
7568 | ||
7569 | case 'g': | |
7570 | if (name[4] == 'e' && | |
7571 | name[5] == 't') | |
7572 | { /* shmget */ | |
7573 | return -KEY_shmget; | |
7574 | } | |
7575 | ||
7576 | goto unknown; | |
7577 | ||
7578 | default: | |
7579 | goto unknown; | |
7580 | } | |
7581 | } | |
7582 | ||
7583 | goto unknown; | |
7584 | ||
7585 | case 'o': | |
7586 | if (name[2] == 'c' && | |
7587 | name[3] == 'k' && | |
7588 | name[4] == 'e' && | |
7589 | name[5] == 't') | |
7590 | { /* socket */ | |
7591 | return -KEY_socket; | |
7592 | } | |
7593 | ||
7594 | goto unknown; | |
7595 | ||
7596 | case 'p': | |
7597 | if (name[2] == 'l' && | |
7598 | name[3] == 'i' && | |
7599 | name[4] == 'c' && | |
7600 | name[5] == 'e') | |
7601 | { /* splice */ | |
7602 | return -KEY_splice; | |
7603 | } | |
7604 | ||
7605 | goto unknown; | |
7606 | ||
7607 | case 'u': | |
7608 | if (name[2] == 'b' && | |
7609 | name[3] == 's' && | |
7610 | name[4] == 't' && | |
7611 | name[5] == 'r') | |
7612 | { /* substr */ | |
7613 | return -KEY_substr; | |
7614 | } | |
7615 | ||
7616 | goto unknown; | |
7617 | ||
7618 | case 'y': | |
7619 | if (name[2] == 's' && | |
7620 | name[3] == 't' && | |
7621 | name[4] == 'e' && | |
7622 | name[5] == 'm') | |
7623 | { /* system */ | |
7624 | return -KEY_system; | |
7625 | } | |
7626 | ||
7627 | goto unknown; | |
7628 | ||
7629 | default: | |
7630 | goto unknown; | |
7631 | } | |
7632 | ||
7633 | case 'u': | |
7634 | if (name[1] == 'n') | |
7635 | { | |
7636 | switch (name[2]) | |
7637 | { | |
7638 | case 'l': | |
7639 | switch (name[3]) | |
7640 | { | |
7641 | case 'e': | |
7642 | if (name[4] == 's' && | |
7643 | name[5] == 's') | |
7644 | { /* unless */ | |
7645 | return KEY_unless; | |
7646 | } | |
7647 | ||
7648 | goto unknown; | |
7649 | ||
7650 | case 'i': | |
7651 | if (name[4] == 'n' && | |
7652 | name[5] == 'k') | |
7653 | { /* unlink */ | |
7654 | return -KEY_unlink; | |
7655 | } | |
7656 | ||
7657 | goto unknown; | |
7658 | ||
7659 | default: | |
7660 | goto unknown; | |
7661 | } | |
7662 | ||
7663 | case 'p': | |
7664 | if (name[3] == 'a' && | |
7665 | name[4] == 'c' && | |
7666 | name[5] == 'k') | |
7667 | { /* unpack */ | |
7668 | return -KEY_unpack; | |
7669 | } | |
7670 | ||
7671 | goto unknown; | |
7672 | ||
7673 | default: | |
7674 | goto unknown; | |
7675 | } | |
7676 | } | |
7677 | ||
7678 | goto unknown; | |
7679 | ||
7680 | case 'v': | |
7681 | if (name[1] == 'a' && | |
7682 | name[2] == 'l' && | |
7683 | name[3] == 'u' && | |
7684 | name[4] == 'e' && | |
7685 | name[5] == 's') | |
7686 | { /* values */ | |
7687 | return -KEY_values; | |
7688 | } | |
7689 | ||
7690 | goto unknown; | |
7691 | ||
7692 | default: | |
7693 | goto unknown; | |
e2e1dd5a | 7694 | } |
4c3bbe0f | 7695 | |
0d863452 | 7696 | case 7: /* 29 tokens of length 7 */ |
4c3bbe0f MHM |
7697 | switch (name[0]) |
7698 | { | |
7699 | case 'D': | |
7700 | if (name[1] == 'E' && | |
7701 | name[2] == 'S' && | |
7702 | name[3] == 'T' && | |
7703 | name[4] == 'R' && | |
7704 | name[5] == 'O' && | |
7705 | name[6] == 'Y') | |
7706 | { /* DESTROY */ | |
7707 | return KEY_DESTROY; | |
7708 | } | |
7709 | ||
7710 | goto unknown; | |
7711 | ||
7712 | case '_': | |
7713 | if (name[1] == '_' && | |
7714 | name[2] == 'E' && | |
7715 | name[3] == 'N' && | |
7716 | name[4] == 'D' && | |
7717 | name[5] == '_' && | |
7718 | name[6] == '_') | |
7719 | { /* __END__ */ | |
7720 | return KEY___END__; | |
7721 | } | |
7722 | ||
7723 | goto unknown; | |
7724 | ||
7725 | case 'b': | |
7726 | if (name[1] == 'i' && | |
7727 | name[2] == 'n' && | |
7728 | name[3] == 'm' && | |
7729 | name[4] == 'o' && | |
7730 | name[5] == 'd' && | |
7731 | name[6] == 'e') | |
7732 | { /* binmode */ | |
7733 | return -KEY_binmode; | |
7734 | } | |
7735 | ||
7736 | goto unknown; | |
7737 | ||
7738 | case 'c': | |
7739 | if (name[1] == 'o' && | |
7740 | name[2] == 'n' && | |
7741 | name[3] == 'n' && | |
7742 | name[4] == 'e' && | |
7743 | name[5] == 'c' && | |
7744 | name[6] == 't') | |
7745 | { /* connect */ | |
7746 | return -KEY_connect; | |
7747 | } | |
7748 | ||
7749 | goto unknown; | |
7750 | ||
7751 | case 'd': | |
7752 | switch (name[1]) | |
7753 | { | |
7754 | case 'b': | |
7755 | if (name[2] == 'm' && | |
7756 | name[3] == 'o' && | |
7757 | name[4] == 'p' && | |
7758 | name[5] == 'e' && | |
7759 | name[6] == 'n') | |
7760 | { /* dbmopen */ | |
7761 | return -KEY_dbmopen; | |
7762 | } | |
7763 | ||
7764 | goto unknown; | |
7765 | ||
7766 | case 'e': | |
0d863452 RH |
7767 | if (name[2] == 'f') |
7768 | { | |
7769 | switch (name[3]) | |
7770 | { | |
7771 | case 'a': | |
7772 | if (name[4] == 'u' && | |
7773 | name[5] == 'l' && | |
7774 | name[6] == 't') | |
7775 | { /* default */ | |
ef89dcc3 | 7776 | return (FEATURE_IS_ENABLED("switch") ? KEY_default : 0); |
0d863452 RH |
7777 | } |
7778 | ||
7779 | goto unknown; | |
7780 | ||
7781 | case 'i': | |
7782 | if (name[4] == 'n' && | |
4c3bbe0f MHM |
7783 | name[5] == 'e' && |
7784 | name[6] == 'd') | |
7785 | { /* defined */ | |
7786 | return KEY_defined; | |
7787 | } | |
7788 | ||
7789 | goto unknown; | |
7790 | ||
7791 | default: | |
7792 | goto unknown; | |
7793 | } | |
0d863452 RH |
7794 | } |
7795 | ||
7796 | goto unknown; | |
7797 | ||
7798 | default: | |
7799 | goto unknown; | |
7800 | } | |
4c3bbe0f MHM |
7801 | |
7802 | case 'f': | |
7803 | if (name[1] == 'o' && | |
7804 | name[2] == 'r' && | |
7805 | name[3] == 'e' && | |
7806 | name[4] == 'a' && | |
7807 | name[5] == 'c' && | |
7808 | name[6] == 'h') | |
7809 | { /* foreach */ | |
7810 | return KEY_foreach; | |
7811 | } | |
7812 | ||
7813 | goto unknown; | |
7814 | ||
7815 | case 'g': | |
7816 | if (name[1] == 'e' && | |
7817 | name[2] == 't' && | |
7818 | name[3] == 'p') | |
7819 | { | |
7820 | switch (name[4]) | |
7821 | { | |
7822 | case 'g': | |
7823 | if (name[5] == 'r' && | |
7824 | name[6] == 'p') | |
7825 | { /* getpgrp */ | |
7826 | return -KEY_getpgrp; | |
7827 | } | |
7828 | ||
7829 | goto unknown; | |
7830 | ||
7831 | case 'p': | |
7832 | if (name[5] == 'i' && | |
7833 | name[6] == 'd') | |
7834 | { /* getppid */ | |
7835 | return -KEY_getppid; | |
7836 | } | |
7837 | ||
7838 | goto unknown; | |
7839 | ||
7840 | default: | |
7841 | goto unknown; | |
7842 | } | |
7843 | } | |
7844 | ||
7845 | goto unknown; | |
7846 | ||
7847 | case 'l': | |
7848 | if (name[1] == 'c' && | |
7849 | name[2] == 'f' && | |
7850 | name[3] == 'i' && | |
7851 | name[4] == 'r' && | |
7852 | name[5] == 's' && | |
7853 | name[6] == 't') | |
7854 | { /* lcfirst */ | |
7855 | return -KEY_lcfirst; | |
7856 | } | |
7857 | ||
7858 | goto unknown; | |
7859 | ||
7860 | case 'o': | |
7861 | if (name[1] == 'p' && | |
7862 | name[2] == 'e' && | |
7863 | name[3] == 'n' && | |
7864 | name[4] == 'd' && | |
7865 | name[5] == 'i' && | |
7866 | name[6] == 'r') | |
7867 | { /* opendir */ | |
7868 | return -KEY_opendir; | |
7869 | } | |
7870 | ||
7871 | goto unknown; | |
7872 | ||
7873 | case 'p': | |
7874 | if (name[1] == 'a' && | |
7875 | name[2] == 'c' && | |
7876 | name[3] == 'k' && | |
7877 | name[4] == 'a' && | |
7878 | name[5] == 'g' && | |
7879 | name[6] == 'e') | |
7880 | { /* package */ | |
7881 | return KEY_package; | |
7882 | } | |
7883 | ||
7884 | goto unknown; | |
7885 | ||
7886 | case 'r': | |
7887 | if (name[1] == 'e') | |
7888 | { | |
7889 | switch (name[2]) | |
7890 | { | |
7891 | case 'a': | |
7892 | if (name[3] == 'd' && | |
7893 | name[4] == 'd' && | |
7894 | name[5] == 'i' && | |
7895 | name[6] == 'r') | |
7896 | { /* readdir */ | |
7897 | return -KEY_readdir; | |
7898 | } | |
7899 | ||
7900 | goto unknown; | |
7901 | ||
7902 | case 'q': | |
7903 | if (name[3] == 'u' && | |
7904 | name[4] == 'i' && | |
7905 | name[5] == 'r' && | |
7906 | name[6] == 'e') | |
7907 | { /* require */ | |
7908 | return KEY_require; | |
7909 | } | |
7910 | ||
7911 | goto unknown; | |
7912 | ||
7913 | case 'v': | |
7914 | if (name[3] == 'e' && | |
7915 | name[4] == 'r' && | |
7916 | name[5] == 's' && | |
7917 | name[6] == 'e') | |
7918 | { /* reverse */ | |
7919 | return -KEY_reverse; | |
7920 | } | |
7921 | ||
7922 | goto unknown; | |
7923 | ||
7924 | default: | |
7925 | goto unknown; | |
7926 | } | |
7927 | } | |
7928 | ||
7929 | goto unknown; | |
7930 | ||
7931 | case 's': | |
7932 | switch (name[1]) | |
7933 | { | |
7934 | case 'e': | |
7935 | switch (name[2]) | |
7936 | { | |
7937 | case 'e': | |
7938 | if (name[3] == 'k' && | |
7939 | name[4] == 'd' && | |
7940 | name[5] == 'i' && | |
7941 | name[6] == 'r') | |
7942 | { /* seekdir */ | |
7943 | return -KEY_seekdir; | |
7944 | } | |
7945 | ||
7946 | goto unknown; | |
7947 | ||
7948 | case 't': | |
7949 | if (name[3] == 'p' && | |
7950 | name[4] == 'g' && | |
7951 | name[5] == 'r' && | |
7952 | name[6] == 'p') | |
7953 | { /* setpgrp */ | |
7954 | return -KEY_setpgrp; | |
7955 | } | |
7956 | ||
7957 | goto unknown; | |
7958 | ||
7959 | default: | |
7960 | goto unknown; | |
7961 | } | |
7962 | ||
7963 | case 'h': | |
7964 | if (name[2] == 'm' && | |
7965 | name[3] == 'r' && | |
7966 | name[4] == 'e' && | |
7967 | name[5] == 'a' && | |
7968 | name[6] == 'd') | |
7969 | { /* shmread */ | |
7970 | return -KEY_shmread; | |
7971 | } | |
7972 | ||
7973 | goto unknown; | |
7974 | ||
7975 | case 'p': | |
7976 | if (name[2] == 'r' && | |
7977 | name[3] == 'i' && | |
7978 | name[4] == 'n' && | |
7979 | name[5] == 't' && | |
7980 | name[6] == 'f') | |
7981 | { /* sprintf */ | |
7982 | return -KEY_sprintf; | |
7983 | } | |
7984 | ||
7985 | goto unknown; | |
7986 | ||
7987 | case 'y': | |
7988 | switch (name[2]) | |
7989 | { | |
7990 | case 'm': | |
7991 | if (name[3] == 'l' && | |
7992 | name[4] == 'i' && | |
7993 | name[5] == 'n' && | |
7994 | name[6] == 'k') | |
7995 | { /* symlink */ | |
7996 | return -KEY_symlink; | |
7997 | } | |
7998 | ||
7999 | goto unknown; | |
8000 | ||
8001 | case 's': | |
8002 | switch (name[3]) | |
8003 | { | |
8004 | case 'c': | |
8005 | if (name[4] == 'a' && | |
8006 | name[5] == 'l' && | |
8007 | name[6] == 'l') | |
8008 | { /* syscall */ | |
8009 | return -KEY_syscall; | |
8010 | } | |
8011 | ||
8012 | goto unknown; | |
8013 | ||
8014 | case 'o': | |
8015 | if (name[4] == 'p' && | |
8016 | name[5] == 'e' && | |
8017 | name[6] == 'n') | |
8018 | { /* sysopen */ | |
8019 | return -KEY_sysopen; | |
8020 | } | |
8021 | ||
8022 | goto unknown; | |
8023 | ||
8024 | case 'r': | |
8025 | if (name[4] == 'e' && | |
8026 | name[5] == 'a' && | |
8027 | name[6] == 'd') | |
8028 | { /* sysread */ | |
8029 | return -KEY_sysread; | |
8030 | } | |
8031 | ||
8032 | goto unknown; | |
8033 | ||
8034 | case 's': | |
8035 | if (name[4] == 'e' && | |
8036 | name[5] == 'e' && | |
8037 | name[6] == 'k') | |
8038 | { /* sysseek */ | |
8039 | return -KEY_sysseek; | |
8040 | } | |
8041 | ||
8042 | goto unknown; | |
8043 | ||
8044 | default: | |
8045 | goto unknown; | |
8046 | } | |
8047 | ||
8048 | default: | |
8049 | goto unknown; | |
8050 | } | |
8051 | ||
8052 | default: | |
8053 | goto unknown; | |
8054 | } | |
8055 | ||
8056 | case 't': | |
8057 | if (name[1] == 'e' && | |
8058 | name[2] == 'l' && | |
8059 | name[3] == 'l' && | |
8060 | name[4] == 'd' && | |
8061 | name[5] == 'i' && | |
8062 | name[6] == 'r') | |
8063 | { /* telldir */ | |
8064 | return -KEY_telldir; | |
8065 | } | |
8066 | ||
8067 | goto unknown; | |
8068 | ||
8069 | case 'u': | |
8070 | switch (name[1]) | |
8071 | { | |
8072 | case 'c': | |
8073 | if (name[2] == 'f' && | |
8074 | name[3] == 'i' && | |
8075 | name[4] == 'r' && | |
8076 | name[5] == 's' && | |
8077 | name[6] == 't') | |
8078 | { /* ucfirst */ | |
8079 | return -KEY_ucfirst; | |
8080 | } | |
8081 | ||
8082 | goto unknown; | |
8083 | ||
8084 | case 'n': | |
8085 | if (name[2] == 's' && | |
8086 | name[3] == 'h' && | |
8087 | name[4] == 'i' && | |
8088 | name[5] == 'f' && | |
8089 | name[6] == 't') | |
8090 | { /* unshift */ | |
8091 | return -KEY_unshift; | |
8092 | } | |
8093 | ||
8094 | goto unknown; | |
8095 | ||
8096 | default: | |
8097 | goto unknown; | |
8098 | } | |
8099 | ||
8100 | case 'w': | |
8101 | if (name[1] == 'a' && | |
8102 | name[2] == 'i' && | |
8103 | name[3] == 't' && | |
8104 | name[4] == 'p' && | |
8105 | name[5] == 'i' && | |
8106 | name[6] == 'd') | |
8107 | { /* waitpid */ | |
8108 | return -KEY_waitpid; | |
8109 | } | |
8110 | ||
8111 | goto unknown; | |
8112 | ||
8113 | default: | |
8114 | goto unknown; | |
8115 | } | |
8116 | ||
8117 | case 8: /* 26 tokens of length 8 */ | |
8118 | switch (name[0]) | |
8119 | { | |
8120 | case 'A': | |
8121 | if (name[1] == 'U' && | |
8122 | name[2] == 'T' && | |
8123 | name[3] == 'O' && | |
8124 | name[4] == 'L' && | |
8125 | name[5] == 'O' && | |
8126 | name[6] == 'A' && | |
8127 | name[7] == 'D') | |
8128 | { /* AUTOLOAD */ | |
8129 | return KEY_AUTOLOAD; | |
8130 | } | |
8131 | ||
8132 | goto unknown; | |
8133 | ||
8134 | case '_': | |
8135 | if (name[1] == '_') | |
8136 | { | |
8137 | switch (name[2]) | |
8138 | { | |
8139 | case 'D': | |
8140 | if (name[3] == 'A' && | |
8141 | name[4] == 'T' && | |
8142 | name[5] == 'A' && | |
8143 | name[6] == '_' && | |
8144 | name[7] == '_') | |
8145 | { /* __DATA__ */ | |
8146 | return KEY___DATA__; | |
8147 | } | |
8148 | ||
8149 | goto unknown; | |
8150 | ||
8151 | case 'F': | |
8152 | if (name[3] == 'I' && | |
8153 | name[4] == 'L' && | |
8154 | name[5] == 'E' && | |
8155 | name[6] == '_' && | |
8156 | name[7] == '_') | |
8157 | { /* __FILE__ */ | |
8158 | return -KEY___FILE__; | |
8159 | } | |
8160 | ||
8161 | goto unknown; | |
8162 | ||
8163 | case 'L': | |
8164 | if (name[3] == 'I' && | |
8165 | name[4] == 'N' && | |
8166 | name[5] == 'E' && | |
8167 | name[6] == '_' && | |
8168 | name[7] == '_') | |
8169 | { /* __LINE__ */ | |
8170 | return -KEY___LINE__; | |
8171 | } | |
8172 | ||
8173 | goto unknown; | |
8174 | ||
8175 | default: | |
8176 | goto unknown; | |
8177 | } | |
8178 | } | |
8179 | ||
8180 | goto unknown; | |
8181 | ||
8182 | case 'c': | |
8183 | switch (name[1]) | |
8184 | { | |
8185 | case 'l': | |
8186 | if (name[2] == 'o' && | |
8187 | name[3] == 's' && | |
8188 | name[4] == 'e' && | |
8189 | name[5] == 'd' && | |
8190 | name[6] == 'i' && | |
8191 | name[7] == 'r') | |
8192 | { /* closedir */ | |
8193 | return -KEY_closedir; | |
8194 | } | |
8195 | ||
8196 | goto unknown; | |
8197 | ||
8198 | case 'o': | |
8199 | if (name[2] == 'n' && | |
8200 | name[3] == 't' && | |
8201 | name[4] == 'i' && | |
8202 | name[5] == 'n' && | |
8203 | name[6] == 'u' && | |
8204 | name[7] == 'e') | |
8205 | { /* continue */ | |
8206 | return -KEY_continue; | |
8207 | } | |
8208 | ||
8209 | goto unknown; | |
8210 | ||
8211 | default: | |
8212 | goto unknown; | |
8213 | } | |
8214 | ||
8215 | case 'd': | |
8216 | if (name[1] == 'b' && | |
8217 | name[2] == 'm' && | |
8218 | name[3] == 'c' && | |
8219 | name[4] == 'l' && | |
8220 | name[5] == 'o' && | |
8221 | name[6] == 's' && | |
8222 | name[7] == 'e') | |
8223 | { /* dbmclose */ | |
8224 | return -KEY_dbmclose; | |
8225 | } | |
8226 | ||
8227 | goto unknown; | |
8228 | ||
8229 | case 'e': | |
8230 | if (name[1] == 'n' && | |
8231 | name[2] == 'd') | |
8232 | { | |
8233 | switch (name[3]) | |
8234 | { | |
8235 | case 'g': | |
8236 | if (name[4] == 'r' && | |
8237 | name[5] == 'e' && | |
8238 | name[6] == 'n' && | |
8239 | name[7] == 't') | |
8240 | { /* endgrent */ | |
8241 | return -KEY_endgrent; | |
8242 | } | |
8243 | ||
8244 | goto unknown; | |
8245 | ||
8246 | case 'p': | |
8247 | if (name[4] == 'w' && | |
8248 | name[5] == 'e' && | |
8249 | name[6] == 'n' && | |
8250 | name[7] == 't') | |
8251 | { /* endpwent */ | |
8252 | return -KEY_endpwent; | |
8253 | } | |
8254 | ||
8255 | goto unknown; | |
8256 | ||
8257 | default: | |
8258 | goto unknown; | |
8259 | } | |
8260 | } | |
8261 | ||
8262 | goto unknown; | |
8263 | ||
8264 | case 'f': | |
8265 | if (name[1] == 'o' && | |
8266 | name[2] == 'r' && | |
8267 | name[3] == 'm' && | |
8268 | name[4] == 'l' && | |
8269 | name[5] == 'i' && | |
8270 | name[6] == 'n' && | |
8271 | name[7] == 'e') | |
8272 | { /* formline */ | |
8273 | return -KEY_formline; | |
8274 | } | |
8275 | ||
8276 | goto unknown; | |
8277 | ||
8278 | case 'g': | |
8279 | if (name[1] == 'e' && | |
8280 | name[2] == 't') | |
8281 | { | |
8282 | switch (name[3]) | |
8283 | { | |
8284 | case 'g': | |
8285 | if (name[4] == 'r') | |
8286 | { | |
8287 | switch (name[5]) | |
8288 | { | |
8289 | case 'e': | |
8290 | if (name[6] == 'n' && | |
8291 | name[7] == 't') | |
8292 | { /* getgrent */ | |
8293 | return -KEY_getgrent; | |
8294 | } | |
8295 | ||
8296 | goto unknown; | |
8297 | ||
8298 | case 'g': | |
8299 | if (name[6] == 'i' && | |
8300 | name[7] == 'd') | |
8301 | { /* getgrgid */ | |
8302 | return -KEY_getgrgid; | |
8303 | } | |
8304 | ||
8305 | goto unknown; | |
8306 | ||
8307 | case 'n': | |
8308 | if (name[6] == 'a' && | |
8309 | name[7] == 'm') | |
8310 | { /* getgrnam */ | |
8311 | return -KEY_getgrnam; | |
8312 | } | |
8313 | ||
8314 | goto unknown; | |
8315 | ||
8316 | default: | |
8317 | goto unknown; | |
8318 | } | |
8319 | } | |
8320 | ||
8321 | goto unknown; | |
8322 | ||
8323 | case 'l': | |
8324 | if (name[4] == 'o' && | |
8325 | name[5] == 'g' && | |
8326 | name[6] == 'i' && | |
8327 | name[7] == 'n') | |
8328 | { /* getlogin */ | |
8329 | return -KEY_getlogin; | |
8330 | } | |
8331 | ||
8332 | goto unknown; | |
8333 | ||
8334 | case 'p': | |
8335 | if (name[4] == 'w') | |
8336 | { | |
8337 | switch (name[5]) | |
8338 | { | |
8339 | case 'e': | |
8340 | if (name[6] == 'n' && | |
8341 | name[7] == 't') | |
8342 | { /* getpwent */ | |
8343 | return -KEY_getpwent; | |
8344 | } | |
8345 | ||
8346 | goto unknown; | |
8347 | ||
8348 | case 'n': | |
8349 | if (name[6] == 'a' && | |
8350 | name[7] == 'm') | |
8351 | { /* getpwnam */ | |
8352 | return -KEY_getpwnam; | |
8353 | } | |
8354 | ||
8355 | goto unknown; | |
8356 | ||
8357 | case 'u': | |
8358 | if (name[6] == 'i' && | |
8359 | name[7] == 'd') | |
8360 | { /* getpwuid */ | |
8361 | return -KEY_getpwuid; | |
8362 | } | |
8363 | ||
8364 | goto unknown; | |
8365 | ||
8366 | default: | |
8367 | goto unknown; | |
8368 | } | |
8369 | } | |
8370 | ||
8371 | goto unknown; | |
8372 | ||
8373 | default: | |
8374 | goto unknown; | |
8375 | } | |
8376 | } | |
8377 | ||
8378 | goto unknown; | |
8379 | ||
8380 | case 'r': | |
8381 | if (name[1] == 'e' && | |
8382 | name[2] == 'a' && | |
8383 | name[3] == 'd') | |
8384 | { | |
8385 | switch (name[4]) | |
8386 | { | |
8387 | case 'l': | |
8388 | if (name[5] == 'i' && | |
8389 | name[6] == 'n') | |
8390 | { | |
8391 | switch (name[7]) | |
8392 | { | |
8393 | case 'e': | |
8394 | { /* readline */ | |
8395 | return -KEY_readline; | |
8396 | } | |
8397 | ||
4c3bbe0f MHM |
8398 | case 'k': |
8399 | { /* readlink */ | |
8400 | return -KEY_readlink; | |
8401 | } | |
8402 | ||
4c3bbe0f MHM |
8403 | default: |
8404 | goto unknown; | |
8405 | } | |
8406 | } | |
8407 | ||
8408 | goto unknown; | |
8409 | ||
8410 | case 'p': | |
8411 | if (name[5] == 'i' && | |
8412 | name[6] == 'p' && | |
8413 | name[7] == 'e') | |
8414 | { /* readpipe */ | |
8415 | return -KEY_readpipe; | |
8416 | } | |
8417 | ||
8418 | goto unknown; | |
8419 | ||
8420 | default: | |
8421 | goto unknown; | |
8422 | } | |
8423 | } | |
8424 | ||
8425 | goto unknown; | |
8426 | ||
8427 | case 's': | |
8428 | switch (name[1]) | |
8429 | { | |
8430 | case 'e': | |
8431 | if (name[2] == 't') | |
8432 | { | |
8433 | switch (name[3]) | |
8434 | { | |
8435 | case 'g': | |
8436 | if (name[4] == 'r' && | |
8437 | name[5] == 'e' && | |
8438 | name[6] == 'n' && | |
8439 | name[7] == 't') | |
8440 | { /* setgrent */ | |
8441 | return -KEY_setgrent; | |
8442 | } | |
8443 | ||
8444 | goto unknown; | |
8445 | ||
8446 | case 'p': | |
8447 | if (name[4] == 'w' && | |
8448 | name[5] == 'e' && | |
8449 | name[6] == 'n' && | |
8450 | name[7] == 't') | |
8451 | { /* setpwent */ | |
8452 | return -KEY_setpwent; | |
8453 | } | |
8454 | ||
8455 | goto unknown; | |
8456 | ||
8457 | default: | |
8458 | goto unknown; | |
8459 | } | |
8460 | } | |
8461 | ||
8462 | goto unknown; | |
8463 | ||
8464 | case 'h': | |
8465 | switch (name[2]) | |
8466 | { | |
8467 | case 'm': | |
8468 | if (name[3] == 'w' && | |
8469 | name[4] == 'r' && | |
8470 | name[5] == 'i' && | |
8471 | name[6] == 't' && | |
8472 | name[7] == 'e') | |
8473 | { /* shmwrite */ | |
8474 | return -KEY_shmwrite; | |
8475 | } | |
8476 | ||
8477 | goto unknown; | |
8478 | ||
8479 | case 'u': | |
8480 | if (name[3] == 't' && | |
8481 | name[4] == 'd' && | |
8482 | name[5] == 'o' && | |
8483 | name[6] == 'w' && | |
8484 | name[7] == 'n') | |
8485 | { /* shutdown */ | |
8486 | return -KEY_shutdown; | |
8487 | } | |
8488 | ||
8489 | goto unknown; | |
8490 | ||
8491 | default: | |
8492 | goto unknown; | |
8493 | } | |
8494 | ||
8495 | case 'y': | |
8496 | if (name[2] == 's' && | |
8497 | name[3] == 'w' && | |
8498 | name[4] == 'r' && | |
8499 | name[5] == 'i' && | |
8500 | name[6] == 't' && | |
8501 | name[7] == 'e') | |
8502 | { /* syswrite */ | |
8503 | return -KEY_syswrite; | |
8504 | } | |
8505 | ||
8506 | goto unknown; | |
8507 | ||
8508 | default: | |
8509 | goto unknown; | |
8510 | } | |
8511 | ||
8512 | case 't': | |
8513 | if (name[1] == 'r' && | |
8514 | name[2] == 'u' && | |
8515 | name[3] == 'n' && | |
8516 | name[4] == 'c' && | |
8517 | name[5] == 'a' && | |
8518 | name[6] == 't' && | |
8519 | name[7] == 'e') | |
8520 | { /* truncate */ | |
8521 | return -KEY_truncate; | |
8522 | } | |
8523 | ||
8524 | goto unknown; | |
8525 | ||
8526 | default: | |
8527 | goto unknown; | |
8528 | } | |
8529 | ||
8530 | case 9: /* 8 tokens of length 9 */ | |
8531 | switch (name[0]) | |
8532 | { | |
8533 | case 'e': | |
8534 | if (name[1] == 'n' && | |
8535 | name[2] == 'd' && | |
8536 | name[3] == 'n' && | |
8537 | name[4] == 'e' && | |
8538 | name[5] == 't' && | |
8539 | name[6] == 'e' && | |
8540 | name[7] == 'n' && | |
8541 | name[8] == 't') | |
8542 | { /* endnetent */ | |
8543 | return -KEY_endnetent; | |
8544 | } | |
8545 | ||
8546 | goto unknown; | |
8547 | ||
8548 | case 'g': | |
8549 | if (name[1] == 'e' && | |
8550 | name[2] == 't' && | |
8551 | name[3] == 'n' && | |
8552 | name[4] == 'e' && | |
8553 | name[5] == 't' && | |
8554 | name[6] == 'e' && | |
8555 | name[7] == 'n' && | |
8556 | name[8] == 't') | |
8557 | { /* getnetent */ | |
8558 | return -KEY_getnetent; | |
8559 | } | |
8560 | ||
8561 | goto unknown; | |
8562 | ||
8563 | case 'l': | |
8564 | if (name[1] == 'o' && | |
8565 | name[2] == 'c' && | |
8566 | name[3] == 'a' && | |
8567 | name[4] == 'l' && | |
8568 | name[5] == 't' && | |
8569 | name[6] == 'i' && | |
8570 | name[7] == 'm' && | |
8571 | name[8] == 'e') | |
8572 | { /* localtime */ | |
8573 | return -KEY_localtime; | |
8574 | } | |
8575 | ||
8576 | goto unknown; | |
8577 | ||
8578 | case 'p': | |
8579 | if (name[1] == 'r' && | |
8580 | name[2] == 'o' && | |
8581 | name[3] == 't' && | |
8582 | name[4] == 'o' && | |
8583 | name[5] == 't' && | |
8584 | name[6] == 'y' && | |
8585 | name[7] == 'p' && | |
8586 | name[8] == 'e') | |
8587 | { /* prototype */ | |
8588 | return KEY_prototype; | |
8589 | } | |
8590 | ||
8591 | goto unknown; | |
8592 | ||
8593 | case 'q': | |
8594 | if (name[1] == 'u' && | |
8595 | name[2] == 'o' && | |
8596 | name[3] == 't' && | |
8597 | name[4] == 'e' && | |
8598 | name[5] == 'm' && | |
8599 | name[6] == 'e' && | |
8600 | name[7] == 't' && | |
8601 | name[8] == 'a') | |
8602 | { /* quotemeta */ | |
8603 | return -KEY_quotemeta; | |
8604 | } | |
8605 | ||
8606 | goto unknown; | |
8607 | ||
8608 | case 'r': | |
8609 | if (name[1] == 'e' && | |
8610 | name[2] == 'w' && | |
8611 | name[3] == 'i' && | |
8612 | name[4] == 'n' && | |
8613 | name[5] == 'd' && | |
8614 | name[6] == 'd' && | |
8615 | name[7] == 'i' && | |
8616 | name[8] == 'r') | |
8617 | { /* rewinddir */ | |
8618 | return -KEY_rewinddir; | |
8619 | } | |
8620 | ||
8621 | goto unknown; | |
8622 | ||
8623 | case 's': | |
8624 | if (name[1] == 'e' && | |
8625 | name[2] == 't' && | |
8626 | name[3] == 'n' && | |
8627 | name[4] == 'e' && | |
8628 | name[5] == 't' && | |
8629 | name[6] == 'e' && | |
8630 | name[7] == 'n' && | |
8631 | name[8] == 't') | |
8632 | { /* setnetent */ | |
8633 | return -KEY_setnetent; | |
8634 | } | |
8635 | ||
8636 | goto unknown; | |
8637 | ||
8638 | case 'w': | |
8639 | if (name[1] == 'a' && | |
8640 | name[2] == 'n' && | |
8641 | name[3] == 't' && | |
8642 | name[4] == 'a' && | |
8643 | name[5] == 'r' && | |
8644 | name[6] == 'r' && | |
8645 | name[7] == 'a' && | |
8646 | name[8] == 'y') | |
8647 | { /* wantarray */ | |
8648 | return -KEY_wantarray; | |
8649 | } | |
8650 | ||
8651 | goto unknown; | |
8652 | ||
8653 | default: | |
8654 | goto unknown; | |
8655 | } | |
8656 | ||
8657 | case 10: /* 9 tokens of length 10 */ | |
8658 | switch (name[0]) | |
8659 | { | |
8660 | case 'e': | |
8661 | if (name[1] == 'n' && | |
8662 | name[2] == 'd') | |
8663 | { | |
8664 | switch (name[3]) | |
8665 | { | |
8666 | case 'h': | |
8667 | if (name[4] == 'o' && | |
8668 | name[5] == 's' && | |
8669 | name[6] == 't' && | |
8670 | name[7] == 'e' && | |
8671 | name[8] == 'n' && | |
8672 | name[9] == 't') | |
8673 | { /* endhostent */ | |
8674 | return -KEY_endhostent; | |
8675 | } | |
8676 | ||
8677 | goto unknown; | |
8678 | ||
8679 | case 's': | |
8680 | if (name[4] == 'e' && | |
8681 | name[5] == 'r' && | |
8682 | name[6] == 'v' && | |
8683 | name[7] == 'e' && | |
8684 | name[8] == 'n' && | |
8685 | name[9] == 't') | |
8686 | { /* endservent */ | |
8687 | return -KEY_endservent; | |
8688 | } | |
8689 | ||
8690 | goto unknown; | |
8691 | ||
8692 | default: | |
8693 | goto unknown; | |
8694 | } | |
8695 | } | |
8696 | ||
8697 | goto unknown; | |
8698 | ||
8699 | case 'g': | |
8700 | if (name[1] == 'e' && | |
8701 | name[2] == 't') | |
8702 | { | |
8703 | switch (name[3]) | |
8704 | { | |
8705 | case 'h': | |
8706 | if (name[4] == 'o' && | |
8707 | name[5] == 's' && | |
8708 | name[6] == 't' && | |
8709 | name[7] == 'e' && | |
8710 | name[8] == 'n' && | |
8711 | name[9] == 't') | |
8712 | { /* gethostent */ | |
8713 | return -KEY_gethostent; | |
8714 | } | |
8715 | ||
8716 | goto unknown; | |
8717 | ||
8718 | case 's': | |
8719 | switch (name[4]) | |
8720 | { | |
8721 | case 'e': | |
8722 | if (name[5] == 'r' && | |
8723 | name[6] == 'v' && | |
8724 | name[7] == 'e' && | |
8725 | name[8] == 'n' && | |
8726 | name[9] == 't') | |
8727 | { /* getservent */ | |
8728 | return -KEY_getservent; | |
8729 | } | |
8730 | ||
8731 | goto unknown; | |
8732 | ||
8733 | case 'o': | |
8734 | if (name[5] == 'c' && | |
8735 | name[6] == 'k' && | |
8736 | name[7] == 'o' && | |
8737 | name[8] == 'p' && | |
8738 | name[9] == 't') | |
8739 | { /* getsockopt */ | |
8740 | return -KEY_getsockopt; | |
8741 | } | |
8742 | ||
8743 | goto unknown; | |
8744 | ||
8745 | default: | |
8746 | goto unknown; | |
8747 | } | |
8748 | ||
8749 | default: | |
8750 | goto unknown; | |
8751 | } | |
8752 | } | |
8753 | ||
8754 | goto unknown; | |
8755 | ||
8756 | case 's': | |
8757 | switch (name[1]) | |
8758 | { | |
8759 | case 'e': | |
8760 | if (name[2] == 't') | |
8761 | { | |
8762 | switch (name[3]) | |
8763 | { | |
8764 | case 'h': | |
8765 | if (name[4] == 'o' && | |
8766 | name[5] == 's' && | |
8767 | name[6] == 't' && | |
8768 | name[7] == 'e' && | |
8769 | name[8] == 'n' && | |
8770 | name[9] == 't') | |
8771 | { /* sethostent */ | |
8772 | return -KEY_sethostent; | |
8773 | } | |
8774 | ||
8775 | goto unknown; | |
8776 | ||
8777 | case 's': | |
8778 | switch (name[4]) | |
8779 | { | |
8780 | case 'e': | |
8781 | if (name[5] == 'r' && | |
8782 | name[6] == 'v' && | |
8783 | name[7] == 'e' && | |
8784 | name[8] == 'n' && | |
8785 | name[9] == 't') | |
8786 | { /* setservent */ | |
8787 | return -KEY_setservent; | |
8788 | } | |
8789 | ||
8790 | goto unknown; | |
8791 | ||
8792 | case 'o': | |
8793 | if (name[5] == 'c' && | |
8794 | name[6] == 'k' && | |
8795 | name[7] == 'o' && | |
8796 | name[8] == 'p' && | |
8797 | name[9] == 't') | |
8798 | { /* setsockopt */ | |
8799 | return -KEY_setsockopt; | |
8800 | } | |
8801 | ||
8802 | goto unknown; | |
8803 | ||
8804 | default: | |
8805 | goto unknown; | |
8806 | } | |
8807 | ||
8808 | default: | |
8809 | goto unknown; | |
8810 | } | |
8811 | } | |
8812 | ||
8813 | goto unknown; | |
8814 | ||
8815 | case 'o': | |
8816 | if (name[2] == 'c' && | |
8817 | name[3] == 'k' && | |
8818 | name[4] == 'e' && | |
8819 | name[5] == 't' && | |
8820 | name[6] == 'p' && | |
8821 | name[7] == 'a' && | |
8822 | name[8] == 'i' && | |
8823 | name[9] == 'r') | |
8824 | { /* socketpair */ | |
8825 | return -KEY_socketpair; | |
8826 | } | |
8827 | ||
8828 | goto unknown; | |
8829 | ||
8830 | default: | |
8831 | goto unknown; | |
8832 | } | |
8833 | ||
8834 | default: | |
8835 | goto unknown; | |
e2e1dd5a | 8836 | } |
4c3bbe0f MHM |
8837 | |
8838 | case 11: /* 8 tokens of length 11 */ | |
8839 | switch (name[0]) | |
8840 | { | |
8841 | case '_': | |
8842 | if (name[1] == '_' && | |
8843 | name[2] == 'P' && | |
8844 | name[3] == 'A' && | |
8845 | name[4] == 'C' && | |
8846 | name[5] == 'K' && | |
8847 | name[6] == 'A' && | |
8848 | name[7] == 'G' && | |
8849 | name[8] == 'E' && | |
8850 | name[9] == '_' && | |
8851 | name[10] == '_') | |
8852 | { /* __PACKAGE__ */ | |
8853 | return -KEY___PACKAGE__; | |
8854 | } | |
8855 | ||
8856 | goto unknown; | |
8857 | ||
8858 | case 'e': | |
8859 | if (name[1] == 'n' && | |
8860 | name[2] == 'd' && | |
8861 | name[3] == 'p' && | |
8862 | name[4] == 'r' && | |
8863 | name[5] == 'o' && | |
8864 | name[6] == 't' && | |
8865 | name[7] == 'o' && | |
8866 | name[8] == 'e' && | |
8867 | name[9] == 'n' && | |
8868 | name[10] == 't') | |
8869 | { /* endprotoent */ | |
8870 | return -KEY_endprotoent; | |
8871 | } | |
8872 | ||
8873 | goto unknown; | |
8874 | ||
8875 | case 'g': | |
8876 | if (name[1] == 'e' && | |
8877 | name[2] == 't') | |
8878 | { | |
8879 | switch (name[3]) | |
8880 | { | |
8881 | case 'p': | |
8882 | switch (name[4]) | |
8883 | { | |
8884 | case 'e': | |
8885 | if (name[5] == 'e' && | |
8886 | name[6] == 'r' && | |
8887 | name[7] == 'n' && | |
8888 | name[8] == 'a' && | |
8889 | name[9] == 'm' && | |
8890 | name[10] == 'e') | |
8891 | { /* getpeername */ | |
8892 | return -KEY_getpeername; | |
8893 | } | |
8894 | ||
8895 | goto unknown; | |
8896 | ||
8897 | case 'r': | |
8898 | switch (name[5]) | |
8899 | { | |
8900 | case 'i': | |
8901 | if (name[6] == 'o' && | |
8902 | name[7] == 'r' && | |
8903 | name[8] == 'i' && | |
8904 | name[9] == 't' && | |
8905 | name[10] == 'y') | |
8906 | { /* getpriority */ | |
8907 | return -KEY_getpriority; | |
8908 | } | |
8909 | ||
8910 | goto unknown; | |
8911 | ||
8912 | case 'o': | |
8913 | if (name[6] == 't' && | |
8914 | name[7] == 'o' && | |
8915 | name[8] == 'e' && | |
8916 | name[9] == 'n' && | |
8917 | name[10] == 't') | |
8918 | { /* getprotoent */ | |
8919 | return -KEY_getprotoent; | |
8920 | } | |
8921 | ||
8922 | goto unknown; | |
8923 | ||
8924 | default: | |
8925 | goto unknown; | |
8926 | } | |
8927 | ||
8928 | default: | |
8929 | goto unknown; | |
8930 | } | |
8931 | ||
8932 | case 's': | |
8933 | if (name[4] == 'o' && | |
8934 | name[5] == 'c' && | |
8935 | name[6] == 'k' && | |
8936 | name[7] == 'n' && | |
8937 | name[8] == 'a' && | |
8938 | name[9] == 'm' && | |
8939 | name[10] == 'e') | |
8940 | { /* getsockname */ | |
8941 | return -KEY_getsockname; | |
8942 | } | |
8943 | ||
8944 | goto unknown; | |
8945 | ||
8946 | default: | |
8947 | goto unknown; | |
8948 | } | |
8949 | } | |
8950 | ||
8951 | goto unknown; | |
8952 | ||
8953 | case 's': | |
8954 | if (name[1] == 'e' && | |
8955 | name[2] == 't' && | |
8956 | name[3] == 'p' && | |
8957 | name[4] == 'r') | |
8958 | { | |
8959 | switch (name[5]) | |
8960 | { | |
8961 | case 'i': | |
8962 | if (name[6] == 'o' && | |
8963 | name[7] == 'r' && | |
8964 | name[8] == 'i' && | |
8965 | name[9] == 't' && | |
8966 | name[10] == 'y') | |
8967 | { /* setpriority */ | |
8968 | return -KEY_setpriority; | |
8969 | } | |
8970 | ||
8971 | goto unknown; | |
8972 | ||
8973 | case 'o': | |
8974 | if (name[6] == 't' && | |
8975 | name[7] == 'o' && | |
8976 | name[8] == 'e' && | |
8977 | name[9] == 'n' && | |
8978 | name[10] == 't') | |
8979 | { /* setprotoent */ | |
8980 | return -KEY_setprotoent; | |
8981 | } | |
8982 | ||
8983 | goto unknown; | |
8984 | ||
8985 | default: | |
8986 | goto unknown; | |
8987 | } | |
8988 | } | |
8989 | ||
8990 | goto unknown; | |
8991 | ||
8992 | default: | |
8993 | goto unknown; | |
e2e1dd5a | 8994 | } |
4c3bbe0f MHM |
8995 | |
8996 | case 12: /* 2 tokens of length 12 */ | |
8997 | if (name[0] == 'g' && | |
8998 | name[1] == 'e' && | |
8999 | name[2] == 't' && | |
9000 | name[3] == 'n' && | |
9001 | name[4] == 'e' && | |
9002 | name[5] == 't' && | |
9003 | name[6] == 'b' && | |
9004 | name[7] == 'y') | |
9005 | { | |
9006 | switch (name[8]) | |
9007 | { | |
9008 | case 'a': | |
9009 | if (name[9] == 'd' && | |
9010 | name[10] == 'd' && | |
9011 | name[11] == 'r') | |
9012 | { /* getnetbyaddr */ | |
9013 | return -KEY_getnetbyaddr; | |
9014 | } | |
9015 | ||
9016 | goto unknown; | |
9017 | ||
9018 | case 'n': | |
9019 | if (name[9] == 'a' && | |
9020 | name[10] == 'm' && | |
9021 | name[11] == 'e') | |
9022 | { /* getnetbyname */ | |
9023 | return -KEY_getnetbyname; | |
9024 | } | |
9025 | ||
9026 | goto unknown; | |
9027 | ||
9028 | default: | |
9029 | goto unknown; | |
9030 | } | |
e2e1dd5a | 9031 | } |
4c3bbe0f MHM |
9032 | |
9033 | goto unknown; | |
9034 | ||
9035 | case 13: /* 4 tokens of length 13 */ | |
9036 | if (name[0] == 'g' && | |
9037 | name[1] == 'e' && | |
9038 | name[2] == 't') | |
9039 | { | |
9040 | switch (name[3]) | |
9041 | { | |
9042 | case 'h': | |
9043 | if (name[4] == 'o' && | |
9044 | name[5] == 's' && | |
9045 | name[6] == 't' && | |
9046 | name[7] == 'b' && | |
9047 | name[8] == 'y') | |
9048 | { | |
9049 | switch (name[9]) | |
9050 | { | |
9051 | case 'a': | |
9052 | if (name[10] == 'd' && | |
9053 | name[11] == 'd' && | |
9054 | name[12] == 'r') | |
9055 | { /* gethostbyaddr */ | |
9056 | return -KEY_gethostbyaddr; | |
9057 | } | |
9058 | ||
9059 | goto unknown; | |
9060 | ||
9061 | case 'n': | |
9062 | if (name[10] == 'a' && | |
9063 | name[11] == 'm' && | |
9064 | name[12] == 'e') | |
9065 | { /* gethostbyname */ | |
9066 | return -KEY_gethostbyname; | |
9067 | } | |
9068 | ||
9069 | goto unknown; | |
9070 | ||
9071 | default: | |
9072 | goto unknown; | |
9073 | } | |
9074 | } | |
9075 | ||
9076 | goto unknown; | |
9077 | ||
9078 | case 's': | |
9079 | if (name[4] == 'e' && | |
9080 | name[5] == 'r' && | |
9081 | name[6] == 'v' && | |
9082 | name[7] == 'b' && | |
9083 | name[8] == 'y') | |
9084 | { | |
9085 | switch (name[9]) | |
9086 | { | |
9087 | case 'n': | |
9088 | if (name[10] == 'a' && | |
9089 | name[11] == 'm' && | |
9090 | name[12] == 'e') | |
9091 | { /* getservbyname */ | |
9092 | return -KEY_getservbyname; | |
9093 | } | |
9094 | ||
9095 | goto unknown; | |
9096 | ||
9097 | case 'p': | |
9098 | if (name[10] == 'o' && | |
9099 | name[11] == 'r' && | |
9100 | name[12] == 't') | |
9101 | { /* getservbyport */ | |
9102 | return -KEY_getservbyport; | |
9103 | } | |
9104 | ||
9105 | goto unknown; | |
9106 | ||
9107 | default: | |
9108 | goto unknown; | |
9109 | } | |
9110 | } | |
9111 | ||
9112 | goto unknown; | |
9113 | ||
9114 | default: | |
9115 | goto unknown; | |
9116 | } | |
e2e1dd5a | 9117 | } |
4c3bbe0f MHM |
9118 | |
9119 | goto unknown; | |
9120 | ||
9121 | case 14: /* 1 tokens of length 14 */ | |
9122 | if (name[0] == 'g' && | |
9123 | name[1] == 'e' && | |
9124 | name[2] == 't' && | |
9125 | name[3] == 'p' && | |
9126 | name[4] == 'r' && | |
9127 | name[5] == 'o' && | |
9128 | name[6] == 't' && | |
9129 | name[7] == 'o' && | |
9130 | name[8] == 'b' && | |
9131 | name[9] == 'y' && | |
9132 | name[10] == 'n' && | |
9133 | name[11] == 'a' && | |
9134 | name[12] == 'm' && | |
9135 | name[13] == 'e') | |
9136 | { /* getprotobyname */ | |
9137 | return -KEY_getprotobyname; | |
9138 | } | |
9139 | ||
9140 | goto unknown; | |
9141 | ||
9142 | case 16: /* 1 tokens of length 16 */ | |
9143 | if (name[0] == 'g' && | |
9144 | name[1] == 'e' && | |
9145 | name[2] == 't' && | |
9146 | name[3] == 'p' && | |
9147 | name[4] == 'r' && | |
9148 | name[5] == 'o' && | |
9149 | name[6] == 't' && | |
9150 | name[7] == 'o' && | |
9151 | name[8] == 'b' && | |
9152 | name[9] == 'y' && | |
9153 | name[10] == 'n' && | |
9154 | name[11] == 'u' && | |
9155 | name[12] == 'm' && | |
9156 | name[13] == 'b' && | |
9157 | name[14] == 'e' && | |
9158 | name[15] == 'r') | |
9159 | { /* getprotobynumber */ | |
9160 | return -KEY_getprotobynumber; | |
9161 | } | |
9162 | ||
9163 | goto unknown; | |
9164 | ||
9165 | default: | |
9166 | goto unknown; | |
e2e1dd5a | 9167 | } |
4c3bbe0f MHM |
9168 | |
9169 | unknown: | |
e2e1dd5a | 9170 | return 0; |
a687059c LW |
9171 | } |
9172 | ||
76e3520e | 9173 | STATIC void |
f54cb97a | 9174 | S_checkcomma(pTHX_ register char *s, const char *name, const char *what) |
a687059c | 9175 | { |
f54cb97a | 9176 | const char *w; |
2f3197b3 | 9177 | |
d008e5eb | 9178 | if (*s == ' ' && s[1] == '(') { /* XXX gotta be a better way */ |
d008e5eb GS |
9179 | if (ckWARN(WARN_SYNTAX)) { |
9180 | int level = 1; | |
9181 | for (w = s+2; *w && level; w++) { | |
9182 | if (*w == '(') | |
9183 | ++level; | |
9184 | else if (*w == ')') | |
9185 | --level; | |
9186 | } | |
9187 | if (*w) | |
9188 | for (; *w && isSPACE(*w); w++) ; | |
9189 | if (!*w || !strchr(";|})]oaiuw!=", *w)) /* an advisory hack only... */ | |
9014280d | 9190 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
65cec589 | 9191 | "%s (...) interpreted as function",name); |
d008e5eb | 9192 | } |
2f3197b3 | 9193 | } |
3280af22 | 9194 | while (s < PL_bufend && isSPACE(*s)) |
2f3197b3 | 9195 | s++; |
a687059c LW |
9196 | if (*s == '(') |
9197 | s++; | |
3280af22 | 9198 | while (s < PL_bufend && isSPACE(*s)) |
a687059c | 9199 | s++; |
7e2040f0 | 9200 | if (isIDFIRST_lazy_if(s,UTF)) { |
2f3197b3 | 9201 | w = s++; |
7e2040f0 | 9202 | while (isALNUM_lazy_if(s,UTF)) |
a687059c | 9203 | s++; |
3280af22 | 9204 | while (s < PL_bufend && isSPACE(*s)) |
a687059c | 9205 | s++; |
e929a76b | 9206 | if (*s == ',') { |
0d863452 | 9207 | I32 kw; |
f54cb97a | 9208 | *s = '\0'; /* XXX If we didn't do this, we could const a lot of toke.c */ |
864dbfa3 | 9209 | kw = keyword(w, s - w) || get_cv(w, FALSE) != 0; |
e929a76b | 9210 | *s = ','; |
463ee0b2 | 9211 | if (kw) |
e929a76b | 9212 | return; |
cea2e8a9 | 9213 | Perl_croak(aTHX_ "No comma allowed after %s", what); |
463ee0b2 LW |
9214 | } |
9215 | } | |
9216 | } | |
9217 | ||
423cee85 JH |
9218 | /* Either returns sv, or mortalizes sv and returns a new SV*. |
9219 | Best used as sv=new_constant(..., sv, ...). | |
9220 | If s, pv are NULL, calls subroutine with one argument, | |
9221 | and type is used with error messages only. */ | |
9222 | ||
b3ac6de7 | 9223 | STATIC SV * |
7fc63493 | 9224 | S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, SV *sv, SV *pv, |
9b0e499b | 9225 | const char *type) |
b3ac6de7 | 9226 | { |
27da23d5 | 9227 | dVAR; dSP; |
890ce7af | 9228 | HV * const table = GvHV(PL_hintgv); /* ^H */ |
b3ac6de7 | 9229 | SV *res; |
b3ac6de7 IZ |
9230 | SV **cvp; |
9231 | SV *cv, *typesv; | |
89e33a05 | 9232 | const char *why1 = "", *why2 = "", *why3 = ""; |
4e553d73 | 9233 | |
f0af216f | 9234 | if (!table || !(PL_hints & HINT_LOCALIZE_HH)) { |
423cee85 JH |
9235 | SV *msg; |
9236 | ||
f0af216f | 9237 | why2 = strEQ(key,"charnames") |
41ab332f | 9238 | ? "(possibly a missing \"use charnames ...\")" |
f0af216f | 9239 | : ""; |
4e553d73 | 9240 | msg = Perl_newSVpvf(aTHX_ "Constant(%s) unknown: %s", |
41ab332f JH |
9241 | (type ? type: "undef"), why2); |
9242 | ||
9243 | /* This is convoluted and evil ("goto considered harmful") | |
9244 | * but I do not understand the intricacies of all the different | |
9245 | * failure modes of %^H in here. The goal here is to make | |
9246 | * the most probable error message user-friendly. --jhi */ | |
9247 | ||
9248 | goto msgdone; | |
9249 | ||
423cee85 | 9250 | report: |
4e553d73 | 9251 | msg = Perl_newSVpvf(aTHX_ "Constant(%s): %s%s%s", |
f0af216f | 9252 | (type ? type: "undef"), why1, why2, why3); |
41ab332f | 9253 | msgdone: |
95a20fc0 | 9254 | yyerror(SvPVX_const(msg)); |
423cee85 JH |
9255 | SvREFCNT_dec(msg); |
9256 | return sv; | |
9257 | } | |
b3ac6de7 IZ |
9258 | cvp = hv_fetch(table, key, strlen(key), FALSE); |
9259 | if (!cvp || !SvOK(*cvp)) { | |
423cee85 JH |
9260 | why1 = "$^H{"; |
9261 | why2 = key; | |
f0af216f | 9262 | why3 = "} is not defined"; |
423cee85 | 9263 | goto report; |
b3ac6de7 IZ |
9264 | } |
9265 | sv_2mortal(sv); /* Parent created it permanently */ | |
9266 | cv = *cvp; | |
423cee85 JH |
9267 | if (!pv && s) |
9268 | pv = sv_2mortal(newSVpvn(s, len)); | |
9269 | if (type && pv) | |
9270 | typesv = sv_2mortal(newSVpv(type, 0)); | |
b3ac6de7 | 9271 | else |
423cee85 | 9272 | typesv = &PL_sv_undef; |
4e553d73 | 9273 | |
e788e7d3 | 9274 | PUSHSTACKi(PERLSI_OVERLOAD); |
423cee85 JH |
9275 | ENTER ; |
9276 | SAVETMPS; | |
4e553d73 | 9277 | |
423cee85 | 9278 | PUSHMARK(SP) ; |
a5845cb7 | 9279 | EXTEND(sp, 3); |
423cee85 JH |
9280 | if (pv) |
9281 | PUSHs(pv); | |
b3ac6de7 | 9282 | PUSHs(sv); |
423cee85 JH |
9283 | if (pv) |
9284 | PUSHs(typesv); | |
b3ac6de7 | 9285 | PUTBACK; |
423cee85 | 9286 | call_sv(cv, G_SCALAR | ( PL_in_eval ? 0 : G_EVAL)); |
4e553d73 | 9287 | |
423cee85 | 9288 | SPAGAIN ; |
4e553d73 | 9289 | |
423cee85 | 9290 | /* Check the eval first */ |
9b0e499b | 9291 | if (!PL_in_eval && SvTRUE(ERRSV)) { |
396482e1 | 9292 | sv_catpvs(ERRSV, "Propagated"); |
8b6b16e7 | 9293 | yyerror(SvPV_nolen_const(ERRSV)); /* Duplicates the message inside eval */ |
e1f15930 | 9294 | (void)POPs; |
423cee85 JH |
9295 | res = SvREFCNT_inc(sv); |
9296 | } | |
9297 | else { | |
9298 | res = POPs; | |
e1f15930 | 9299 | (void)SvREFCNT_inc(res); |
423cee85 | 9300 | } |
4e553d73 | 9301 | |
423cee85 JH |
9302 | PUTBACK ; |
9303 | FREETMPS ; | |
9304 | LEAVE ; | |
b3ac6de7 | 9305 | POPSTACK; |
4e553d73 | 9306 | |
b3ac6de7 | 9307 | if (!SvOK(res)) { |
423cee85 JH |
9308 | why1 = "Call to &{$^H{"; |
9309 | why2 = key; | |
f0af216f | 9310 | why3 = "}} did not return a defined value"; |
423cee85 JH |
9311 | sv = res; |
9312 | goto report; | |
9b0e499b | 9313 | } |
423cee85 | 9314 | |
9b0e499b | 9315 | return res; |
b3ac6de7 | 9316 | } |
4e553d73 | 9317 | |
d0a148a6 NC |
9318 | /* Returns a NUL terminated string, with the length of the string written to |
9319 | *slp | |
9320 | */ | |
76e3520e | 9321 | STATIC char * |
cea2e8a9 | 9322 | S_scan_word(pTHX_ register char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp) |
463ee0b2 LW |
9323 | { |
9324 | register char *d = dest; | |
890ce7af | 9325 | register char * const e = d + destlen - 3; /* two-character token, ending NUL */ |
463ee0b2 | 9326 | for (;;) { |
8903cb82 | 9327 | if (d >= e) |
cea2e8a9 | 9328 | Perl_croak(aTHX_ ident_too_long); |
834a4ddd | 9329 | if (isALNUM(*s)) /* UTF handled below */ |
463ee0b2 | 9330 | *d++ = *s++; |
7e2040f0 | 9331 | else if (*s == '\'' && allow_package && isIDFIRST_lazy_if(s+1,UTF)) { |
463ee0b2 LW |
9332 | *d++ = ':'; |
9333 | *d++ = ':'; | |
9334 | s++; | |
9335 | } | |
c3e0f903 | 9336 | else if (*s == ':' && s[1] == ':' && allow_package && s[2] != '$') { |
463ee0b2 LW |
9337 | *d++ = *s++; |
9338 | *d++ = *s++; | |
9339 | } | |
fd400ab9 | 9340 | else if (UTF && UTF8_IS_START(*s) && isALNUM_utf8((U8*)s)) { |
a0ed51b3 | 9341 | char *t = s + UTF8SKIP(s); |
fd400ab9 | 9342 | while (UTF8_IS_CONTINUED(*t) && is_utf8_mark((U8*)t)) |
a0ed51b3 LW |
9343 | t += UTF8SKIP(t); |
9344 | if (d + (t - s) > e) | |
cea2e8a9 | 9345 | Perl_croak(aTHX_ ident_too_long); |
a0ed51b3 LW |
9346 | Copy(s, d, t - s, char); |
9347 | d += t - s; | |
9348 | s = t; | |
9349 | } | |
463ee0b2 LW |
9350 | else { |
9351 | *d = '\0'; | |
9352 | *slp = d - dest; | |
9353 | return s; | |
e929a76b | 9354 | } |
378cc40b LW |
9355 | } |
9356 | } | |
9357 | ||
76e3520e | 9358 | STATIC char * |
f54cb97a | 9359 | S_scan_ident(pTHX_ register char *s, register const char *send, char *dest, STRLEN destlen, I32 ck_uni) |
378cc40b LW |
9360 | { |
9361 | register char *d; | |
8903cb82 | 9362 | register char *e; |
46c461b5 | 9363 | char *bracket = Nullch; |
748a9306 | 9364 | char funny = *s++; |
378cc40b | 9365 | |
a0d0e21e LW |
9366 | if (isSPACE(*s)) |
9367 | s = skipspace(s); | |
378cc40b | 9368 | d = dest; |
8903cb82 | 9369 | e = d + destlen - 3; /* two-character token, ending NUL */ |
de3bb511 | 9370 | if (isDIGIT(*s)) { |
8903cb82 | 9371 | while (isDIGIT(*s)) { |
9372 | if (d >= e) | |
cea2e8a9 | 9373 | Perl_croak(aTHX_ ident_too_long); |
378cc40b | 9374 | *d++ = *s++; |
8903cb82 | 9375 | } |
378cc40b LW |
9376 | } |
9377 | else { | |
463ee0b2 | 9378 | for (;;) { |
8903cb82 | 9379 | if (d >= e) |
cea2e8a9 | 9380 | Perl_croak(aTHX_ ident_too_long); |
834a4ddd | 9381 | if (isALNUM(*s)) /* UTF handled below */ |
463ee0b2 | 9382 | *d++ = *s++; |
7e2040f0 | 9383 | else if (*s == '\'' && isIDFIRST_lazy_if(s+1,UTF)) { |
463ee0b2 LW |
9384 | *d++ = ':'; |
9385 | *d++ = ':'; | |
9386 | s++; | |
9387 | } | |
a0d0e21e | 9388 | else if (*s == ':' && s[1] == ':') { |
463ee0b2 LW |
9389 | *d++ = *s++; |
9390 | *d++ = *s++; | |
9391 | } | |
fd400ab9 | 9392 | else if (UTF && UTF8_IS_START(*s) && isALNUM_utf8((U8*)s)) { |
a0ed51b3 | 9393 | char *t = s + UTF8SKIP(s); |
fd400ab9 | 9394 | while (UTF8_IS_CONTINUED(*t) && is_utf8_mark((U8*)t)) |
a0ed51b3 LW |
9395 | t += UTF8SKIP(t); |
9396 | if (d + (t - s) > e) | |
cea2e8a9 | 9397 | Perl_croak(aTHX_ ident_too_long); |
a0ed51b3 LW |
9398 | Copy(s, d, t - s, char); |
9399 | d += t - s; | |
9400 | s = t; | |
9401 | } | |
463ee0b2 LW |
9402 | else |
9403 | break; | |
9404 | } | |
378cc40b LW |
9405 | } |
9406 | *d = '\0'; | |
9407 | d = dest; | |
79072805 | 9408 | if (*d) { |
3280af22 NIS |
9409 | if (PL_lex_state != LEX_NORMAL) |
9410 | PL_lex_state = LEX_INTERPENDMAYBE; | |
79072805 | 9411 | return s; |
378cc40b | 9412 | } |
748a9306 | 9413 | if (*s == '$' && s[1] && |
3792a11b | 9414 | (isALNUM_lazy_if(s+1,UTF) || s[1] == '$' || s[1] == '{' || strnEQ(s+1,"::",2)) ) |
5cd24f17 | 9415 | { |
4810e5ec | 9416 | return s; |
5cd24f17 | 9417 | } |
79072805 LW |
9418 | if (*s == '{') { |
9419 | bracket = s; | |
9420 | s++; | |
9421 | } | |
9422 | else if (ck_uni) | |
9423 | check_uni(); | |
93a17b20 | 9424 | if (s < send) |
79072805 LW |
9425 | *d = *s++; |
9426 | d[1] = '\0'; | |
2b92dfce | 9427 | if (*d == '^' && *s && isCONTROLVAR(*s)) { |
bbce6d69 | 9428 | *d = toCTRL(*s); |
9429 | s++; | |
de3bb511 | 9430 | } |
79072805 | 9431 | if (bracket) { |
748a9306 | 9432 | if (isSPACE(s[-1])) { |
fa83b5b6 | 9433 | while (s < send) { |
f54cb97a | 9434 | const char ch = *s++; |
bf4acbe4 | 9435 | if (!SPACE_OR_TAB(ch)) { |
fa83b5b6 | 9436 | *d = ch; |
9437 | break; | |
9438 | } | |
9439 | } | |
748a9306 | 9440 | } |
7e2040f0 | 9441 | if (isIDFIRST_lazy_if(d,UTF)) { |
79072805 | 9442 | d++; |
a0ed51b3 LW |
9443 | if (UTF) { |
9444 | e = s; | |
155aba94 | 9445 | while ((e < send && isALNUM_lazy_if(e,UTF)) || *e == ':') { |
a0ed51b3 | 9446 | e += UTF8SKIP(e); |
fd400ab9 | 9447 | while (e < send && UTF8_IS_CONTINUED(*e) && is_utf8_mark((U8*)e)) |
a0ed51b3 LW |
9448 | e += UTF8SKIP(e); |
9449 | } | |
9450 | Copy(s, d, e - s, char); | |
9451 | d += e - s; | |
9452 | s = e; | |
9453 | } | |
9454 | else { | |
2b92dfce | 9455 | while ((isALNUM(*s) || *s == ':') && d < e) |
a0ed51b3 | 9456 | *d++ = *s++; |
2b92dfce | 9457 | if (d >= e) |
cea2e8a9 | 9458 | Perl_croak(aTHX_ ident_too_long); |
a0ed51b3 | 9459 | } |
79072805 | 9460 | *d = '\0'; |
bf4acbe4 | 9461 | while (s < send && SPACE_OR_TAB(*s)) s++; |
ff68c719 | 9462 | if ((*s == '[' || (*s == '{' && strNE(dest, "sub")))) { |
599cee73 | 9463 | if (ckWARN(WARN_AMBIGUOUS) && keyword(dest, d - dest)) { |
dff6d3cd | 9464 | const char *brack = *s == '[' ? "[...]" : "{...}"; |
9014280d | 9465 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
599cee73 | 9466 | "Ambiguous use of %c{%s%s} resolved to %c%s%s", |
748a9306 LW |
9467 | funny, dest, brack, funny, dest, brack); |
9468 | } | |
79072805 | 9469 | bracket++; |
a0be28da | 9470 | PL_lex_brackstack[PL_lex_brackets++] = (char)(XOPERATOR | XFAKEBRACK); |
79072805 LW |
9471 | return s; |
9472 | } | |
4e553d73 NIS |
9473 | } |
9474 | /* Handle extended ${^Foo} variables | |
2b92dfce GS |
9475 | * 1999-02-27 mjd-perl-patch@plover.com */ |
9476 | else if (!isALNUM(*d) && !isPRINT(*d) /* isCTRL(d) */ | |
9477 | && isALNUM(*s)) | |
9478 | { | |
9479 | d++; | |
9480 | while (isALNUM(*s) && d < e) { | |
9481 | *d++ = *s++; | |
9482 | } | |
9483 | if (d >= e) | |
cea2e8a9 | 9484 | Perl_croak(aTHX_ ident_too_long); |
2b92dfce | 9485 | *d = '\0'; |
79072805 LW |
9486 | } |
9487 | if (*s == '}') { | |
9488 | s++; | |
7df0d042 | 9489 | if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets) { |
3280af22 | 9490 | PL_lex_state = LEX_INTERPEND; |
7df0d042 AE |
9491 | PL_expect = XREF; |
9492 | } | |
748a9306 LW |
9493 | if (funny == '#') |
9494 | funny = '@'; | |
d008e5eb | 9495 | if (PL_lex_state == LEX_NORMAL) { |
d008e5eb | 9496 | if (ckWARN(WARN_AMBIGUOUS) && |
864dbfa3 | 9497 | (keyword(dest, d - dest) || get_cv(dest, FALSE))) |
d008e5eb | 9498 | { |
9014280d | 9499 | Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS), |
d008e5eb GS |
9500 | "Ambiguous use of %c{%s} resolved to %c%s", |
9501 | funny, dest, funny, dest); | |
9502 | } | |
9503 | } | |
79072805 LW |
9504 | } |
9505 | else { | |
9506 | s = bracket; /* let the parser handle it */ | |
93a17b20 | 9507 | *dest = '\0'; |
79072805 LW |
9508 | } |
9509 | } | |
3280af22 NIS |
9510 | else if (PL_lex_state == LEX_INTERPNORMAL && !PL_lex_brackets && !intuit_more(s)) |
9511 | PL_lex_state = LEX_INTERPEND; | |
378cc40b LW |
9512 | return s; |
9513 | } | |
9514 | ||
cea2e8a9 | 9515 | void |
2b36a5a0 | 9516 | Perl_pmflag(pTHX_ U32* pmfl, int ch) |
a0d0e21e | 9517 | { |
bbce6d69 | 9518 | if (ch == 'i') |
a0d0e21e | 9519 | *pmfl |= PMf_FOLD; |
a0d0e21e LW |
9520 | else if (ch == 'g') |
9521 | *pmfl |= PMf_GLOBAL; | |
c90c0ff4 | 9522 | else if (ch == 'c') |
9523 | *pmfl |= PMf_CONTINUE; | |
a0d0e21e LW |
9524 | else if (ch == 'o') |
9525 | *pmfl |= PMf_KEEP; | |
9526 | else if (ch == 'm') | |
9527 | *pmfl |= PMf_MULTILINE; | |
9528 | else if (ch == 's') | |
9529 | *pmfl |= PMf_SINGLELINE; | |
9530 | else if (ch == 'x') | |
9531 | *pmfl |= PMf_EXTENDED; | |
9532 | } | |
378cc40b | 9533 | |
76e3520e | 9534 | STATIC char * |
cea2e8a9 | 9535 | S_scan_pat(pTHX_ char *start, I32 type) |
378cc40b | 9536 | { |
79072805 | 9537 | PMOP *pm; |
f54cb97a | 9538 | char *s = scan_str(start,FALSE,FALSE); |
378cc40b | 9539 | |
25c09cbf | 9540 | if (!s) { |
46c461b5 | 9541 | char * const delimiter = skipspace(start); |
25c09cbf SF |
9542 | Perl_croak(aTHX_ *delimiter == '?' |
9543 | ? "Search pattern not terminated or ternary operator parsed as search pattern" | |
9544 | : "Search pattern not terminated" ); | |
9545 | } | |
bbce6d69 | 9546 | |
8782bef2 | 9547 | pm = (PMOP*)newPMOP(type, 0); |
3280af22 | 9548 | if (PL_multi_open == '?') |
79072805 | 9549 | pm->op_pmflags |= PMf_ONCE; |
8782bef2 GB |
9550 | if(type == OP_QR) { |
9551 | while (*s && strchr("iomsx", *s)) | |
9552 | pmflag(&pm->op_pmflags,*s++); | |
9553 | } | |
9554 | else { | |
9555 | while (*s && strchr("iogcmsx", *s)) | |
9556 | pmflag(&pm->op_pmflags,*s++); | |
9557 | } | |
4ac733c9 | 9558 | /* issue a warning if /c is specified,but /g is not */ |
041457d9 DM |
9559 | if ((pm->op_pmflags & PMf_CONTINUE) && !(pm->op_pmflags & PMf_GLOBAL) |
9560 | && ckWARN(WARN_REGEXP)) | |
4ac733c9 | 9561 | { |
0bd48802 | 9562 | Perl_warner(aTHX_ packWARN(WARN_REGEXP), "Use of /c modifier is meaningless without /g" ); |
4ac733c9 MJD |
9563 | } |
9564 | ||
4633a7c4 | 9565 | pm->op_pmpermflags = pm->op_pmflags; |
bbce6d69 | 9566 | |
3280af22 | 9567 | PL_lex_op = (OP*)pm; |
79072805 | 9568 | yylval.ival = OP_MATCH; |
378cc40b LW |
9569 | return s; |
9570 | } | |
9571 | ||
76e3520e | 9572 | STATIC char * |
cea2e8a9 | 9573 | S_scan_subst(pTHX_ char *start) |
79072805 | 9574 | { |
27da23d5 | 9575 | dVAR; |
a0d0e21e | 9576 | register char *s; |
79072805 | 9577 | register PMOP *pm; |
4fdae800 | 9578 | I32 first_start; |
79072805 LW |
9579 | I32 es = 0; |
9580 | ||
79072805 LW |
9581 | yylval.ival = OP_NULL; |
9582 | ||
09bef843 | 9583 | s = scan_str(start,FALSE,FALSE); |
79072805 | 9584 | |
37fd879b | 9585 | if (!s) |
cea2e8a9 | 9586 | Perl_croak(aTHX_ "Substitution pattern not terminated"); |
79072805 | 9587 | |
3280af22 | 9588 | if (s[-1] == PL_multi_open) |
79072805 LW |
9589 | s--; |
9590 | ||
3280af22 | 9591 | first_start = PL_multi_start; |
09bef843 | 9592 | s = scan_str(s,FALSE,FALSE); |
79072805 | 9593 | if (!s) { |
37fd879b | 9594 | if (PL_lex_stuff) { |
3280af22 | 9595 | SvREFCNT_dec(PL_lex_stuff); |
37fd879b HS |
9596 | PL_lex_stuff = Nullsv; |
9597 | } | |
cea2e8a9 | 9598 | Perl_croak(aTHX_ "Substitution replacement not terminated"); |
a687059c | 9599 | } |
3280af22 | 9600 | PL_multi_start = first_start; /* so whole substitution is taken together */ |
2f3197b3 | 9601 | |
79072805 | 9602 | pm = (PMOP*)newPMOP(OP_SUBST, 0); |
48c036b1 | 9603 | while (*s) { |
a687059c LW |
9604 | if (*s == 'e') { |
9605 | s++; | |
2f3197b3 | 9606 | es++; |
a687059c | 9607 | } |
b3eb6a9b | 9608 | else if (strchr("iogcmsx", *s)) |
a0d0e21e | 9609 | pmflag(&pm->op_pmflags,*s++); |
48c036b1 GS |
9610 | else |
9611 | break; | |
378cc40b | 9612 | } |
79072805 | 9613 | |
0bd48802 AL |
9614 | if ((pm->op_pmflags & PMf_CONTINUE) && ckWARN(WARN_REGEXP)) { |
9615 | Perl_warner(aTHX_ packWARN(WARN_REGEXP), "Use of /c modifier is meaningless in s///" ); | |
4ac733c9 MJD |
9616 | } |
9617 | ||
79072805 LW |
9618 | if (es) { |
9619 | SV *repl; | |
0244c3a4 GS |
9620 | PL_sublex_info.super_bufptr = s; |
9621 | PL_sublex_info.super_bufend = PL_bufend; | |
9622 | PL_multi_end = 0; | |
79072805 | 9623 | pm->op_pmflags |= PMf_EVAL; |
396482e1 | 9624 | repl = newSVpvs(""); |
463ee0b2 | 9625 | while (es-- > 0) |
a0d0e21e | 9626 | sv_catpv(repl, es ? "eval " : "do "); |
396482e1 | 9627 | sv_catpvs(repl, "{ "); |
3280af22 | 9628 | sv_catsv(repl, PL_lex_repl); |
396482e1 | 9629 | sv_catpvs(repl, " }"); |
25da4f38 | 9630 | SvEVALED_on(repl); |
3280af22 NIS |
9631 | SvREFCNT_dec(PL_lex_repl); |
9632 | PL_lex_repl = repl; | |
378cc40b | 9633 | } |
79072805 | 9634 | |
4633a7c4 | 9635 | pm->op_pmpermflags = pm->op_pmflags; |
3280af22 | 9636 | PL_lex_op = (OP*)pm; |
79072805 | 9637 | yylval.ival = OP_SUBST; |
378cc40b LW |
9638 | return s; |
9639 | } | |
9640 | ||
76e3520e | 9641 | STATIC char * |
cea2e8a9 | 9642 | S_scan_trans(pTHX_ char *start) |
378cc40b | 9643 | { |
a0d0e21e | 9644 | register char* s; |
11343788 | 9645 | OP *o; |
79072805 LW |
9646 | short *tbl; |
9647 | I32 squash; | |
a0ed51b3 | 9648 | I32 del; |
79072805 LW |
9649 | I32 complement; |
9650 | ||
9651 | yylval.ival = OP_NULL; | |
9652 | ||
09bef843 | 9653 | s = scan_str(start,FALSE,FALSE); |
37fd879b | 9654 | if (!s) |
cea2e8a9 | 9655 | Perl_croak(aTHX_ "Transliteration pattern not terminated"); |
3280af22 | 9656 | if (s[-1] == PL_multi_open) |
2f3197b3 LW |
9657 | s--; |
9658 | ||
09bef843 | 9659 | s = scan_str(s,FALSE,FALSE); |
79072805 | 9660 | if (!s) { |
37fd879b | 9661 | if (PL_lex_stuff) { |
3280af22 | 9662 | SvREFCNT_dec(PL_lex_stuff); |
37fd879b HS |
9663 | PL_lex_stuff = Nullsv; |
9664 | } | |
cea2e8a9 | 9665 | Perl_croak(aTHX_ "Transliteration replacement not terminated"); |
a687059c | 9666 | } |
79072805 | 9667 | |
a0ed51b3 | 9668 | complement = del = squash = 0; |
7a1e2023 NC |
9669 | while (1) { |
9670 | switch (*s) { | |
9671 | case 'c': | |
79072805 | 9672 | complement = OPpTRANS_COMPLEMENT; |
7a1e2023 NC |
9673 | break; |
9674 | case 'd': | |
a0ed51b3 | 9675 | del = OPpTRANS_DELETE; |
7a1e2023 NC |
9676 | break; |
9677 | case 's': | |
79072805 | 9678 | squash = OPpTRANS_SQUASH; |
7a1e2023 NC |
9679 | break; |
9680 | default: | |
9681 | goto no_more; | |
9682 | } | |
395c3793 LW |
9683 | s++; |
9684 | } | |
7a1e2023 | 9685 | no_more: |
8973db79 | 9686 | |
a02a5408 | 9687 | Newx(tbl, complement&&!del?258:256, short); |
8973db79 | 9688 | o = newPVOP(OP_TRANS, 0, (char*)tbl); |
59f00321 RGS |
9689 | o->op_private &= ~OPpTRANS_ALL; |
9690 | o->op_private |= del|squash|complement| | |
7948272d NIS |
9691 | (DO_UTF8(PL_lex_stuff)? OPpTRANS_FROM_UTF : 0)| |
9692 | (DO_UTF8(PL_lex_repl) ? OPpTRANS_TO_UTF : 0); | |
79072805 | 9693 | |
3280af22 | 9694 | PL_lex_op = o; |
79072805 LW |
9695 | yylval.ival = OP_TRANS; |
9696 | return s; | |
9697 | } | |
9698 | ||
76e3520e | 9699 | STATIC char * |
cea2e8a9 | 9700 | S_scan_heredoc(pTHX_ register char *s) |
79072805 LW |
9701 | { |
9702 | SV *herewas; | |
9703 | I32 op_type = OP_SCALAR; | |
9704 | I32 len; | |
9705 | SV *tmpstr; | |
9706 | char term; | |
73d840c0 | 9707 | const char *found_newline; |
79072805 | 9708 | register char *d; |
fc36a67e | 9709 | register char *e; |
4633a7c4 | 9710 | char *peek; |
f54cb97a | 9711 | const int outer = (PL_rsfp && !(PL_lex_inwhat == OP_SCALAR)); |
79072805 LW |
9712 | |
9713 | s += 2; | |
3280af22 NIS |
9714 | d = PL_tokenbuf; |
9715 | e = PL_tokenbuf + sizeof PL_tokenbuf - 1; | |
fd2d0953 | 9716 | if (!outer) |
79072805 | 9717 | *d++ = '\n'; |
bf4acbe4 | 9718 | for (peek = s; SPACE_OR_TAB(*peek); peek++) ; |
3792a11b | 9719 | if (*peek == '`' || *peek == '\'' || *peek =='"') { |
4633a7c4 | 9720 | s = peek; |
79072805 | 9721 | term = *s++; |
3280af22 | 9722 | s = delimcpy(d, e, s, PL_bufend, term, &len); |
fc36a67e | 9723 | d += len; |
3280af22 | 9724 | if (s < PL_bufend) |
79072805 | 9725 | s++; |
79072805 LW |
9726 | } |
9727 | else { | |
9728 | if (*s == '\\') | |
9729 | s++, term = '\''; | |
9730 | else | |
9731 | term = '"'; | |
7e2040f0 | 9732 | if (!isALNUM_lazy_if(s,UTF)) |
12bcd1a6 | 9733 | deprecate_old("bare << to mean <<\"\""); |
7e2040f0 | 9734 | for (; isALNUM_lazy_if(s,UTF); s++) { |
fc36a67e | 9735 | if (d < e) |
9736 | *d++ = *s; | |
9737 | } | |
9738 | } | |
3280af22 | 9739 | if (d >= PL_tokenbuf + sizeof PL_tokenbuf - 1) |
cea2e8a9 | 9740 | Perl_croak(aTHX_ "Delimiter for here document is too long"); |
79072805 LW |
9741 | *d++ = '\n'; |
9742 | *d = '\0'; | |
3280af22 | 9743 | len = d - PL_tokenbuf; |
6a27c188 | 9744 | #ifndef PERL_STRICT_CR |
f63a84b2 LW |
9745 | d = strchr(s, '\r'); |
9746 | if (d) { | |
b464bac0 | 9747 | char * const olds = s; |
f63a84b2 | 9748 | s = d; |
3280af22 | 9749 | while (s < PL_bufend) { |
f63a84b2 LW |
9750 | if (*s == '\r') { |
9751 | *d++ = '\n'; | |
9752 | if (*++s == '\n') | |
9753 | s++; | |
9754 | } | |
9755 | else if (*s == '\n' && s[1] == '\r') { /* \015\013 on a mac? */ | |
9756 | *d++ = *s++; | |
9757 | s++; | |
9758 | } | |
9759 | else | |
9760 | *d++ = *s++; | |
9761 | } | |
9762 | *d = '\0'; | |
3280af22 | 9763 | PL_bufend = d; |
95a20fc0 | 9764 | SvCUR_set(PL_linestr, PL_bufend - SvPVX_const(PL_linestr)); |
f63a84b2 LW |
9765 | s = olds; |
9766 | } | |
9767 | #endif | |
e81b0615 | 9768 | if ( outer || !(found_newline = memchr(s, '\n', PL_bufend - s)) ) { |
73d840c0 AL |
9769 | herewas = newSVpvn(s,PL_bufend-s); |
9770 | } | |
9771 | else { | |
9772 | s--; | |
9773 | herewas = newSVpvn(s,found_newline-s); | |
9774 | } | |
79072805 | 9775 | s += SvCUR(herewas); |
748a9306 | 9776 | |
8d6dde3e | 9777 | tmpstr = NEWSV(87,79); |
748a9306 LW |
9778 | sv_upgrade(tmpstr, SVt_PVIV); |
9779 | if (term == '\'') { | |
79072805 | 9780 | op_type = OP_CONST; |
45977657 | 9781 | SvIV_set(tmpstr, -1); |
748a9306 LW |
9782 | } |
9783 | else if (term == '`') { | |
79072805 | 9784 | op_type = OP_BACKTICK; |
45977657 | 9785 | SvIV_set(tmpstr, '\\'); |
748a9306 | 9786 | } |
79072805 LW |
9787 | |
9788 | CLINE; | |
57843af0 | 9789 | PL_multi_start = CopLINE(PL_curcop); |
3280af22 NIS |
9790 | PL_multi_open = PL_multi_close = '<'; |
9791 | term = *PL_tokenbuf; | |
0244c3a4 GS |
9792 | if (PL_lex_inwhat == OP_SUBST && PL_in_eval && !PL_rsfp) { |
9793 | char *bufptr = PL_sublex_info.super_bufptr; | |
9794 | char *bufend = PL_sublex_info.super_bufend; | |
b464bac0 | 9795 | char * const olds = s - SvCUR(herewas); |
0244c3a4 GS |
9796 | s = strchr(bufptr, '\n'); |
9797 | if (!s) | |
9798 | s = bufend; | |
9799 | d = s; | |
9800 | while (s < bufend && | |
9801 | (*s != term || memNE(s,PL_tokenbuf,len)) ) { | |
9802 | if (*s++ == '\n') | |
57843af0 | 9803 | CopLINE_inc(PL_curcop); |
0244c3a4 GS |
9804 | } |
9805 | if (s >= bufend) { | |
eb160463 | 9806 | CopLINE_set(PL_curcop, (line_t)PL_multi_start); |
0244c3a4 GS |
9807 | missingterm(PL_tokenbuf); |
9808 | } | |
9809 | sv_setpvn(herewas,bufptr,d-bufptr+1); | |
9810 | sv_setpvn(tmpstr,d+1,s-d); | |
9811 | s += len - 1; | |
9812 | sv_catpvn(herewas,s,bufend-s); | |
95a20fc0 | 9813 | Copy(SvPVX_const(herewas),bufptr,SvCUR(herewas) + 1,char); |
0244c3a4 GS |
9814 | |
9815 | s = olds; | |
9816 | goto retval; | |
9817 | } | |
9818 | else if (!outer) { | |
79072805 | 9819 | d = s; |
3280af22 NIS |
9820 | while (s < PL_bufend && |
9821 | (*s != term || memNE(s,PL_tokenbuf,len)) ) { | |
79072805 | 9822 | if (*s++ == '\n') |
57843af0 | 9823 | CopLINE_inc(PL_curcop); |
79072805 | 9824 | } |
3280af22 | 9825 | if (s >= PL_bufend) { |
eb160463 | 9826 | CopLINE_set(PL_curcop, (line_t)PL_multi_start); |
3280af22 | 9827 | missingterm(PL_tokenbuf); |
79072805 LW |
9828 | } |
9829 | sv_setpvn(tmpstr,d+1,s-d); | |
9830 | s += len - 1; | |
57843af0 | 9831 | CopLINE_inc(PL_curcop); /* the preceding stmt passes a newline */ |
49d8d3a1 | 9832 | |
3280af22 NIS |
9833 | sv_catpvn(herewas,s,PL_bufend-s); |
9834 | sv_setsv(PL_linestr,herewas); | |
9835 | PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = s = PL_linestart = SvPVX(PL_linestr); | |
9836 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
207e3d1a | 9837 | PL_last_lop = PL_last_uni = Nullch; |
79072805 LW |
9838 | } |
9839 | else | |
9840 | sv_setpvn(tmpstr,"",0); /* avoid "uninitialized" warning */ | |
3280af22 | 9841 | while (s >= PL_bufend) { /* multiple line string? */ |
fd2d0953 | 9842 | if (!outer || |
3280af22 | 9843 | !(PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = filter_gets(PL_linestr, PL_rsfp, 0))) { |
eb160463 | 9844 | CopLINE_set(PL_curcop, (line_t)PL_multi_start); |
3280af22 | 9845 | missingterm(PL_tokenbuf); |
79072805 | 9846 | } |
57843af0 | 9847 | CopLINE_inc(PL_curcop); |
3280af22 | 9848 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); |
207e3d1a | 9849 | PL_last_lop = PL_last_uni = Nullch; |
6a27c188 | 9850 | #ifndef PERL_STRICT_CR |
3280af22 | 9851 | if (PL_bufend - PL_linestart >= 2) { |
a1529941 NIS |
9852 | if ((PL_bufend[-2] == '\r' && PL_bufend[-1] == '\n') || |
9853 | (PL_bufend[-2] == '\n' && PL_bufend[-1] == '\r')) | |
c6f14548 | 9854 | { |
3280af22 NIS |
9855 | PL_bufend[-2] = '\n'; |
9856 | PL_bufend--; | |
95a20fc0 | 9857 | SvCUR_set(PL_linestr, PL_bufend - SvPVX_const(PL_linestr)); |
f63a84b2 | 9858 | } |
3280af22 NIS |
9859 | else if (PL_bufend[-1] == '\r') |
9860 | PL_bufend[-1] = '\n'; | |
f63a84b2 | 9861 | } |
3280af22 NIS |
9862 | else if (PL_bufend - PL_linestart == 1 && PL_bufend[-1] == '\r') |
9863 | PL_bufend[-1] = '\n'; | |
f63a84b2 | 9864 | #endif |
3280af22 | 9865 | if (PERLDB_LINE && PL_curstash != PL_debstash) { |
79072805 LW |
9866 | SV *sv = NEWSV(88,0); |
9867 | ||
93a17b20 | 9868 | sv_upgrade(sv, SVt_PVMG); |
3280af22 | 9869 | sv_setsv(sv,PL_linestr); |
0ac0412a | 9870 | (void)SvIOK_on(sv); |
45977657 | 9871 | SvIV_set(sv, 0); |
36c7798d | 9872 | av_store(CopFILEAVx(PL_curcop), (I32)CopLINE(PL_curcop),sv); |
79072805 | 9873 | } |
3280af22 | 9874 | if (*s == term && memEQ(s,PL_tokenbuf,len)) { |
95a20fc0 | 9875 | STRLEN off = PL_bufend - 1 - SvPVX_const(PL_linestr); |
1de9afcd | 9876 | *(SvPVX(PL_linestr) + off ) = ' '; |
3280af22 NIS |
9877 | sv_catsv(PL_linestr,herewas); |
9878 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
1de9afcd | 9879 | s = SvPVX(PL_linestr) + off; /* In case PV of PL_linestr moved. */ |
79072805 LW |
9880 | } |
9881 | else { | |
3280af22 NIS |
9882 | s = PL_bufend; |
9883 | sv_catsv(tmpstr,PL_linestr); | |
395c3793 LW |
9884 | } |
9885 | } | |
79072805 | 9886 | s++; |
0244c3a4 | 9887 | retval: |
57843af0 | 9888 | PL_multi_end = CopLINE(PL_curcop); |
79072805 | 9889 | if (SvCUR(tmpstr) + 5 < SvLEN(tmpstr)) { |
1da4ca5f | 9890 | SvPV_shrink_to_cur(tmpstr); |
79072805 | 9891 | } |
8990e307 | 9892 | SvREFCNT_dec(herewas); |
2f31ce75 | 9893 | if (!IN_BYTES) { |
95a20fc0 | 9894 | if (UTF && is_utf8_string((U8*)SvPVX_const(tmpstr), SvCUR(tmpstr))) |
2f31ce75 JH |
9895 | SvUTF8_on(tmpstr); |
9896 | else if (PL_encoding) | |
9897 | sv_recode_to_utf8(tmpstr, PL_encoding); | |
9898 | } | |
3280af22 | 9899 | PL_lex_stuff = tmpstr; |
79072805 LW |
9900 | yylval.ival = op_type; |
9901 | return s; | |
9902 | } | |
9903 | ||
02aa26ce NT |
9904 | /* scan_inputsymbol |
9905 | takes: current position in input buffer | |
9906 | returns: new position in input buffer | |
9907 | side-effects: yylval and lex_op are set. | |
9908 | ||
9909 | This code handles: | |
9910 | ||
9911 | <> read from ARGV | |
9912 | <FH> read from filehandle | |
9913 | <pkg::FH> read from package qualified filehandle | |
9914 | <pkg'FH> read from package qualified filehandle | |
9915 | <$fh> read from filehandle in $fh | |
9916 | <*.h> filename glob | |
9917 | ||
9918 | */ | |
9919 | ||
76e3520e | 9920 | STATIC char * |
cea2e8a9 | 9921 | S_scan_inputsymbol(pTHX_ char *start) |
79072805 | 9922 | { |
02aa26ce | 9923 | register char *s = start; /* current position in buffer */ |
79072805 | 9924 | register char *d; |
cfd0369c | 9925 | const char *e; |
1b420867 | 9926 | char *end; |
79072805 LW |
9927 | I32 len; |
9928 | ||
3280af22 NIS |
9929 | d = PL_tokenbuf; /* start of temp holding space */ |
9930 | e = PL_tokenbuf + sizeof PL_tokenbuf; /* end of temp holding space */ | |
1b420867 GS |
9931 | end = strchr(s, '\n'); |
9932 | if (!end) | |
9933 | end = PL_bufend; | |
9934 | s = delimcpy(d, e, s + 1, end, '>', &len); /* extract until > */ | |
02aa26ce NT |
9935 | |
9936 | /* die if we didn't have space for the contents of the <>, | |
1b420867 | 9937 | or if it didn't end, or if we see a newline |
02aa26ce NT |
9938 | */ |
9939 | ||
3280af22 | 9940 | if (len >= sizeof PL_tokenbuf) |
cea2e8a9 | 9941 | Perl_croak(aTHX_ "Excessively long <> operator"); |
1b420867 | 9942 | if (s >= end) |
cea2e8a9 | 9943 | Perl_croak(aTHX_ "Unterminated <> operator"); |
02aa26ce | 9944 | |
fc36a67e | 9945 | s++; |
02aa26ce NT |
9946 | |
9947 | /* check for <$fh> | |
9948 | Remember, only scalar variables are interpreted as filehandles by | |
9949 | this code. Anything more complex (e.g., <$fh{$num}>) will be | |
9950 | treated as a glob() call. | |
9951 | This code makes use of the fact that except for the $ at the front, | |
9952 | a scalar variable and a filehandle look the same. | |
9953 | */ | |
4633a7c4 | 9954 | if (*d == '$' && d[1]) d++; |
02aa26ce NT |
9955 | |
9956 | /* allow <Pkg'VALUE> or <Pkg::VALUE> */ | |
7e2040f0 | 9957 | while (*d && (isALNUM_lazy_if(d,UTF) || *d == '\'' || *d == ':')) |
79072805 | 9958 | d++; |
02aa26ce NT |
9959 | |
9960 | /* If we've tried to read what we allow filehandles to look like, and | |
9961 | there's still text left, then it must be a glob() and not a getline. | |
9962 | Use scan_str to pull out the stuff between the <> and treat it | |
9963 | as nothing more than a string. | |
9964 | */ | |
9965 | ||
3280af22 | 9966 | if (d - PL_tokenbuf != len) { |
79072805 LW |
9967 | yylval.ival = OP_GLOB; |
9968 | set_csh(); | |
09bef843 | 9969 | s = scan_str(start,FALSE,FALSE); |
79072805 | 9970 | if (!s) |
cea2e8a9 | 9971 | Perl_croak(aTHX_ "Glob not terminated"); |
79072805 LW |
9972 | return s; |
9973 | } | |
395c3793 | 9974 | else { |
9b3023bc RGS |
9975 | bool readline_overriden = FALSE; |
9976 | GV *gv_readline = Nullgv; | |
9977 | GV **gvp; | |
02aa26ce | 9978 | /* we're in a filehandle read situation */ |
3280af22 | 9979 | d = PL_tokenbuf; |
02aa26ce NT |
9980 | |
9981 | /* turn <> into <ARGV> */ | |
79072805 | 9982 | if (!len) |
689badd5 | 9983 | Copy("ARGV",d,5,char); |
02aa26ce | 9984 | |
9b3023bc | 9985 | /* Check whether readline() is overriden */ |
f776e3cd | 9986 | if (((gv_readline = gv_fetchpv("readline", 0, SVt_PVCV)) |
ba979b31 | 9987 | && GvCVu(gv_readline) && GvIMPORTED_CV(gv_readline)) |
9b3023bc | 9988 | || |
ba979b31 | 9989 | ((gvp = (GV**)hv_fetch(PL_globalstash, "readline", 8, FALSE)) |
9b3023bc | 9990 | && (gv_readline = *gvp) != (GV*)&PL_sv_undef |
ba979b31 | 9991 | && GvCVu(gv_readline) && GvIMPORTED_CV(gv_readline))) |
9b3023bc RGS |
9992 | readline_overriden = TRUE; |
9993 | ||
02aa26ce NT |
9994 | /* if <$fh>, create the ops to turn the variable into a |
9995 | filehandle | |
9996 | */ | |
79072805 | 9997 | if (*d == '$') { |
a0d0e21e | 9998 | I32 tmp; |
02aa26ce NT |
9999 | |
10000 | /* try to find it in the pad for this block, otherwise find | |
10001 | add symbol table ops | |
10002 | */ | |
11343788 | 10003 | if ((tmp = pad_findmy(d)) != NOT_IN_PAD) { |
dd2155a4 | 10004 | if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { |
4b6dd97a NC |
10005 | HV *stash = PAD_COMPNAME_OURSTASH(tmp); |
10006 | HEK *stashname = HvNAME_HEK(stash); | |
5aaec2b4 | 10007 | SV *sym = sv_2mortal(newSVhek(stashname)); |
396482e1 | 10008 | sv_catpvs(sym, "::"); |
f558d5af JH |
10009 | sv_catpv(sym, d+1); |
10010 | d = SvPVX(sym); | |
10011 | goto intro_sym; | |
10012 | } | |
10013 | else { | |
10014 | OP *o = newOP(OP_PADSV, 0); | |
10015 | o->op_targ = tmp; | |
9b3023bc RGS |
10016 | PL_lex_op = readline_overriden |
10017 | ? (OP*)newUNOP(OP_ENTERSUB, OPf_STACKED, | |
10018 | append_elem(OP_LIST, o, | |
10019 | newCVREF(0, newGVOP(OP_GV,0,gv_readline)))) | |
10020 | : (OP*)newUNOP(OP_READLINE, 0, o); | |
f558d5af | 10021 | } |
a0d0e21e LW |
10022 | } |
10023 | else { | |
f558d5af JH |
10024 | GV *gv; |
10025 | ++d; | |
10026 | intro_sym: | |
10027 | gv = gv_fetchpv(d, | |
10028 | (PL_in_eval | |
10029 | ? (GV_ADDMULTI | GV_ADDINEVAL) | |
bea70d1e | 10030 | : GV_ADDMULTI), |
f558d5af | 10031 | SVt_PV); |
9b3023bc RGS |
10032 | PL_lex_op = readline_overriden |
10033 | ? (OP*)newUNOP(OP_ENTERSUB, OPf_STACKED, | |
10034 | append_elem(OP_LIST, | |
10035 | newUNOP(OP_RV2SV, 0, newGVOP(OP_GV, 0, gv)), | |
10036 | newCVREF(0, newGVOP(OP_GV, 0, gv_readline)))) | |
10037 | : (OP*)newUNOP(OP_READLINE, 0, | |
10038 | newUNOP(OP_RV2SV, 0, | |
10039 | newGVOP(OP_GV, 0, gv))); | |
a0d0e21e | 10040 | } |
7c6fadd6 RGS |
10041 | if (!readline_overriden) |
10042 | PL_lex_op->op_flags |= OPf_SPECIAL; | |
f5284f61 | 10043 | /* we created the ops in PL_lex_op, so make yylval.ival a null op */ |
79072805 LW |
10044 | yylval.ival = OP_NULL; |
10045 | } | |
02aa26ce NT |
10046 | |
10047 | /* If it's none of the above, it must be a literal filehandle | |
10048 | (<Foo::BAR> or <FOO>) so build a simple readline OP */ | |
79072805 | 10049 | else { |
f776e3cd | 10050 | GV *gv = gv_fetchpv(d, GV_ADD, SVt_PVIO); |
9b3023bc RGS |
10051 | PL_lex_op = readline_overriden |
10052 | ? (OP*)newUNOP(OP_ENTERSUB, OPf_STACKED, | |
10053 | append_elem(OP_LIST, | |
10054 | newGVOP(OP_GV, 0, gv), | |
10055 | newCVREF(0, newGVOP(OP_GV, 0, gv_readline)))) | |
10056 | : (OP*)newUNOP(OP_READLINE, 0, newGVOP(OP_GV, 0, gv)); | |
79072805 LW |
10057 | yylval.ival = OP_NULL; |
10058 | } | |
10059 | } | |
02aa26ce | 10060 | |
79072805 LW |
10061 | return s; |
10062 | } | |
10063 | ||
02aa26ce NT |
10064 | |
10065 | /* scan_str | |
10066 | takes: start position in buffer | |
09bef843 SB |
10067 | keep_quoted preserve \ on the embedded delimiter(s) |
10068 | keep_delims preserve the delimiters around the string | |
02aa26ce NT |
10069 | returns: position to continue reading from buffer |
10070 | side-effects: multi_start, multi_close, lex_repl or lex_stuff, and | |
10071 | updates the read buffer. | |
10072 | ||
10073 | This subroutine pulls a string out of the input. It is called for: | |
10074 | q single quotes q(literal text) | |
10075 | ' single quotes 'literal text' | |
10076 | qq double quotes qq(interpolate $here please) | |
10077 | " double quotes "interpolate $here please" | |
10078 | qx backticks qx(/bin/ls -l) | |
10079 | ` backticks `/bin/ls -l` | |
10080 | qw quote words @EXPORT_OK = qw( func() $spam ) | |
10081 | m// regexp match m/this/ | |
10082 | s/// regexp substitute s/this/that/ | |
10083 | tr/// string transliterate tr/this/that/ | |
10084 | y/// string transliterate y/this/that/ | |
10085 | ($*@) sub prototypes sub foo ($) | |
09bef843 | 10086 | (stuff) sub attr parameters sub foo : attr(stuff) |
02aa26ce NT |
10087 | <> readline or globs <FOO>, <>, <$fh>, or <*.c> |
10088 | ||
10089 | In most of these cases (all but <>, patterns and transliterate) | |
10090 | yylex() calls scan_str(). m// makes yylex() call scan_pat() which | |
10091 | calls scan_str(). s/// makes yylex() call scan_subst() which calls | |
10092 | scan_str(). tr/// and y/// make yylex() call scan_trans() which | |
10093 | calls scan_str(). | |
4e553d73 | 10094 | |
02aa26ce NT |
10095 | It skips whitespace before the string starts, and treats the first |
10096 | character as the delimiter. If the delimiter is one of ([{< then | |
10097 | the corresponding "close" character )]}> is used as the closing | |
10098 | delimiter. It allows quoting of delimiters, and if the string has | |
10099 | balanced delimiters ([{<>}]) it allows nesting. | |
10100 | ||
37fd879b HS |
10101 | On success, the SV with the resulting string is put into lex_stuff or, |
10102 | if that is already non-NULL, into lex_repl. The second case occurs only | |
10103 | when parsing the RHS of the special constructs s/// and tr/// (y///). | |
10104 | For convenience, the terminating delimiter character is stuffed into | |
10105 | SvIVX of the SV. | |
02aa26ce NT |
10106 | */ |
10107 | ||
76e3520e | 10108 | STATIC char * |
09bef843 | 10109 | S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims) |
79072805 | 10110 | { |
02aa26ce NT |
10111 | SV *sv; /* scalar value: string */ |
10112 | char *tmps; /* temp string, used for delimiter matching */ | |
10113 | register char *s = start; /* current position in the buffer */ | |
10114 | register char term; /* terminating character */ | |
10115 | register char *to; /* current position in the sv's data */ | |
10116 | I32 brackets = 1; /* bracket nesting level */ | |
89491803 | 10117 | bool has_utf8 = FALSE; /* is there any utf8 content? */ |
220e2d4e | 10118 | I32 termcode; /* terminating char. code */ |
89ebb4a3 | 10119 | U8 termstr[UTF8_MAXBYTES]; /* terminating string */ |
220e2d4e IH |
10120 | STRLEN termlen; /* length of terminating string */ |
10121 | char *last = NULL; /* last position for nesting bracket */ | |
02aa26ce NT |
10122 | |
10123 | /* skip space before the delimiter */ | |
fb73857a | 10124 | if (isSPACE(*s)) |
10125 | s = skipspace(s); | |
02aa26ce NT |
10126 | |
10127 | /* mark where we are, in case we need to report errors */ | |
79072805 | 10128 | CLINE; |
02aa26ce NT |
10129 | |
10130 | /* after skipping whitespace, the next character is the terminator */ | |
a0d0e21e | 10131 | term = *s; |
220e2d4e IH |
10132 | if (!UTF) { |
10133 | termcode = termstr[0] = term; | |
10134 | termlen = 1; | |
10135 | } | |
10136 | else { | |
f3b9ce0f | 10137 | termcode = utf8_to_uvchr((U8*)s, &termlen); |
220e2d4e IH |
10138 | Copy(s, termstr, termlen, U8); |
10139 | if (!UTF8_IS_INVARIANT(term)) | |
10140 | has_utf8 = TRUE; | |
10141 | } | |
b1c7b182 | 10142 | |
02aa26ce | 10143 | /* mark where we are */ |
57843af0 | 10144 | PL_multi_start = CopLINE(PL_curcop); |
3280af22 | 10145 | PL_multi_open = term; |
02aa26ce NT |
10146 | |
10147 | /* find corresponding closing delimiter */ | |
93a17b20 | 10148 | if (term && (tmps = strchr("([{< )]}> )]}>",term))) |
220e2d4e IH |
10149 | termcode = termstr[0] = term = tmps[5]; |
10150 | ||
3280af22 | 10151 | PL_multi_close = term; |
79072805 | 10152 | |
02aa26ce | 10153 | /* create a new SV to hold the contents. 87 is leak category, I'm |
8d6dde3e IZ |
10154 | assuming. 79 is the SV's initial length. What a random number. */ |
10155 | sv = NEWSV(87,79); | |
ed6116ce | 10156 | sv_upgrade(sv, SVt_PVIV); |
45977657 | 10157 | SvIV_set(sv, termcode); |
a0d0e21e | 10158 | (void)SvPOK_only(sv); /* validate pointer */ |
02aa26ce NT |
10159 | |
10160 | /* move past delimiter and try to read a complete string */ | |
09bef843 | 10161 | if (keep_delims) |
220e2d4e IH |
10162 | sv_catpvn(sv, s, termlen); |
10163 | s += termlen; | |
93a17b20 | 10164 | for (;;) { |
220e2d4e IH |
10165 | if (PL_encoding && !UTF) { |
10166 | bool cont = TRUE; | |
10167 | ||
10168 | while (cont) { | |
95a20fc0 | 10169 | int offset = s - SvPVX_const(PL_linestr); |
66a1b24b | 10170 | const bool found = sv_cat_decode(sv, PL_encoding, PL_linestr, |
f3b9ce0f | 10171 | &offset, (char*)termstr, termlen); |
95a20fc0 | 10172 | const char *ns = SvPVX_const(PL_linestr) + offset; |
220e2d4e IH |
10173 | char *svlast = SvEND(sv) - 1; |
10174 | ||
10175 | for (; s < ns; s++) { | |
10176 | if (*s == '\n' && !PL_rsfp) | |
10177 | CopLINE_inc(PL_curcop); | |
10178 | } | |
10179 | if (!found) | |
10180 | goto read_more_line; | |
10181 | else { | |
10182 | /* handle quoted delimiters */ | |
52327caf | 10183 | if (SvCUR(sv) > 1 && *(svlast-1) == '\\') { |
f54cb97a | 10184 | const char *t; |
95a20fc0 | 10185 | for (t = svlast-2; t >= SvPVX_const(sv) && *t == '\\';) |
220e2d4e IH |
10186 | t--; |
10187 | if ((svlast-1 - t) % 2) { | |
10188 | if (!keep_quoted) { | |
10189 | *(svlast-1) = term; | |
10190 | *svlast = '\0'; | |
10191 | SvCUR_set(sv, SvCUR(sv) - 1); | |
10192 | } | |
10193 | continue; | |
10194 | } | |
10195 | } | |
10196 | if (PL_multi_open == PL_multi_close) { | |
10197 | cont = FALSE; | |
10198 | } | |
10199 | else { | |
f54cb97a AL |
10200 | const char *t; |
10201 | char *w; | |
220e2d4e IH |
10202 | if (!last) |
10203 | last = SvPVX(sv); | |
f54cb97a | 10204 | for (t = w = last; t < svlast; w++, t++) { |
220e2d4e IH |
10205 | /* At here, all closes are "was quoted" one, |
10206 | so we don't check PL_multi_close. */ | |
10207 | if (*t == '\\') { | |
10208 | if (!keep_quoted && *(t+1) == PL_multi_open) | |
10209 | t++; | |
10210 | else | |
10211 | *w++ = *t++; | |
10212 | } | |
10213 | else if (*t == PL_multi_open) | |
10214 | brackets++; | |
10215 | ||
10216 | *w = *t; | |
10217 | } | |
10218 | if (w < t) { | |
10219 | *w++ = term; | |
10220 | *w = '\0'; | |
95a20fc0 | 10221 | SvCUR_set(sv, w - SvPVX_const(sv)); |
220e2d4e IH |
10222 | } |
10223 | last = w; | |
10224 | if (--brackets <= 0) | |
10225 | cont = FALSE; | |
10226 | } | |
10227 | } | |
10228 | } | |
10229 | if (!keep_delims) { | |
10230 | SvCUR_set(sv, SvCUR(sv) - 1); | |
10231 | *SvEND(sv) = '\0'; | |
10232 | } | |
10233 | break; | |
10234 | } | |
10235 | ||
02aa26ce | 10236 | /* extend sv if need be */ |
3280af22 | 10237 | SvGROW(sv, SvCUR(sv) + (PL_bufend - s) + 1); |
02aa26ce | 10238 | /* set 'to' to the next character in the sv's string */ |
463ee0b2 | 10239 | to = SvPVX(sv)+SvCUR(sv); |
09bef843 | 10240 | |
02aa26ce | 10241 | /* if open delimiter is the close delimiter read unbridle */ |
3280af22 NIS |
10242 | if (PL_multi_open == PL_multi_close) { |
10243 | for (; s < PL_bufend; s++,to++) { | |
02aa26ce | 10244 | /* embedded newlines increment the current line number */ |
3280af22 | 10245 | if (*s == '\n' && !PL_rsfp) |
57843af0 | 10246 | CopLINE_inc(PL_curcop); |
02aa26ce | 10247 | /* handle quoted delimiters */ |
3280af22 | 10248 | if (*s == '\\' && s+1 < PL_bufend && term != '\\') { |
09bef843 | 10249 | if (!keep_quoted && s[1] == term) |
a0d0e21e | 10250 | s++; |
02aa26ce | 10251 | /* any other quotes are simply copied straight through */ |
a0d0e21e LW |
10252 | else |
10253 | *to++ = *s++; | |
10254 | } | |
02aa26ce NT |
10255 | /* terminate when run out of buffer (the for() condition), or |
10256 | have found the terminator */ | |
220e2d4e IH |
10257 | else if (*s == term) { |
10258 | if (termlen == 1) | |
10259 | break; | |
f3b9ce0f | 10260 | if (s+termlen <= PL_bufend && memEQ(s, (char*)termstr, termlen)) |
220e2d4e IH |
10261 | break; |
10262 | } | |
63cd0674 | 10263 | else if (!has_utf8 && !UTF8_IS_INVARIANT((U8)*s) && UTF) |
89491803 | 10264 | has_utf8 = TRUE; |
93a17b20 LW |
10265 | *to = *s; |
10266 | } | |
10267 | } | |
02aa26ce NT |
10268 | |
10269 | /* if the terminator isn't the same as the start character (e.g., | |
10270 | matched brackets), we have to allow more in the quoting, and | |
10271 | be prepared for nested brackets. | |
10272 | */ | |
93a17b20 | 10273 | else { |
02aa26ce | 10274 | /* read until we run out of string, or we find the terminator */ |
3280af22 | 10275 | for (; s < PL_bufend; s++,to++) { |
02aa26ce | 10276 | /* embedded newlines increment the line count */ |
3280af22 | 10277 | if (*s == '\n' && !PL_rsfp) |
57843af0 | 10278 | CopLINE_inc(PL_curcop); |
02aa26ce | 10279 | /* backslashes can escape the open or closing characters */ |
3280af22 | 10280 | if (*s == '\\' && s+1 < PL_bufend) { |
09bef843 SB |
10281 | if (!keep_quoted && |
10282 | ((s[1] == PL_multi_open) || (s[1] == PL_multi_close))) | |
a0d0e21e LW |
10283 | s++; |
10284 | else | |
10285 | *to++ = *s++; | |
10286 | } | |
02aa26ce | 10287 | /* allow nested opens and closes */ |
3280af22 | 10288 | else if (*s == PL_multi_close && --brackets <= 0) |
93a17b20 | 10289 | break; |
3280af22 | 10290 | else if (*s == PL_multi_open) |
93a17b20 | 10291 | brackets++; |
63cd0674 | 10292 | else if (!has_utf8 && !UTF8_IS_INVARIANT((U8)*s) && UTF) |
89491803 | 10293 | has_utf8 = TRUE; |
93a17b20 LW |
10294 | *to = *s; |
10295 | } | |
10296 | } | |
02aa26ce | 10297 | /* terminate the copied string and update the sv's end-of-string */ |
93a17b20 | 10298 | *to = '\0'; |
95a20fc0 | 10299 | SvCUR_set(sv, to - SvPVX_const(sv)); |
93a17b20 | 10300 | |
02aa26ce NT |
10301 | /* |
10302 | * this next chunk reads more into the buffer if we're not done yet | |
10303 | */ | |
10304 | ||
b1c7b182 GS |
10305 | if (s < PL_bufend) |
10306 | break; /* handle case where we are done yet :-) */ | |
79072805 | 10307 | |
6a27c188 | 10308 | #ifndef PERL_STRICT_CR |
95a20fc0 | 10309 | if (to - SvPVX_const(sv) >= 2) { |
c6f14548 GS |
10310 | if ((to[-2] == '\r' && to[-1] == '\n') || |
10311 | (to[-2] == '\n' && to[-1] == '\r')) | |
10312 | { | |
f63a84b2 LW |
10313 | to[-2] = '\n'; |
10314 | to--; | |
95a20fc0 | 10315 | SvCUR_set(sv, to - SvPVX_const(sv)); |
f63a84b2 LW |
10316 | } |
10317 | else if (to[-1] == '\r') | |
10318 | to[-1] = '\n'; | |
10319 | } | |
95a20fc0 | 10320 | else if (to - SvPVX_const(sv) == 1 && to[-1] == '\r') |
f63a84b2 LW |
10321 | to[-1] = '\n'; |
10322 | #endif | |
10323 | ||
220e2d4e | 10324 | read_more_line: |
02aa26ce NT |
10325 | /* if we're out of file, or a read fails, bail and reset the current |
10326 | line marker so we can report where the unterminated string began | |
10327 | */ | |
3280af22 NIS |
10328 | if (!PL_rsfp || |
10329 | !(PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = filter_gets(PL_linestr, PL_rsfp, 0))) { | |
c07a80fd | 10330 | sv_free(sv); |
eb160463 | 10331 | CopLINE_set(PL_curcop, (line_t)PL_multi_start); |
79072805 LW |
10332 | return Nullch; |
10333 | } | |
02aa26ce | 10334 | /* we read a line, so increment our line counter */ |
57843af0 | 10335 | CopLINE_inc(PL_curcop); |
a0ed51b3 | 10336 | |
02aa26ce | 10337 | /* update debugger info */ |
3280af22 | 10338 | if (PERLDB_LINE && PL_curstash != PL_debstash) { |
7a5b473e | 10339 | SV * const sv = NEWSV(88,0); |
79072805 | 10340 | |
93a17b20 | 10341 | sv_upgrade(sv, SVt_PVMG); |
3280af22 | 10342 | sv_setsv(sv,PL_linestr); |
0ac0412a | 10343 | (void)SvIOK_on(sv); |
45977657 | 10344 | SvIV_set(sv, 0); |
36c7798d | 10345 | av_store(CopFILEAVx(PL_curcop), (I32)CopLINE(PL_curcop), sv); |
395c3793 | 10346 | } |
a0ed51b3 | 10347 | |
3280af22 NIS |
10348 | /* having changed the buffer, we must update PL_bufend */ |
10349 | PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); | |
207e3d1a | 10350 | PL_last_lop = PL_last_uni = Nullch; |
378cc40b | 10351 | } |
4e553d73 | 10352 | |
02aa26ce NT |
10353 | /* at this point, we have successfully read the delimited string */ |
10354 | ||
220e2d4e IH |
10355 | if (!PL_encoding || UTF) { |
10356 | if (keep_delims) | |
10357 | sv_catpvn(sv, s, termlen); | |
10358 | s += termlen; | |
10359 | } | |
10360 | if (has_utf8 || PL_encoding) | |
b1c7b182 | 10361 | SvUTF8_on(sv); |
d0063567 | 10362 | |
57843af0 | 10363 | PL_multi_end = CopLINE(PL_curcop); |
02aa26ce NT |
10364 | |
10365 | /* if we allocated too much space, give some back */ | |
93a17b20 LW |
10366 | if (SvCUR(sv) + 5 < SvLEN(sv)) { |
10367 | SvLEN_set(sv, SvCUR(sv) + 1); | |
b7e9a5c2 | 10368 | SvPV_renew(sv, SvLEN(sv)); |
79072805 | 10369 | } |
02aa26ce NT |
10370 | |
10371 | /* decide whether this is the first or second quoted string we've read | |
10372 | for this op | |
10373 | */ | |
4e553d73 | 10374 | |
3280af22 NIS |
10375 | if (PL_lex_stuff) |
10376 | PL_lex_repl = sv; | |
79072805 | 10377 | else |
3280af22 | 10378 | PL_lex_stuff = sv; |
378cc40b LW |
10379 | return s; |
10380 | } | |
10381 | ||
02aa26ce NT |
10382 | /* |
10383 | scan_num | |
10384 | takes: pointer to position in buffer | |
10385 | returns: pointer to new position in buffer | |
10386 | side-effects: builds ops for the constant in yylval.op | |
10387 | ||
10388 | Read a number in any of the formats that Perl accepts: | |
10389 | ||
7fd134d9 JH |
10390 | \d(_?\d)*(\.(\d(_?\d)*)?)?[Ee][\+\-]?(\d(_?\d)*) 12 12.34 12. |
10391 | \.\d(_?\d)*[Ee][\+\-]?(\d(_?\d)*) .34 | |
24138b49 JH |
10392 | 0b[01](_?[01])* |
10393 | 0[0-7](_?[0-7])* | |
10394 | 0x[0-9A-Fa-f](_?[0-9A-Fa-f])* | |
02aa26ce | 10395 | |
3280af22 | 10396 | Like most scan_ routines, it uses the PL_tokenbuf buffer to hold the |
02aa26ce NT |
10397 | thing it reads. |
10398 | ||
10399 | If it reads a number without a decimal point or an exponent, it will | |
10400 | try converting the number to an integer and see if it can do so | |
10401 | without loss of precision. | |
10402 | */ | |
4e553d73 | 10403 | |
378cc40b | 10404 | char * |
bfed75c6 | 10405 | Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) |
378cc40b | 10406 | { |
bfed75c6 | 10407 | register const char *s = start; /* current position in buffer */ |
02aa26ce NT |
10408 | register char *d; /* destination in temp buffer */ |
10409 | register char *e; /* end of temp buffer */ | |
86554af2 | 10410 | NV nv; /* number read, as a double */ |
a7cb1f99 | 10411 | SV *sv = Nullsv; /* place to put the converted number */ |
a86a20aa | 10412 | bool floatit; /* boolean: int or float? */ |
cbbf8932 | 10413 | const char *lastub = NULL; /* position of last underbar */ |
bfed75c6 | 10414 | static char const number_too_long[] = "Number too long"; |
378cc40b | 10415 | |
02aa26ce NT |
10416 | /* We use the first character to decide what type of number this is */ |
10417 | ||
378cc40b | 10418 | switch (*s) { |
79072805 | 10419 | default: |
cea2e8a9 | 10420 | Perl_croak(aTHX_ "panic: scan_num"); |
4e553d73 | 10421 | |
02aa26ce | 10422 | /* if it starts with a 0, it could be an octal number, a decimal in |
a7cb1f99 | 10423 | 0.13 disguise, or a hexadecimal number, or a binary number. */ |
378cc40b LW |
10424 | case '0': |
10425 | { | |
02aa26ce NT |
10426 | /* variables: |
10427 | u holds the "number so far" | |
4f19785b WSI |
10428 | shift the power of 2 of the base |
10429 | (hex == 4, octal == 3, binary == 1) | |
02aa26ce NT |
10430 | overflowed was the number more than we can hold? |
10431 | ||
10432 | Shift is used when we add a digit. It also serves as an "are | |
4f19785b WSI |
10433 | we in octal/hex/binary?" indicator to disallow hex characters |
10434 | when in octal mode. | |
02aa26ce | 10435 | */ |
9e24b6e2 JH |
10436 | NV n = 0.0; |
10437 | UV u = 0; | |
79072805 | 10438 | I32 shift; |
9e24b6e2 | 10439 | bool overflowed = FALSE; |
61f33854 | 10440 | bool just_zero = TRUE; /* just plain 0 or binary number? */ |
27da23d5 JH |
10441 | static const NV nvshift[5] = { 1.0, 2.0, 4.0, 8.0, 16.0 }; |
10442 | static const char* const bases[5] = | |
10443 | { "", "binary", "", "octal", "hexadecimal" }; | |
10444 | static const char* const Bases[5] = | |
10445 | { "", "Binary", "", "Octal", "Hexadecimal" }; | |
10446 | static const char* const maxima[5] = | |
10447 | { "", | |
10448 | "0b11111111111111111111111111111111", | |
10449 | "", | |
10450 | "037777777777", | |
10451 | "0xffffffff" }; | |
bfed75c6 | 10452 | const char *base, *Base, *max; |
378cc40b | 10453 | |
02aa26ce | 10454 | /* check for hex */ |
378cc40b LW |
10455 | if (s[1] == 'x') { |
10456 | shift = 4; | |
10457 | s += 2; | |
61f33854 | 10458 | just_zero = FALSE; |
4f19785b WSI |
10459 | } else if (s[1] == 'b') { |
10460 | shift = 1; | |
10461 | s += 2; | |
61f33854 | 10462 | just_zero = FALSE; |
378cc40b | 10463 | } |
02aa26ce | 10464 | /* check for a decimal in disguise */ |
b78218b7 | 10465 | else if (s[1] == '.' || s[1] == 'e' || s[1] == 'E') |
378cc40b | 10466 | goto decimal; |
02aa26ce | 10467 | /* so it must be octal */ |
928753ea | 10468 | else { |
378cc40b | 10469 | shift = 3; |
928753ea JH |
10470 | s++; |
10471 | } | |
10472 | ||
10473 | if (*s == '_') { | |
10474 | if (ckWARN(WARN_SYNTAX)) | |
9014280d | 10475 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
928753ea JH |
10476 | "Misplaced _ in number"); |
10477 | lastub = s++; | |
10478 | } | |
9e24b6e2 JH |
10479 | |
10480 | base = bases[shift]; | |
10481 | Base = Bases[shift]; | |
10482 | max = maxima[shift]; | |
02aa26ce | 10483 | |
4f19785b | 10484 | /* read the rest of the number */ |
378cc40b | 10485 | for (;;) { |
9e24b6e2 | 10486 | /* x is used in the overflow test, |
893fe2c2 | 10487 | b is the digit we're adding on. */ |
9e24b6e2 | 10488 | UV x, b; |
55497cff | 10489 | |
378cc40b | 10490 | switch (*s) { |
02aa26ce NT |
10491 | |
10492 | /* if we don't mention it, we're done */ | |
378cc40b LW |
10493 | default: |
10494 | goto out; | |
02aa26ce | 10495 | |
928753ea | 10496 | /* _ are ignored -- but warned about if consecutive */ |
de3bb511 | 10497 | case '_': |
041457d9 | 10498 | if (lastub && s == lastub + 1 && ckWARN(WARN_SYNTAX)) |
9014280d | 10499 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
928753ea JH |
10500 | "Misplaced _ in number"); |
10501 | lastub = s++; | |
de3bb511 | 10502 | break; |
02aa26ce NT |
10503 | |
10504 | /* 8 and 9 are not octal */ | |
378cc40b | 10505 | case '8': case '9': |
4f19785b | 10506 | if (shift == 3) |
cea2e8a9 | 10507 | yyerror(Perl_form(aTHX_ "Illegal octal digit '%c'", *s)); |
378cc40b | 10508 | /* FALL THROUGH */ |
02aa26ce NT |
10509 | |
10510 | /* octal digits */ | |
4f19785b | 10511 | case '2': case '3': case '4': |
378cc40b | 10512 | case '5': case '6': case '7': |
4f19785b | 10513 | if (shift == 1) |
cea2e8a9 | 10514 | yyerror(Perl_form(aTHX_ "Illegal binary digit '%c'", *s)); |
4f19785b WSI |
10515 | /* FALL THROUGH */ |
10516 | ||
10517 | case '0': case '1': | |
02aa26ce | 10518 | b = *s++ & 15; /* ASCII digit -> value of digit */ |
55497cff | 10519 | goto digit; |
02aa26ce NT |
10520 | |
10521 | /* hex digits */ | |
378cc40b LW |
10522 | case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': |
10523 | case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': | |
02aa26ce | 10524 | /* make sure they said 0x */ |
378cc40b LW |
10525 | if (shift != 4) |
10526 | goto out; | |
55497cff | 10527 | b = (*s++ & 7) + 9; |
02aa26ce NT |
10528 | |
10529 | /* Prepare to put the digit we have onto the end | |
10530 | of the number so far. We check for overflows. | |
10531 | */ | |
10532 | ||
55497cff | 10533 | digit: |
61f33854 | 10534 | just_zero = FALSE; |
9e24b6e2 JH |
10535 | if (!overflowed) { |
10536 | x = u << shift; /* make room for the digit */ | |
10537 | ||
10538 | if ((x >> shift) != u | |
10539 | && !(PL_hints & HINT_NEW_BINARY)) { | |
9e24b6e2 JH |
10540 | overflowed = TRUE; |
10541 | n = (NV) u; | |
767a6a26 | 10542 | if (ckWARN_d(WARN_OVERFLOW)) |
9014280d | 10543 | Perl_warner(aTHX_ packWARN(WARN_OVERFLOW), |
9e24b6e2 JH |
10544 | "Integer overflow in %s number", |
10545 | base); | |
10546 | } else | |
10547 | u = x | b; /* add the digit to the end */ | |
10548 | } | |
10549 | if (overflowed) { | |
10550 | n *= nvshift[shift]; | |
10551 | /* If an NV has not enough bits in its | |
10552 | * mantissa to represent an UV this summing of | |
10553 | * small low-order numbers is a waste of time | |
10554 | * (because the NV cannot preserve the | |
10555 | * low-order bits anyway): we could just | |
10556 | * remember when did we overflow and in the | |
10557 | * end just multiply n by the right | |
10558 | * amount. */ | |
10559 | n += (NV) b; | |
55497cff | 10560 | } |
378cc40b LW |
10561 | break; |
10562 | } | |
10563 | } | |
02aa26ce NT |
10564 | |
10565 | /* if we get here, we had success: make a scalar value from | |
10566 | the number. | |
10567 | */ | |
378cc40b | 10568 | out: |
928753ea JH |
10569 | |
10570 | /* final misplaced underbar check */ | |
10571 | if (s[-1] == '_') { | |
10572 | if (ckWARN(WARN_SYNTAX)) | |
9014280d | 10573 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "Misplaced _ in number"); |
928753ea JH |
10574 | } |
10575 | ||
79072805 | 10576 | sv = NEWSV(92,0); |
9e24b6e2 | 10577 | if (overflowed) { |
041457d9 | 10578 | if (n > 4294967295.0 && ckWARN(WARN_PORTABLE)) |
9014280d | 10579 | Perl_warner(aTHX_ packWARN(WARN_PORTABLE), |
9e24b6e2 JH |
10580 | "%s number > %s non-portable", |
10581 | Base, max); | |
10582 | sv_setnv(sv, n); | |
10583 | } | |
10584 | else { | |
15041a67 | 10585 | #if UVSIZE > 4 |
041457d9 | 10586 | if (u > 0xffffffff && ckWARN(WARN_PORTABLE)) |
9014280d | 10587 | Perl_warner(aTHX_ packWARN(WARN_PORTABLE), |
9e24b6e2 JH |
10588 | "%s number > %s non-portable", |
10589 | Base, max); | |
2cc4c2dc | 10590 | #endif |
9e24b6e2 JH |
10591 | sv_setuv(sv, u); |
10592 | } | |
61f33854 | 10593 | if (just_zero && (PL_hints & HINT_NEW_INTEGER)) |
bfed75c6 | 10594 | sv = new_constant(start, s - start, "integer", |
61f33854 RGS |
10595 | sv, Nullsv, NULL); |
10596 | else if (PL_hints & HINT_NEW_BINARY) | |
b3ac6de7 | 10597 | sv = new_constant(start, s - start, "binary", sv, Nullsv, NULL); |
378cc40b LW |
10598 | } |
10599 | break; | |
02aa26ce NT |
10600 | |
10601 | /* | |
10602 | handle decimal numbers. | |
10603 | we're also sent here when we read a 0 as the first digit | |
10604 | */ | |
378cc40b LW |
10605 | case '1': case '2': case '3': case '4': case '5': |
10606 | case '6': case '7': case '8': case '9': case '.': | |
10607 | decimal: | |
3280af22 NIS |
10608 | d = PL_tokenbuf; |
10609 | e = PL_tokenbuf + sizeof PL_tokenbuf - 6; /* room for various punctuation */ | |
79072805 | 10610 | floatit = FALSE; |
02aa26ce NT |
10611 | |
10612 | /* read next group of digits and _ and copy into d */ | |
de3bb511 | 10613 | while (isDIGIT(*s) || *s == '_') { |
4e553d73 | 10614 | /* skip underscores, checking for misplaced ones |
02aa26ce NT |
10615 | if -w is on |
10616 | */ | |
93a17b20 | 10617 | if (*s == '_') { |
041457d9 | 10618 | if (lastub && s == lastub + 1 && ckWARN(WARN_SYNTAX)) |
9014280d | 10619 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
928753ea JH |
10620 | "Misplaced _ in number"); |
10621 | lastub = s++; | |
93a17b20 | 10622 | } |
fc36a67e | 10623 | else { |
02aa26ce | 10624 | /* check for end of fixed-length buffer */ |
fc36a67e | 10625 | if (d >= e) |
cea2e8a9 | 10626 | Perl_croak(aTHX_ number_too_long); |
02aa26ce | 10627 | /* if we're ok, copy the character */ |
378cc40b | 10628 | *d++ = *s++; |
fc36a67e | 10629 | } |
378cc40b | 10630 | } |
02aa26ce NT |
10631 | |
10632 | /* final misplaced underbar check */ | |
928753ea | 10633 | if (lastub && s == lastub + 1) { |
d008e5eb | 10634 | if (ckWARN(WARN_SYNTAX)) |
9014280d | 10635 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "Misplaced _ in number"); |
d008e5eb | 10636 | } |
02aa26ce NT |
10637 | |
10638 | /* read a decimal portion if there is one. avoid | |
10639 | 3..5 being interpreted as the number 3. followed | |
10640 | by .5 | |
10641 | */ | |
2f3197b3 | 10642 | if (*s == '.' && s[1] != '.') { |
79072805 | 10643 | floatit = TRUE; |
378cc40b | 10644 | *d++ = *s++; |
02aa26ce | 10645 | |
928753ea JH |
10646 | if (*s == '_') { |
10647 | if (ckWARN(WARN_SYNTAX)) | |
9014280d | 10648 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
928753ea JH |
10649 | "Misplaced _ in number"); |
10650 | lastub = s; | |
10651 | } | |
10652 | ||
10653 | /* copy, ignoring underbars, until we run out of digits. | |
02aa26ce | 10654 | */ |
fc36a67e | 10655 | for (; isDIGIT(*s) || *s == '_'; s++) { |
02aa26ce | 10656 | /* fixed length buffer check */ |
fc36a67e | 10657 | if (d >= e) |
cea2e8a9 | 10658 | Perl_croak(aTHX_ number_too_long); |
928753ea | 10659 | if (*s == '_') { |
041457d9 | 10660 | if (lastub && s == lastub + 1 && ckWARN(WARN_SYNTAX)) |
9014280d | 10661 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
928753ea JH |
10662 | "Misplaced _ in number"); |
10663 | lastub = s; | |
10664 | } | |
10665 | else | |
fc36a67e | 10666 | *d++ = *s; |
378cc40b | 10667 | } |
928753ea JH |
10668 | /* fractional part ending in underbar? */ |
10669 | if (s[-1] == '_') { | |
10670 | if (ckWARN(WARN_SYNTAX)) | |
9014280d | 10671 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
928753ea JH |
10672 | "Misplaced _ in number"); |
10673 | } | |
dd629d5b GS |
10674 | if (*s == '.' && isDIGIT(s[1])) { |
10675 | /* oops, it's really a v-string, but without the "v" */ | |
f4758303 | 10676 | s = start; |
dd629d5b GS |
10677 | goto vstring; |
10678 | } | |
378cc40b | 10679 | } |
02aa26ce NT |
10680 | |
10681 | /* read exponent part, if present */ | |
3792a11b | 10682 | if ((*s == 'e' || *s == 'E') && strchr("+-0123456789_", s[1])) { |
79072805 LW |
10683 | floatit = TRUE; |
10684 | s++; | |
02aa26ce NT |
10685 | |
10686 | /* regardless of whether user said 3E5 or 3e5, use lower 'e' */ | |
79072805 | 10687 | *d++ = 'e'; /* At least some Mach atof()s don't grok 'E' */ |
02aa26ce | 10688 | |
7fd134d9 JH |
10689 | /* stray preinitial _ */ |
10690 | if (*s == '_') { | |
10691 | if (ckWARN(WARN_SYNTAX)) | |
9014280d | 10692 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
7fd134d9 JH |
10693 | "Misplaced _ in number"); |
10694 | lastub = s++; | |
10695 | } | |
10696 | ||
02aa26ce | 10697 | /* allow positive or negative exponent */ |
378cc40b LW |
10698 | if (*s == '+' || *s == '-') |
10699 | *d++ = *s++; | |
02aa26ce | 10700 | |
7fd134d9 JH |
10701 | /* stray initial _ */ |
10702 | if (*s == '_') { | |
10703 | if (ckWARN(WARN_SYNTAX)) | |
9014280d | 10704 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
7fd134d9 JH |
10705 | "Misplaced _ in number"); |
10706 | lastub = s++; | |
10707 | } | |
10708 | ||
7fd134d9 JH |
10709 | /* read digits of exponent */ |
10710 | while (isDIGIT(*s) || *s == '_') { | |
10711 | if (isDIGIT(*s)) { | |
10712 | if (d >= e) | |
10713 | Perl_croak(aTHX_ number_too_long); | |
b3b48e3e | 10714 | *d++ = *s++; |
7fd134d9 JH |
10715 | } |
10716 | else { | |
041457d9 DM |
10717 | if (((lastub && s == lastub + 1) || |
10718 | (!isDIGIT(s[1]) && s[1] != '_')) | |
10719 | && ckWARN(WARN_SYNTAX)) | |
9014280d | 10720 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), |
7fd134d9 | 10721 | "Misplaced _ in number"); |
b3b48e3e | 10722 | lastub = s++; |
7fd134d9 | 10723 | } |
7fd134d9 | 10724 | } |
378cc40b | 10725 | } |
02aa26ce | 10726 | |
02aa26ce NT |
10727 | |
10728 | /* make an sv from the string */ | |
79072805 | 10729 | sv = NEWSV(92,0); |
097ee67d | 10730 | |
0b7fceb9 | 10731 | /* |
58bb9ec3 NC |
10732 | We try to do an integer conversion first if no characters |
10733 | indicating "float" have been found. | |
0b7fceb9 MU |
10734 | */ |
10735 | ||
10736 | if (!floatit) { | |
58bb9ec3 NC |
10737 | UV uv; |
10738 | int flags = grok_number (PL_tokenbuf, d - PL_tokenbuf, &uv); | |
10739 | ||
10740 | if (flags == IS_NUMBER_IN_UV) { | |
10741 | if (uv <= IV_MAX) | |
86554af2 | 10742 | sv_setiv(sv, uv); /* Prefer IVs over UVs. */ |
58bb9ec3 | 10743 | else |
c239479b | 10744 | sv_setuv(sv, uv); |
58bb9ec3 NC |
10745 | } else if (flags == (IS_NUMBER_IN_UV | IS_NUMBER_NEG)) { |
10746 | if (uv <= (UV) IV_MIN) | |
10747 | sv_setiv(sv, -(IV)uv); | |
10748 | else | |
10749 | floatit = TRUE; | |
10750 | } else | |
10751 | floatit = TRUE; | |
10752 | } | |
0b7fceb9 | 10753 | if (floatit) { |
58bb9ec3 NC |
10754 | /* terminate the string */ |
10755 | *d = '\0'; | |
86554af2 JH |
10756 | nv = Atof(PL_tokenbuf); |
10757 | sv_setnv(sv, nv); | |
10758 | } | |
86554af2 | 10759 | |
b8403495 JH |
10760 | if ( floatit ? (PL_hints & HINT_NEW_FLOAT) : |
10761 | (PL_hints & HINT_NEW_INTEGER) ) | |
4e553d73 | 10762 | sv = new_constant(PL_tokenbuf, d - PL_tokenbuf, |
b8403495 JH |
10763 | (floatit ? "float" : "integer"), |
10764 | sv, Nullsv, NULL); | |
378cc40b | 10765 | break; |
0b7fceb9 | 10766 | |
e312add1 | 10767 | /* if it starts with a v, it could be a v-string */ |
a7cb1f99 | 10768 | case 'v': |
dd629d5b | 10769 | vstring: |
f4758303 | 10770 | sv = NEWSV(92,5); /* preallocate storage space */ |
b0f01acb | 10771 | s = scan_vstring(s,sv); |
a7cb1f99 | 10772 | break; |
79072805 | 10773 | } |
a687059c | 10774 | |
02aa26ce NT |
10775 | /* make the op for the constant and return */ |
10776 | ||
a86a20aa | 10777 | if (sv) |
b73d6f50 | 10778 | lvalp->opval = newSVOP(OP_CONST, 0, sv); |
a7cb1f99 | 10779 | else |
b73d6f50 | 10780 | lvalp->opval = Nullop; |
a687059c | 10781 | |
73d840c0 | 10782 | return (char *)s; |
378cc40b LW |
10783 | } |
10784 | ||
76e3520e | 10785 | STATIC char * |
cea2e8a9 | 10786 | S_scan_formline(pTHX_ register char *s) |
378cc40b | 10787 | { |
79072805 | 10788 | register char *eol; |
378cc40b | 10789 | register char *t; |
396482e1 | 10790 | SV *stuff = newSVpvs(""); |
79072805 | 10791 | bool needargs = FALSE; |
c5ee2135 | 10792 | bool eofmt = FALSE; |
378cc40b | 10793 | |
79072805 | 10794 | while (!needargs) { |
a1b95068 | 10795 | if (*s == '.') { |
51882d45 | 10796 | #ifdef PERL_STRICT_CR |
bf4acbe4 | 10797 | for (t = s+1;SPACE_OR_TAB(*t); t++) ; |
51882d45 | 10798 | #else |
bf4acbe4 | 10799 | for (t = s+1;SPACE_OR_TAB(*t) || *t == '\r'; t++) ; |
51882d45 | 10800 | #endif |
c5ee2135 WL |
10801 | if (*t == '\n' || t == PL_bufend) { |
10802 | eofmt = TRUE; | |
79072805 | 10803 | break; |
c5ee2135 | 10804 | } |
79072805 | 10805 | } |
3280af22 | 10806 | if (PL_in_eval && !PL_rsfp) { |
07409e01 | 10807 | eol = (char *) memchr(s,'\n',PL_bufend-s); |
0f85fab0 | 10808 | if (!eol++) |
3280af22 | 10809 | eol = PL_bufend; |
0f85fab0 LW |
10810 | } |
10811 | else | |
3280af22 | 10812 | eol = PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); |
79072805 | 10813 | if (*s != '#') { |
a0d0e21e LW |
10814 | for (t = s; t < eol; t++) { |
10815 | if (*t == '~' && t[1] == '~' && SvCUR(stuff)) { | |
10816 | needargs = FALSE; | |
10817 | goto enough; /* ~~ must be first line in formline */ | |
378cc40b | 10818 | } |
a0d0e21e LW |
10819 | if (*t == '@' || *t == '^') |
10820 | needargs = TRUE; | |
378cc40b | 10821 | } |
7121b347 MG |
10822 | if (eol > s) { |
10823 | sv_catpvn(stuff, s, eol-s); | |
2dc4c65b | 10824 | #ifndef PERL_STRICT_CR |
7121b347 MG |
10825 | if (eol-s > 1 && eol[-2] == '\r' && eol[-1] == '\n') { |
10826 | char *end = SvPVX(stuff) + SvCUR(stuff); | |
10827 | end[-2] = '\n'; | |
10828 | end[-1] = '\0'; | |
b162af07 | 10829 | SvCUR_set(stuff, SvCUR(stuff) - 1); |
7121b347 | 10830 | } |
2dc4c65b | 10831 | #endif |
7121b347 MG |
10832 | } |
10833 | else | |
10834 | break; | |
79072805 | 10835 | } |
95a20fc0 | 10836 | s = (char*)eol; |
3280af22 NIS |
10837 | if (PL_rsfp) { |
10838 | s = filter_gets(PL_linestr, PL_rsfp, 0); | |
10839 | PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(PL_linestr); | |
10840 | PL_bufend = PL_bufptr + SvCUR(PL_linestr); | |
207e3d1a | 10841 | PL_last_lop = PL_last_uni = Nullch; |
79072805 | 10842 | if (!s) { |
3280af22 | 10843 | s = PL_bufptr; |
378cc40b LW |
10844 | break; |
10845 | } | |
378cc40b | 10846 | } |
463ee0b2 | 10847 | incline(s); |
79072805 | 10848 | } |
a0d0e21e LW |
10849 | enough: |
10850 | if (SvCUR(stuff)) { | |
3280af22 | 10851 | PL_expect = XTERM; |
79072805 | 10852 | if (needargs) { |
3280af22 NIS |
10853 | PL_lex_state = LEX_NORMAL; |
10854 | PL_nextval[PL_nexttoke].ival = 0; | |
79072805 LW |
10855 | force_next(','); |
10856 | } | |
a0d0e21e | 10857 | else |
3280af22 | 10858 | PL_lex_state = LEX_FORMLINE; |
1bd51a4c | 10859 | if (!IN_BYTES) { |
95a20fc0 | 10860 | if (UTF && is_utf8_string((U8*)SvPVX_const(stuff), SvCUR(stuff))) |
1bd51a4c IH |
10861 | SvUTF8_on(stuff); |
10862 | else if (PL_encoding) | |
10863 | sv_recode_to_utf8(stuff, PL_encoding); | |
10864 | } | |
3280af22 | 10865 | PL_nextval[PL_nexttoke].opval = (OP*)newSVOP(OP_CONST, 0, stuff); |
79072805 | 10866 | force_next(THING); |
3280af22 | 10867 | PL_nextval[PL_nexttoke].ival = OP_FORMLINE; |
79072805 | 10868 | force_next(LSTOP); |
378cc40b | 10869 | } |
79072805 | 10870 | else { |
8990e307 | 10871 | SvREFCNT_dec(stuff); |
c5ee2135 WL |
10872 | if (eofmt) |
10873 | PL_lex_formbrack = 0; | |
3280af22 | 10874 | PL_bufptr = s; |
79072805 LW |
10875 | } |
10876 | return s; | |
378cc40b | 10877 | } |
a687059c | 10878 | |
76e3520e | 10879 | STATIC void |
cea2e8a9 | 10880 | S_set_csh(pTHX) |
a687059c | 10881 | { |
ae986130 | 10882 | #ifdef CSH |
3280af22 NIS |
10883 | if (!PL_cshlen) |
10884 | PL_cshlen = strlen(PL_cshname); | |
ae986130 | 10885 | #endif |
a687059c | 10886 | } |
463ee0b2 | 10887 | |
ba6d6ac9 | 10888 | I32 |
864dbfa3 | 10889 | Perl_start_subparse(pTHX_ I32 is_format, U32 flags) |
8990e307 | 10890 | { |
a3b680e6 | 10891 | const I32 oldsavestack_ix = PL_savestack_ix; |
3280af22 | 10892 | CV* outsidecv = PL_compcv; |
8990e307 | 10893 | |
3280af22 NIS |
10894 | if (PL_compcv) { |
10895 | assert(SvTYPE(PL_compcv) == SVt_PVCV); | |
e9a444f0 | 10896 | } |
7766f137 | 10897 | SAVEI32(PL_subline); |
3280af22 | 10898 | save_item(PL_subname); |
3280af22 | 10899 | SAVESPTR(PL_compcv); |
3280af22 NIS |
10900 | |
10901 | PL_compcv = (CV*)NEWSV(1104,0); | |
10902 | sv_upgrade((SV *)PL_compcv, is_format ? SVt_PVFM : SVt_PVCV); | |
10903 | CvFLAGS(PL_compcv) |= flags; | |
10904 | ||
57843af0 | 10905 | PL_subline = CopLINE(PL_curcop); |
dd2155a4 | 10906 | CvPADLIST(PL_compcv) = pad_new(padnew_SAVE|padnew_SAVESUB); |
3280af22 | 10907 | CvOUTSIDE(PL_compcv) = (CV*)SvREFCNT_inc(outsidecv); |
a3985cdc | 10908 | CvOUTSIDE_SEQ(PL_compcv) = PL_cop_seqmax; |
748a9306 | 10909 | |
8990e307 LW |
10910 | return oldsavestack_ix; |
10911 | } | |
10912 | ||
084592ab CN |
10913 | #ifdef __SC__ |
10914 | #pragma segment Perl_yylex | |
10915 | #endif | |
8990e307 | 10916 | int |
bfed75c6 | 10917 | Perl_yywarn(pTHX_ const char *s) |
8990e307 | 10918 | { |
faef0170 | 10919 | PL_in_eval |= EVAL_WARNONLY; |
748a9306 | 10920 | yyerror(s); |
faef0170 | 10921 | PL_in_eval &= ~EVAL_WARNONLY; |
748a9306 | 10922 | return 0; |
8990e307 LW |
10923 | } |
10924 | ||
10925 | int | |
bfed75c6 | 10926 | Perl_yyerror(pTHX_ const char *s) |
463ee0b2 | 10927 | { |
bfed75c6 AL |
10928 | const char *where = NULL; |
10929 | const char *context = NULL; | |
68dc0745 | 10930 | int contlen = -1; |
46fc3d4c | 10931 | SV *msg; |
463ee0b2 | 10932 | |
3280af22 | 10933 | if (!yychar || (yychar == ';' && !PL_rsfp)) |
54310121 | 10934 | where = "at EOF"; |
8bcfe651 TM |
10935 | else if (PL_oldoldbufptr && PL_bufptr > PL_oldoldbufptr && |
10936 | PL_bufptr - PL_oldoldbufptr < 200 && PL_oldoldbufptr != PL_oldbufptr && | |
10937 | PL_oldbufptr != PL_bufptr) { | |
f355267c JH |
10938 | /* |
10939 | Only for NetWare: | |
10940 | The code below is removed for NetWare because it abends/crashes on NetWare | |
10941 | when the script has error such as not having the closing quotes like: | |
10942 | if ($var eq "value) | |
10943 | Checking of white spaces is anyway done in NetWare code. | |
10944 | */ | |
10945 | #ifndef NETWARE | |
3280af22 NIS |
10946 | while (isSPACE(*PL_oldoldbufptr)) |
10947 | PL_oldoldbufptr++; | |
f355267c | 10948 | #endif |
3280af22 NIS |
10949 | context = PL_oldoldbufptr; |
10950 | contlen = PL_bufptr - PL_oldoldbufptr; | |
463ee0b2 | 10951 | } |
8bcfe651 TM |
10952 | else if (PL_oldbufptr && PL_bufptr > PL_oldbufptr && |
10953 | PL_bufptr - PL_oldbufptr < 200 && PL_oldbufptr != PL_bufptr) { | |
f355267c JH |
10954 | /* |
10955 | Only for NetWare: | |
10956 | The code below is removed for NetWare because it abends/crashes on NetWare | |
10957 | when the script has error such as not having the closing quotes like: | |
10958 | if ($var eq "value) | |
10959 | Checking of white spaces is anyway done in NetWare code. | |
10960 | */ | |
10961 | #ifndef NETWARE | |
3280af22 NIS |
10962 | while (isSPACE(*PL_oldbufptr)) |
10963 | PL_oldbufptr++; | |
f355267c | 10964 | #endif |
3280af22 NIS |
10965 | context = PL_oldbufptr; |
10966 | contlen = PL_bufptr - PL_oldbufptr; | |
463ee0b2 LW |
10967 | } |
10968 | else if (yychar > 255) | |
68dc0745 | 10969 | where = "next token ???"; |
12fbd33b | 10970 | else if (yychar == -2) { /* YYEMPTY */ |
3280af22 NIS |
10971 | if (PL_lex_state == LEX_NORMAL || |
10972 | (PL_lex_state == LEX_KNOWNEXT && PL_lex_defer == LEX_NORMAL)) | |
68dc0745 | 10973 | where = "at end of line"; |
3280af22 | 10974 | else if (PL_lex_inpat) |
68dc0745 | 10975 | where = "within pattern"; |
463ee0b2 | 10976 | else |
68dc0745 | 10977 | where = "within string"; |
463ee0b2 | 10978 | } |
46fc3d4c | 10979 | else { |
396482e1 | 10980 | SV *where_sv = sv_2mortal(newSVpvs("next char ")); |
46fc3d4c | 10981 | if (yychar < 32) |
cea2e8a9 | 10982 | Perl_sv_catpvf(aTHX_ where_sv, "^%c", toCTRL(yychar)); |
46fc3d4c | 10983 | else if (isPRINT_LC(yychar)) |
cea2e8a9 | 10984 | Perl_sv_catpvf(aTHX_ where_sv, "%c", yychar); |
463ee0b2 | 10985 | else |
cea2e8a9 | 10986 | Perl_sv_catpvf(aTHX_ where_sv, "\\%03o", yychar & 255); |
95a20fc0 | 10987 | where = SvPVX_const(where_sv); |
463ee0b2 | 10988 | } |
46fc3d4c | 10989 | msg = sv_2mortal(newSVpv(s, 0)); |
ed094faf | 10990 | Perl_sv_catpvf(aTHX_ msg, " at %s line %"IVdf", ", |
248c2a4d | 10991 | OutCopFILE(PL_curcop), (IV)CopLINE(PL_curcop)); |
68dc0745 | 10992 | if (context) |
cea2e8a9 | 10993 | Perl_sv_catpvf(aTHX_ msg, "near \"%.*s\"\n", contlen, context); |
463ee0b2 | 10994 | else |
cea2e8a9 | 10995 | Perl_sv_catpvf(aTHX_ msg, "%s\n", where); |
57843af0 | 10996 | if (PL_multi_start < PL_multi_end && (U32)(CopLINE(PL_curcop) - PL_multi_end) <= 1) { |
cf2093f6 | 10997 | Perl_sv_catpvf(aTHX_ msg, |
57def98f | 10998 | " (Might be a runaway multi-line %c%c string starting on line %"IVdf")\n", |
cf2093f6 | 10999 | (int)PL_multi_open,(int)PL_multi_close,(IV)PL_multi_start); |
3280af22 | 11000 | PL_multi_end = 0; |
a0d0e21e | 11001 | } |
56da5a46 RGS |
11002 | if (PL_in_eval & EVAL_WARNONLY && ckWARN_d(WARN_SYNTAX)) |
11003 | Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "%"SVf, msg); | |
463ee0b2 | 11004 | else |
5a844595 | 11005 | qerror(msg); |
c7d6bfb2 GS |
11006 | if (PL_error_count >= 10) { |
11007 | if (PL_in_eval && SvCUR(ERRSV)) | |
d2560b70 | 11008 | Perl_croak(aTHX_ "%"SVf"%s has too many errors.\n", |
248c2a4d | 11009 | ERRSV, OutCopFILE(PL_curcop)); |
c7d6bfb2 GS |
11010 | else |
11011 | Perl_croak(aTHX_ "%s has too many errors.\n", | |
248c2a4d | 11012 | OutCopFILE(PL_curcop)); |
c7d6bfb2 | 11013 | } |
3280af22 | 11014 | PL_in_my = 0; |
5c284bb0 | 11015 | PL_in_my_stash = NULL; |
463ee0b2 LW |
11016 | return 0; |
11017 | } | |
084592ab CN |
11018 | #ifdef __SC__ |
11019 | #pragma segment Main | |
11020 | #endif | |
4e35701f | 11021 | |
b250498f | 11022 | STATIC char* |
3ae08724 | 11023 | S_swallow_bom(pTHX_ U8 *s) |
01ec43d0 | 11024 | { |
f54cb97a | 11025 | const STRLEN slen = SvCUR(PL_linestr); |
7aa207d6 | 11026 | switch (s[0]) { |
4e553d73 NIS |
11027 | case 0xFF: |
11028 | if (s[1] == 0xFE) { | |
7aa207d6 | 11029 | /* UTF-16 little-endian? (or UTF32-LE?) */ |
3ae08724 | 11030 | if (s[2] == 0 && s[3] == 0) /* UTF-32 little-endian */ |
7aa207d6 | 11031 | Perl_croak(aTHX_ "Unsupported script encoding UTF32-LE"); |
01ec43d0 | 11032 | #ifndef PERL_NO_UTF16_FILTER |
7aa207d6 | 11033 | if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF16-LE script encoding (BOM)\n"); |
3ae08724 | 11034 | s += 2; |
7aa207d6 | 11035 | utf16le: |
dea0fc0b JH |
11036 | if (PL_bufend > (char*)s) { |
11037 | U8 *news; | |
11038 | I32 newlen; | |
11039 | ||
11040 | filter_add(utf16rev_textfilter, NULL); | |
a02a5408 | 11041 | Newx(news, (PL_bufend - (char*)s) * 3 / 2 + 1, U8); |
1de9afcd RGS |
11042 | utf16_to_utf8_reversed(s, news, |
11043 | PL_bufend - (char*)s - 1, | |
11044 | &newlen); | |
7aa207d6 | 11045 | sv_setpvn(PL_linestr, (const char*)news, newlen); |
dea0fc0b | 11046 | Safefree(news); |
7aa207d6 JH |
11047 | SvUTF8_on(PL_linestr); |
11048 | s = (U8*)SvPVX(PL_linestr); | |
11049 | PL_bufend = SvPVX(PL_linestr) + newlen; | |
dea0fc0b | 11050 | } |
b250498f | 11051 | #else |
7aa207d6 | 11052 | Perl_croak(aTHX_ "Unsupported script encoding UTF16-LE"); |
b250498f | 11053 | #endif |
01ec43d0 GS |
11054 | } |
11055 | break; | |
78ae23f5 | 11056 | case 0xFE: |
7aa207d6 | 11057 | if (s[1] == 0xFF) { /* UTF-16 big-endian? */ |
01ec43d0 | 11058 | #ifndef PERL_NO_UTF16_FILTER |
7aa207d6 | 11059 | if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-16BE script encoding (BOM)\n"); |
dea0fc0b | 11060 | s += 2; |
7aa207d6 | 11061 | utf16be: |
dea0fc0b JH |
11062 | if (PL_bufend > (char *)s) { |
11063 | U8 *news; | |
11064 | I32 newlen; | |
11065 | ||
11066 | filter_add(utf16_textfilter, NULL); | |
a02a5408 | 11067 | Newx(news, (PL_bufend - (char*)s) * 3 / 2 + 1, U8); |
1de9afcd RGS |
11068 | utf16_to_utf8(s, news, |
11069 | PL_bufend - (char*)s, | |
11070 | &newlen); | |
7aa207d6 | 11071 | sv_setpvn(PL_linestr, (const char*)news, newlen); |
dea0fc0b | 11072 | Safefree(news); |
7aa207d6 JH |
11073 | SvUTF8_on(PL_linestr); |
11074 | s = (U8*)SvPVX(PL_linestr); | |
11075 | PL_bufend = SvPVX(PL_linestr) + newlen; | |
dea0fc0b | 11076 | } |
b250498f | 11077 | #else |
7aa207d6 | 11078 | Perl_croak(aTHX_ "Unsupported script encoding UTF16-BE"); |
b250498f | 11079 | #endif |
01ec43d0 GS |
11080 | } |
11081 | break; | |
3ae08724 GS |
11082 | case 0xEF: |
11083 | if (slen > 2 && s[1] == 0xBB && s[2] == 0xBF) { | |
7aa207d6 | 11084 | if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-8 script encoding (BOM)\n"); |
01ec43d0 GS |
11085 | s += 3; /* UTF-8 */ |
11086 | } | |
11087 | break; | |
11088 | case 0: | |
7aa207d6 JH |
11089 | if (slen > 3) { |
11090 | if (s[1] == 0) { | |
11091 | if (s[2] == 0xFE && s[3] == 0xFF) { | |
11092 | /* UTF-32 big-endian */ | |
11093 | Perl_croak(aTHX_ "Unsupported script encoding UTF32-BE"); | |
11094 | } | |
11095 | } | |
11096 | else if (s[2] == 0 && s[3] != 0) { | |
11097 | /* Leading bytes | |
11098 | * 00 xx 00 xx | |
11099 | * are a good indicator of UTF-16BE. */ | |
11100 | if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-16BE script encoding (no BOM)\n"); | |
11101 | goto utf16be; | |
11102 | } | |
01ec43d0 | 11103 | } |
7aa207d6 JH |
11104 | default: |
11105 | if (slen > 3 && s[1] == 0 && s[2] != 0 && s[3] == 0) { | |
11106 | /* Leading bytes | |
11107 | * xx 00 xx 00 | |
11108 | * are a good indicator of UTF-16LE. */ | |
11109 | if (DEBUG_p_TEST || DEBUG_T_TEST) PerlIO_printf(Perl_debug_log, "UTF-16LE script encoding (no BOM)\n"); | |
11110 | goto utf16le; | |
11111 | } | |
01ec43d0 | 11112 | } |
b8f84bb2 | 11113 | return (char*)s; |
b250498f | 11114 | } |
4755096e | 11115 | |
4755096e GS |
11116 | /* |
11117 | * restore_rsfp | |
11118 | * Restore a source filter. | |
11119 | */ | |
11120 | ||
11121 | static void | |
acfe0abc | 11122 | restore_rsfp(pTHX_ void *f) |
4755096e | 11123 | { |
0bd48802 | 11124 | PerlIO * const fp = (PerlIO*)f; |
4755096e GS |
11125 | |
11126 | if (PL_rsfp == PerlIO_stdin()) | |
11127 | PerlIO_clearerr(PL_rsfp); | |
11128 | else if (PL_rsfp && (PL_rsfp != fp)) | |
11129 | PerlIO_close(PL_rsfp); | |
11130 | PL_rsfp = fp; | |
11131 | } | |
6e3aabd6 GS |
11132 | |
11133 | #ifndef PERL_NO_UTF16_FILTER | |
11134 | static I32 | |
acfe0abc | 11135 | utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen) |
6e3aabd6 | 11136 | { |
f54cb97a AL |
11137 | const STRLEN old = SvCUR(sv); |
11138 | const I32 count = FILTER_READ(idx+1, sv, maxlen); | |
1de9afcd RGS |
11139 | DEBUG_P(PerlIO_printf(Perl_debug_log, |
11140 | "utf16_textfilter(%p): %d %d (%d)\n", | |
4fccd7c6 | 11141 | utf16_textfilter, idx, maxlen, (int) count)); |
6e3aabd6 GS |
11142 | if (count) { |
11143 | U8* tmps; | |
dea0fc0b | 11144 | I32 newlen; |
a02a5408 | 11145 | Newx(tmps, SvCUR(sv) * 3 / 2 + 1, U8); |
95a20fc0 SP |
11146 | Copy(SvPVX_const(sv), tmps, old, char); |
11147 | utf16_to_utf8((U8*)SvPVX_const(sv) + old, tmps + old, | |
1de9afcd RGS |
11148 | SvCUR(sv) - old, &newlen); |
11149 | sv_usepvn(sv, (char*)tmps, (STRLEN)newlen + old); | |
6e3aabd6 | 11150 | } |
1de9afcd RGS |
11151 | DEBUG_P({sv_dump(sv);}); |
11152 | return SvCUR(sv); | |
6e3aabd6 GS |
11153 | } |
11154 | ||
11155 | static I32 | |
acfe0abc | 11156 | utf16rev_textfilter(pTHX_ int idx, SV *sv, int maxlen) |
6e3aabd6 | 11157 | { |
f54cb97a AL |
11158 | const STRLEN old = SvCUR(sv); |
11159 | const I32 count = FILTER_READ(idx+1, sv, maxlen); | |
1de9afcd RGS |
11160 | DEBUG_P(PerlIO_printf(Perl_debug_log, |
11161 | "utf16rev_textfilter(%p): %d %d (%d)\n", | |
4fccd7c6 | 11162 | utf16rev_textfilter, idx, maxlen, (int) count)); |
6e3aabd6 GS |
11163 | if (count) { |
11164 | U8* tmps; | |
dea0fc0b | 11165 | I32 newlen; |
a02a5408 | 11166 | Newx(tmps, SvCUR(sv) * 3 / 2 + 1, U8); |
95a20fc0 SP |
11167 | Copy(SvPVX_const(sv), tmps, old, char); |
11168 | utf16_to_utf8((U8*)SvPVX_const(sv) + old, tmps + old, | |
1de9afcd RGS |
11169 | SvCUR(sv) - old, &newlen); |
11170 | sv_usepvn(sv, (char*)tmps, (STRLEN)newlen + old); | |
6e3aabd6 | 11171 | } |
1de9afcd | 11172 | DEBUG_P({ sv_dump(sv); }); |
6e3aabd6 GS |
11173 | return count; |
11174 | } | |
11175 | #endif | |
9f4817db | 11176 | |
f333445c JP |
11177 | /* |
11178 | Returns a pointer to the next character after the parsed | |
11179 | vstring, as well as updating the passed in sv. | |
11180 | ||
11181 | Function must be called like | |
11182 | ||
11183 | sv = NEWSV(92,5); | |
11184 | s = scan_vstring(s,sv); | |
11185 | ||
11186 | The sv should already be large enough to store the vstring | |
11187 | passed in, for performance reasons. | |
11188 | ||
11189 | */ | |
11190 | ||
11191 | char * | |
bfed75c6 | 11192 | Perl_scan_vstring(pTHX_ const char *s, SV *sv) |
f333445c | 11193 | { |
bfed75c6 AL |
11194 | const char *pos = s; |
11195 | const char *start = s; | |
f333445c | 11196 | if (*pos == 'v') pos++; /* get past 'v' */ |
3e884cbf JH |
11197 | while (pos < PL_bufend && (isDIGIT(*pos) || *pos == '_')) |
11198 | pos++; | |
f333445c JP |
11199 | if ( *pos != '.') { |
11200 | /* this may not be a v-string if followed by => */ | |
bfed75c6 | 11201 | const char *next = pos; |
8fc7bb1c SM |
11202 | while (next < PL_bufend && isSPACE(*next)) |
11203 | ++next; | |
11204 | if ((PL_bufend - next) >= 2 && *next == '=' && next[1] == '>' ) { | |
f333445c JP |
11205 | /* return string not v-string */ |
11206 | sv_setpvn(sv,(char *)s,pos-s); | |
73d840c0 | 11207 | return (char *)pos; |
f333445c JP |
11208 | } |
11209 | } | |
11210 | ||
11211 | if (!isALPHA(*pos)) { | |
89ebb4a3 | 11212 | U8 tmpbuf[UTF8_MAXBYTES+1]; |
f333445c JP |
11213 | |
11214 | if (*s == 'v') s++; /* get past 'v' */ | |
11215 | ||
11216 | sv_setpvn(sv, "", 0); | |
11217 | ||
11218 | for (;;) { | |
0bd48802 AL |
11219 | U8 *tmpend; |
11220 | UV rev = 0; | |
f333445c JP |
11221 | { |
11222 | /* this is atoi() that tolerates underscores */ | |
bfed75c6 | 11223 | const char *end = pos; |
f333445c JP |
11224 | UV mult = 1; |
11225 | while (--end >= s) { | |
11226 | UV orev; | |
11227 | if (*end == '_') | |
11228 | continue; | |
11229 | orev = rev; | |
11230 | rev += (*end - '0') * mult; | |
11231 | mult *= 10; | |
11232 | if (orev > rev && ckWARN_d(WARN_OVERFLOW)) | |
11233 | Perl_warner(aTHX_ packWARN(WARN_OVERFLOW), | |
11234 | "Integer overflow in decimal number"); | |
11235 | } | |
11236 | } | |
11237 | #ifdef EBCDIC | |
11238 | if (rev > 0x7FFFFFFF) | |
11239 | Perl_croak(aTHX_ "In EBCDIC the v-string components cannot exceed 2147483647"); | |
11240 | #endif | |
11241 | /* Append native character for the rev point */ | |
11242 | tmpend = uvchr_to_utf8(tmpbuf, rev); | |
11243 | sv_catpvn(sv, (const char*)tmpbuf, tmpend - tmpbuf); | |
11244 | if (!UNI_IS_INVARIANT(NATIVE_TO_UNI(rev))) | |
11245 | SvUTF8_on(sv); | |
3e884cbf | 11246 | if (pos + 1 < PL_bufend && *pos == '.' && isDIGIT(pos[1])) |
f333445c JP |
11247 | s = ++pos; |
11248 | else { | |
11249 | s = pos; | |
11250 | break; | |
11251 | } | |
3e884cbf | 11252 | while (pos < PL_bufend && (isDIGIT(*pos) || *pos == '_')) |
f333445c JP |
11253 | pos++; |
11254 | } | |
11255 | SvPOK_on(sv); | |
11256 | sv_magic(sv,NULL,PERL_MAGIC_vstring,(const char*)start, pos-start); | |
11257 | SvRMAGICAL_on(sv); | |
11258 | } | |
73d840c0 | 11259 | return (char *)s; |
f333445c JP |
11260 | } |
11261 | ||
1da4ca5f NC |
11262 | /* |
11263 | * Local variables: | |
11264 | * c-indentation-style: bsd | |
11265 | * c-basic-offset: 4 | |
11266 | * indent-tabs-mode: t | |
11267 | * End: | |
11268 | * | |
37442d52 RGS |
11269 | * ex: set ts=8 sts=4 sw=4 noet: |
11270 | */ |