changeset 5295:2474dce7304e

Make sure (format "%b" 0) is non-zero length, print.c src/ChangeLog addition: 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> * print.c (ulong_to_bit_string): If printing zero, actually print a zero, don't return the empty string. tests/ChangeLog addition: 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Test format strings with %b, too.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 25 Oct 2010 13:15:53 +0100
parents bbff29a01820
children d185fa593d5f
files src/ChangeLog src/print.c tests/ChangeLog tests/automated/lisp-tests.el
diffstat 4 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Oct 25 13:04:04 2010 +0100
+++ b/src/ChangeLog	Mon Oct 25 13:15:53 2010 +0100
@@ -1,3 +1,8 @@
+2010-10-25  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* print.c (ulong_to_bit_string): If printing zero, actually print
+	a zero, don't return the empty string.
+
 2010-07-06  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* emodules.c (emodules_load):
--- a/src/print.c	Mon Oct 25 13:04:04 2010 +0100
+++ b/src/print.c	Mon Oct 25 13:15:53 2010 +0100
@@ -1339,6 +1339,12 @@
             }
         }
     }
+
+  if (!seen_high_order)
+    {
+      *p++ = '0';
+    }
+
   *p = '\0';
 }
 
--- a/tests/ChangeLog	Mon Oct 25 13:04:04 2010 +0100
+++ b/tests/ChangeLog	Mon Oct 25 13:15:53 2010 +0100
@@ -1,3 +1,8 @@
+2010-10-25  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* automated/lisp-tests.el:
+	Test format strings with %b, too.
+
 2010-06-14  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* automated/lisp-reader-tests.el:
--- a/tests/automated/lisp-tests.el	Mon Oct 25 13:04:04 2010 +0100
+++ b/tests/automated/lisp-tests.el	Mon Oct 25 13:15:53 2010 +0100
@@ -1325,8 +1325,11 @@
 ;;-----------------------------------------------------
 (Assert (string= (format "%d" 10) "10"))
 (Assert (string= (format "%o" 8) "10"))
+(Assert (string= (format "%b" 2) "10"))
 (Assert (string= (format "%x" 31) "1f"))
 (Assert (string= (format "%X" 31) "1F"))
+(Assert (string= (format "%b" 0) "0"))
+(Assert (string= (format "%b" 3) "11"))
 ;; MS-Windows uses +002 in its floating-point numbers.  #### We should
 ;; perhaps fix this, but writing our own floating-point support in doprnt.c
 ;; is very hard.