summaryrefslogtreecommitdiff
path: root/pp_sys.c
Commit message (Collapse)AuthorAgeFilesLines
* (perl #134291) propagate non-PVs in $@ in bare die()Tony Cook2019-07-221-1/+1
|
* pp_sys.c: fix the position of HAS_SETNETENT definementAlexandr Savca2019-07-091-1/+1
| | | | Else, DIE() will bever be executed.
* pp.c, pp_sys.c: Use DO_UTF8 instead of its expansionKarl Williamson2019-03-191-1/+1
| | | | We have a macro to hide the details of this; use it
* First "eof" should return trueHauke D2019-01-021-1/+1
| | | | | When no file has previously been opened, "eof" should return true. This behavior was broken by 32e653230c7ccc (see also [#60978]).
* Remove 1 comparison whose result is always the same.James E Keenan2018-11-251-2/+1
| | | | | | Per: https://lgtm.com/projects/g/Perl/perl5/alerts/?mode=tree&ruleFocus=2154840804 For: RT 133686 (partial)
* Cast away const from AIX' accessx() path argumentDagfinn Ilmari Mannsåker2018-10-231-2/+2
| | | | | | Unlike every other platform's access() or equivalent (and as required by POSIX), AIX doesn't declare the path argument to access() and accessx() as const char*, so cast the const away.
* (perl #125760) fatalize sysread/syswrite/recv/send on :utf8 handlesTony Cook2018-10-101-66/+14
| | | | | | | | | | | | | This includes removing the :utf8 logic from pp_syswrite. pp_sysread retains it, since it's also used for read(). Tests that are specifically testing the behaviour against :utf8 handles have been removed (eg in lib/open.t), several other tests that incidentally used those functions on :utf8 handles have been adapted to use :raw handles instead (eg. op/readline.t). Test lib/sigtrap.t fails if STDERR is :utf8, in code from the original 5.000 commit, which is intended to run in a signal handler
* pp_warn: use MEXTEND rather than EXTENDDavid Mitchell2018-01-311-1/+1
| | | | RT #132602
* Revert "Revert "make PerlIO handle FD_CLOEXEC""Zefram2018-01-181-6/+0
| | | | | | This reverts commit 523d71b314dc75bd212794cc8392eab8267ea744, reinstating commit 2cdf406af42834c46ef407517daab0734f7066fc. Reversion is not the way to address the porting problem that motivated that reversion.
* Revert "make PerlIO handle FD_CLOEXEC"Abigail2018-01-181-0/+6
| | | | | | | | | | | | | | | | | | | | | This reverts commit 2cdf406af42834c46ef407517daab0734f7066fc. The reason for the revert is that with this commit, perl fails to compile on darwin (or at least, one some versions of it): ./miniperl -Ilib make_ext.pl lib/auto/DB_File/DB_File.bundle MAKE="/Applications/Xcode.app/Contents/Developer/usr/bin/make" LIBPERL_A=libperl.a LINKTYPE=dynamic Parsing config.in... Looks Good. dyld: lazy symbol binding failed: Symbol not found: _mkostemp Referenced from: /private/tmp/perl/cpan/DB_File/../../miniperl Expected in: flat namespace dyld: Symbol not found: _mkostemp Referenced from: /private/tmp/perl/cpan/DB_File/../../miniperl Expected in: flat namespace Unsuccessful Makefile.PL(cpan/DB_File): code=5 at make_ext.pl line 518. make: *** [lib/auto/DB_File/DB_File.bundle] Error 2
* Reenable numeric first argument of system() on VMS.Craig A. Berry2018-01-011-1/+1
| | | | | | | This was broken in 64def2aeaeb63f92dadc6dfa334, and fixed for Win32 only in 8fe3452cc6ac7af8c08. But VMS also uses a numeric first argument to system() as a flag indicating spawn without waiting for completion.
* make PerlIO handle FD_CLOEXECZefram2017-12-221-6/+0
| | | | | | Move handling of close-on-exec flag for PerlIO handles into PerlIO itself. Where PerlIO opens new file descriptors, have them opened in O_CLOEXEC mode where possible.
* set FD_CLOEXEC atomically in easy casesZefram2017-12-221-34/+13
| | | | | | | In many places where a file descriptor is being opened, open it with FD_CLOEXEC already set if possible. This commit covers the easy cases, where the file descriptor arises without the use of PerlIO, pp_open, or my_popen.
* preserve numericness of system() args on Win32Zefram2017-12-221-4/+31
| | | | | | | | | | | On Windows there's a nasty variation in the meaning of arguments to Perl's system(), in which a numeric first argument isn't used as part of the command to run, but instead selects between two different operations to perform with the command (whether to wait for the command to complete or not). Therefore the reduction of argument scalars to their operative values in the parent process, which was added in commit 64def2aeaeb63f92dadc6dfa33486c1d7b311963, needs to preserve numericness of arguments on Windows. Fixes [perl #132633].
* semicolon-friendly diagnostic controlZefram2017-12-161-8/+8
| | | | | | New macros {GCC,CLANG}_DIAG_{IGNORE,RESTORE}_{DECL,STMT}, which take a following semicolon. It is necessary to use the _DECL or _STMT version as appropriate to the context. Fixes [perl #130726].
* perform system() arg processing before forkZefram2017-12-161-6/+10
| | | | | | | | | | A lot of things can happen when stringifying an argument list: side effects, warnings, exceptions. In the case of system(), these effects should happen in the context of the parent process. The stringification can also depend on which process it happens in, as in the case of $$, and in that case it should also happen in the parent process. Therefore reduce the argument scalars to strings first thing in pp_system. Fixes [perl #121105].
* make exec keep its argument list more reliablyZefram2017-12-141-2/+0
| | | | | | | | | | Bits of exec code were putting the constructed commands into globals PL_Argv and PL_Cmd, which could then be clobbered by reentrancy. These are only global in order to manage their freeing, but that's better managed by using the scope stack. So replace them with automatic variables, with ENTER/SAVEFREEPV/LEAVE to free the memory. Also copy the strings acquired from SVs, to avoid magic clobbering the buffers of SVs already read. Fixes [perl #129888].
* handle null op_next in stacked filetestsZefram2017-12-061-1/+1
| | | | | | | When a filetest op returns false, it skips past following ops that are stacked filetests. The code to do this was assuming that op_next would always be non-null, which is not always the case, for example in a sort comparator. Allow for it to be null. Fixes [perl #129347].
* revert changes to st_ino signedness handlingZefram2017-12-011-5/+4
| | | | | | | | | | | | | This reverts commits 8843856e9716655549cce789b3338e1d4c72fffb, 3676f9e77d46b61f4785aad171f02bed29df0c07, and 793c2ded15ca832d1df1fabbc3b2e7562a057697. As noted in the large comment above the relevant code, the probed ST_INO_SIGN is not reliable enough for its purpose, because Configure makes guesses. The actual compiler knows whether st_ino is signed, and is perfectly capable of optimising out the negative-handling code in the usual case that st_ino is unsigned, without any need for us to preprocess it away.
* More robust version of 793c2ded.Jarkko Hietaniemi2017-11-291-8/+5
| | | | | | In platforms with st.ino always positive, never even see the negative code. Coverity #169271.
* False false.Jarkko Hietaniemi2017-11-281-1/+1
| | | | (Solaris cc got angry.)
* STDCHAR * might not be char *.Jarkko Hietaniemi2017-11-281-1/+1
| | | | | And therefore one may not be able to subtract the pointers, for example in HP-UX.
* In some systems st.ino is never negative.Jarkko Hietaniemi2017-11-281-0/+4
| | | | (Like HP-UX.)
* pp_sys.c: Avoid reparsing stringKarl Williamson2017-11-241-2/+6
| | | | | | | By using is_utf8_invariant_string_loc() instead of plain is_utf8_invariant_string(), we can start parsing at the first variant (if any is found) instead of the previous behavior of starting again at the beginning of the string.
* correctly error on -k "nonexistent" on WindowsZefram2017-11-171-18/+0
| | | | | | | | | | The file test operators for Unix permission bits were returning a blanket false result on systems where the bit being tested for doesn't exist. That's a sensible way to treat a nonexistent bit when statting a file, but the false result was being returned without checking that the argument actually refers to a file. Remove the pre-stat checks for nonexistent bits, so that we get the correct errors for non-files. We still get a blanket false result for nonexistent bits on files.
* set $! when statting a closed filehandleZefram2017-11-151-9/+13
| | | | | | | When a stat fails because it's on a closed or otherwise invalid filehandle, $! was often not being set, depending on the operation and the nature of the invalidity. Consistently set it to EBADF. Fixes [perl #108288].
* suppress clang warning in inode number handlingZefram2017-11-111-0/+2
| | | | | The gcc warning was already suppressed, but clang needs a different formulation.
* return inode numbers as strings where necessaryZefram2017-11-111-7/+55
| | | | | | | | | We previously used a lossy conversion of inode numbers to floating point, where they're too big to fit the IV/UV format. That sucks; a rounded inode number is nearly useless. Instead, fall back to returning a string of decimal digits. That preserves the entire value, for code that looks at it in the right way, and collapses to the former fallback in other situations.
* pp_sys.c; Use memchr instead of strchrKarl Williamson2017-11-061-1/+2
| | | | | This allows things to work properly in the face of embedded NULs. See the branch merge message for more information.
* Avoid a segfault when untying an objectNicolas R2017-11-021-1/+1
| | | | | Check if the tied object has a stash set before calling UNTIE method.
* (perl #131895) fail stat on names with \0 embeddedTony Cook2017-11-021-6/+23
| | | | Also lstat() and the file test ops.
* pp_sys.c: simplify cpp conditionalsAaron Crane2017-10-211-67/+35
|
* pp_readline,close,getc: explain NULL stack argDavid Mitchell2017-07-271-0/+4
| | | | | | | add code comments to explain why these functions can sometimes be called with a NULL pointer on the stack. (feature introduced by v5.15.2-112-g30901a8)
* make callers of SvTRUE() more efficientDavid Mitchell2017-07-271-1/+1
| | | | | | Where its obvious that the args can't be null, use SvTRUE_NN() instead. Avoid possible multiple evaluations of the arg by assigning to a local var first if necessary.
* use the new PL_sv_zero in obvious placesDavid Mitchell2017-07-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | In places that do things like mPUSHi(0) or newSViv(0), replace them with PUSHs(&PL_sv_zero) and &PL_sv_zero, etc. This avoids the cost of creating and/or mortalising an SV, and/or setting its value to 0. This commit causes a subtle change to tainting in various places as a side-effect. For example, grep in scalar context retunrs 0 if it has no args. Formerly the zero value could in theory get tainted: @a = (); $x = ( ($^X . ""), grep { 1 } @a); It used to be the case that $x would be tainted; now its not. In practice this doesn't matter - the zero value was only getting tainted as a side-effect of tainting's "if anything in the statement uses a tainted value, taint everything" mechanism, which gives (documented) false positives. This commit merely removes some such false positives, and makes the behaviour similar to functions which return &PL_sv_undef/no/yes, which are also immune to side-effect tainting.
* [perl #131645] Fix assert fail in pp_sselectFather Chrysostomos2017-07-021-6/+15
| | | | | | | | | | | | | | | | | pp_sselect (4-arg select) process its first three bitfield arguments first, making sure each one has a valid PV, and then it moves on to the final, timeout argument. SvGETMAGIC() on the timeout argument will wipe out any values the SV holds, so if the same scalar is used as a bitfield argument *and* as the timeout, it will no longer hold a valid PV. Assertions later in pp_sselect make sure there is a valid PV. This commit solves the assertion failure by making a temporary copy of any gmagical or overloaded argument. When the temporary copy is made, the values written to the temporary copies of the bitfield arguments are then copied back to the original magical arguments.
* recv: reset stack when returning undefDavid Mitchell2017-06-221-2/+2
| | | | | | | | | | | When recv() detects an error, it returns undef: but it was failing to pop its args off the stack first. So in list context it returned both its original args and undef. It was also then not extending the stack to push the undef. After this commit it resets SP to the base of its args list first, like the other ops already do which share the Perl_pp_systread() function body.
* pp_leavewrite: extend stack for return valueDavid Mitchell2017-06-221-0/+2
| | | | | | | | | | | | When pushing &PL_sv_yes/no on the stack, make room for it. Normally this isn't an issue as previous formlines() will have caused the stack to be extended anyway; but for the null format: format FOO = . this isn't the case.
* Disallow opening the same symbol as both a file and directory handleDagfinn Ilmari Mannsåker2017-06-051-5/+3
| | | | This has been deprecated since Perl 5.10
* Eliminate remaining uses of PL_statbufDagfinn Ilmari Mannsåker2017-06-011-1/+1
| | | | | | | | | | Give Perl_nextargv its own statbuf and pass a pointer to it into Perl_do_open_raw and thence S_openn_cleanup when needed. Also reduce the scope of the existing statbuf in Perl_nextargv to make it clear it's distinct from the one populated by do_open_raw. Fix perldelta entry for PL_statbuf removal
* Moving variables to their innermost scope.Andy Lester2017-02-181-6/+3
| | | | | | Some vars have been tagged as const because they do not change in their new scopes. In pp_reverse in pp.c, I32 tmp is only used to hold a char, so is changed to char.
* Fix memory leak in generating an exception messageAaron Crane2017-02-041-1/+1
| | | | This was my fault; oops.
* RT#130623: assertions when tying into non-packagesAaron Crane2017-01-241-6/+19
|
* Reading/writing bytes from :utf8 handles will be fatal in 5.30Abigail2017-01-161-2/+4
|
* Opening a file and dir using the same symbol will be fatal in 5.28.Abigail2017-01-161-2/+2
| | | | | | | | Perl 5.10 deprecated using the same symbol to open both a filehandle and a dirhandle, as this can lead to confusing code. In Pelr 5.28, this will become a fatal error. This patch changes the warning to reflect this.
* pp_sys.c: White space onlyKarl Williamson2017-01-131-5/+5
| | | | Vertically align some components of an 'if' for readability.
* Change white space to avoid C++ deprecation warningKarl Williamson2016-11-181-27/+27
| | | | | | | | | | | | | | | | | | | | | | C++11 requires space between the end of a string literal and a macro, so that a feature can unambiguously be added to the language. Starting in g++ 6.2, the compiler emits a warning when there isn't a space (presumably so that future versions can support C++11). Unfortunately there are many such instances in the perl core. This commit fixes those, including those in ext/, but individual commits will be used for the other modules, those in dist/ and cpan/. This commit also inserts space at the end of a macro before a string literal, even though that is not deprecated, and removes useless "" literals following a macro (instead of inserting a blank). The result is easier to read, making the macro stand out, and be clearer as to the intention. Code and modules included with the Perl core need to be compilable using C++. This is so that perl can be embedded in C++ programs. (Actually, only the hdr files need to be so compilable, but it would be hard to test that just the hdrs are compilable.) So we need to accommodate changes to the C++ language.
* Improve error for missing tie() pacakge/methodDagfinn Ilmari Mannsåker2016-11-141-4/+17
| | | | | This brings the error messages in line with the ones used for normal method calls, despite not using call_method().
* make the sysread()/syswrite/() etc :utf8 handle warnings defaultTony Cook2016-11-141-6/+6
| | | | as they should be for deprecation warnings
* (perl #129130) make chdir allocate the stack it needsTony Cook2016-10-241-0/+1
| | | | | chdir with no argument didn't ensure there was stack space available for its result.