summaryrefslogtreecommitdiff
path: root/perl.c
Commit message (Collapse)AuthorAgeFilesLines
* free up CvPADLIST slot for XSUBs for future useDaniel Dragan2014-10-311-1/+1
| | | | | | | | | | | | | | | | | | | CvRESERVED is a placeholder, it will be replaced with a sentinal value from future revised BOOTCHECK API. CvPADLIST_set was helpful during development of this patch, so keep it around for now. PoisonPADLIST's magic value is from PERL_POISON 0xEF pattern. Some PoisonPADLIST locations will get code from future BOOTCHECK API. Make padlist_dup a NN function to avoid overhead of calling it for XSUBs during closing. Perl_cv_undef_flags's else if (CvISXSUB(&cvbody)) is to avoid whitespace changes. Filed as perl [#123059].
* [perl #122445] use magic on $DB::single etc to avoid overload issuesTony Cook2014-10-091-1/+17
| | | | | | | | | This prevents perl recursing infinitely when an overloaded object is assigned to $DB::single, $DB::trace or $DB::signal This is done by referencing their values as IVs instead of as SVs in dbstate, and by adding magic to those variables so that assignments to the scalars update the PL_DBcontrol array.
* Make OP_METHOD* to be of new class METHOPsyber2014-10-031-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new opcode class, METHOP, which will hold class/method related info needed at runtime to improve performance of class/object method calls, then change OP_METHOD and OP_METHOD_NAMED from being UNOP/SVOP to being METHOP. Note that because OP_METHOD is a UNOP with an op_first, while OP_METHOD_NAMED is an SVOP, the first field of the METHOP structure is a union holding either op_first or op_sv. This was seen as less messy than having to introduce two new op classes. The new op class's character is '.' Nothing has changed in functionality and/or performance by this commit. It just introduces new structure which will be extended with extra fields and used in later commits. Added METHOP constructors: - newMETHOP() for method ops with dynamic method names. The only optype for this op is OP_METHOD. - newMETHOP_named() for method ops with constant method names. Optypes for this op are: OP_METHOD_NAMED (currently) and (later) OP_METHOD_SUPER, OP_METHOD_REDIR, OP_METHOD_NEXT, OP_METHOD_NEXTCAN, OP_METHOD_MAYBENEXT (This commit includes fixups by davem)
* perl.c: fix small bug on Android from commit 9054c81Alexandre (Midnite) Jousset2014-09-041-2/+2
| | | | | | | Commit b33b7ab made PERL_LIB absolute when cross-compiling on Android. Commit 9054c81 added incompatibility with this. Now, only add "./" to run buildcustomize.pl when miniperl is running with -T.
* Allow for changing size of bracketed regex char classKarl Williamson2014-09-031-0/+2
| | | | | | | | This commit allows Perl to be compiled with a bitmap size that is larger than 256. This bitmap is used to directly look up whether a character matches or not, without having to do a binary search or hash lookup. It might improve the performance for some installations that have a lot of use of scripts that are above the Latin1 range.
* perl.c: Improve buildcustomize error messageFather Chrysostomos2014-08-311-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | buildcustomize.pl was being loaded with generated code that died if ‘lib/buildcustomize.pl’ existed but do-file failed. $@ was used as the error message. If the file does not exist (do-file searching @INC), then $@ is empty and the error is in $!. Before 9054c817, this is what we would get: $ ./miniperl -T -Ilib -e0 Died. BEGIN failed--compilation aborted. I fixed that in 9054c817 so there would be no error (by adding an ini- tial ‘./’ to the path.) That message was rather baffling. It would have been easier to track down the cause if I had seen something like this: $ ./miniperl -T -Ilib -e0 lib/buildcustomize.pl: No such file or directory. BEGIN failed--compilation aborted. This commit changes the generated code to output $! like that if $@ is empty, in case a similar bug occurs again.
* Get ‘./miniperl -Ilib -T’ workingFather Chrysostomos2014-08-311-1/+3
| | | | | | | | | | | | | | | | | | | | | If the first directory included via -I contains buildcustomize.pl, then miniperl will try to load it at startup. This allows the build process to access all the necessary directories, because buildcustomize.pl fills in @INC. This was not working under taint mode, making it a pain for me to diagnose tainting bugs with miniperl (which builds faster than perl proper, obviously). It failed because buildcustomize.pl is loaded with generated code that does ‘do "lib/buildcustomize.pl"’ (where ‘lib’ is taken from -Ilib), but do-file searches @INC, which does not include the current direc- tory under taint mode. The easiest solution here is to add ‘./’ to the beginning of the path. It is unlikely that anyone is using miniperl -I/... (with an absolute path), and miniperl is only supposed to be used for building or devel- oping perl, anyway.
* Make eval_pv documentation more preciseTadeusz Sośnierz2014-08-241-1/+1
|
* Add and use macros for case-insensitive comparisonKarl Williamson2014-08-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This adds to handy.h isALPHA_FOLD_EQ(c1,c2) which efficiently tests if c1 and c2 are the same character, case-insensitively. For example isALPHA_FOLD_EQ(c, 's') returns true if and only if <c> is 's' or 'S'. isALPHA_FOLD_NE() is also added by this commit. At least one of c1 and c2 must be known to be in [A-Za-z] or this macro doesn't work properly. (There is an assert for this in the macro in DEBUGGING builds). That is why the name includes "ALPHA", so you won't forget when using it. This functionality has been in regcomp.c for a while, under a different name. I had thought that the only reason to make it more generally available was potential speed gain, but recent gcc versions optimize to the same code, so I thought there wasn't any point to doing so. But I now think that using this makes things easier to read (and certainly shorter to type in). Once you grok what this macro does, it simplifies what you have to keep in your mind when reading logical expressions with multiple operands. That something can be either upper or lower case can be a distraction to understanding the larger point of the expression.
* Use grok_atou instead of atoi.Jarkko Hietaniemi2014-07-221-8/+16
| | | | | Remaining atoi() uses include at least: ext/DynaLoader/dl_aix.xs, os2/os2.c, vms/vms.c
* Remove or downgrade unnecessary dVAR.Jarkko Hietaniemi2014-06-251-27/+5
| | | | | | | | You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference. (g++ does not do the "post-annotation" form of "unused".) The version code has some of these issues, reported upstream.
* PERL_UNUSED_CONTEXT -> remove interp context where possibleDaniel Dragan2014-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | | Removing context params will save machine code in the callers of these functions, and 1 ptr of stack space. Some of these funcs are heavily used as mg_find*. The contexts can always be readded in the future the same way they were removed. This patch inspired by commit dc3bf40570. Also remove PERL_UNUSED_CONTEXT when its not needed. See removal candidate rejection rational in [perl #122106]. -Perl_hv_backreferences_p uses context in S_hv_auxinit commit 96a5add60f was wrong -Perl_whichsig_sv and Perl_whichsig_pv wrongly used PERL_UNUSED_CONTEXT from inception in commit 84c7b88cca -in authors opinion cast_* shouldn't be public API, no CPAN grep usage, can't be static and/or inline optimized since it is exported -Perl_my_unexec move to block where it is needed, make Win32 block, context free, for inlining likelyhood, private api and only 2 callers in core -Perl_my_dirfd make all blocks context free, then change proto -Perl_bytes_cmp_utf8 wrongly used PERL_UNUSED_CONTEXT from inception in commit fed3ba5d6b
* Revert "/* NOTREACHED */ belongs *before* the unreachable."Jarkko Hietaniemi2014-06-191-8/+4
| | | | | | This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca. (Still needs more work, but wanted to see how well this passed with Jenkins.)
* /* NOTREACHED */ belongs *before* the unreachable.Jarkko Hietaniemi2014-06-191-4/+8
| | | | | | Definitely not *after* it. It marks the start of the unreachable, not the first unrechable line. And if they are in that order, it looks better to linebreak after the lint hint.
* Remove MAD.Jarkko Hietaniemi2014-06-131-42/+1
| | | | | | MAD = Misc Attribute Decoration; unmaintained attempt at preserving the Perl parse tree more faithfully so that automatic conversion to Perl 6 would have been easier.
* Adding missing SVfARG() invocationsBrian Fraser2014-06-131-5/+5
| | | | This silences a chunk of warnings under -Wformat
* Removed NeXT supportBrian Fraser2014-06-111-5/+0
|
* Keep LC_NUMERIC in C locale, except for brief periodsKarl Williamson2014-06-051-7/+0
| | | | | | | This is for XS modules, so they don't have to worry about the radix being a non-dot. When the locale needs to be in the underlying one, the operation should be wrapped using macros for the purpose. That API may change as we gain experience in 5.21, so I'm not including it now.
* Unify the "fall-through" lint annotation.Jarkko Hietaniemi2014-05-291-8/+8
| | | | | | | Used by linters (static checkers), and also good for human readers. Even though "FALL THROUGH" seems to be the most common, e.g BSD lint manual only knows "FALLTHROUGH" (or "FALLTHRU").
* fcntl receiving -1 from fileno, fcntl failing.Jarkko Hietaniemi2014-05-291-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Also very few spots of negative numgroups for getgroups(), and fgetc() return, but almost all checking is for fcntl.) (merged fix for perl #121743 and perl #121745: hopefully picked up all the fixes-to-fixes from the ticket...) Fix for Coverity perl5 CIDs 28990..29003,29005..29011,29013, 45354,45363,49926: Argument cannot be negative (NEGATIVE_RETURNS) fd is passed to a parameter that cannot be negative. and CIDs 29004, 29012: Argument cannot be negative (NEGATIVE_RETURNS) num_groups is passed to a parameter that cannot be negative and because of CIDs 29005 and 29006 also CID 28924. In the first set of issues a fd is retrieved from PerlIO_fileno, and that is then used in places like fstat(), fchown(), dup(), etc., without checking whether the fd is valid (>=0). In the second set of issues a potentially negative number is potentially passed to getgroups(). The CIDs 29005 and 29006 were a bit messy: fixing them needed also resolving CID 28924 where the return value of fstat() was ignored, and for completeness adding two croak calls (with perldiag updates): a bit of a waste since it's suidperl code.
* Fix for Coverity perl5 CID 29068: Insecure temporary file (SECURE_TEMP) ↵Jarkko Hietaniemi2014-05-281-0/+2
| | | | | | | | | | secure_temp: Calling mkstemp() without securely setting umask first. The umask used for mkstemp should be secure, but umask 0600 has been the required umask only since POSIX.1-2008. In glibc 2.06 and earlier the default was 0666, which is not secure. And no explicit knowledge of how well non-glibc platforms implement mkstemp. Better err on the side security, so set the umask temporarily to 0600, and then restore it.
* Use the C_ARRAY_LENGTH.Jarkko Hietaniemi2014-05-281-1/+1
| | | | | | | | | | | | Use the C_ARRAY_LENGTH instead of sizeof(c_array)/sizeof(c_array[0]) or sizeof(c_array)/sizeof(type_of_element_in_c_array), and C_ARRAY_END for c_array + C_ARRAY_LENGTH(c_array). While doing this found potential off-by-one error in sv.c:Perl_sv_magic: how > C_ARRAY_LENGTH(PL_magic_data) should probably have been how >= C_ARRAY_LENGTH(PL_magic_data) No tests fail, but this seems to be more of an internal sanity check.
* For ptr masking use PTRSIZE-1, not nested conditional statement.Jarkko Hietaniemi2014-05-281-2/+1
|
* PATCH: [perl 121317] Gconvert() obeys LC_NUMERIC without "use locale"Karl Williamson2014-04-011-0/+7
| | | | | | | | | | | | | | | | | | This reverts part of bc8ec7cc020d0562094a551b280fd3f32bf5eb04. leaving LC_NUMERIC set to the C locale at start-up. This allows the tests for quite a few XS modules to pass, as they (and likely the modules themselves) are expecting a dot as the decimal point character. However,such modules remain vulnerable to explicit calls to setlocale() by the Perl code or other modules, See the ticket's discussion for ideas on how to fix this better in 5.21 going forward. I did not add tests because this fix only affects XS code that is not in the Perl API, and we don't have any infrastructure for testing that. Building such infrastructure seems to me to be too much for the code freeze situation we are in, and all this is planned to change very early in v5.21 anyway.
* Change av_len calls to av_tindex for clarityKarl Williamson2014-02-201-2/+2
| | | | | | av_tindex is a more clearly named synonym for av_len, available starting in v5.18. This changes the core uses to it, including modules in /ext, which are not dual-lifed.
* New bincompat optionsH.Merijn Brand2014-02-191-0/+3
|
* Fix the prototypes of some functions without contextBrian Fraser2014-02-051-1/+1
| | | | Their prototypes are (void), but the implementation was ()
* Avoid compiler warnings by consistently using #ifdef instead of plain #ifBrian Fraser2014-02-051-11/+11
|
* Add -DL option to trace setlocale callsKarl Williamson2014-02-031-1/+2
| | | | This will help field debugging of locale issues.
* perl.c: Add missing ref count decrementKarl Williamson2014-01-221-0/+1
| | | | This could have led to a leak.
* rename sTHX to PERL_MEMORY_DEBUG_HEADER_SIZEDavid Mitchell2014-01-201-1/+1
| | | | | | | | | Originally this macro evaluated to the size of the THX pointer; this was used with the memory pool facility to store the context of the caller of the malloc() for debugging. Later, the header of the malloc() stored more than just the context, so sTHX became a mismoner. Rename it to something less misleading.
* update latest copyright year to 2014Ricardo Signes2014-01-191-1/+1
|
* Move initialization of PL_XPosix_ptrs[] to perl.cKarl Williamson2014-01-091-0/+19
| | | | | | | This was performed unconditionally in regcomp.c. However, future commits will use this from other code. Almost all (but not completely all) Perl code uses regular expressions, so only rarely will this small amount of initialization be performed when it currently isn't.
* Rmv PL_Posix_ptrsKarl Williamson2014-01-091-3/+0
| | | | | | | | | | | | Previous commits in this series have removed all uses of this global array. This completely removes it. Since it is a global, consideration need be given to possible uses of it outside the core. It has never been externally documented, and is an opaque structure whose internals have changed with every release. The functions used to access it are almost all static to regcomp.c; those few that aren't have been hidden from all but the few .c files that need to have access to them, via #if's.
* Remove PL_L1Posix_ptrsKarl Williamson2014-01-091-3/+0
| | | | | | | | | | | | This global array is no longer used, having been removed in previous commits in this series. Since it is a global, consideration need be given to possible uses of it outside the core. It has never been externally documented, and is an opaque structure whose internals have changed with every release. The functions used to access it are almost all static to regcomp.c; those few that aren't have been hidden from all but the few .c files that need to have access to them, via #if's.
* PATCH: [perl #120723] Setting LC_NUMERIC breaks parsing of constantsKarl Williamson2014-01-041-1/+0
| | | | | | | | | | | | This is the final patch for [perl #120723], and adds tests for it. LC_NUMERIC Locale handling was broken for code during the compilation phase, such as BEGIN {} blocks. This is because, for some reason, perl.c set LC_NUMERIC unconditionally back to the C locale right after locale initialization. I suspect that was to allow the core's parsing to not be affected by locale. However, earlier commits in this series have added code to change/restore the locale during sections of the parsing where this might matter, so this setting to the C locale is not needed.
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-7/+8
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* Fix VMS-specific wraparound error in S_mayberelocate.Craig A. Berry2013-11-241-1/+1
| | | | | | | | | In trimming the trailing slash from a Unix path spec, we haven't (since 5.003 or so) been ensuring that we weren't stepping off the beginning of the string. No, it's not normal to have '/' as a library path, but if it happens we shouldn't allow a zero or negative (actually wraparound since unsigned) value for the path length.
* Remove redundant SPAGAIN & PUTBACK after PUSHSTACKi().Nicholas Clark2013-11-221-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PUSHSTACKi() calls SWITCHSTACK(), which sets PL_stack_sp and sp like this: sp = PL_stack_sp = PL_stack_base + AvFILLp(t) Hence after PUSHSTACKi() both are identical, so use of SPAGAIN or PUTBACK to assign one to the other is redundant. The use of SPAGAIN in encoding.xs and via.xs was added with commit 24f59afc531955e5 (April 2002) which added the use of PUSHSTACKi(). It feels like cargo-cult. The use of PUTBACK in Perl_amagic_call() predates the introduction of nested stacks and PUSHSTACKi() in commit e336de0d01f30cc4 (April 1998). It dates from perl 5.000, but it's not clear that it was ever needed, as the code in question looked like this, and nothing could have moved the stack between the dSP and PUTBACK: dSP; BINOP myop; SV* res; Zero(&myop, 1, BINOP); myop.op_last = (OP *) &myop; myop.op_next = Nullop; myop.op_flags = OPf_KNOW|OPf_STACKED; ENTER; SAVESPTR(op); op = (OP *) &myop; PUTBACK; The PUTBACK and SPAGAIN in Perl_require_pv() were added by commit d3acc0f7e5197310 (June 1998) which also added the PUSHSTACKi(). They have both been redundant since they were added.
* Get perl to build under STRESS_REALLOC once moreFather Chrysostomos2013-11-221-2/+4
| | | | | | | | | | | | It had been broken since v5.17.6-144-ga3444cc. That commit added, inter alia, this comment to scope.h: + * Of course, doing the size check *after* pushing means we must always + * ensure there are SS_MAXPUSH free slots on the savestack But STRESS_REALLOC makes the initial savestack size just 1, and SS_MAXPUSH is 4. So ‘./miniperl -e0’ failed an assertion.
* fix a few warnings (format strings, unused variable)Lukas Mai2013-11-201-2/+2
| | | | | | | | | | | | | | During compilation gcc complains about the following: perl.c:4970: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'U32' [-Wformat=] perl.c:5075: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'I32' [-Wformat=] mg.c:1972: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'ssize_t' [-Wformat=] pp_ctl.c:2610: warning: unused variable 'mark' [-Wunused-variable] regexec.c:2275: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int' [-Wformat=] This patch fixes all of them. Tony: warning: unused variable 'mark' was fixed in 481c819b
* remove PL_patchlevel from S_minus_vDaniel Dragan2013-11-201-16/+21
| | | | | | | | | | | | | | | | | |SvPVX(vstringify(PL_patchlevel))| is the same string as |"v" PERL_VERSION_STRING|. No need to go through the overhead of using a version object. Instead of creating a SV, then further manipulating it. Create and manipulate it at the same time with Perl_newSVpvf_nocontext or newSVpvn. "num_len >= level_len " will be folded away by the compiler, previously, since both lengths came from SVs, they were not const technically. A very smart compiler might see strncmp/strnEQ takes all const arguments, and will optimize that away also. VC 2003 didnt do that. Change SvREFCNT_dec to SvREFCNT_dec_NN for obvious reasons. There should not be any user visible changes to -v with this patch. switches.t contains a regexp for -v already so no further tests were added. This patch is part of #116296.
* perl.c: White space onlyKarl Williamson2013-11-091-3/+3
| | | | Properly indent a few lines
* Move the function to set $^X to its own filePeter Martini2013-11-041-85/+2
| | | | | | | This also moves the indirect dependency on stdbool.h to its own file, rather than being pulled in for all of perl.c, for those cases where one may want to test using other definitions of bool.
* Introduce PERL_BOOL_AS_CHAR defineFather Chrysostomos2013-10-301-4/+0
| | | | | | | | | This allows compilers that do support real booleans (C++ or anything with stdbool.h) to emulate those that don’t. See ticket #120314. This patch incorporates suggestions from Craig Berry.
* Make PL_incgv fully refcountedFather Chrysostomos2013-10-281-1/+2
| | | | | | | | | It was only reference-counted in the main thread: $ ./perl -Ilib -e 'delete $::{INC}; eval q"my $foo : bar"' $ ./perl -Ilib -e 'use threads; async {delete $::{INC}; eval q"my $foo : bar"}->join' Assertion failed: (SvTYPE(_gvgp) == SVt_PVGV || SvTYPE(_gvgp) == SVt_PVLV), function S_apply_attrs_my, file op.c, line 2600. Abort trap: 6
* [perl #54044] Make PL_replgv refcountedFather Chrysostomos2013-10-281-1/+3
| | | | | | | | | | Otherwise one can free it and make perl crash: $ perl -e 'delete $::{"\cR"}; //' Segmentation fault: 11 It crashes because PL_replgv now points to a freed SV which has no GV slots, so GvSV on it fails.
* Make PL_argvgv refcountedFather Chrysostomos2013-10-281-1/+3
| | | | | | | | | Otherwise one can free it and cause assertion failures when other things do SvREFCNT_inc on a freed scalar: $ ./miniperl -le 'undef *x; delete $::{ARGV}; $x++; eval "BEGIN{undef *x} readline"' Assertion failed: (SvTYPE(sv) != (svtype)SVTYPEMASK), function Perl_sv_clear, file sv.c, line 6215. Abort trap: 6
* Make PL_hintgv refcountedFather Chrysostomos2013-10-281-0/+1
| | | | | | | | | | | Otherwise one can free it (by deleting the *^H glob) and cause a crash: $ perl -e 'delete $::{"\cH"}; ${^OPEN}=foo' Segmentation fault: 11 That happens because PL_hintgv points to a freed scalar, and GvHV(PL_hintgv) ends up trying to access nonexistent fields.
* Don’t create %@ on startupFather Chrysostomos2013-10-281-1/+1
| | | | | | | | | | | | | | This hash has been unused since perl-5.005_02-2093-g98eae8f: commit 98eae8f585b9800849b5e5482e2d405f21bab67e Author: Gurusamy Sarathy <gsar@cpan.org> Date: Fri Oct 8 10:26:15 1999 +0000 remove kludgey duplicate background error avoidance (caused "leaks"; %@ wasn't even user-visible under -Dusethreads); only repeats of most recent error are now avoided p4raw-id: //depot/perl@4316