This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fetch magic on the first stacked filetest, not the last
[perl5.git] / pp_sys.c
index 0214367..5c9f768 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -498,7 +498,7 @@ PP(pp_die)
                }
            }
        }
-       else if (SvPOK(errsv) && SvCUR(errsv)) {
+       else if (SvOK(errsv) && (SvPV_nomg(errsv,len), len)) {
            exsv = sv_mortalcopy(errsv);
            sv_catpvs(exsv, "\t...propagated");
        }
@@ -1293,7 +1293,7 @@ PP(pp_sselect)
 
 /*
 
-=head1 GV Functions
+=for apidoc_section $GV
 
 =for apidoc setdefout
 
@@ -2129,7 +2129,7 @@ PP(pp_eof)
 
     if (!MAXARG && (PL_op->op_flags & OPf_SPECIAL)) {  /* eof() */
        if (io && !IoIFP(io)) {
-           if ((IoFLAGS(io) & IOf_START) && av_tindex(GvAVn(gv)) < 0) {
+           if ((IoFLAGS(io) & IOf_START) && av_count(GvAVn(gv)) == 0) {
                SV ** svp;
                IoLINES(io) = 0;
                IoFLAGS(io) &= ~IOf_START;
@@ -2179,9 +2179,9 @@ PP(pp_tell)
     }
 
 #if LSEEKSIZE > IVSIZE
-    PUSHn( do_tell(gv) );
+    PUSHn( (NV)do_tell(gv) );
 #else
-    PUSHi( do_tell(gv) );
+    PUSHi( (IV)do_tell(gv) );
 #endif
     RETURN;
 }
@@ -2705,30 +2705,16 @@ PP(pp_ssockopt)
        PUSHs(sv);
        break;
     case OP_SSOCKOPT: {
-#if defined(__SYMBIAN32__)
-# define SETSOCKOPT_OPTION_VALUE_T void *
-#else
-# define SETSOCKOPT_OPTION_VALUE_T const char *
-#endif
-       /* XXX TODO: We need to have a proper type (a Configure probe,
-        * etc.) for what the C headers think of the third argument of
-        * setsockopt(), the option_value read-only buffer: is it
-        * a "char *", or a "void *", const or not.  Some compilers
-        * don't take kindly to e.g. assuming that "char *" implicitly
-        * promotes to a "void *", or to explicitly promoting/demoting
-        * consts to non/vice versa.  The "const void *" is the SUS
-        * definition, but that does not fly everywhere for the above
-        * reasons. */
-           SETSOCKOPT_OPTION_VALUE_T buf;
+           const char *buf;
            int aint;
            if (SvPOKp(sv)) {
                STRLEN l;
-               buf = (SETSOCKOPT_OPTION_VALUE_T) SvPV_const(sv, l);
+               buf = SvPV_const(sv, l);
                len = l;
            }
            else {
                aint = (int)SvIV(sv);
-               buf = (SETSOCKOPT_OPTION_VALUE_T) &aint;
+               buf = (const char *) &aint;
                len = sizeof(int);
            }
            if (PerlSock_setsockopt(fd, lvl, optname, buf, len) < 0)
@@ -2763,9 +2749,13 @@ PP(pp_getpeername)
     if (!IoIFP(io))
        goto nuts;
 
-    sv = sv_2mortal(newSV(257));
-    (void)SvPOK_only(sv);
+#ifdef HAS_SOCKADDR_STORAGE
+    len = sizeof(struct sockaddr_storage);
+#else
     len = 256;
+#endif
+    sv = sv_2mortal(newSV(len+1));
+    (void)SvPOK_only(sv);
     SvCUR_set(sv, len);
     *SvEND(sv) ='\0';
     fd = PerlIO_fileno(IoIFP(io));
@@ -3077,7 +3067,7 @@ S_try_amagic_ftest(pTHX_ char chr) {
     SV *const arg = *PL_stack_sp;
 
     assert(chr != '?');
-    if (!(PL_op->op_private & OPpFT_STACKING)) SvGETMAGIC(arg);
+    if (!(PL_op->op_private & OPpFT_STACKED)) SvGETMAGIC(arg);
 
     if (SvAMAGIC(arg))
     {
@@ -4490,14 +4480,14 @@ PP(pp_system)
     result = 0;
     if (PL_op->op_flags & OPf_STACKED) {
        SV * const really = *++MARK;
-#  if defined(WIN32) || defined(OS2) || defined(__SYMBIAN32__) || defined(__VMS)
+#  if defined(WIN32) || defined(OS2) || defined(__VMS)
        value = (I32)do_aspawn(really, MARK, SP);
 #  else
        value = (I32)do_aspawn(really, (void **)MARK, (void **)SP);
 #  endif
     }
     else if (SP - MARK != 1) {
-#  if defined(WIN32) || defined(OS2) || defined(__SYMBIAN32__) || defined(__VMS)
+#  if defined(WIN32) || defined(OS2) || defined(__VMS)
        value = (I32)do_aspawn(NULL, MARK, SP);
 #  else
        value = (I32)do_aspawn(NULL, (void **)MARK, (void **)SP);
@@ -4619,6 +4609,11 @@ PP(pp_setpgrp)
 #endif
 }
 
+/*
+ * The glibc headers typedef __priority_which_t to an enum under C, but
+ * under C++, it keeps it as int. -Wc++-compat doesn't know this, so we
+ * need to explicitly cast it to shut up the warning.
+ */
 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__GLIBC__ > 2))
 #  define PRIORITY_WHICH_T(which) (__priority_which_t)which
 #else
@@ -4661,9 +4656,9 @@ PP(pp_time)
 {
     dSP; dTARGET;
 #ifdef BIG_TIME
-    XPUSHn( time(NULL) );
+    XPUSHn( (NV)time(NULL) );
 #else
-    XPUSHi( time(NULL) );
+    XPUSHu( (UV)time(NULL) );
 #endif
     RETURN;
 }
@@ -4863,7 +4858,7 @@ PP(pp_sleep)
         }
     }
     (void)time(&when);
-    XPUSHi(when - lasttime);
+    XPUSHu((UV)(when - lasttime));
     RETURN;
 }
 
@@ -5432,7 +5427,7 @@ PP(pp_gpwent)
      * it is only included in special cases.
      *
      * In Digital UNIX/Tru64 if using the getespw*() (which seems to be
-     * be preferred interface, even though also the getprpw*() interface
+     * the preferred interface, even though also the getprpw*() interface
      * is available) one needs to link with -lsecurity -ldb -laud -lm.
      * One also needs to call set_auth_parameters() in main() before
      * doing anything else, whether one is using getespw*() or getprpw*().