summaryrefslogtreecommitdiff
path: root/libguile/i18n.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-02-24 23:17:06 +0100
committerLudovic Courtès <ludo@gnu.org>2011-02-24 23:17:06 +0100
commit914c4300b2e6857152363529706799ae692bc2a4 (patch)
treeac8a9ab74fdfc840373989c89d797bcf80349840 /libguile/i18n.c
parentcfad56a4449011e34aa917136cb6844ef453edcc (diff)
downloadguile-914c4300b2e6857152363529706799ae692bc2a4.tar.gz
Make `locale-digit-grouping' more robust.
* libguile/i18n.c (scm_nl_langinfo)[GROUPING]: Consider negative numbers like `CHAR_MAX'. Reported by David Fang <fang@csl.cornell.edu>. Fix suggested by Bruno Haible <bruno@clisp.org>.
Diffstat (limited to 'libguile/i18n.c')
-rw-r--r--libguile/i18n.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libguile/i18n.c b/libguile/i18n.c
index 14dc9b985..c51df4a2c 100644
--- a/libguile/i18n.c
+++ b/libguile/i18n.c
@@ -1564,11 +1564,14 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
{
char *p;
- /* In this cases, the result is to be interpreted as a list of
- numbers. If the last item is `CHARS_MAX', it has the special
- meaning "no more grouping". */
+ /* In this cases, the result is to be interpreted as a list
+ of numbers. If the last item is `CHAR_MAX' or a negative
+ number, it has the special meaning "no more grouping"
+ (negative numbers aren't specified in POSIX but can be
+ used by glibc; see
+ <http://lists.gnu.org/archive/html/bug-guile/2011-02/msg00159.html>). */
result = SCM_EOL;
- for (p = c_result; (*p != '\0') && (*p != CHAR_MAX); p++)
+ for (p = c_result; (*p > 0) && (*p != CHAR_MAX); p++)
result = scm_cons (SCM_I_MAKINUM ((int) *p), result);
{
@@ -1576,7 +1579,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
result = scm_reverse_x (result, SCM_EOL);
- if (*p != CHAR_MAX)
+ if (*p == 0)
{
/* Cyclic grouping information. */
if (last_pair != SCM_EOL)