allow '!' after 'S' specifier of mrb_get_args() that allow nil.

thus "S!" means String|nil type. you have to check nil before
dereferencing the value.  this is added to address #2882 while
keeping code simplicity. besides that current #2882 fix lose
polymorphism provided by mrb_get_args().
parent 9c311ddc
......@@ -435,7 +435,7 @@ to_sym(mrb_state *mrb, mrb_value ss)
----------------------------------------------------------------------------------------------
o: Object [mrb_value]
C: class/module [mrb_value]
S: String [mrb_value]
S: String [mrb_value] when ! follows the value may be nil
A: Array [mrb_value]
H: Hash [mrb_value]
s: String [char*,mrb_int] Receive two arguments.
......@@ -525,6 +525,14 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
mrb_value *p;
p = va_arg(ap, mrb_value*);
if (*format == '!') {
format++;
if (mrb_nil_p(*sp)) {
*p = *sp++;
i++;
break;
}
}
if (i < argc) {
*p = to_str(mrb, *sp++);
i++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment