Merge the implementations of pp_e{host,net,proto,serv}ent.
authorNicholas Clark <nick@ccl4.org>
Mon, 10 Jan 2011 10:12:10 +0000 (10:12 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 10 Jan 2011 11:19:18 +0000 (11:19 +0000)
PL_op_desc[] rather than PL_op_name(), as the OPs are internally named e*ent,
but implement the ent*ent functions, and when unimplemented report themselves
using the function name. No need for OP_DESC(), as the switch statement means
that we can't encounter OP_CUSTOM.

opcode.h
pp_proto.h
pp_sys.c
regen/opcode.pl

index 8cc671a..0f5954f 100644 (file)
--- a/opcode.h
+++ b/opcode.h
 #define Perl_pp_gpbynumber Perl_pp_gprotoent
 #define Perl_pp_gsbyname Perl_pp_gservent
 #define Perl_pp_gsbyport Perl_pp_gservent
+#define Perl_pp_enetent Perl_pp_ehostent
+#define Perl_pp_eprotoent Perl_pp_ehostent
+#define Perl_pp_eservent Perl_pp_ehostent
 #define Perl_pp_gpwnam Perl_pp_gpwent
 #define Perl_pp_gpwuid Perl_pp_gpwent
 #define Perl_pp_ggrnam Perl_pp_ggrent
@@ -1251,9 +1254,9 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
        Perl_pp_sprotoent,
        Perl_pp_sservent,
        Perl_pp_ehostent,
-       Perl_pp_enetent,
-       Perl_pp_eprotoent,
-       Perl_pp_eservent,
+       Perl_pp_enetent,        /* implemented by Perl_pp_ehostent */
+       Perl_pp_eprotoent,      /* implemented by Perl_pp_ehostent */
+       Perl_pp_eservent,       /* implemented by Perl_pp_ehostent */
        Perl_pp_gpwnam, /* implemented by Perl_pp_gpwent */
        Perl_pp_gpwuid, /* implemented by Perl_pp_gpwent */
        Perl_pp_gpwent,
index 41f03e0..0585536 100644 (file)
@@ -52,7 +52,6 @@ PERL_CALLCONV OP *Perl_pp_divide(pTHX);
 PERL_CALLCONV OP *Perl_pp_each(pTHX);
 PERL_CALLCONV OP *Perl_pp_egrent(pTHX);
 PERL_CALLCONV OP *Perl_pp_ehostent(pTHX);
-PERL_CALLCONV OP *Perl_pp_enetent(pTHX);
 PERL_CALLCONV OP *Perl_pp_enter(pTHX);
 PERL_CALLCONV OP *Perl_pp_entereval(pTHX);
 PERL_CALLCONV OP *Perl_pp_entergiven(pTHX);
@@ -63,10 +62,8 @@ PERL_CALLCONV OP *Perl_pp_entertry(pTHX);
 PERL_CALLCONV OP *Perl_pp_enterwhen(pTHX);
 PERL_CALLCONV OP *Perl_pp_enterwrite(pTHX);
 PERL_CALLCONV OP *Perl_pp_eof(pTHX);
-PERL_CALLCONV OP *Perl_pp_eprotoent(pTHX);
 PERL_CALLCONV OP *Perl_pp_epwent(pTHX);
 PERL_CALLCONV OP *Perl_pp_eq(pTHX);
-PERL_CALLCONV OP *Perl_pp_eservent(pTHX);
 PERL_CALLCONV OP *Perl_pp_exec(pTHX);
 PERL_CALLCONV OP *Perl_pp_exists(pTHX);
 PERL_CALLCONV OP *Perl_pp_exit(pTHX);
index f8c50d6..7359f95 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -5029,50 +5029,39 @@ PP(pp_sservent)
 
 PP(pp_ehostent)
 {
-#ifdef HAS_ENDHOSTENT
     dVAR; dSP;
-    PerlSock_endhostent();
-    EXTEND(SP,1);
-    RETPUSHYES;
+    switch(PL_op->op_type) {
+    case OP_EHOSTENT:
+#ifdef HAS_ENDHOSTENT
+       PerlSock_endhostent();
 #else
-    DIE(aTHX_ PL_no_sock_func, "endhostent");
+       DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]);
 #endif
-}
-
-PP(pp_enetent)
-{
+       break;
+    case OP_ENETENT:
 #ifdef HAS_ENDNETENT
-    dVAR; dSP;
-    PerlSock_endnetent();
-    EXTEND(SP,1);
-    RETPUSHYES;
+       PerlSock_endnetent();
 #else
-    DIE(aTHX_ PL_no_sock_func, "endnetent");
+       DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]);
 #endif
-}
-
-PP(pp_eprotoent)
-{
+       break;
+    case OP_EPROTOENT:
 #ifdef HAS_ENDPROTOENT
-    dVAR; dSP;
-    PerlSock_endprotoent();
-    EXTEND(SP,1);
-    RETPUSHYES;
+       PerlSock_endprotoent();
 #else
-    DIE(aTHX_ PL_no_sock_func, "endprotoent");
+       DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]);
 #endif
-}
-
-PP(pp_eservent)
-{
+       break;
+    case OP_ESERVENT:
 #ifdef HAS_ENDSERVENT
-    dVAR; dSP;
-    PerlSock_endservent();
-    EXTEND(SP,1);
-    RETPUSHYES;
+       PerlSock_endservent();
 #else
-    DIE(aTHX_ PL_no_sock_func, "endservent");
+       DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]);
 #endif
+       break;
+    }
+    EXTEND(SP,1);
+    RETPUSHYES;
 }
 
 PP(pp_gpwent)
index 701ec27..2d58450 100755 (executable)
@@ -117,6 +117,7 @@ my @raw_alias = (
                 Perl_pp_predec => ['i_predec'],
                 Perl_pp_postinc => ['i_postinc'],
                 Perl_pp_postdec => ['i_postdec'],
+                Perl_pp_ehostent => [qw(enetent eprotoent eservent)],
                );
 
 while (my ($func, $names) = splice @raw_alias, 0, 2) {