Fix for format strings like "%2.f".
authorBruno Haible <bruno@clisp.org>
Mon, 17 May 2004 11:27:08 +0000 (11:27 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 17 May 2004 11:27:08 +0000 (11:27 +0000)
lib/ChangeLog
lib/vasnprintf.c

index 23d45e39b22dfeea0cf0210809d43ff6618477f0..c784c8b080d928a3ce31d937bd4d03f4f1f36f17 100644 (file)
@@ -1,3 +1,9 @@
+2004-05-14  Bruno Haible  <bruno@clisp.org>
+
+       * vasnprintf.c (VASNPRINTF): Correctly handle the case of a precision
+       that consists of a '.' followed by an empty digit string.
+       Patch by Tor Lillqvist <tml@iki.fi>.
+
 2004-05-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        Port obstack to the AS/400, where pointers are 16 bytes wide and
index c0754ead9a3ecee7668ef3180f5e8dd743a3dc22..0fa24708fe80aa96212f25c60d633106a4b2bd68 100644 (file)
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2004 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -315,9 +315,8 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                          const CHAR_T *digitp = dp->precision_start + 1;
 
                          precision = 0;
-                         do
+                         while (digitp != dp->precision_end)
                            precision = xsum (xtimes (precision, 10), *digitp++ - '0');
-                         while (digitp != dp->precision_end);
                        }
                    }