Integrate from ansi branch to mainline.
[p5sagit/p5-mst-13.2.git] / pp_sys.c
index 39cc4e2..9dc6201 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -38,7 +38,9 @@ extern "C" int syscall(unsigned long,...);
 
 #if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
 # include <sys/socket.h>
-# include <netdb.h>
+# ifdef I_NETDB
+#  include <netdb.h>
+# endif
 # ifndef ENOTSOCK
 #  ifdef I_NET_ERRNO
 #   include <net/errno.h>
@@ -284,10 +286,10 @@ PP(pp_warn)
        tmps = SvPV(TOPs, na);
     }
     if (!tmps || !*tmps) {
-       (void)SvUPGRADE(errsv, SVt_PV);
-       if (SvPOK(errsv) && SvCUR(errsv))
-           sv_catpv(errsv, "\t...caught");
-       tmps = SvPV(errsv, na);
+       (void)SvUPGRADE(ERRSV, SVt_PV);
+       if (SvPOK(ERRSV) && SvCUR(ERRSV))
+           sv_catpv(ERRSV, "\t...caught");
+       tmps = SvPV(ERRSV, na);
     }
     if (!tmps || !*tmps)
        tmps = "Warning: something's wrong";
@@ -309,10 +311,10 @@ PP(pp_die)
        tmps = SvPV(TOPs, na);
     }
     if (!tmps || !*tmps) {
-       (void)SvUPGRADE(errsv, SVt_PV);
-       if (SvPOK(errsv) && SvCUR(errsv))
-           sv_catpv(errsv, "\t...propagated");
-       tmps = SvPV(errsv, na);
+       (void)SvUPGRADE(ERRSV, SVt_PV);
+       if (SvPOK(ERRSV) && SvCUR(ERRSV))
+           sv_catpv(ERRSV, "\t...propagated");
+       tmps = SvPV(ERRSV, na);
     }
     if (!tmps || !*tmps)
        tmps = "Died";
@@ -503,6 +505,7 @@ PP(pp_binmode)
 
 }
 
+
 PP(pp_tie)
 {
     djSP;
@@ -556,7 +559,7 @@ PP(pp_tie)
     CATCH_SET(oldcatch);
 #else
     ENTER;
-    perl_call_sv((SV*)gv, G_SCALAR);
+    perl_call_sv((SV*)GvCV(gv), G_SCALAR);
     SPAGAIN;
 #endif 
     sv = TOPs;
@@ -686,7 +689,7 @@ PP(pp_dbmopen)
         runops();
 #else
     PUTBACK;
-    perl_call_sv((SV*)gv, G_SCALAR);
+    perl_call_sv((SV*)GvCV(gv), G_SCALAR);
 #endif 
     SPAGAIN;
 
@@ -713,7 +716,7 @@ PP(pp_dbmopen)
        if (op = pp_entersub(ARGS))
            runops();
 #else
-       perl_call_sv((SV*)gv, G_SCALAR);
+       perl_call_sv((SV*)GvCV(gv), G_SCALAR);
 #endif 
        SPAGAIN;
     }
@@ -955,7 +958,7 @@ static OP *
 doform(CV *cv, GV *gv, OP *retop)
 {
     dTHR;
-    register CONTEXT *cx;
+    register PERL_CONTEXT *cx;
     I32 gimme = GIMME_V;
     AV* padlist = CvPADLIST(cv);
     SV** svp = AvARRAY(padlist);
@@ -1023,7 +1026,7 @@ PP(pp_leavewrite)
     PerlIO *fp;
     SV **newsp;
     I32 gimme;
-    register CONTEXT *cx;
+    register PERL_CONTEXT *cx;
 
     DEBUG_f(PerlIO_printf(Perl_debug_log, "left=%ld, todo=%ld\n",
          (long)IoLINES_LEFT(io), (long)FmLINES(formtarget)));
@@ -3637,7 +3640,7 @@ PP(pp_ghostent)
     register SV *sv;
 #if defined(HAS_GETHOSTENT) && !defined(DONT_DECLARE_STD)
     struct hostent *gethostbyname(const char *);
-    struct hostent *gethostbyaddr(const char *, int, int);
+    struct hostent *gethostbyaddr(const Gethbadd_addr_t, Gethbadd_alen_t, int);
     struct hostent *gethostent(void);
 #endif
     struct hostent *hent;
@@ -3651,9 +3654,9 @@ PP(pp_ghostent)
        int addrtype = POPi;
        SV *addrsv = POPs;
        STRLEN addrlen;
-       char *addr = SvPV(addrsv, addrlen);
+       Gethbadd_addr_t addr = (Gethbadd_addr_t) SvPV(addrsv, addrlen);
 
-       hent = gethostbyaddr(addr, addrlen, addrtype);
+       hent = gethostbyaddr(addr, (Gethbadd_alen_t) addrlen, addrtype);
     }
     else
 #ifdef HAS_GETHOSTENT
@@ -3736,9 +3739,13 @@ PP(pp_gnetent)
     I32 which = op->op_type;
     register char **elem;
     register SV *sv;
-#ifndef DONT_DECLARE_STD
+#ifdef NETDB_H_OMITS_GETNET
     struct netent *getnetbyname(const char *);
-    struct netent *getnetbyaddr(long int, int);
+    /*
+     * long is wrong for getnetbyadddr (e.g. on Alpha). POSIX.1g says
+     * in_addr_t but then such systems don't have broken netdb.h anyway.
+     */
+    struct netent *getnetbyaddr(Getnbadd_net_t, int);
     struct netent *getnetent(void);
 #endif
     struct netent *nent;
@@ -3747,8 +3754,8 @@ PP(pp_gnetent)
        nent = getnetbyname(POPp);
     else if (which == OP_GNBYADDR) {
        int addrtype = POPi;
-       unsigned long addr = U_L(POPn);
-       nent = getnetbyaddr((long)addr, addrtype);
+       Getnbadd_net_t addr = (Getnbadd_net_t) U_L(POPn);
+       nent = getnetbyaddr(addr, addrtype);
     }
     else
        nent = getnetent();