Merge the opcode bodies for pp_bind and pp_connect.
authorNicholas Clark <nick@ccl4.org>
Thu, 30 Dec 2010 17:45:53 +0000 (17:45 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 30 Dec 2010 18:08:10 +0000 (18:08 +0000)
mathoms.c
opcode.h
pp_sys.c
regen/opcode.pl

index c648833..f9c2ad3 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -1133,6 +1133,11 @@ PP(pp_chomp)
     return Perl_pp_chop(aTHX);
 }
 
+PP(pp_connect)
+{
+    return Perl_pp_bind(aTHX);
+}
+
 U8 *
 Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
 {
index 5895b8f..ac9886b 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1037,7 +1037,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        Perl_pp_socket,
        Perl_pp_sockpair,
        Perl_pp_bind,
-       Perl_pp_connect,
+       Perl_pp_bind,   /* Perl_pp_connect */
        Perl_pp_listen,
        Perl_pp_accept,
        Perl_pp_shutdown,
index d93cc87..6a89fb4 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2488,42 +2488,17 @@ PP(pp_bind)
     GV * const gv = MUTABLE_GV(POPs);
     register IO * const io = GvIOn(gv);
     STRLEN len;
+    const int op_type = PL_op->op_type;
 
     if (!io || !IoIFP(io))
        goto nuts;
 
     addr = SvPV_const(addrsv, len);
-    TAINT_PROPER("bind");
-    if (PerlSock_bind(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) >= 0)
-       RETPUSHYES;
-    else
-       RETPUSHUNDEF;
-
-nuts:
-    report_evil_fh(gv);
-    SETERRNO(EBADF,SS_IVCHAN);
-    RETPUSHUNDEF;
-#else
-    DIE(aTHX_ PL_no_sock_func, "bind");
-#endif
-}
-
-PP(pp_connect)
-{
-#ifdef HAS_SOCKET
-    dVAR; dSP;
-    SV * const addrsv = POPs;
-    GV * const gv = MUTABLE_GV(POPs);
-    register IO * const io = GvIOn(gv);
-    const char *addr;
-    STRLEN len;
-
-    if (!io || !IoIFP(io))
-       goto nuts;
-
-    addr = SvPV_const(addrsv, len);
-    TAINT_PROPER("connect");
-    if (PerlSock_connect(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) >= 0)
+    TAINT_PROPER(PL_op_desc[op_type]);
+    if ((op_type == OP_BIND
+        ? PerlSock_bind(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len)
+        : PerlSock_connect(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len))
+       >= 0)
        RETPUSHYES;
     else
        RETPUSHUNDEF;
@@ -2533,7 +2508,7 @@ nuts:
     SETERRNO(EBADF,SS_IVCHAN);
     RETPUSHUNDEF;
 #else
-    DIE(aTHX_ PL_no_sock_func, "connect");
+    DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]);
 #endif
 }
 
index b8887c2..6501380 100755 (executable)
@@ -110,6 +110,7 @@ my @raw_alias = (
                 Perl_pp_trans => [qw(trans transr)],
                 Perl_pp_chop => [qw(chop chomp)],
                 Perl_pp_schop => [qw(schop schomp)],
+                Perl_pp_bind => ['connect'],
                );
 
 while (my ($func, $names) = splice @raw_alias, 0, 2) {