Package: bash
Version: 4.3-2
Severity: normal
Tags: patch

Built-in function time doesn't use locale's decimal separator

$ time sleep 1s

real    0m1.001s
user    0m0.000s
sys     0m0.000s

But for the Russian locale (ru_RU.UTF-8) it should use ',' as decimal separator
instead of '.'

$ LC_ALL=ru_RU.UTF-8 locale decimal_point
,

So output should be

real    0m1,001s
user    0m0,000s
sys     0m0,000s

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 3.12-1-686-pae (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages bash depends on:
ii  base-files   7.2
ii  dash         0.5.7-4
ii  debianutils  4.4
ii  libc6        2.18-1
ii  libtinfo5    5.9+20140118-1

Versions of packages bash recommends:
pn  bash-completion  <none>

Versions of packages bash suggests:
pn  bash-doc  <none>

-- no debconf information
Index: bash-4.3/execute_cmd.c
===================================================================
--- bash-4.3.orig/execute_cmd.c	2014-03-15 22:21:13.586568694 +0300
+++ bash-4.3/execute_cmd.c	2014-03-15 23:12:55.354513579 +0300
@@ -98,6 +98,10 @@
 #  include "bashhist.h"
 #endif
 
+#if defined (HAVE_LANGINFO_RADIXCHAR)
+#   include <langinfo.h>
+#endif
+
 extern int dollar_dollar_pid;
 extern int posixly_correct;
 extern int expand_aliases;
@@ -1125,7 +1129,11 @@
      and 999. */
   if (prec != 0)
     {
+#if defined (HAVE_LANGINFO_RADIXCHAR)
+      buf[ind++] = *nl_langinfo(RADIXCHAR);
+#else
       buf[ind++] = '.';
+#endif
       for (aind = 1; aind <= prec; aind++)
 	{
 	  buf[ind++] = (sec_fraction / precs[aind]) + '0';
Index: bash-4.3/aclocal.m4
===================================================================
--- bash-4.3.orig/aclocal.m4	2013-10-21 01:37:50.000000000 +0300
+++ bash-4.3/aclocal.m4	2014-03-15 23:12:24.978514119 +0300
@@ -1725,6 +1725,15 @@
   AC_DEFINE(HAVE_LANGINFO_CODESET)
 fi
 
+AC_CACHE_CHECK([for nl_langinfo and RADIXCHAR], bash_cv_langinfo_radixchar,
+[AC_TRY_LINK(
+[#include <langinfo.h>],
+[char* rc = nl_langinfo(RADIXCHAR);],
+bash_cv_langinfo_radixchar=yes, bash_cv_langinfo_radixchar=no)])
+if test $bash_cv_langinfo_radixchar = yes; then
+  AC_DEFINE(HAVE_LANGINFO_RADIXCHAR)
+fi
+
 dnl check for wchar_t in <wchar.h>
 AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t,
 [AC_TRY_COMPILE(
Index: bash-4.3/config.h.in
===================================================================
--- bash-4.3.orig/config.h.in	2013-06-30 00:35:33.000000000 +0300
+++ bash-4.3/config.h.in	2014-03-15 23:12:21.902514173 +0300
@@ -508,6 +508,9 @@
 /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
 #undef HAVE_LANGINFO_CODESET
 
+/* Define if you have <langinfo.h> and nl_langinfo(RADIXCHAR). */
+#undef HAVE_LANGINFO_RADIXCHAR
+
 /* Characteristics of properties exported by the kernel. */
 
 /* Define if the kernel can exec files beginning with #! */

Reply via email to