summaryrefslogtreecommitdiff
path: root/universal.c
Commit message (Collapse)AuthorAgeFilesLines
* Produce right error msg for $ver < "version"Father Chrysostomos2011-11-241-1/+1
| | | | | | | | | | | | | | "version" was being treated as a version object and then failing the validation check. It should be treated as a string, just like "versions": $ perl5.15.4 -Ilib -e '$^V < "version"' Invalid version object at -e line 1. $ perl5.15.4 -Ilib -e '$^V < "versions"' Invalid version format (dotted-decimal versions require at least three parts) at -e line 1. See also perl #102586.
* UNIVERSAL::VERSION should treat "version" as a stringFather Chrysostomos2011-11-231-2/+2
| | | | | | | | | | | | | It was treating it as a version object and then failing the validation test, instead of treating it as an invalid version format, as it does with "versions": $ ./perl -Ilib -e'$VERSION = "versions"; main->VERSION(1)' Invalid version format (dotted-decimal versions require at least three parts) at -e line 1. $ ./perl -Ilib -e'$VERSION = "version"; main->VERSION(1)' Invalid version object at -e line 1. See also perl #102586.
* Remove comment added by mistake in c7abbf64Father Chrysostomos2011-11-191-1/+1
|
* Internals::SvREFCNT() now treats reference counts as unsignedTony Cook2011-11-141-3/+3
| | | | | | Previously setting a large (negative in 32-bit signed) reference count would be returned as a positive number on 64-bit builds and negative on 32-bit builds.
* [rt #103222] make Internals::SvREFCNT set/get consistentTony Cook2011-11-141-2/+2
|
* Use HEKfFather Chrysostomos2011-10-071-12/+13
| | | | This avoids creating a lot of temporary SVs.
* universal.c: VERSION UTF8 cleanupBrian Fraser2011-10-061-27/+46
|
* universal.c: Make croak_xs_usage account for UTF8Brian Fraser2011-10-061-6/+8
|
* Document sv_does_pvnFather Chrysostomos2011-10-061-2/+9
|
* Correct name of sv_does_sv apidoc entryFather Chrysostomos2011-10-061-3/+3
| | | | plus other tweaks
* universal.c: sv_does() UTF8 cleanup.Brian Fraser2011-10-061-12/+51
| | | | | This adds _sv, _pv, and _pvn forms to sv_does, and changes it to use sv_ref() instead of sv_reftype().
* universal.c: ->can UTF8 cleanup.Brian Fraser2011-10-061-3/+1
|
* universal.c: ->isa, sv_derived_from UTF8 cleanup.Brian Fraser2011-10-061-13/+62
| | | | | | | This makes them both nul-and-UTF8 clean, although the latter is somewhat superficial, as mro isn't clean yet. (Tests coming once ->can and ->DOES are clean)
* [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
|