Permalink
Browse files

Fixed bug #843: Text output depends on php locale.

  • Loading branch information...
1 parent d0f753e commit 6c72559be41eeec065f5ff858e15d49236526fe7 @derickr derickr committed May 28, 2012
Showing with 44 additions and 1 deletion.
  1. +34 −0 tests/bug00843.phpt
  2. +6 −0 xdebug_str.c
  3. +4 −1 xdebug_tracing.c
View
@@ -0,0 +1,34 @@
+--TEST--
+Test for bug #843: Text output depends on php locale.
+--SKIPIF--
+<?php if (false == setlocale(LC_ALL, "de_DE.UTF-8", "de_DE", "de", "german", "ge", "de_DE.ISO-8859-1")) print "skip locale with , not found"; ?>
+--INI--
+xdebug.enable=1
+xdebug.auto_trace=0
+xdebug.collect_params=3
+xdebug.collect_return=0
+xdebug.collect_assignments=0
+xdebug.auto_profile=0
+xdebug.profiler_enable=0
+xdebug.show_mem_delta=0
+xdebug.trace_format=1
+--FILE--
+<?php
+$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE));
+
+setlocale(LC_ALL, "ro_RO.UTF-8", "de_DE.UTF-8", "de_DE", "de", "german", "ge", "de_DE.ISO-8859-1");
+
+xdebug_stop_trace();
+echo file_get_contents($tf);
+unlink($tf);
+?>
+--EXPECTF--
+Version: 2.%s
+File format: 2
+TRACE START [%d-%d-%d %d:%d:%d]
+2 2 1 %d.%d %d
+2 3 0 %d.%d %d setlocale 0 %sbug00843.php 4 2 6 'ro_RO.UTF-8'
+2 3 1 %d.%d %d
+2 4 0 %d.%d %d xdebug_stop_trace 0 %sbug00843.php 6 0
+ %d.%d %d
+TRACE END [%d-%d-%d %d:%d:%d]
View
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
#include "php.h"
#include "ext/standard/php_string.h"
@@ -85,7 +86,10 @@ char *xdebug_sprintf(const char* fmt, ...)
char *new_str;
int size = 1;
va_list args;
+ char *orig_locale;
+ orig_locale = xdstrdup(setlocale(LC_ALL, NULL));
+ setlocale(LC_ALL, "C");
new_str = (char *) xdmalloc(size);
for (;;) {
@@ -105,6 +109,8 @@ char *xdebug_sprintf(const char* fmt, ...)
}
new_str = (char *) xdrealloc(new_str, size);
}
+ setlocale(LC_ALL, orig_locale);
+ xdfree(orig_locale);
return new_str;
}
View
@@ -442,12 +442,15 @@ void xdebug_stop_trace(TSRMLS_D)
{
char *str_time;
double u_time;
+ char *tmp;
XG(do_trace) = 0;
if (XG(trace_file)) {
if (XG(trace_format) == 0 || XG(trace_format) == 1) {
u_time = xdebug_get_utime();
- fprintf(XG(trace_file), XG(trace_format) == 0 ? "%10.4f " : "\t\t\t%f\t", u_time - XG(start_time));
+ tmp = xdebug_sprintf(XG(trace_format) == 0 ? "%10.4f " : "\t\t\t%f\t", u_time - XG(start_time));
+ fprintf(XG(trace_file), tmp);
+ xdfree(tmp);
#if HAVE_PHP_MEMORY_USAGE
fprintf(XG(trace_file), XG(trace_format) == 0 ? "%10zu" : "%lu", XG_MEMORY_USAGE());
#else

0 comments on commit 6c72559

Please sign in to comment.