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

ruby-changes:3792

From: ko1@a...
Date: Sun, 27 Jan 2008 23:33:53 +0900 (JST)
Subject: [ruby-changes:3792] nobu - Ruby:r15281 (trunk): * sprintf.c (rb_str_format): fix for left justify flag.

nobu	2008-01-27 23:33:37 +0900 (Sun, 27 Jan 2008)

  New Revision: 15281

  Modified files:
    trunk/ChangeLog
    trunk/sprintf.c

  Log:
    * sprintf.c (rb_str_format): fix for left justify flag.
    
    * sprintf.c (rb_str_format): zero-precision zero bug revised.
      [ruby-dev:33419]


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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15280)
+++ ChangeLog	(revision 15281)
@@ -1,3 +1,10 @@
+Sun Jan 27 23:33:35 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* sprintf.c (rb_str_format): fix for left justify flag.
+
+	* sprintf.c (rb_str_format): zero-precision zero bug revised.
+	  [ruby-dev:33419]
+
 Sun Jan 27 23:20:54 2008  Tanaka Akira  <akr@f...>
 
 	* include/ruby/oniguruma.h: precise mbclen API redesigned to avoid
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 15280)
+++ sprintf.c	(revision 15281)
@@ -699,12 +699,15 @@
 		if (prefix) {
 		    width -= strlen(prefix);
 		}
-		if ((flags&(FZERO|FPREC)) == FZERO) {
+		if ((flags & (FZERO|FMINUS|FPREC)) == FZERO) {
 		    prec = width;
 		    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)) {
@@ -726,7 +729,7 @@
 			buf[blen++] = c;
 		    }
 		}
-		else {
+		else if ((flags & (FMINUS|FPREC)) != FMINUS) {
 		    char c;
 
 		    if (!sign && bignum && !RBIGNUM_SIGN(val))

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

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