getservbyport() should accept an empty string as its
Slaven Rezic [Sun, 8 Dec 2002 01:54:37 +0000 (02:54 +0100)]
proto argument (as does getservbyname()).

Subject: Re: Is this a bug or am I being stupid?
Message-ID: <87znrhl48i.fsf@vran.herceg.de>

p4raw-id: //depot/perl@18262

pp_sys.c

index f1eb1b9..472f041 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4952,6 +4952,9 @@ PP(pp_gservent)
        char *proto = POPpbytex;
        unsigned short port = (unsigned short)POPu;
 
+       if (proto && !*proto)
+           proto = Nullch;
+
 #ifdef HAS_HTONS
        port = PerlSock_htons(port);
 #endif