summaryrefslogtreecommitdiff
path: root/pp_sys.c
Commit message (Collapse)AuthorAgeFilesLines
* Make stacked -l workFather Chrysostomos2011-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Perl 5.10.0 introduced stacked filetest operators, -x -r $foo being equivalent to -r $foo && -x _ That does not work with -l. It was these suspicious lines in Perl_my_lstat_flags that drew my attention to it: > else if (PL_laststype != OP_LSTAT > && (PL_op->op_private & OPpFT_STACKED) && ckWARN(WARN_IO)) > Perl_croak(aTHX_ no_prev_lstat); That croak only happens when warnings are on. Warnings are just supposed to be warnings, unless the ‘user’ explicitly requests fatal warnings. $ perl -le 'print "foo", -l -e "miniperl"' foo $ perl -lwe 'print "foo", -l -e "miniperl"' The stat preceding -l _ wasn't an lstat at -e line 1. That it doesn’t die in the first example is a bug. In fact, it’s using the return value of -e as a file name: $ ln -s miniperl 1 $ ./miniperl -le 'print -l -e "miniperl"' 1 And, with warnings on, if the preceding stat *was* an lstat, it falls back to the pre-stacked behaviour, just as it does when warn- ings are off. It’s meant to be equivalent to -e "miniperl" && -l _ (which is why the error message above says ‘The stat preceding -l _’).
* Don't #include headers already included by perl.hNicholas Clark2011-09-151-4/+0
| | | | | | | | | 097ee67dff1c60f2 didn't need to include <locale.h> in locale.c (then util.c) because it had been included by perl.h since 5.002 beta 1 3f270f98f9305540 missed removing the include of <unistd.h> from perl.c or perlio.c de8ca8af19546d49 changed perl.h to also include <sys/wait.h>, but didn't notice that it code therefore be removed from perl.c, pp_sys.c and util.c
* Add diag_listed_as for lstat error msgFather Chrysostomos2011-09-121-0/+1
| | | | to let porting/diag.t know how it’s listed in perldiag.
* Make (l)stat respect get-magic on globs and globrefsFather Chrysostomos2011-09-121-14/+5
| | | | | | | | | | | | | | | They were ignoring get-magic for those. A side effect of this fix is that lstat filehandle warnings and errors are now consistent: lstat _ used to die if the previous stat was not an lstat, but lstat *_ and lstat \*_ would happily return what was in the buffer. Now they die. lstat FH and \*FH used to warn, but not lstat *FH. Now it does. See bug #98864.
* Make truncate respect get-magic on globs and globrefsFather Chrysostomos2011-09-111-20/+8
| | | | It was ignoring get-magic for those.
* Stop filetest ops from calling FETCH on parent op’s argFather Chrysostomos2011-09-101-2/+2
| | | | | | | | | | | | | This is a regression in 5.14.0. Commit 6f1401dc made ops call get-magic before overloading, but it ended up making filetest ops call get-magic on the topmost item of the stack even if the filetest op was not going to use the stack (which happens for ‘-r bareword’ and plain ‘-r’). This would affect cases like: push @foo, $tied, -r;
* Make filetest ops handle get-magic correctly for glob(ref)sFather Chrysostomos2011-09-101-11/+2
| | | | | | This patch uses the recently-added MAYBE_DEREF_GV macro which puts the glob deref logic in one spot. It also adds _nomg and _flags varia- tions of it. _flags understands the SV_GMAGIC flag.
* ch(dir|mod|own) should also call FETCH on refs to tied globsFather Chrysostomos2011-09-101-11/+1
| | | | | | | | Following on from commit 935647290357b277, which corrected the beha- viour for tied globs, this commit corrects the behaviour for refer- ences to tied globs. (With tests by Nicholas Clark.)
* In pp_chdir, move SvGETMAGIC(sv) out of the if() condition.Nicholas Clark2011-09-091-7/+10
| | | | | | It was added to the if() condition as part of 935647290357b277. Unfortunately the syntax used to implemented SvGETMAGIC(sv) is considered by gcc to be valid in an expression, but is not valid in other compilers.
* ch(dir|mod|own) should not ignore get-magic on glob(ref)sFather Chrysostomos2011-09-081-2/+2
| | | | | | | | When the chdir(*handle) feature was added in 5.8.8, the fact that globs and refs could be magical was not taken into account. They can easily be magical if a typeglob or reference is returned from or assigned to a tied variable.
* &CORE::umask()Father Chrysostomos2011-08-291-2/+2
| | | | | | | | This commit allows &CORE::umask to be called through references and via ampersand syntax. pp_umask is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell umask how many arguments it’s actually getting. See commit 0163043a for details.
* &CORE::tell()Father Chrysostomos2011-08-291-1/+1
| | | | | | | | This commit allows &CORE::tell to be called through references and via ampersand syntax. pp_tell is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell pp_tell how many arguments it’s actually getting. See commit 0163043a for details.
* &CORE::setpgrp()Father Chrysostomos2011-08-291-7/+3
| | | | | | | | This commit allows &CORE::setpgrp to be called through references and via ampersand syntax. pp_setpgrp is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell setpgrp how many arguments it’s actually getting. See commit 0163043a for details.
* Make setpgrp($x) equivalent to setpgrp($x,0)Father Chrysostomos2011-08-291-1/+2
| | | | | Prior to this commit, setpgrp(27) was equivalent to (27, setpgrp), because it ignored the argument on the stack when there was only one.
* &CORE::sysopen()Father Chrysostomos2011-08-281-1/+1
| | | | | | | | This commit allows &CORE::sysopen to be called through references and via ampersand syntax. pp_sysopen is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell sysopen how many arguments it’s actually getting. See commit 0163043a for details.
* &CORE::sleep()Father Chrysostomos2011-08-271-1/+1
| | | | | | | | | | | This commit allows &CORE::sleep to be called through references and via ampersand syntax. pp_sleep is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell sleep how many arguments it’s actually getting. See commit 0163043a for details. Unfortunately, sleep with no args is nearly impossible to test porta- bly. But I have checked that it works.
* &CORE::mkdir()Father Chrysostomos2011-08-261-1/+1
| | | | | | | | This commit allows &CORE::mkdir to be called through references and via ampersand syntax. pp_mkdir is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell mkdir how many arguments it’s actually getting.
* &CORE::gmtime() and &CORE::localtime()Father Chrysostomos2011-08-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit allows &CORE::gmtime and &CORE::localtime to be called through references and via ampersand syntax. pp_gmtime is modified to take into account the nulls pushed on to the stack in pp_coreargs, which happens because pp_coreargs has no other way to tell pp_gmtime how many arguments it’s actually getting. I was going to say ‘see commit f6a1686942 for more details’, but found out, to my horror, that most of the commit message was cut off. I don’t know which commit-munging part of git is responsible, but I’ve had similar problems with git am and git commit --amend. But, then, this could have been sloppy copy and paste. Anyway, here is the missing part: Usually, an op that has optional arguments has the number of arguments indicated with flags on the op itself: $ ./perl -Ilib -MO=Concise -e 'binmode 1' 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 5 <@> binmode vK/1 ->6 - <0> ex-pushmark s ->3 4 <1> rv2gv sK*/1 ->5 3 <$> gv(*1) s ->4 -e syntax OK $ ./perl -Ilib -MO=Concise -e 'binmode 1,2' 7 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 6 <@> binmode vK/2 ->7 - <0> ex-pushmark s ->3 4 <1> rv2gv sK*/1 ->5 3 <$> gv(*1) s ->4 5 <$> const(IV 2) s ->6 -e syntax OK Notice the /1 vs /2 on the binmode op. With a CORE sub, we have a single op for both cases. So, what this commit does is set the number of arguments to the maximum, push nulls on to the stack in pp_coreargs (actually, it was already set up to do it, so there is no change there), and have the pp_ functions for each op that has optional arguments do a null check after popping the stack. pp_binmode already does a null check, but other pp_ functions will need to be modified. Since each one is different, those will come in separate commits. This is what &CORE::binmode’s op tree looks like: $ ./perl -Ilib -MO=Concise,CORE::binmode -e 'BEGIN{\&CORE::binmode}' CORE::binmode: 3 <1> leavesub[1 ref] K/REFC,1 ->(end) 2 <@> binmode sK/2 ->3 - <0> ex-pushmark s ->1 1 <$> coreargs(IV 212) s ->2 -e syntax OK
* &CORE::getpgrp()Father Chrysostomos2011-08-251-1/+2
| | | | | | | This commit allows &CORE::getpgrp to be called through references and via ampersand syntax. pp_getpgrp is modified to take into account the nulls pushed on to the stack in pp_coreargs, since pp_coreargs has no other way to tell getpgrp how many arguments it’s actually getting.
* &CORE::foo() for close, getc and readlineFather Chrysostomos2011-08-251-2/+4
| | | | | | | This commit allows the subs in the CORE package for close, getc and readline to be called through references and via ampersand syntax. The pp functions are modified to take into account the nulls that coreargs pushes on to the stack to indicate that there is no argument.
* [rt #84590] try to preserve the inode number, even if it's largeTony Cook2011-08-011-0/+8
| | | | This matches the checks done for other stat() fields.
* Remove an unused variableFlorian Ragwitz2011-07-131-1/+0
|
* use a flag to signal a stacking filetests instead of peeking at the next op.Gerard Goossen2011-07-111-5/+1
| | | | Preparation for the codegeneration changes where the next op isn't accessible.
* [perl #8611] tied handles and gotos don't mixDavid Mitchell2011-06-141-2/+20
| | | | | | | | | | | | | | | tied handle method calls, unlike other types of tie, don't push a new stack. This means that a goto within a method to an outer scope "succeeds", and pops back the context stack past the method call. When control (at the C level) eventually passes back to the return from call_method(), we've lost all our relevant stack contents (like all the ENTERs), and corruption ensures. The fix is to add PUSHSTACKi/POPSTACK. The side effect of this is that attempts to goto out of a tied handle method call now give "Can't find label" errors, like non-handle methods already do.
* Revert "Revert "Make untie check the FAKE flag on globs""Father Chrysostomos2011-06-111-1/+1
| | | | This reverts commit 84b9ac853508aaff52254b6cf2b95a2a6783ff00.
* Revert "Revert "[perl #77688] tie $scalar can tie a handle""Father Chrysostomos2011-06-111-1/+1
| | | | This reverts commit 7850f4d6b732ab5f426cd3bcd9757c70a46cfda1.
* Revert "Revert "[perl #77496] tied gets scalars and globs confused""Father Chrysostomos2011-06-111-1/+1
| | | | This reverts commit b029825916bf29623e00b45fa4226fab0d52d217.
* Revert ‘Deprecate tie $handle without *’Father Chrysostomos2011-06-111-18/+2
| | | | | This reverts commit 7c7df8124bbdd7a0091f8ed82589548c8182f624, except for the perldiag entry, which we still need for splain’s sake.
* 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 pp_warn and pp_die, eliminate pv, which is assigned to but never read.Nicholas Clark2011-05-181-4/+2
|
* [perl #82250] fix tainted (s)print formatDavid Mitchell2011-03-141-2/+0
| | | | | | | | | | | | commit 20ee07fbbcfa6be9f90bb8e5474a4d69d7396617 introduced dieing in (s)printf when the format is tainted; however it only worked when the format is part of an expression (because TAINT_PROPER checks for PL_tainted being set). Fix by doing TAINT_PROPER only after get magic has been done on the format SV (which will set PL_tainted). This is done by moving the checks in pp_sprintf and pp_prtf into do_sprintf() (which is called by the two pp functions).
* [perl #77384] Passing a ref to warn doesn't append file and lineFather Chrysostomos2011-03-051-1/+3
| | | | | This commit makes pp_warn stringify the warning if there is no $SIG{__WARN__} handler. See the RT ticket for the discussion.
* Correct the "unimplemented" message for get{host,net,proto,serv}ent aliases.Nicholas Clark2011-01-101-4/+4
| | | | | | | | | Previously, if all of gethost{byaddr,byname,ent} were unimplemented on a platform, they would all return 'Unsupported socket function "gethostent" called', with the analogous results for getnet{byaddr,byname,ent}, getproto{byname,bynumber,ent} and getserv{byname,byport,ent}. This bug was introduced by change af51a00e97d5c559 - prior to this, all 12 functions would report their own name when unimplemented.
* Merge the implementations of {end,set}{gr,pw}ent with endhostent.Nicholas Clark2011-01-101-44/+28
| | | | | Unlike set{host,net,proto,serv}ent, set{gr,pw}ent don't have stayopen parameter, hence their "signature" is the same as the ent*ent functions.
* Merge the implementations of pp_s{host,net,proto,serv}ent.Nicholas Clark2011-01-101-28/+21
|
* Merge the implementations of pp_e{host,net,proto,serv}ent.Nicholas Clark2011-01-101-32/+21
| | | | | | | PL_op_desc[] rather than PL_op_name(), as the OPs are internally named e*ent, but implement the ent*ent functions, and when unimplemented report themselves using the function name. No need for OP_DESC(), as the switch statement means that we can't encounter OP_CUSTOM.
* Generate "Unsupported socket function" stubs using PL_ppaddr.Nicholas Clark2011-01-091-35/+10
| | | | | | | | | | | | | | | Instead of having each socket op conditionally compile as either the implementation or a DIE() depending on #HAS_SOCKET 1: remove the conditional code from the ops themselves 2: only compile the ops if HAS_SOCKET is defined 3: general conditional code for the intialisation of PL_ppaddr - as appropriate either the ops, or Perl_unimplemented_op 4: Amend Perl_unimplemented_op to generate the appropriate DIE() for socket ops (ie not the "panic"... message) Whilst this complicates the support code in regen/opcode.pl, it's already a net saving of 5 lines in the C code.
* Rename pp_send to pp_syswrite, making send an alias for syswrite.Nicholas Clark2011-01-091-1/+1
| | | | | Previously syswrite was an alias for send. However, syswrite is always available, whereas send is not implemented if HAS_SOCKET is not defined.
* Generate pp_* prototypes in pp_proto.h, and remove pp.symNicholas Clark2011-01-091-2/+2
| | | | | | | | | | | Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13 locations that relied on them. regen/opcode.pl now generates prototypes for the PP functions directly, into pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads this, removing the only ordering dependency in the regen scripts. opcode.pl is now responsible for prototypes for pp_* functions. (embed.pl remains responsible for ck_* functions, reading from regen/opcodes)
* In pp_send, assign to io earlier, and use op_type instead of PL_op->op_type.Nicholas Clark2011-01-081-5/+3
| | | | | | On this platform, this doesn't change the size of the object code, suggesting that there are all transformations that the optimiser had already spotted. However, the code is now clearer for humans.
* In pp_send, transpose the blocks for OP_SYSWRITE and OP_SENDNicholas Clark2011-01-081-19/+17
|
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # 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>
* Convert tied PRINT to using Perl_tied_method()Nicholas Clark2011-01-051-0/+6
| | | | | Add a flag TIED_METHOD_SAY to Perl_tied_method(), to allow tied PRINT to effect C<local $\ = "\n";> within the ENTER/LEAVE pair of Perl_tied_method().
* Rename tied_handle_method() to tied_method(), and make it non-static.Nicholas Clark2011-01-051-46/+41
| | | | It can be used for (at least) the call to "SPLICE" from pp_splice.
* In pp_sys.c, rename the macro tied_handle_method() to tied_handle_method0()Nicholas Clark2011-01-051-4/+4
| | | | | This makes it clear that it's not a direct aTHX_ wrapper for S_tied_handle_method().
* The mg parameter to S_tied_handle_method() can be const MG *Nicholas Clark2011-01-051-13/+13
|
* Split the flags and argc parameters to S_tied_handle_method().Nicholas Clark2011-01-051-22/+18
| | | | | Previously they were combined into one numeric value, using a bitshift. This was a false economy.
* Convert tied WRITE to using S_tied_handle_method()Nicholas Clark2011-01-041-6/+3
|
* Convert tied READ to using S_tied_handle_method()Nicholas Clark2011-01-041-7/+4
|
* Convert tied PRINTF to using S_tied_handle_method()Nicholas Clark2011-01-041-7/+3
|