summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Move PL_{No,Yes,hexdigit} from perlvars.h to perl.h, as all are const char[]Nicholas Clark2011-06-121-3/+0
| | | | | | | | | | | They were converted in perl.h from const char[] to #define in 31fb120917c4f65d, then re-instated as const char[], but in perlvars.h, in 3fe35a814d0a98f4. There's no need for compile-time constants to jump through the hoops of perlvars.h, even for Symbian, as the various "EXTCONST" variables already in perl.h demonstrate. These were the only 3 users of the the PERLVARISC macro, so eliminate that, and all related code.
* Refactor Perl_get_vtbl() to a small array lookup from a large switch statement.Nicholas Clark2011-06-111-95/+2
| | | | Provide magic_vtable_max, the number of elements in PL_magic_vtables[].
* Abolish PL_vtbl_sig. It's been all 0s since it was added in 5.0 alpha 2.Nicholas Clark2011-06-111-3/+0
| | | | | Magic with a NULL vtable is equivalent to magic with a vtable of all 0s. On CPAN, only Apache::Peek's code for 5.005 is referencing it.
* Don't even declare PL_vtbl_sigelem under -DPERL_MICRONicholas Clark2011-06-111-0/+2
| | | | This turns out to be a simpler solution than 9ba75e3cf905a6e6.
* Store FBMs in PVMGs, instead of GVs.Nicholas Clark2011-06-111-2/+2
| | | | | | | | This should reduce the complexity of code dealing with GVs, as they no longer try to play several different incompatible roles. (As suggested by Ben Morrow. However, it didn't turn out to be as straightforward as one might have hoped).
* Store the BM table in mg_ptr instead of after SvCUR().Nicholas Clark2011-06-111-11/+28
| | | | | | | | | | | | Previously the 256 byte Boyer-Moore table was stored in the buffer of SvPVX() after the raw string by extending the buffer. Given that the scalar is alway upgraded to add PERL_MAGIC_bm magic, to clear the table and other flags, there's no extra memory cost in using mg_ptr in the MAGIC struct to point directly to the table. I believe that this removes the last place in the core that stores data beyond SvCUR().
* Exit early from Perl_fbm_compile() if the SV is already "compiled".Nicholas Clark2011-06-111-0/+3
| | | | | I believe that this can only happen if a constant subroutine is used more than once as the second argument to index.
* In Perl_fbm_instr(), use a switch() statement for the special case code.Nicholas Clark2011-06-111-8/+10
| | | | | Previously the special-case code for lengths 0, 1 and 2 was in a nested set of if() statements, which was slightly cryptic to read.
* In Perl_fbm_compile(), use STRLEN instead of U32 to calculate BmPREVIOUS().Nicholas Clark2011-06-111-4/+4
| | | | | | | | | This should fix a theoretical bug on strings longer than 2**32 bytes where the byte referenced by BmRARE() is at an offset beyond 2**32. I'm not sure how to test this, as I think to trigger it one would need to have one of a: the second argument to index as a string literal, longer than 2**32 bytes b: a fixed string in a regex, longer than 2**32 bytes
* Use SvTAIL() instead of BmFLAGS(). The core no longer uses BmFLAGS().Nicholas Clark2011-06-111-1/+1
|
* Emulate the value of BmFLAGS() using SvTAIL().Nicholas Clark2011-06-111-1/+0
| | | | | | | | | | | | | | | | | | | | Don't set BmFLAGS() in Perl_fbm_compile() Originally fbm_compile() had an I32 flags argument, which seems to have been part of case folding/locale improvements. bbce6d69784bf43b removed this. SvTAIL() was only used in once place until c277df42229d99fe. 2779dcf1a3ceec16 added the U32 flags argument to fbm_compile(), not used until cf93c79d660ae36c. That commit also added FBMcf_TAIL and FBMcf_TAIL{z,Z,DOLLAR} but didn't use the last three. Additionally, it stored the BmFLAGS as part of the compiled table: + table[-1] = flags; /* Not used yet */ f722798beaa43749 added FBMcf_TAIL_DOLLARM, renumbered FBMcf_TAIL{z,Z,DOLLAR}, but still didn't use anything other than FBMcf_TAIL. The core, nothing on CPAN, and nothing visible to Google codesearch, has ever used the 4 specialist flags. The only use is 0 or FBMcf_TAIL, which is in lockstep with SvTAIL() of 0 or non-0.
* Don't fbm_compile() studied scalars, to give more flexibility in SV flag usage.Nicholas Clark2011-06-111-0/+7
| | | | | No real-world code would ever end up using a studied scalar as a compile-time second argument to index, so this isn't a real pessimisation.
* unused variable tmpgvRobin Barker2011-06-101-1/+0
| | | | | | | | gcc reports an unused variable 'tmpgv', this was left behind by commit 0e21945565eb4664d843bb819fb032cedee4d5a6. Deleting the declaration has no consequences. Signed-off-by: David Golden <dagolden@cpan.org>
* Turn $$ into a magical readonly variable that always fetches getpid() ↵Max Maischein2011-05-221-6/+0
| | | | | | | | | | | instead of caching it The intent is that by not caching $$, we eliminate one opportunity for bugs: If one embeds Perl or uses XS and calls fork(3) from C, Perls notion of $$ may go out of sync with what getpid() returns. By always fetching the value of $$ via getpid(), this bug opportunity is eliminated. The overhead of always fetching $$ should be small and is likely only used for tempfile creation, which should be dwarfed by file system accesses.
* In Perl_safesyscalloc(), only declare total_size if conditional code needs it.Nicholas Clark2011-05-181-1/+6
| | | | | | gcc 4.6.0 warns about variables that are set but never read, and for most combinations of conditional compilation options, total_size is never read. So avoid declaring or setting it if it's not actually going to be used later.
* Fix building with -UuseperlioNicholas Clark2011-03-071-0/+4
| | | | | | It was inadvertently broken by 2e0cfa16dea85dd3. Many tests still fail, but that is unrelated to that change. It's more likely that we will remove -Uuseperlio than fix the tests.
* Windows builds require perliol.h conditional on USE_PERLIO.George Greer2011-02-161-0/+2
|
* [perl #78494] Pipes cause threads to hang on join()Father Chrysostomos2011-02-151-4/+15
| | | | | | | | | | | | | or on close() in either thread. close() in one thread blocks until close() is called in the other thread, because both closes are waiting for the child process to end. Since we have a reference-counting mechanism for the underlying fileno, we can use that to determine whether close() should wait. This does not solve the problem of close $OUT block when it has been duplicated via open $OUT2, ">&" and $OUT2 is still in scope.
* Silence util.c compiler warning from win32 smokesKarl Williamson2011-02-131-1/+1
|
* Move grok_bslash_c to dquote.c and make staticKarl Williamson2011-02-091-41/+0
| | | | No other changes were made
* Move grok_blsash_o and make staticKarl Williamson2011-02-091-79/+0
| | | | | | This function is only used in the same places as dquote_static.c is used, so move it there, and we won't have to worry about changing its API will break something. No other changes made
* util.c handling of return value of vsnprintfRobin Barker2011-01-161-4/+16
| | | | | | | At two points in util.c, there is code that use vsnprintf if available, otherwise vsprintf. The handling of the return value does not reflect which function has been called. The patch tries to improve this.
* In Perl_write_to_stderr(), use Perl_magic_methcall() if STDERR is tied.Nicholas Clark2011-01-131-22/+2
| | | | | | Add a flag G_WRITING_TO_STDERR to signal that Perl_magic_methcall() needs to localise PL_stderrgv to NULL, and save/free temps, inside its ENTER/LEAVE pair.
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-2/+2
| | | | | | | | | # 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>
* Calling "PRINT" on a tied STDERR can use G_DISCARD, as the result is ignored.Nicholas Clark2011-01-051-1/+1
|
* Argument op to report_evil_fh() is always PL_op->op_type, so need not be passedNicholas Clark2010-12-281-2/+2
|
* The io argument to report_evil_fh() is always GvIO(gv), so need not be passed.Nicholas Clark2010-12-281-4/+5
|
* Extract the OP_phoney_* code from report_evil_fh() into report_wrongway_fh()Nicholas Clark2010-12-281-59/+60
| | | | | Previously Perl_report_evil_fh()'s body was just an if/else at the top level - a good sign that it is actually implementing two disjoint functions.
* Add Perl_foldEQ_latin1()Karl Williamson2010-11-281-0/+21
| | | | | | | | | | This function compares two non-utf8 strings to see if they are equivalent without regards to case differences. It does not work nor check for three problematic code points that require special handling: MICRO_SIGN, LATIN_SMALL_LETTER_SHARP_S, and LATIN_SMALL_LETTER_Y_WITH_DIAERESIS. make regen required
* Bring core Perl in line with CPAN 0.86 releaseJohn Peacock2010-11-271-21/+32
| | | | | | | Attached is a patch that bring the core Perl version code inline with the latest CPAN release. The vast majority of changes are in code that does not execute in core, but that makes it easier to keep the core and CPAN changes in sync.
* Document the refcount of version functions’ retvalFather Chrysostomos2010-11-231-1/+7
|
* Eliminate PL_dirtyFlorian Ragwitz2010-11-141-2/+2
| | | | | It now only exists as a compatibility macro for extensions that want to introspect it.
* adjust output of -DmDavid Mitchell2010-10-311-1/+1
| | | | | The address printed for malloc() didn't always match that for free(). Print the malloc() address *after* any modification by PERL_TRACK_MEMPOOL
* 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
|