helly           Sun Sep 14 05:50:36 2003 EDT

  Modified files:              
    /php-src/main       snprintf.c snprintf.h spprintf.c 
  Log:
  Add length modifier L
  
  
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.29 php-src/main/snprintf.c:1.30
--- php-src/main/snprintf.c:1.29        Sun Sep 14 05:12:54 2003
+++ php-src/main/snprintf.c     Sun Sep 14 05:50:35 2003
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.c,v 1.29 2003/09/14 09:12:54 helly Exp $ */
+/* $Id: snprintf.c,v 1.30 2003/09/14 09:50:35 helly Exp $ */
 
 /* ====================================================================
  * Copyright (c) 1995-1998 The Apache Group.  All rights reserved.
@@ -670,6 +670,10 @@
                         * Modifier check
                         */
                        switch (*fmt) {
+                               case 'L':
+                                       fmt++;
+                                       modifier = LM_LONG_DOUBLE;
+                                       break;
                                case 'l':
                                        fmt++;
 #if SIZEOF_LONG_LONG
@@ -681,9 +685,11 @@
                                                modifier = LM_LONG;
                                        break;
                                case 'z':
+                                       fmt++;
                                        modifier = LM_SIZE_T;
                                        break;
                                case 'j':
+                                       fmt++;
 #if SIZEOF_INTMAX_T
                                        modifier = LM_INTMAX_T;
 #else
@@ -691,6 +697,7 @@
 #endif
                                        break;
                                case 't':
+                                       fmt++;
 #if SIZEOF_PTRDIFF_T
                                        modifier = LM_PTRDIFF_T;
 #else
@@ -725,6 +732,8 @@
                                                default:
                                                        i_num = (wide_int) va_arg(ap, 
unsigned int);
                                                        break;
+                                               case LM_LONG_DOUBLE:
+                                                       goto fmt_error;
                                                case LM_LONG:
                                                        i_num = (wide_int) va_arg(ap, 
unsigned long int);
                                                        break;
@@ -761,6 +770,8 @@
                                                        default:
                                                                i_num = (wide_int) 
va_arg(ap, int);
                                                                break;
+                                                       case LM_LONG_DOUBLE:
+                                                               goto fmt_error;
                                                        case LM_LONG:
                                                                i_num = (wide_int) 
va_arg(ap, long int);
                                                                break;
@@ -808,6 +819,8 @@
                                                default:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned int);
                                                        break;
+                                               case LM_LONG_DOUBLE:
+                                                       goto fmt_error;
                                                case LM_LONG:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned long int);
                                                        break;
@@ -846,6 +859,8 @@
                                                default:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned int);
                                                        break;
+                                               case LM_LONG_DOUBLE:
+                                                       goto fmt_error;
                                                case LM_LONG:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned long int);
                                                        break;
@@ -896,7 +911,16 @@
                                case 'f':
                                case 'e':
                                case 'E':
