summaryrefslogtreecommitdiff
path: root/universal.c
Commit message (Collapse)AuthorAgeFilesLines
* [perl #96126] Allocate CvFILE more simplyFather Chrysostomos2011-08-171-2/+7
| | | | | | | | | | | | | | | | | | | See the thread starting at: http://www.nntp.perl.org/group/perl.perl5.porters/2011/07/msg175161.html Instead of assuming that only Perl subs have mallocked CvFILEs and only under threads, resulting in various hackery to borrow parts of the SvPVX buffer where that assumption proves wrong, we can simply add another flag (DYNFILE) to indicate whether CvFILE is mallocked, instead of trying to use the ISXSUB flag for two purposes. This simplifies the code greatly, eliminating bug #96126 in the pro- cess (which had to do with sv_dup not knowing about the hackery that this commit removes). I removed that comment from cv_ckproto_len about CONSTSUBs doubling up the buffer field, as it is no longer relevant. But I still left the code as it is, since it’s better to do an explicit length check.
* [perl #95544] Make UNIVERSAL::VERSION return $VERSIONFather Chrysostomos2011-07-271-11/+8
| | | | | | | | | | | | | | With this patch: $ ./miniperl -le ' $VERSION = "3alpha"; print "main"->VERSION' 3alpha $ ./miniperl -le ' $VERSION = "3alpha"; print "main"->VERSION(4)' Invalid version format (non-numeric data) at -e line 1. See the discussion starting at: http://www.nntp.perl.org/group/perl.perl5.porters/2011/06/msg173710.html Basically, this patch allows custom version parsers to call ->VERSION to retrieve the version, even if the default parser would choke on it.
* Make Internals::SvREADONLY smarterFather Chrysostomos2011-07-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (aka: More fun with Hash::Util) $ perl -lMHash::Util=lock_value $h{a} = __PACKAGE__; lock_value %h, a; $h{a} = "3"; print $h{a}' ^D 3 OK, so it didn’t really lock it. Now for more fun: $ perl -lMHash::Util=unlock_value $h{a} = __PACKAGE__; unlock_value %h, a; $h{a} =~ y/ia/ao/; print __PACKAGE__ ^D moan There are three different ways to fix this: 1) Add an SvFAKE function to Internals:: (not *more* ‘internals’ for people [ahem, Const::Fast, ahem] to abuse!) 2) Use B::* functions in Hash::Util to check the flags (too slow) 3) Make Internals::SvREADONLY less ‘internal’, by having it deal with readonliness in general, rather than just the SVf_READONLY flag. The third approach seems the most logical, so that’s what this commit does. There is one test in t/op/tr.t that uses Internals::SvREADONLY to detect bovinity, so I’ve changed it to use B instead, as that will have no effect on post-install efficiency. (This approach also fixes Const::Fast’s bugginess, but that is purely accidental.)
* Remove two pointless uses of sv_2mortalFather Chrysostomos2011-06-051-2/+0
| | | | | boolSV returns an immortal. When sv_2mortal is called on an immortal, it simply returns. So eliminate the call.
* 2nd try: [perl #91834] utf8::decode does not respect copy-on-writeFather Chrysostomos2011-05-291-1/+3
| | | | | | I reverted the first version of this patch because I put the if() statement before a declaration. I did a revert, rather than a correc- tion, to make back-porting easier.
* Revert "[perl #91834] utf8::decode does not respect copy-on-write"Father Chrysostomos2011-05-291-1/+0
| | | | This reverts commit 40f11004fb3b5fa1cd207a20090df837d721b736.
* [perl #91834] utf8::decode does not respect copy-on-writeFather Chrysostomos2011-05-291-0/+1
| | | | | | | | | | | | | | | | | | | | | utf8::decode was not respecting copy-on-write, but simply modify- ing the PV (the scalar’s string buffer) in place, causing problems with hashes: my $name = "\x{c3}\x{b3}"; my ($k1) = keys %{ { $name=>undef } }; my $k2 = $name; utf8::decode($k1); utf8::decode($k2); print "k1 eq k2 = '", $k1 eq $k2, "'\n"; my $h = { $k1 => 1, $k2 => 2 }; print "{k1} '", $h->{$k1}, "'\n"; print "{k2} '", $h->{$k2}, "'\n"; This example (from the RT ticket) shows that there were two hash ele- ments with the same key. As of this commit, the hash only has one element.
* [perl #90054] Fix typo in universal.cJohan Vromans2011-05-181-1/+1
| | | | At XS(XS_UNIVERSAL_DOES), invocant is spelled wrong.
* CH] Change usage of regex/op common to common namesKarl Williamson2011-01-161-1/+1
| | | | | | | | | This patch changes the core functions to use the common names for the fields that are shared between op.c and regcomp.c, just for consistency of using one name throughout the core for the same thing. A grep of cpan shows that both names are used in various modules; so both names must be retained.
* Use multi-bit field for regex character setKarl Williamson2011-01-161-8/+8
| | | | | | | | | | | | | The /d, /l, and /u regex modifiers are mutually exclusive. This patch changes the field that stores the character set to use more than one bit with an enum determining which one. This data structure more closely follows the semantics of their being mutually exclusive, and conserves bits as well, and is better expandable. A small API is added to set and query the bit field. This patch is not .xs source backwards compatible. A handful of cpan programs are affected.
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-3/+3
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>
* Remove S_get_isa_hashFather Chrysostomos2010-10-311-15/+6
| | | | It no longer serves much purpose, as of 7311f41d6.
* Move the meta->isa code from UNIVERSAL::isa to mro_get_linear_isaFather Chrysostomos2010-10-301-23/+1
| | | | | | | | This is so that it can be used for PL_isarev bookkeeping as well. This will have no effect on the speed of DFS classes. C3 classes on which ->isa is never called will have a slight slowdown. (We could always add an API for setting meta->isa if we want to avoid that.)
* Switch UNIVERSAL::isa over to HvENAMEFather Chrysostomos2010-10-301-3/+6
|
* Move remaining Tie::Hash::NamedCapture XS code to NamedCapture.xsNicholas Clark2010-10-141-78/+0
| | | | Now all the support code for %+ and %- is contained in the module in ext/
* Move Tie::Hash::NamedCapture::{FIRST,NEXT}KEY to NamedCapture.xsNicholas Clark2010-10-141-42/+0
|
* Convert lib/Tie/Hash/NamedCapture.pm to an XS module in ext/Nicholas Clark2010-10-141-15/+0
| | | | Initially move only Tie::Hash::NamedCapture::flags from universal.c to it.
* Merge XS_Tie_Hash_NamedCapture_{FIRSTK,NEXTK} into S_named_capture_iter_common.Nicholas Clark2010-10-141-27/+13
|
* Merge XS_Tie_Hash_NamedCapture_STORE into S_named_capture_common.Nicholas Clark2010-10-141-30/+4
|
* Merge XS_Tie_Hash_NamedCapture_CLEAR into S_named_capture_common.Nicholas Clark2010-10-141-31/+13
|
* Merge XS_Tie_Hash_NamedCapture_DELETE into S_named_capture_common.Nicholas Clark2010-10-141-27/+12
|
* Merge XS_Tie_Hash_NamedCapture_SCALAR into S_named_capture_common.Nicholas Clark2010-10-141-29/+8
|
* Merge XS_Tie_Hash_NamedCapture_{FETCH,EXISTS} into S_named_capture_common.Nicholas Clark2010-10-141-25/+9
|
* Expand CALLREG_NAMED_BUFF* macros in XS_Tie_Hash_NamedCapture_*Nicholas Clark2010-10-141-8/+8
| | | | This reveals even more similarity between the routines' bodies.
* Consistent stack handling for XS_re_regnames_*Nicholas Clark2010-10-131-17/+8
| | | | | This may also fix bugs for the (untested) cases where the called routine returns NULL, and the calling routine attempted XSRETURN_UNDEF.
* Consistent usage messages for XS_Tie_Hash_NamedCapture_*Nicholas Clark2010-10-131-5/+5
| | | | The $flags argument is actually the object, so should not be mentioned.
* In XS_Tie_Hash_NamedCapture_{CLEAR,STORE}, free any returned value.Nicholas Clark2010-10-131-2/+13
| | | | | | The calling convention for CALLREG_NAMED_BUFF_*() is to return NULL, or a reference to a scalar. For CLEAR and STORE we return no values, so if we're erroneously passed a reference, we should free it to stop it being leaked.
* Consistent stack handling for XS_Tie_Hash_NamedCapture_*Nicholas Clark2010-10-131-34/+19
| | | | | | | | This may also fix bugs for the (untested) cases where CALLREG_NAMED_BUFF_* returned NULL, and the calling routine attempted XSRETURN_UNDEF. It's fine to call sv_2mortal() on the immortals returned by CALLREG_NAMED_BUFF_EXISTS()
* XS_Tie_Hash_NamedCapture_DELETE should return a value.Nicholas Clark2010-10-131-1/+11
| | | | | | | | The core's regexp implementation will always croak, but other pluggable engines may have read/write semantics, and hence return from their delete call. Note that STORE and EXISTS are called in void context, hence their return stack is discarded.
* XS_Tie_Hash_NamedCapture_STORE should always croak on invalid parameters.Nicholas Clark2010-10-121-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, it would return undef instead of calling Perl_croak_no_modify() if PL_localizing was true. However, that case can never be reached. PL_localizing is set non-zero for 1: Perl_mg_localize and PL_save_scalar, for the duration of executing the local 2: Perl_leave_scope for the duration of unwinding the local However, XS_Tie_Hash_NamedCapture_STORE can't be reached in either case, with PL_curpm NULL (or otherwise invalid) || !SvROK(ST(0)). Case 1 would be the call to save_helem_flags() in pp_helem. However, this is only reached if preeminent is TRUE, which will only hold if hv_exists_ent() has already returned TRUE, which will only be possible if PL_curpm and ST(0) are valid. Case 2 would be the case SAVEt_HELEM in Perl_leave_scope(). However, this case is only reached as part of the unwinding from Case 1 above, so again PL_curpm and ST(0) will be valid, for this dynamic scope. This commit is the patch proposed in RT ##77610. It does not resolve all issues in that ticket. Currently C<local $1> is legal - it's a runtime no-op, which neither errors *nor* resets $1 to undef. Clearly C<local $+{k}> is inconsistent with this, (as it errors at scope exit for all cases, and additionally errors at local time if $+{k} exists) but I consider it not worth fixing until we decide whether C<local $1>'s current behaviour is a "bug" or a "feature".
* Fix code-before-declaration problem in universal.cSteve Hay2010-09-231-3/+6
|
* Add /d, /l, /u (infixed) regex modifiersKarl Williamson2010-09-221-2/+9
| | | | | | | | | | | | This patch adds recognition of these modifiers, with appropriate action for d and l. u does nothing useful yet. This allows for the interpolation of a regex into another one without losing the character set semantics that it was compiled with, as for the first time, the semantics is now specified in the stringification as one of these modifiers. To this end, it allocates an unused bit in the structures. The off- sets change so as to not disturb other bits.
* Back out the mauve module and related changesFlorian Ragwitz2010-09-161-110/+0
| | | | | | | | | | | | | | | | | | | | | It's was intended as a temporary namespace only, and we really don't want to ship it in any release until we've figured out what it should really look like. This reverts commit 05c0d6bbe3ec5cc9af99d105b8648ad02ed7cc95, "add sv_reftype_len() and make sv_reftype() be a wrapper for it" commit 792477b9c2e4c75cb03d07bd6d25dc7e1fdf448e, "create the "mauve" temporary namespace for things like reftype" commit 8df6b97c1de8326d50ac9c8cae4bf716393b45bb, "mauve.t needs access to %Config, make sure it's available" commit cfe9162d0d593cd12a979c73df82c7509b324343, "use more efficient sv_reftype_len() interface" and commit 47b13905e23c2a72acdde8bb4669e25e5eaefec4 "add more tests to lib/mauve.t so it tests also that mauve::reftype can return "LVALUE"" There's a `mauve' branch still containing all the code for the temporary mauve namespace. That should be used to work on it until it's mostly ready to be released, and only then merged to blead. Alternatively, it should be deleted if another way to provide mauve's features in the core is found.
* segfault on &Internals::* due to missing SvROK()Ævar Arnfjörð Bjarmason2010-09-111-3/+17
| | | | | | | | | | | | | | | | | | | | Change the &Internals::* functions that use references in their prototypes to check if the argument is SvROK() before calling SvRV(). If the function is called as Internals::FOO() perl does this check for us, but prototypes are bypassed on &Internals::FOO() so we still have to check this manually. This fixes [perl #77776], this bug was present in 5.10.x, 5.12.x, and probably all earlier perl versions that had these functions, but I haven't tested that. I'm adding a new test file (t/lib/universal.t) to test universal.c functions as part of this patch. The testing for Internal::* in t/ was and is very sparse, but before universal.t there was no obvious place to put these tests. Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
* Remove unneeded use of INT2PTR() in the XS for Tie::Hash::NamedCapture.Nicholas Clark2010-08-311-8/+8
|
* create the "mauve" temporary namespace for things like reftypeYves Orton2010-08-301-0/+110
| | | | | | | | | | | | | | | | | | | | | | Scalar::Util::reftype(), refaddr() and blessed() are all a bit less useful than they could be as they all return C<undef> when their argument is not a reference. While this is logical, it also means that using these routines has to be guarded, and normally guarded in such a way that the internal logic is called twice. Additionally these routines are quite commonly used and having to load an additional DLL and XS code every program is inefficient. Therefore we introduce the "mauve" namespace for to hold the "fixed" equivalents, this namespace is /always/ loaded (like the 're' or 'utf8' namespaces), and thus these routines can be accessed easily at any time. We also provide a new module wrapper in t/lib which allows these routines to be exported into other namespaces if the user so chooses. At Jesse's request I have included weaken() and as it seemed logical to do so I have also added isweak(). Once we have a good name for the namespace we can s/mauve/whatever/g
* Stop leaking temporary version objects from XSgfx2010-06-281-6/+7
|
* Prevent object methods called as class methodsJohn Peacock2010-06-281-16/+16
| | | | | | | | | | There are a number of object methods which make absolutely no sense when called as class methods. In addition, with Perl 5.11.5/5.12.0, there are asserts which will trigger SEGV's when you do that. So we check in the XS code and refuse to continue if an object method is called as a class method.
* Add Perl_croak_no_modify() to implement Perl_croak("%s", PL_no_modify).Nicholas Clark2010-06-271-3/+3
| | | | | This reduces object code size, reducing CPU cache pressure on the non-exception paths.
* PATCH: teach diag.t new warning function namesKarl Williamson2010-06-011-1/+1
| | | | | | | | | | | | | | | | | A number of function names that do warnings have been added, but diag.t hasn't kept up. This patch changes it to look for likely function names in embed.fnc, so it will automatically keep up in the future. There's no need to worry about it looking for inappropriate functions, as the syntax of messages that it looks for is so restrictive, that there won't be false positives. Instead there are still many messages it fails to catch. As a result of it's falling behind several issues have crept in. I resolved the couple I thought were clear (including one in a comment; diag.t doesn't strip comments, but mostly it doesn't matter), and added the others to the <DATA> section to ignore. are
* Use sizeof instead of hard-coded array sizeKarl Williamson2010-05-291-1/+1
| | | | The array should be declared with its actual size.
* TypoKarl Williamson2010-05-291-1/+1
|
* InPerl_boot_core_UNIVERSAL() use a data structure for calls to newXS{,proto}Nicholas Clark2010-05-281-118/+81
| | | | | Replacing the longhand list of calls to newXS{,proto} with loop over a data structure reduces the object size by over 1K.
* Fix utf8::is_utf8 to respect GMAGIC (e.g. $1)gfx2010-04-251-1/+2
|
* initialize undefined version objects with zero, not 'undef'David Golden2010-01-211-2/+2
|
* Omnibus strict and lax version parsingDavid Golden2010-01-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Authors: John Peacock, David Golden and Zefram The goal of this mega-patch is to enforce strict rules for version numbers provided to 'package NAME VERSION' while formalizing the prior, lax rules used for version object creation. Parsing for use() is unchanged. version.pm adds two globals, $STRICT and $LAX, containing regular expressions that define the rules. There are two additional functions -- version::is_strict and version::is_lax -- that test an argument against these rules. However, parsing of strings that might contain version numbers is done in core via the Perl_scan_version function, which may be called during compilation or may be called later when version objects are created by Perl_new_version or Perl_upg_version. A new helper function, Perl_prescan_version, has been added to validate a string under either strict or lax rules. This is used in toke.c for 'package NAME VERSION' in strict mode and by Perl_scan_version in lax mode. It matches the behavior of the verison.pm regular expressions, but does not use them directly. A new test file, comp/packagev.t, validates strict and lax behaviors of 'package NAME VERSION' and 'version->new(VERSION)' respectively and verifies their behavior against the $STRICT and $LAX regular expressions, as well. Validating these two implementation should help ensure they each work as intended. Other files and tests have been modified as necessary to support these changes. There is remaining work to be done in a few areas: * documenting all changes in behavior and new functions * determining proper treatment of "," as decimal separators in various locales * updating diagnostics for new error messages * porting changes back to the version.pm distribution on CPAN, including pure-Perl versions
* Tie::Hash::NamedCapture::* shouldn't abort if passed bad input [RT #71828]Nicholas Clark2010-01-051-8/+8
|
* Add missing LEAVE to universal.c sv_doesGerard Goossen2009-11-121-2/+6
|
* Unused 'cv'Jerry D. Hedden2009-07-021-0/+1
|
* Integrate version.pm-0.77 into bleadperlJohn Peacock2009-06-281-9/+41
|