summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Refactor Perl_xs_apiversion_bootcheck()Nicholas Clark2010-10-081-7/+12
| | | | Use fewer mortals, and avoid leaking an SV if upg_version() croaks.
* Convert the implementation of XS_APIVERSION_BOOTCHECK to a function.Nicholas Clark2010-10-081-0/+25
| | | | | | The previous macro generated over .5K of object code. This is in every shared object, and is only called once. Hence this change increases the perl binary by about .5K (once), to save .5K for every XS module loaded.
* Refactor xs_version_bootcheck() to remove complex constructions.Nicholas Clark2010-10-081-13/+22
| | | | | | Replace complex format strings ternary conditionals with an if/else block. Avoid assignment within expressions. Directly use the SV for the module's name, rather than converting it to a char *.
* xs_version_bootcheck() must use mortals, as {new,upg}_version() can croak.Nicholas Clark2010-10-081-7/+3
| | | | | | | It's unlikely that XS_VERSION will contain a bogus version string (for long), but the value passed in (or derived from $XS_VERSION or $VERSION) might well. For that case, without this change, temporary SVs created within xs_version_bootcheck() won't be freed (before interpreter exit).
* Change vverify() to return HV or NULL (RT#78286)David Golden2010-10-081-28/+23
| | | | | | | | | | Multiple code paths were dereferencing version objects without checking the underlying type, which could result in segmentation faults per RT#78286 This patch consolidates all dereferencing into vverify() and has vverify return the underlying HV or NULL instead of a boolean value.
* Convert the implementation of XS_VERSION_BOOTCHECK to a function from a macro.Nicholas Clark2010-10-071-0/+43
| | | | | | The macro expansion generates over 1K of object code. This is in every shared object, and is only called once. Hence this change increases the perl binary by about 1K (once), to save 1K for every XS module loaded.
* [perl #48332] Debugger corrupts symbol table mungingFather Chrysostomos2010-09-301-2/+6
| | | | | | | | This reverts commit 92adfbd49af0758bcc9a198cf2df2bd78c4176b9, which removed a necessary assignment for the sake of consting. In doing so, it allows subroutine redefinition to work properly again in the debugger.
* systematically provide pv/pvn/pvs/sv quartetsZefram2010-09-281-0/+19
| | | | | Anywhere an API function takes a string in pvn form, ensure that there are corresponding pv, pvs, and sv APIs.
* #!perl -C -w diesFather Chrysostomos2010-09-261-2/+10
| | | | | | parse_unicode_opts expects to end on '\0'. So #!perl -C -w causes an ‘Unknown Unicode option letter ' '’ error. The attached patch fixes it.
* [perl #77362] Assigning glob to lvalue causes stringificationFather Chrysostomos2010-09-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test from t/op/gv.t was added by change 22315/4ce457a6: { # test the assignment of a GLOB to an LVALUE my $e = ''; local $SIG{__DIE__} = sub { $e = $_[0] }; my $v; sub f { $_[0] = 0; $_[0] = "a"; $_[0] = *DATA } f($v); is ($v, '*main::DATA'); my $x = <$v>; is ($x, "perl\n"); } That change was the one that made glob-to-lvalue assignment work to begin with. But this test passes in perl version *prior* to that change. This patch fixes the test and adds tests to make sure what is assigned is actually a glob, and not just a string. It also happens to fix the stringification bug. In doing so, it essen- tially ‘enables’ globs-as-PVLVs. It turns out that many different parts of the perl source don’t fully take this into account, so this patch also fixes the following to work with them (I tried to make these into separate patches, but they are so intertwined it just got too complicated): • GvIO(gv) to make readline and other I/O ops work. • Autovivification of glob slots. • tie *$pvlv • *$pvlv = undef, *$pvlv = $number, *$pvlv = $ref • Duplicating a filehandle accessed through a PVLV glob when the stringified form of the glob cannot be used to access the file handle (!) • Using a PVLV glob as a subroutine reference • Coderef assignment when the glob is no longer in the symbol table • open with a PVLV glob for the filehandle • -t and -T • Unopened file handle warnings
* Fix warn to respect utf8-encoded scalars [perl #45549]Father Chrysostomos2010-09-161-3/+1
|
* don't taint $DB::subDavid Mitchell2010-08-251-0/+4
| | | | | | | | | | | | | | | | [perl #76872] showed a case where code like the following, run under -d, would cause $DB::sub to get set: $tainted_expression && func() The tainted expression sets PL_tainted, so calling func() under -d, which sets $DB::sub, causes it to get tainted. Consequently any further sub calls would set PL_tainted while getting the old value of $DB::sub (and cause the new value to be tainted too), and if the sub was XS, then its code would be executed with PL_tainted set. It isn't an issue with perl subs as the first nextstate op resets PL_tainted.
* Change function signature of grok_bslash_oKarl Williamson2010-07-271-13/+26
| | | | The previous return value where NULL meant OK is outside-the-norm.
* C++ compiler fix for util.cGeorge Greer2010-07-211-1/+1
| | | | | | | | | | | | | | | Even with all of the changes, we still die on a strchr() call now because glibc provides "correct" strchr prototypes rather than the C ones. C: char *strchr(const char *s, int c) C++: const char *strchr(const char *s, int c) char *strchr( char *s, int c) and of course C++ doesn't let you convert a 'const char *' to a 'char *' so boom on util.c:3972 in Perl_grok_bslash_o (due to 'e').
* Add \o{} escapeKarl Williamson2010-07-171-1/+67
| | | | | | | | | | This commit adds the new construct \o{} to express a character constant by its octal ordinal value, along with ancillary tests and documentation. A function to handle this is added to util.c, and it is called from the 3 parsing places it could occur. The function is a candidate for in-lining, though I doubt that it will ever be used frequently.
* RT #73520: POSIX::strftime memory leakTony Cook2010-07-111-1/+1
| | | | Tested before/after with valgrind.
* POD fixRafael Garcia-Suarez2010-06-281-0/+1
|
* Add Perl_croak_no_modify() to implement Perl_croak("%s", PL_no_modify).Nicholas Clark2010-06-271-0/+15
| | | | | This reduces object code size, reducing CPU cache pressure on the non-exception paths.
* PERL_IMPLICIT_SYS also needs thread context for safesysfree()Nicholas Clark2010-06-171-2/+2
| | | | | | PERL_TRACK_MEMPOOL needs it to work without -DDEBUGGING. Fixes for 0cb20dae370512c6 not addressed by 1f4d2d4e2e4bb7bb.
* PERL_IMPLICIT_SYS also needs thread context for the *alloc success paths.Nicholas Clark2010-06-161-6/+10
| | | | 0cb20dae370512c6 was a bit to aggressive in its deferral of dTHX.
* In Perl_safesys{c,m,re}alloc(), defer dTHX for non-DEBUGING builds.Nicholas Clark2010-06-151-10/+31
| | | | | | | | | | | Under ithreads, dTHX expands to pthread_getspecific() [or something similarly expensive], which the compiler can't optimise away. However, its return value isn't needed unless the allocation fails. So defer the call, hence avoiding it entirely on a successful allocation. DEBUGING builds require the value of dTHX for debugging purposes, so we can't postpone it for them. Unthreaded builds were never affected as they don't use thread local storage for the interpreter context.
* Change name of ibcmp to foldEQKarl Williamson2010-06-051-8/+29
| | | | | | | | | | | | | | | | As discussed on p5p, ibcmp has different semantics from other cmp functions in that it is a binary instead of ternary function. It is less confusing then to have a name that implies true/false. There are three functions affected: ibcmp, ibcmp_locale and ibcmp_utf8. ibcmp is actually equivalent to foldNE, but for the same reason that things like 'unless' and 'until' are cautioned against, I changed the functions to foldEQ, so that the existing names, like ibcmp_utf8 are defined as macros as being the complement of foldEQ. This patch also changes the one file where turning ibcmp into a macro causes problems. It changes it to use the new name. It also documents for the first time ibcmp, ibcmp_locale and their new names.
* PATCH: [perl #75138] "\c`" -> " "Karl Williamson2010-05-301-2/+10
| | | | | | | | | | | | | | | | | | | Attached is a patch for some of this issue. I took Nicholas' advice, and if the result of \cX isn't a word character, the output message will precede it with a backslash, so the message in the example would be "\c`" more clearly written simply as "\ " at -e line 1. I think that message is true. I also added tests. There is a test that guarantees that we won't ship 5.14 with things as they are now in it. I added wording to the comments next to that test to be sure to verify with this email thread if we should remove the deprecation, and mentioned that in the explanatory wording in the pod. I support removing the deprecation, but for now I'm not touching that, to see what other issues may yet arise before 5.14.
* support "package Foo { ... }"Zefram2010-05-201-3/+3
| | | | | | Package block syntax limits the scope of the package declaration to the attached block. It's cleaner than requiring the declaration to come inside the block.
* PATCH: Clean up EBCDIC handling of \cXKarl Williamson2010-05-171-40/+0
| | | | | | | | | | The function perl_ebcdic_control() is unnecessary, as the toCTRL macro that calls it can be changed to just map EBCDIC to ASCII first, and then doing the normal procedure. This means that EBCDIC and ASCII will no longer diverge. Currently, EBCIDIC gives a syntax error for inputs outside its domain, whereas the ASCII version accepts some of them.
* Merge remote branch 'zefram/zefram/reliable_exception' into bleadRafael Garcia-Suarez2010-05-041-99/+288
|\ | | | | | | | | Conflicts: pp_ctl.c
| * SV-based interfaces for dieing and warningZefram2010-04-231-99/+288
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New functions croak_sv(), die_sv(), mess_sv(), and warn_sv(), each act much like their _sv-less counterparts, but take a single SV argument instead of sprintf-like format and args. They will accept RVs, passing them through as such. This means there's no more need to clobber ERRSV in order to throw a structured exception. pp_warn() and pp_die() are rewritten to use the _sv interfaces. This fixes part of [perl #74538]. It also means that a structured warning object will be passed through to $SIG{__WARN__} instead of being stringified, thus bringing warn in line with die with respect to structured exception objects. The new functions and their existing counterparts are all fully documented.
* | Deal with "\c{", and its kinKarl Williamson2010-04-261-0/+33
|/ | | | | | | | | | | | | | | | | | make regen is needed This patch forbids non-ascii following the "\c". It also terminates for "\c{" with a message to contact p5p if there is need for continuing its current definition. And if the character following the "\c" causes the result to not be a control character, a warning is issued. This is currently 'deprecated', which by default is turned on. This can easily be changed later. This patch is the initial patch. It does not do any fancy showing the context where the problematic construct occurs. This can be added later. It gathers the 3 occurrences of evaluating \c and puts them in one common routine.
* Add perlintern.pod documentation docatch + prescan_versionReini Urban2010-03-081-0/+5
| | | | docatch - perl run-time exception handling
* Fix SV leaks in Perl_vnumify() and Perl_vnormal() for "Invalid version object"sNicholas Clark2010-01-151-10/+7
|
* Omnibus strict and lax version parsingDavid Golden2010-01-131-52/+227
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Correct some #ifdef USE_ITHREADS / USE_MULTIMax Maischein2009-12-171-0/+8
|
* Add mingw64 supportSisyphus2009-11-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, Using the attached patch to the blead source (as of a few hours ago), I can build perl with the following OS/compiler/make combos. On 32-bit XP: MSVC++ 7.0 / dmake (uses win32/makefile.mk) MSVC++ 7.0 / nmake (uses win32/Makefile) Borland C++ 5.5.1 / dmake mingw.org's gcc-4.3.0 / dmake mingw.org's gcc-3.4.5 / dmake mingw-w64.sf's 32-bit gcc-4.4.3 / dmake (There's a bug with that last compiler on XP. The perl it builds on XP hangs on XP, but runs ok if copied across to Vista. I think this is unrelated to the patches - probably even unrelated to perl. Without these patches perl will not even build using that last compiler.) On 64-bit Vista: 32-bit MSVC++ 7.0 / nmake (uses win32/Makefile) 32-bit MSVC++ 7.0 / dmake (uses win32/makfile.mk) 32-bit Borland C++ 5.5.1 / dmake mingw.org's 32-bit gcc-4.4.0 / dmake mingw.org's 32-bit gcc-3.4.5 / dmake mingw-w64.sf's 32-bit gcc-4.4.3 / dmake mingw-w64.sf's 64-bit gcc-4.4.3 / dmake mingw-w64.sf's 64-bit x86_64-w64-mingw32-gcc-4.4.3 / dmake 64-bit MicrosoftPlatform SDK for Windows Server 2003 R2 / dmake (uses win32/makefile.mk) 64-bit MicrosoftPlatform SDK for Windows Server 2003 R2 / nmake (uses win32/Makefile) Not all of those builds pass all tests - but where the removal of the patches still permits perl to build, the same tests still fail. That is, *nothing* is lost by including these patches - but there are significant gains. Each of the above builds was done according to the normal win32 configuration parameters - ie multi-threaded, non debug. No unusual config settings were applied. (I did build one debug perl on Vista using mingw-w64.sf's 32-bit gcc-4.4.3 and it built fine.) Please feel free to apply these patches (with or without modification) - and, yes, you're more than welcome to blame me if they cause any breakages ;-) Of course, some of those compilers (Borland, Microsoft, and the compilers from mingw.org) already build perl *without* having to apply any patches. It's just the other compilers that need the patches. The purpose of testing with Borland, Microsoft, and the mingw.org compilers is just to check that these patches don't break them. As a final check, I've done a build on my aging linux (mandrake-9.1) box, gcc-3.2.2. I built with '-des -Duselongdouble -Duse64bitint -Dusedevel'. No problem with that, either. If there's additional testing requirements please let me know, and I'll try to oblige. I believe the patch applied successfully for me - see below my sig for the output. Cheers, Rob Rob@desktop2 ~/GIT/blead $ patch -p0 <blead_diff.diff patching file dist/threads/threads.xs patching file handy.h patching file cpan/ExtUtils-MakeMaker/lib/ExtUtils/MM_Win32.pm patching file op.c Hunk #1 succeeded at 5774 (offset 47 lines). patching file pp_pack.c patching file util.c Hunk #1 succeeded at 5366 (offset -28 lines). patching file win32/makefile.mk patching file win32/perlhost.h patching file win32/win32.c patching file win32/win32.h patching file README.win32 patching file XSUB.h
* move JMPENV_JUMP to die_where and mark it as "noreturn"Gerard Goossen2009-11-061-15/+3
|
* Use of SV* instead of message, msglen, utf8 to contain error messageGerard Goossen2009-11-011-40/+25
|
* Remove unused variableRafael Garcia-Suarez2009-10-291-1/+0
|
* remove unnecessary (always true) condition in S_vdieGerard Goossen2009-10-291-3/+3
|
* Let SvRX(OK) recognise a bare REGEXP.Ben Morrow2009-10-221-7/+4
| | | | This means that re::is_regexp(${qr/x/}) will now return true.
* Change S_ckwarn_common() to looping over the packed warning value.Nicholas Clark2009-10-131-7/+18
| | | | | | The core never uses WARN3() or WARN4(), and rarely uses WARN2(), so the previous code, effectively an unwrapped loop, wasn't a speed up. Functionally equivalent smaller code fits better into CPU caches.
* Migrate common code in Perl_ckwarn() and Perl_ckwarn_d() to S_ckwarn_common()Nicholas Clark2009-10-131-15/+9
|
* In Perl_ckwarn() and Perl_ckwarn_d() disentangle the complex conditionals.Nicholas Clark2009-10-131-30/+36
| | | | It's much easier to see what is going on, if we use multiple return statements.
* Add Perl_ck_warner_d(), which combines Perl_ckwarn_d() and Perl_warner().Nicholas Clark2009-10-121-0/+13
| | | | | Replace ckWARN_d{,2,3,4}() && Perl_warner() with it, which trades reduced code size for 1 more function call if warnings are not enabled.
* Add Perl_ck_warner(), which combines Perl_ckwarn() and Perl_warner().Nicholas Clark2009-10-121-14/+22
| | | | | | | Replace ckWARN{,2,3,4}() && Perl_warner() with it, which trades reduced code size (about 0.2%), for 1 more function call if warnings are not enabled. However, if we're now in the L1 or L2 cache when we weren't previously, that's still going to be a speed win.
* In Perl_ckwarn(), simplify the check of isLEXWARN_on/isLEXWARN_off.Nicholas Clark2009-10-121-11/+5
|
* Speed up repeatcpy() by at least 40% for 1-char or numerous repeatsVincent Pit2009-08-271-15/+25
| | | | | | | | | | | | And don't make it receive the interpreter anymore. For 1-char repeats, use memset(). Otherwise, use the old implementation up to some (small) length, and then use memcpy() in a binary manner, based on what we previously copied. Note that we use memcpy() so both strings shouldn't overlap. The previous implementation didn't allow this as well. This would be a good place to use the restrict keyword from C99. I'm not sure if Configure has a probe for it.
* delimcopy(), ibcmp(), ibcmp_locale(), instr(), ninstr() and rninstr() from ↵Vincent Pit2009-08-271-12/+6
| | | | util.c don't need the interpreter as well
* Perl_die_nocontext() is also called with NULL from XS extensions that want ↵Vincent Pit2009-08-131-1/+0
| | | | | | to set $@ themselves. This commit goes with 52a5bfab8876f302d269f1bfa46eae1998f0d3ca.
* Remove the port to MiNT. It's a dead platform that hasn't had any love ↵Jesse Vincent2009-08-031-1/+1
| | | | since 5.005
* Integrate version.pm-0.77 into bleadperlJohn Peacock2009-06-281-1/+9
|
* A few docs nits after the few last commitsRafael Garcia-Suarez2009-06-211-2/+2
|