This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Allow %j on non-C99 platforms
authorKarl Williamson <khw@cpan.org>
Tue, 5 Dec 2017 20:39:27 +0000 (13:39 -0700)
committerKarl Williamson <khw@cpan.org>
Sat, 9 Dec 2017 05:27:44 +0000 (22:27 -0700)
Now that intmax_t is emulated, the %j format is usable on platforms that
aren't C99.

pod/perldelta.pod
pod/perlfunc.pod
sv.c

index 9e8b436..21c855a 100644 (file)
@@ -27,6 +27,11 @@ here, but most should go in the L</Performance Enhancements> section.
 
 [ List each enhancement as a =head2 entry ]
 
+=head2  The C<sprintf> C<%j> format size modifier is now available with
+pre-C99 compilers
+
+The actual size used depends on the platform, so remains unportable.
+
 =head1 Security
 
 XXX Any security-related notices go here.  In particular, any security
index 98cba47..32f0e64 100644 (file)
@@ -7991,8 +7991,8 @@ as supported by the compiler used to build Perl:
    h           interpret integer as C type "short" or
                "unsigned short"
    j           interpret integer as C type "intmax_t" on Perl
-               5.14 or later, and only with a C99 compiler
-               (unportable)
+               5.14 or later; and only with a C99 compiler
+               prior to Perl 5.30 (unportable)
    l           interpret integer as C type "long" or
                "unsigned long"
    q, L, or ll interpret integer as C type "long long",
diff --git a/sv.c b/sv.c
index a5bc1e3..a40d0aa 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12335,9 +12335,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
        case 'V':
        case 'z':
        case 't':
-#ifdef I_STDINT
         case 'j':
-#endif
            intsize = *q++;
            break;
        }
@@ -12660,9 +12658,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                         case 't':  iv = va_arg(*args, ptrdiff_t);  break;
 #endif
                         default:   iv = va_arg(*args, int);        break;
-#ifdef I_STDINT
-                        case 'j':  iv = va_arg(*args, intmax_t);   break;
-#endif
+                        case 'j':  iv = va_arg(*args, PERL_INTMAX_T); break;
                         case 'q':
 #if IVSIZE >= 8
                                    iv = va_arg(*args, Quad_t);     break;
@@ -12717,9 +12713,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                                    * uptrdiff_t, so oh well */
                         case 't': uv = va_arg(*args, ptrdiff_t);     break;
 #endif
-#ifdef I_STDINT
-                        case 'j': uv = va_arg(*args, uintmax_t);     break;
-#endif
+                        case 'j': uv = va_arg(*args, PERL_UINTMAX_T); break;
                         default:  uv = va_arg(*args, unsigned);      break;
                         case 'q':
 #if IVSIZE >= 8
@@ -13259,9 +13253,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 #ifdef HAS_PTRDIFF_T
                     case 't':  *(va_arg(*args, ptrdiff_t*)) = i; break;
 #endif
-#ifdef I_STDINT
-                    case 'j':  *(va_arg(*args, intmax_t*))  = i; break;
-#endif
+                    case 'j':  *(va_arg(*args, PERL_INTMAX_T*)) = i; break;
                     case 'q':
 #if IVSIZE >= 8
                                *(va_arg(*args, Quad_t*))    = i; break;