This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In I18N::Langinfo::langinfo(), use newSVpv(), as it will call strlen()
authorNicholas Clark <nick@ccl4.org>
Tue, 26 Oct 2010 04:50:14 +0000 (05:50 +0100)
committerNicholas Clark <nick@ccl4.org>
Tue, 26 Oct 2010 04:53:17 +0000 (05:53 +0100)
newSVpv() will return an undef if the passed pointer is NULL, which allows
langinfo() to be simplified further.

ext/I18N-Langinfo/Langinfo.xs

index 62f3580..d087075 100644 (file)
@@ -21,14 +21,7 @@ langinfo(code)
   PROTOTYPE: _
   CODE:
 #ifdef HAS_NL_LANGINFO
-       {
-         char *s;
-
-         if ((s = nl_langinfo(code)))
-             RETVAL = newSVpvn(s, strlen(s));
-         else
-             RETVAL = &PL_sv_undef;
-       }
+       RETVAL = newSVpv(nl_langinfo(code), 0);
 #else
        croak("nl_langinfo() not implemented on this architecture");
 #endif