cvs: php4 /ext/standard formatted_print.c

From: Date: Mon, 17 Jun 2002 11:50:37 +0000
Subject: cvs: php4 /ext/standard formatted_print.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12386@lists.php.net to get a copy of this message
hholzgra Mon Jun 17 07:50:37 2002 EDT Modified files: /php4/ext/standard formatted_print.c Log: making printf/sprintf locale-aware without external dependencies Index: php4/ext/standard/formatted_print.c diff -u php4/ext/standard/formatted_print.c:1.49 php4/ext/standard/formatted_print.c:1.50 --- php4/ext/standard/formatted_print.c:1.49 Sun Jun 16 17:22:10 2002 +++ php4/ext/standard/formatted_print.c Mon Jun 17 07:50:25 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: formatted_print.c,v 1.49 2002/06/16 21:22:10 hholzgra Exp $ */ +/* $Id: formatted_print.c,v 1.50 2002/06/17 11:50:25 hholzgra Exp $ */ #include <math.h> /* modf() */ #include "php.h" @@ -25,6 +25,10 @@ #include "zend_execute.h" #include <stdio.h> +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif + #define ALIGN_LEFT 0 #define ALIGN_RIGHT 1 #define ADJ_WIDTH 1 @@ -274,6 +278,14 @@ char *cvt; register int i = 0, j = 0; int sign, decpt; + char decimal_point = '.'; +#ifdef HAVE_LOCALECONV + struct lconv l; + + localeconv_r(&l); + + decimal_point = l.decimal_point[0]; +#endif PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", *buffer, pos, size, number, width, padding, alignment, fmt)); @@ -308,7 +320,7 @@ numbuf[i++] = '0'; if (precision > 0) { int k = precision; - numbuf[i++] = '.'; + numbuf[i++] = decimal_point; while ((decpt++ < 0) && k--) { numbuf[i++] = '0'; } @@ -317,12 +329,12 @@ while (decpt-- > 0) numbuf[i++] = cvt[j++]; if (precision > 0) - numbuf[i++] = '.'; + numbuf[i++] = decimal_point; } } else { numbuf[i++] = cvt[j++]; if (precision > 0) - numbuf[i++] = '.'; + numbuf[i++] = decimal_point; } while (cvt[j]) {

« previous php.cvs (#12386) next »