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

ruby-changes:43084

From: nobu <ko1@a...>
Date: Wed, 25 May 2016 17:11:42 +0900 (JST)
Subject: [ruby-changes:43084] nobu:r55158 (trunk): ruby.h: rb_scan_args_validate

nobu	2016-05-25 17:11:36 +0900 (Wed, 25 May 2016)

  New Revision: 55158

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

  Log:
    ruby.h: rb_scan_args_validate
    
    * include/ruby/ruby.h (rb_scan_args_validate): move failed
      condition to the terminal.  [ruby-core:75714] [Bug #12426]

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/ruby.h
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 55157)
+++ include/ruby/ruby.h	(revision 55158)
@@ -2160,8 +2160,8 @@ ERRORFUNC(("bad scan arg format"), int r https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2160
 ERRORFUNC(("variable argument length doesn't match"), int rb_scan_args_length_mismatch(int,int));
 # else
 #   define rb_scan_args_bad_format(fmt) 0
-#   define rb_scan_args_length_mismatch(vari,varc) 0
-#endif
+#   define rb_scan_args_length_mismatch(vari, varc) 0
+# endif
 
 # define rb_scan_args_isdigit(c) ((unsigned char)((c)-'0')<10)
 
@@ -2217,12 +2217,35 @@ ERRORFUNC(("variable argument length doe https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2217
 # define rb_scan_args_f_block(fmt) ((fmt)[rb_scan_args_block_idx(fmt)]=='&')
 # define rb_scan_args_end_idx(fmt) \
     (rb_scan_args_block_idx(fmt)+rb_scan_args_f_block(fmt))
-# define rb_scan_args_valid_p(fmt) (!(fmt)[rb_scan_args_end_idx(fmt)])
+
+# define rb_scan_args_validate(fmt, varc) \
+    (!rb_scan_args_isdigit((fmt)[0]) ? \
+     rb_scan_args_validate_var(fmt, 0, varc) : \
+     !rb_scan_args_isdigit((fmt)[1]) ? \
+     rb_scan_args_validate_var(fmt, 1, (varc-(fmt)[0]+'0')) : \
+     rb_scan_args_validate_var(fmt, 2, (varc-(fmt)[0]+'0'-(fmt)[1]+'0')))
+# define rb_scan_args_validate_var(fmt, ofs, varc) \
+    ((fmt)[ofs]=='*' ? \
+     rb_scan_args_validate_trail(fmt, ofs+1, (varc-1)) : \
+     rb_scan_args_validate_trail(fmt, ofs, varc))
+# define rb_scan_args_validate_trail(fmt, ofs, varc) \
+    (rb_scan_args_isdigit((fmt)[ofs]) ? \
+     rb_scan_args_validate_hash(fmt, ofs+1, (varc-1)) : \
+     rb_scan_args_validate_hash(fmt, ofs, varc))
+# define rb_scan_args_validate_hash(fmt, ofs, varc) \
+    ((fmt)[ofs]==':' ? \
+     rb_scan_args_validate_block(fmt, ofs+1, (varc-1)) : \
+     rb_scan_args_validate_block(fmt, ofs, varc))
+# define rb_scan_args_validate_block(fmt, ofs, varc) \
+    ((fmt)[ofs]=='&' ? \
+     rb_scan_args_validate_end(fmt, ofs+1, (varc-1)) : \
+     rb_scan_args_validate_end(fmt, ofs, varc))
+# define rb_scan_args_validate_end(fmt, ofs, varc) \
+    ((fmt)[ofs]?rb_scan_args_bad_format(fmt):!(varc))
 
 # define rb_scan_args_verify(fmt, varc) \
-    (((varc)\
-      /(rb_scan_args_valid_p(fmt)||rb_scan_args_bad_format(fmt))) \
-     /(((varc)==rb_scan_args_count(fmt))|| \
+    ((varc)\
+     /(rb_scan_args_validate(fmt, varc)|| \
        rb_scan_args_length_mismatch((varc), rb_scan_args_count(fmt))))
 
 # define rb_scan_args0(argc, argv, fmt, varc, vars) \
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55157)
+++ ChangeLog	(revision 55158)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed May 25 17:11:34 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* include/ruby/ruby.h (rb_scan_args_validate): move failed
+	  condition to the terminal.  [ruby-core:75714] [Bug #12426]
+
 Wed May 25 13:13:37 2016  NARUSE, Yui  <naruse@r...>
 
 	* regcomp.c: remove condition for debug output because prelude

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

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