mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-sprintf: raise ArgumentError for % at the bottom
This commit is contained in:
@@ -607,7 +607,10 @@ mrb_str_format(mrb_state *mrb, mrb_int argc, const mrb_value *argv, mrb_value fm
|
||||
|
||||
for (t = p; t < end && *t != '%'; t++)
|
||||
;
|
||||
if (t + 1 == end) t++;
|
||||
if (t + 1 == end) {
|
||||
/* % at the bottom */
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "incomplete format specifier; use %% (double %) instead");
|
||||
}
|
||||
PUSH(p, t - p);
|
||||
if (t >= end)
|
||||
goto sprint_exit; /* end of fmt string */
|
||||
|
||||
@@ -90,8 +90,3 @@ assert("String#% invalid format") do
|
||||
"%?" % ""
|
||||
end
|
||||
end
|
||||
|
||||
assert("String#% invalid format shared substring") do
|
||||
fmt = ("x"*30+"%!")[0...-1]
|
||||
assert_equal fmt, sprintf(fmt, "")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user