summaryrefslogtreecommitdiff
path: root/toke.c
Commit message (Collapse)AuthorAgeFilesLines
* toke.c, util.c: setlocale returns new locale, not oldKarl Williamson2011-12-181-1/+3
| | | | | This means we have to call setlocale with a NULL second parameter to get the correct old value; then call it with the new value
* toke.c, perldiag: Note delay of some things to 5.18Karl Williamson2011-12-161-1/+1
| | | | | | We are mostly allowing two release cycles before removing a deprecated feature; therefore several things have been retained for 5.16, that are documented as being removed for it; Update the docs.
* Disable $[ under 5.16Father Chrysostomos2011-12-151-5/+13
| | | | | | | | | | | | | | | | | | | | | This adds the array_base feature to feature.pm Perl_feature_is_enabled has been modified to use PL_curcop, rather than PL_hintgv, so it can work with run-time hints as well. (PL_curcop holds the current state op at run time, and &PL_compiling at compile time, so it works for both.) The hints in $^H are not stored in the same place at compile time and run time, so the FEATURE_IS_ENABLED macro has been modified to check first whether PL_curop == &PL_compiling. Since array_base is on by default with no hint for it in %^H, it is a ‘negative’ feature, whose entry in %^H turns it off. feature.pm has been modified to support such negative features. The new FEATURE_IS_ENABLED_d can check whether such default features are enabled. This does make things less efficient, as every version declaration now loads feature.pm to disable all features (including turning off array_base, which entails adding an entry to %^H) before loading the new bundle. I have plans to make this more efficient.
* Don’t warn for open local *FHFather Chrysostomos2011-12-081-0/+1
| | | | | | | | There is this ancient ‘Precedence problem’ warning that warns for open followed by a bareword and then an operator that would have made open into a unary-precedence operator in Perl 4. It was not taking into account that the bareword might be a Perl keyword. In that case it shouldn’t be warning.
* Optimise __SUB__ to a constantFather Chrysostomos2011-11-261-1/+1
| | | | | | | | | | | | | | | | | | | If __SUB__ is not inside a closure, it can be optimised to a constant. We can only do this in the peephole optimiser, as we cannot tell whether PL_compcv will become a closure until we reach the end of the sub. The __SUB__ op cannot simply be replaced with a const op, as the par- ent op is not readily available in the peephole optimiser and, hence, we cannot change its pointer. So we have to convert the runcv op itself into a const op. So it has to be the same size. This commit makes it a PVOP, since newPVOP, unlike newSVOP, allows a null pv. To avoid adding workarounds to B modules, I put an exception in newPVOP’s assertion, instead of chang- ing the type in regen/opcodes. But B::Deparse still had to be updated to avoid infinite recursion.
* Don’t warn for foo+1 with ($) protoFather Chrysostomos2011-11-241-5/+9
| | | | | Commit 22393538 added the warning for (;$) prototypes, but ended up adding it for ($) as well.
* When parsing subs with user-defined prototypes, store information needed to ↵Matthew Horsfall (alh)2011-11-241-2/+6
| | | | throw warnings
* [perl #80628] __SUB__Father Chrysostomos2011-11-221-0/+3
| | | | | After much alternation, altercation and alteration, __SUB__ is finally here.
* Don’t create an AV for unfiltered codeFather Chrysostomos2011-11-181-2/+6
| | | | | When there are no source filters, we don’t need to create an AV to hold them. The code for adding a filter already does a null check.
* In Perl_lex_start(), don't read the byte before SvPVX().Nicholas Clark2011-11-131-1/+1
| | | | | | | | If len is 0, we shouldn't be reading from len - 1, as it's one before the start of the buffer, and hence an out of bounds read. Fixes a bug inadvertently added by commit 0abcdfa4c5da571f, restoring the previous behaviour for the len == 0 case.
* toke.c:lex_start: Move len into the only block that uses itFather Chrysostomos2011-11-061-1/+1
|
* Update docs about lex_start’s flags paramFather Chrysostomos2011-11-061-3/+2
|
* Avoid redundant copies in string evalsFather Chrysostomos2011-11-061-8/+5
| | | | | | | Perl_lex_start copies the string passed to it unconditionally. Sometimes pp_entereval makes a copy before passing the string to lex_start. So in those cases we can pass a flag to avoid a redundant copy.
* Make multiple #line’s update dblines in evalsFather Chrysostomos2011-11-061-1/+1
| | | | | | | | | | | | | | | The array-copying stuff that happens when #line 3 "filename" is encountered in a string eval is not sufficient. If there are multiple such statements, only the first one copies the debugger’s lines arrays (@{"_<filename"}) into the new array. Checking that CopFILESV(PL_curcop) begins with ‘(eval ’ is a bit silly, since the parser already knows whether it’s processing a file without having to check file names. (And what if you have a real file beginning with ‘(eval ’?) See commit 8818d40 and others that it references, for the history of this piece of code.
* Make source filters work in evalbytesFather Chrysostomos2011-11-061-20/+88
| | | | | | When a filter is added, the current buffer is hung on the end of the filters array, and a new substring of it becomes the current buffer.
* Add evalbytes functionFather Chrysostomos2011-11-061-0/+4
| | | | | | | | | | | This function evaluates its argument as a byte string, regardless of the internal encoding. It croaks if the string contains characters outside the byte range. Hence evalbytes(" use utf8; '\xc4\x80' ") will return "\x{100}", even if the original string had the UTF8 flag on, and evalbytes(" '\xc4\x80' ") will return "\xc4\x80". This has the side effect of fixing the deparsing of CORE::break under ‘use feature’ when there is an override.
* Forbid source filters in Unicode evalsFather Chrysostomos2011-11-061-0/+3
| | | | | | Source filters have always been byte-level filters. Therefore they don’t make sense on Unicode strings, unless we are planning to add new APIs to support it. Until then, croak.
* eval STRING UTF8 cleanup.Brian Fraser2011-11-061-2/+3
| | | | | (modified by the committer only to apply when the unicode_eval feature is enabled)
* Fix CORE::globFather Chrysostomos2011-10-261-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | This commit makes CORE::glob bypassing glob overrides. A side effect of the fix is that, with the default glob implementa- tion, undefining *CORE::GLOBAL::glob no longer results in an ‘unde- fined subroutine’ error. Another side effect is that compilation of a glob op no longer assumes that the loading of File::Glob will create the *CORE::GLOB::glob type- glob. ‘++$INC{"File/Glob.pm"}; sub File::Glob::csh_glob; eval '<*>';’ used to crash. This is accomplished using a mechanism similar to lock() and threads::shared. There is a new PL_globhook interpreter varia- ble that pp_glob calls when there is no override present. Thus, File::Glob (which is supposed to be transparent, as it *is* the built-in implementation) no longer interferes with the user mechanism for overriding glob. This removes one tier from the five or so hacks that constitute glob’s implementation, and which work together to make it one of the buggiest and most inconsistent areas of Perl.
* Resolve XS AUTOLOAD-prototype conflictFather Chrysostomos2011-10-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Did you know that a subroutine’s prototype can be modified with s///? Don’t look: *AUTOLOAD = *Internals'SvREFCNT; my $f = "Just another "; eval{main->$f}; print prototype AUTOLOAD; $f =~ s/Just another /Perl hacker,\n/; print prototype AUTOLOAD; You did look, didn’t you? You must admit that’s creepy. The problem goes back to this: commit adb5a9ae91a0bed93d396bb0abda99831f9e2e6f Author: Doug MacEachern <dougm@covalent.net> Date: Sat Jan 6 01:30:05 2001 -0800 [patch] xsub AUTOLOAD fix/optimization Message-ID: <Pine.LNX.4.10.10101060924280.24460-100000@mojo.covalent.net> Allow AUTOLOAD to be an xsub and allow such xsubs to avoid use of $AUTOLOAD. p4raw-id: //depot/perl@8362 which includes this: + if (CvXSUB(cv)) { + /* rather than lookup/init $AUTOLOAD here + * only to have the XSUB do another lookup for $AUTOLOAD + * and split that value on the last '::', + * pass along the same data via some unused fields in the CV + */ + CvSTASH(cv) = stash; + SvPVX(cv) = (char *)name; /* cast to loose constness warning */ + SvCUR(cv) = len; + return gv; + } That ‘unused’ field is not unused. It’s where the prototype is stored. So, not only is it clobbering the prototype, it’s also leak- ing it by assigning over the top of SvPVX. Furthermore, it’s blindly assigning someone else’s string, which could be freed before it’s even used. Since it has been documented for a long time that SvPVX contains the name of the AUTOLOADed sub, and since the use of SvPVX for prototypes is documented nowhere, we have to preserve the former. So this commit makes the prototype and the sub name share the same buffer, in a manner resembling that which CvFILE used before I changed it with bad4ae38. There are two new internal macros, CvPROTO and CvPROTOLEN for retriev- ing the prototype.
* Cast to signed before negating, to avoid compiler warningsBrian Fraser2011-10-061-1/+1
|
* toke.c, ext/attributes/attributes.xs: Make attributes UTF-8 clean.Brian Fraser2011-10-061-1/+1
|
* Modify S_pending_ident to use sv_catpvn_flagsFather Chrysostomos2011-10-061-1/+1
| | | | | with the new SV_CAT* constants, since that’s faster than creating an SV to pass to sv_catsv.
* toke.c, op.c, sv.c: Prototype parsing and checking are nul-and-UTF8 clean.Brian Fraser2011-10-061-8/+14
| | | | | | | | | | | | This means that eval "sub foo ($;\0whoops) { say @_ }" will correctly include \0whoops in the CV's prototype (while complaining about illegal characters), and that use utf8; BEGIN { $::{"foo"} = "\$\0L\351on" } BEGIN { eval "sub foo (\$\0L\x{c3}\x{a9}on) {};"; } will not warn about a mismatched prototype.
* toke.c: Some simple mending to get readline() working with UTF-8 filehandlesBrian Fraser2011-10-061-1/+1
|
* toke.c: Take utf8 into account when creating DATA handleFather Chrysostomos2011-10-061-3/+13
| | | | | This is based on work from Brian Fraser, but differs from his original in that it does not require an intermediate SV.
* mro UTF8 cleanup.Brian Fraser2011-10-061-4/+14
| | | | | | | | | | | This patch also duplicates existing mro tests with copies that use Unicode in identifiers, to test the mro code. Since those tests trigger it, it also fixes a bug in the parsing of *{...}: If the first character inside the braces is a non-ASCII Unicode identifier character, the inside is now implicitly quoted if it is just an identifier (just as it is with ASCII identifiers), instead of being parsed as a bareword that would violate strict subs.
* toke.c: S_scan_inputsymbol, initial GV-related UTF8 cleanupBrian Fraser2011-10-061-2/+2
|
* toke.c: S_checkcomma, GV-related UTF8 cleanupBrian Fraser2011-10-061-1/+1
|
* toke.c: yylex, GV-related UTF8 cleanupBrian Fraser2011-10-061-10/+18
|
* toke.c: S_find_in_my_stash, GV-related UTF8 cleanupBrian Fraser2011-10-061-3/+3
|
* toke.c: S_intuit_method, GV-related UTF8 cleanupBrian Fraser2011-10-061-3/+4
|
* toke.c: S_intuit_more, GV-related UTF8 cleanupBrian Fraser2011-10-061-1/+2
|
* toke.c: S_force_ident, GV-related UTF8 cleanupBrian Fraser2011-10-061-3/+4
|
* gv.c: Initial gv_fetchpvn_flags and gv_stashpvn UTF8 cleanupBrian Fraser2011-10-061-6/+8
| | | | | | | | | Now that a glob can be initialized and fetched in UTF-8, the next commit will introduce some changes in toke.c to actually test this. Committer’s note: To keep tests passing I had to incorporate the toke.c:S_pending_ident changes in the same patch.
* Fix inability of lex_read_unichar to handle 80-FF under "no utf8;". ↵Eric Brine2011-09-201-1/+4
| | | | lex_peek_unichar is already correct.
* The Borland Chainsaw MassacreSteve Hay2011-09-101-6/+0
| | | | | Remove support for the Borland C++ compiler on Win32, as agreed here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2011-09/msg00034.html
* remove index offsetting ($[)Zefram2011-09-091-8/+0
| | | | | | $[ remains as a variable. It no longer has compile-time magic. At runtime, it always reads as zero, accepts a write of zero, but dies on writing any other value.
* remove unused variables and assignmentsRobin Barker2011-09-081-2/+1
| | | | | | and silences some compiler warnings. I do not understand the code in toke.c but the change aligns the code with other uses of FUN0OP, it has no warnings and does not break any test.
* [perl #95546] Allow () after __FILE__, etc.Father Chrysostomos2011-08-121-9/+15
| | | | | | | | This commit makes the __FILE__, __LINE__ and __PACKAGE__ token parse the same way as nullary functions. It adds two extra rules to perly.y to allow the op to be created in toke.c, instead of directly inside the parser.
* Passing the flag to the pad functions in toke.cBrian Fraser2011-07-121-4/+6
|
* APIify pad functionsZefram2011-07-121-2/+2
| | | | | | | Move several pad functions into the core API. Document the pad functions more consistently for perlapi. Fix the interface issues around delimitation of lexical variable names, providing _pvn, _pvs, _pv, and _sv forms of pad_add_name and pad_findmy.
* Stop having one of the following qw() warnings hide the other:Eric Brine2011-07-031-6/+7
| | | | | - Possible attempt to separate words with commas - Possible attempt to put comments in qw() list
* Allow ‘continue;’ without feature.pmFather Chrysostomos2011-06-141-12/+1
| | | | | | | | | Since there is no conflict between ‘continue;’ and a user-defined sub- routine (it’s a syntax error, as ‘continue’ is already a keyword), there is no need to require the ‘switch’ feature to be enabled for this keyword. This actually simplifies the implementation.
* [perl #90130] Allow CORE::* without feature.pmFather Chrysostomos2011-06-111-4/+7
| | | | | This commit allows feature.pm-enabled keywords to work with CORE::* even outside the scope of ‘use feature’.
* [perl #88776] Signedness warning in toke.cDavid Mitchell2011-06-061-3/+3
| | | | fix a warning introduced by 6d51015587940c2032a6533d886163f69ca028f9
* scan_heredoc could reallocate PL_parser->linestr's PVDavid Leadbeater2011-05-181-0/+1
| | | | | | | | | | | Since f0e67a1 it was possible the freed buffer may be read from when parsing a heredoc. This adds a call to lex_grow_linestr to grow the buffer and ensure the pointers in PL_parser are updated. The bug is pretty hard to reproduce, hence no test. I'm able to reproduce it with the following: perl -Meverywhere=re,debug -MParams::Util -e1
* [perl #88420] BOM support on Windows broken in 5.13.11Jan Dubois2011-04-131-1/+7
| | | | | | | When Perl reads the script in text mode, then the tell() position on the script handle may include stripped carriage return characters. Therefore the file position after reading the first line of the script may be one larger than the length of the input buffer.
* PATCH: partial [perl #86972]: Allow /aiaKarl Williamson2011-04-101-9/+16
| | | | | | This allows a second /a modifier to not have to be contiguous with the first. This patch changes only the part in toke.c where the modifiers are in suffix form.
* [perl #87064] eval no longer shares filtersFather Chrysostomos2011-04-031-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit: commit f07ec6dd59215a56bc1159449a9631be7a02a94d Author: Zefram <zefram@fysh.org> Date: Wed Oct 13 19:05:19 2010 +0100 remove filter inheritance option from lex_start The only uses of lex_start that had the new_filter parameter false, to make the new lexer context share source filters with the previous lexer context, were uses with rsfp null, which therefore never invoked source filters. Inheriting source filters from a logically unrelated file seems like a silly idea anyway. string evals could inherit the same source filter space as the cur- rently compiling code. Despite what the quoted commit message says, sharing source filters allows filters to be inherited in both direc- tions: A source filter created when the eval is being compiled also applies to the file with which it is sharing its space. There are at least 20 CPAN distributions relying on this behaviour (or, rather, what could be considered a Test::More bug). So this com- mit restores the source-filter-sharing capability. It does not change the current API or make public the API for sharing source filters, as this is supposed to be a temporary stop-gap measure for 5.14.