This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Fix wrong comment
[perl5.git] / ext / Sys-Hostname / Hostname.xs
index 23ecd69..c75bbce 100644 (file)
@@ -1,3 +1,5 @@
+#define PERL_NO_GET_CONTEXT
+
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
 #  define MAXHOSTNAMELEN       256
 #endif
 
-/* swiped from POSIX.xs */
-#if defined(__VMS) && !defined(__POSIX_SOURCE)
-#  if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
-#    include <utsname.h>
-#  endif
-#endif
-
 #ifdef I_SYSUTSNAME
 #  include <sys/utsname.h>
 #endif
 
 MODULE = Sys::Hostname         PACKAGE = Sys::Hostname
+PROTOTYPES: DISABLE
 
 void
 ghname()
@@ -35,7 +31,7 @@ ghname()
     {
        char tmps[MAXHOSTNAMELEN];
        retval = PerlSock_gethostname(tmps, sizeof(tmps));
-       sv = newSVpvn(tmps, strlen(tmps));
+       sv = newSVpv(tmps, 0);
     }
 #else
 #  ifdef HAS_PHOSTNAME
@@ -53,9 +49,8 @@ ghname()
            *p++ = c;
        }
        PerlProc_pclose(io);
-       *p = '\0';
        retval = 0;
-       sv = newSVpvn(tmps, strlen(tmps));
+       sv = newSVpvn(tmps, p - tmps);
     }
 #  else
 #    ifdef HAS_UNAME
@@ -63,7 +58,7 @@ ghname()
        struct utsname u;
        if (PerlEnv_uname(&u) == -1)
            goto check_out;
-       sv = newSVpvn(u.nodename, strlen(u.nodename));
+       sv = newSVpv(u.nodename, 0);
         retval = 0;
     }
 #    endif