This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
eliminate an unused variable
[perl5.git] / ext / POSIX / POSIX.xs
index 49c504d..e4c9e88 100644 (file)
@@ -13,9 +13,6 @@
 
 #define PERL_NO_GET_CONTEXT
 
-/* Solaris needs this in order not to zero out all the untouched fields in strptime() */
-#define _STRPTIME_DONTZERO
-
 #include "EXTERN.h"
 #define PERLIO_NOT_STDIO 1
 #include "perl.h"
@@ -376,9 +373,11 @@ typedef struct termios* POSIX__Termios;
 
 /* Possibly needed prototypes */
 #ifndef WIN32
+START_EXTERN_C
 double strtod (const char *, char **);
 long strtol (const char *, char **, int);
 unsigned long strtoul (const char *, char **, int);
+END_EXTERN_C
 #endif
 
 #ifndef HAS_DIFFTIME
@@ -549,7 +548,7 @@ const struct lconv_offset lconv_integers[] = {
  * as expected. The better solution would be not to use the W*() macros
  * in the first place, though. -- Ingo Weinhold
  */
-#if defined(__BEOS__) || defined(__HAIKU__)
+#if defined(__HAIKU__)
 #    define WMUNGE(x) (((x) & 0xFF00) >> 8 | ((x) & 0x00FF) << 8)
 #else
 #    define WMUNGE(x) (x)
@@ -705,7 +704,6 @@ static XSPROTO(is_common); /* prototype to pass -Wmissing-prototypes */
 static XSPROTO(is_common)
 {
     dXSARGS;
-    SV *charstring;
     if (items != 1)
        croak_xs_usage(cv,  "charstring");
 
@@ -1845,122 +1843,6 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
        }
 
 void
-strptime(str, fmt, sec=-1, min=-1, hour=-1, mday=-1, mon=-1, year=-1, wday=-1, yday=-1, isdst=-1)
-       SV *            str
-       SV *            fmt
-       int             sec
-       int             min
-       int             hour
-       int             mday
-       int             mon
-       int             year
-       int             wday
-       int             yday
-       int             isdst
-    PPCODE:
-       {
-           const char *str_c;
-           SV *strref = NULL;
-           MAGIC *posmg = NULL;
-           int str_offset = 0;
-           struct tm tm;
-           char *remains;
-
-           init_tm(&tm);       /* XXX workaround - see init_tm() in core util.c */
-           tm.tm_sec = sec;
-           tm.tm_min = min;
-           tm.tm_hour = hour;
-           tm.tm_mday = mday;
-           tm.tm_mon = mon;
-           tm.tm_year = year;
-           tm.tm_wday = wday;
-           tm.tm_yday = yday;
-           tm.tm_isdst = isdst;
-
-           if(SvROK(str) && !SvOBJECT(SvRV(str))) {
-               strref = SvRV(str);
-
-               if(SvTYPE(strref) > SVt_PVMG || SvREADONLY(strref))
-                   croak("str is not a reference to a mutable scalar");
-
-               str = strref;
-
-               if(SvTYPE(strref) >= SVt_PVMG && SvMAGIC(strref))
-                   posmg = mg_find(strref, PERL_MAGIC_regex_global);
-
-               if(posmg)
-                   str_offset = posmg->mg_len;
-           }
-           else if(SvROK(str) && SvTYPE(SvRV(str)) == SVt_REGEXP) {
-               croak("str is not a reference to a mutable scalar");
-           }
-
-           if(!SvUTF8(str) && SvUTF8(fmt)) {
-               /* fmt is UTF-8, str is not. Upgrade a local copy of it, and
-                * take care to update str_offset to match. */
-               str = sv_mortalcopy(str);
-               sv_utf8_upgrade_nomg(str);
-
-               if(str_offset) {
-                   U8 *bytes = SvPV_nolen(str);
-                   str_offset = utf8_hop(bytes, str_offset) - bytes;
-               }
-           }
-
-           str_c = SvPV_nolen(str);
-
-           remains = strptime(str_c + str_offset, SvPV_nolen(fmt), &tm);
-
-           if(!remains)
-               /* failed parse */
-               XSRETURN(0);
-           if(remains[0] && !strref)
-               /* leftovers - without ref we can't signal this so this is a failure */
-               XSRETURN(0);
-
-           if(strref) {
-               if(str != strref) {
-                   /* str is a UTF-8 upgraded copy of the original non-UTF-8
-                    * string the caller referred us to in strref */
-                   str_offset = utf8_distance(remains, str_c);
-               }
-               else {
-                   str_offset = remains - str_c;
-               }
-               if(!posmg)
-                   posmg = sv_magicext(strref, NULL, PERL_MAGIC_regex_global,
-                       &PL_vtbl_mglob, NULL, 0);
-               posmg->mg_len = str_offset;
-           }
-
-           if(tm.tm_mday > -1 && tm.tm_mon > -1 && tm.tm_year > -1) {
-               /* if we leave sec/min/hour == -1, then these will be
-                * normalised to the previous day */
-               int was_sec  = tm.tm_sec;  tm.tm_sec  = 0;
-               int was_min  = tm.tm_min;  tm.tm_min  = 0;
-               int was_hour = tm.tm_hour; tm.tm_hour = 0;
-
-               if(mktime(&tm) == (time_t)-1)
-                   XSRETURN(0);
-
-               tm.tm_sec  = was_sec;
-               tm.tm_min  = was_min;
-               tm.tm_hour = was_hour;
-           }
-
-           EXTEND(SP, 9);
-           PUSHs(tm.tm_sec  != -1 ? sv_2mortal(newSViv(tm.tm_sec))  : &PL_sv_undef);
-           PUSHs(tm.tm_min  != -1 ? sv_2mortal(newSViv(tm.tm_min))  : &PL_sv_undef);
-           PUSHs(tm.tm_hour != -1 ? sv_2mortal(newSViv(tm.tm_hour)) : &PL_sv_undef);
-           PUSHs(tm.tm_mday != -1 ? sv_2mortal(newSViv(tm.tm_mday)) : &PL_sv_undef);
-           PUSHs(tm.tm_mon  != -1 ? sv_2mortal(newSViv(tm.tm_mon))  : &PL_sv_undef);
-           PUSHs(tm.tm_year != -1 ? sv_2mortal(newSViv(tm.tm_year)) : &PL_sv_undef);
-           PUSHs(tm.tm_wday != -1 ? sv_2mortal(newSViv(tm.tm_wday)) : &PL_sv_undef);
-           PUSHs(tm.tm_yday != -1 ? sv_2mortal(newSViv(tm.tm_yday)) : &PL_sv_undef);
-           PUSHs(tm.tm_isdst!= -1 ? sv_2mortal(newSViv(tm.tm_isdst)): &PL_sv_undef);
-       }
-
-void
 tzset()
   PPCODE:
     my_tzset(aTHX);
@@ -2026,24 +1908,10 @@ sleep(seconds)
 SysRet
 setgid(gid)
        Gid_t           gid
-    CLEANUP:
-#ifndef WIN32
-       if (RETVAL >= 0) {
-           PL_gid  = getgid();
-           PL_egid = getegid();
-       }
-#endif
 
 SysRet
 setuid(uid)
        Uid_t           uid
-    CLEANUP:
-#ifndef WIN32
-       if (RETVAL >= 0) {
-           PL_uid  = getuid();
-           PL_euid = geteuid();
-       }
-#endif
 
 SysRetLong
 sysconf(name)