-                                       fp_num = va_arg(ap, double);
+                                       switch(modifier) {
+                                               case LM_LONG_DOUBLE:
+                                                       fp_num = (double) va_arg(ap, 
long double);
+                                                       break;
+                                               case LM_STD:
+                                                       fp_num = va_arg(ap, double);
+                                                       break;
+                                               default:
+                                                       goto fmt_error;
+                                       }
 
                                        if (zend_isnan(fp_num)) {
                                                s = "nan";
@@ -920,6 +944,16 @@
 
                                case 'g':
                                case 'G':
+                                       switch(modifier) {
+                                               case LM_LONG_DOUBLE:
+                                                       fp_num = (double) va_arg(ap, 
long double);
+                                                       break;
+                                               case LM_STD:
+                                                       fp_num = va_arg(ap, double);
+                                                       break;
+                                               default:
+                                                       goto fmt_error;
+                                       }
                                        if (adjust_precision == NO)
                                                precision = FLOAT_DIGITS;
                                        else if (precision == 0)
@@ -927,7 +961,7 @@
                                        /*
                                         * * We use &num_buf[ 1 ], so that we have 
room for the sign
                                         */
-                                       s = ap_php_gcvt(va_arg(ap, double), precision, 
&num_buf[1],
+                                       s = ap_php_gcvt(fp_num, precision, &num_buf[1],
                                                        alternate_form);
                                        if (*s == '-')
                                                prefix_char = *s++;
@@ -999,6 +1033,8 @@
                                        continue;
 
 
+fmt_error:
+                               php_error(E_ERROR, "Illegal length modifier specified 
'%c' in s[np]printf call", *fmt);
                                        /*
                                         * The default case is for unrecognized %'s.
                                         * We print %<char> to help the user identify 
what
Index: php-src/main/snprintf.h
diff -u php-src/main/snprintf.h:1.25 php-src/main/snprintf.h:1.26
--- php-src/main/snprintf.h:1.25        Sun Sep 14 05:12:54 2003
+++ php-src/main/snprintf.h     Sun Sep 14 05:50:35 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.h,v 1.25 2003/09/14 09:12:54 helly Exp $ */
+/* $Id: snprintf.h,v 1.26 2003/09/14 09:50:35 helly Exp $ */
 
 /*
 
@@ -95,7 +95,8 @@
        LM_LONG_LONG,
 #endif
        LM_SIZE_T,
-       LM_LONG
+       LM_LONG,
+       LM_LONG_DOUBLE
 } length_modifier_e;
 
 extern char * ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, 
char *buf);
Index: php-src/main/spprintf.c
diff -u php-src/main/spprintf.c:1.18 php-src/main/spprintf.c:1.19
--- php-src/main/spprintf.c:1.18        Sun Sep 14 05:12:54 2003
+++ php-src/main/spprintf.c     Sun Sep 14 05:50:36 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: spprintf.c,v 1.18 2003/09/14 09:12:54 helly Exp $ */
+/* $Id: spprintf.c,v 1.19 2003/09/14 09:50:36 helly Exp $ */
 
 /* This is the spprintf implementation.
  * It has emerged from apache snprintf. See original header:
@@ -285,6 +285,10 @@
                         * Modifier check
                         */
                        switch (*fmt) {
+                               case 'L':
+                                       fmt++;
+                                       modifier = LM_LONG_DOUBLE;
+                                       break;
                                case 'l':
                                        fmt++;
 #if SIZEOF_LONG_LONG
@@ -296,9 +300,11 @@
                                                modifier = LM_LONG;
                                        break;
                                case 'z':
+                                       fmt++;
                                        modifier = LM_SIZE_T;
                                        break;
                                case 'j':
+                                       fmt++;
 #if SIZEOF_INTMAX_T
                                        modifier = LM_INTMAX_T;
 #else
@@ -306,6 +312,7 @@
 #endif
                                        break;
                                case 't':
+                                       fmt++;
 #if SIZEOF_PTRDIFF_T
                                        modifier = LM_PTRDIFF_T;
 #else
@@ -340,6 +347,8 @@
                                                default:
                                                        i_num = (wide_int) va_arg(ap, 
unsigned int);
                                                        break;
+                                               case LM_LONG_DOUBLE:
+                                                       goto fmt_error;
                                                case LM_LONG:
                                                        i_num = (wide_int) va_arg(ap, 
unsigned long int);
                                                        break;
@@ -376,6 +385,8 @@
                                                        default:
                                                                i_num = (wide_int) 
va_arg(ap, int);
                                                                break;
+                                                       case LM_LONG_DOUBLE:
+                                                               goto fmt_error;
                                                        case LM_LONG:
                                                                i_num = (wide_int) 
va_arg(ap, long int);
                                                                break;
@@ -423,6 +434,8 @@
                                                default:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned int);
                                                        break;
+                                               case LM_LONG_DOUBLE:
+                                                       goto fmt_error;
                                                case LM_LONG:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned long int);
                                                        break;
@@ -461,6 +474,8 @@
                                                default:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned int);
                                                        break;
+                                               case LM_LONG_DOUBLE:
+                                                       goto fmt_error;
                                                case LM_LONG:
                                                        ui_num = (u_wide_int) 
va_arg(ap, unsigned long int);
                                                        break;
@@ -511,7 +526,16 @@
                                case 'f':
                                case 'e':
                                case 'E':
-                                       fp_num = va_arg(ap, double);
+                                       switch(modifier) {
+                                               case LM_LONG_DOUBLE:
+                                                       fp_num = (double) va_arg(ap, 
long double);
+                                                       break;
+                                               case LM_STD:
+                                                       fp_num = va_arg(ap, double);
+                                                       break;
+                                               default:
+                                                       goto fmt_error;
+                                       }
 
                                        if (zend_isnan(fp_num)) {
                                                s = "nan";
@@ -535,6 +559,16 @@
 
                                case 'g':
                                case 'G':
+                                       switch(modifier) {
+                                               case LM_LONG_DOUBLE:
+                                                       fp_num = (double) va_arg(ap, 
long double);
+                                                       break;
+                                               case LM_STD:
+                                                       fp_num = va_arg(ap, double);
+                                                       break;
+                                               default:
+                                                       goto fmt_error;
+                                       }
                                        if (adjust_precision == NO)
                                                precision = FLOAT_DIGITS;
                                        else if (precision == 0)
@@ -542,7 +576,7 @@
                                        /*
                                         * * We use &num_buf[ 1 ], so that we have 
room for the sign
                                         */
-                                       s = ap_php_gcvt(va_arg(ap, double), precision, 
&num_buf[1],
+                                       s = ap_php_gcvt(fp_num, precision, &num_buf[1],
                                                        alternate_form);
                                        if (*s == '-')
                                                prefix_char = *s++;
@@ -614,6 +648,8 @@
                                        continue;
 
 
+fmt_error:
+                               php_error(E_ERROR, "Illegal length modifier specified 
'%c' in s[np]printf call", *fmt);
                                        /*
                                         * The default case is for unrecognized %'s.
                                         * We print %<char> to help the user identify 
what

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to