[前][次][番号順一覧][スレッド一覧]

ruby-changes:3768

From: ko1@a...
Date: Sat, 26 Jan 2008 23:46:48 +0900 (JST)
Subject: [ruby-changes:3768] nobu - Ruby:r15257 (trunk): * sprintf.c (rb_str_format): zero-precision zero should be empty.

nobu	2008-01-26 23:46:36 +0900 (Sat, 26 Jan 2008)

  New Revision: 15257

  Modified files:
    trunk/ChangeLog
    trunk/sprintf.c

  Log:
    * sprintf.c (rb_str_format): zero-precision zero should be empty.
      [ruby-dev:33363]
    
    * sprintf.c (rb_str_format): not prepend octal prefix to negative or
      zero value.  [ruby-dev:33363], [ruby-dev:33367]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15257&r2=15256&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/sprintf.c?r1=15257&r2=15256&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15256)
+++ ChangeLog	(revision 15257)
@@ -1,3 +1,11 @@
+Sat Jan 26 23:46:33 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* sprintf.c (rb_str_format): zero-precision zero should be empty.
+	  [ruby-dev:33363]
+
+	* sprintf.c (rb_str_format): not prepend octal prefix to negative or
+	  zero value.  [ruby-dev:33363], [ruby-dev:33367]
+
 Sat Jan 26 23:42:15 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (assignable_gen, keyword_to_name): __ENCODING__ was missing.
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 15256)
+++ sprintf.c	(revision 15257)
@@ -692,7 +692,10 @@
 		    width = 0;
 		}
 		else {
-		    if (prec < len) prec = len;
+		    if (prec < len) {
+			if ((flags & FPREC) && len == 1 && *s == '0') len = 0;
+			else prec = len;
+		    }
 		    width -= prec;
 		}
 		if (!(flags&FMINUS)) {
@@ -702,15 +705,12 @@
 		    }
 		}
 		if (sc) PUSH(&sc, 1);
-		if (prefix) {
+		if (prefix && (prefix[1] || !(dots || (len && s[0] == '0')))) {
 		    int plen = strlen(prefix);
 		    PUSH(prefix, plen);
 		}
 		CHECK(prec - len);
-		if (dots) {
-		    memcpy(&buf[blen], "..", 2);
-		    blen += 2;
-		}
+		if (dots) PUSH("..", 2);
 		if (!bignum && v < 0) {
 		    char c = sign_bits(base, p);
 		    while (len < prec--) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]