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

ruby-changes:34577

From: nobu <ko1@a...>
Date: Wed, 2 Jul 2014 17:04:09 +0900 (JST)
Subject: [ruby-changes:34577] nobu:r46657 (trunk): sprintf.c: check_next_arg

nobu	2014-07-02 17:03:51 +0900 (Wed, 02 Jul 2014)

  New Revision: 46657

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46657

  Log:
    sprintf.c: check_next_arg
    
    * sprintf.c (check_next_arg): utility function for GETNEXTARG().

  Modified files:
    trunk/sprintf.c
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 46656)
+++ sprintf.c	(revision 46657)
@@ -82,10 +82,7 @@ sign_bits(int base, const char *p) https://github.com/ruby/ruby/blob/trunk/sprintf.c#L82
 		  GETNEXTARG())
 
 #define GETNEXTARG() ( \
-    posarg == -1 ? \
-    (rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
-    posarg == -2 ? \
-    (rb_raise(rb_eArgError, "unnumbered(%d) mixed with named", nextarg), 0) : \
+    check_next_arg(posarg, nextarg), \
     (posarg = nextarg++, GETNTHARG(posarg)))
 
 #define GETPOSARG(n) (posarg > 0 ? \
@@ -142,6 +139,17 @@ get_num(const char *p, const char *end, https://github.com/ruby/ruby/blob/trunk/sprintf.c#L139
     return p;
 }
 
+static void
+check_next_arg(int posarg, int nextarg)
+{
+    switch (posarg) {
+      case -1:
+	rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg);
+      case -2:
+	rb_raise(rb_eArgError, "unnumbered(%d) mixed with named", nextarg);
+    }
+}
+
 static VALUE
 get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
 {

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

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