Skip to content

Commit 60bbcd7

Browse files
committed
Exclude sprintf failure and indicate macro areas to be fixed.
1 parent 80e475f commit 60bbcd7

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

core/src/main/java/org/jruby/util/Sprintf.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,12 @@ private static boolean rubySprintfToBuffer(ByteList buf, CharSequence charFormat
374374
// MRI doesn't flag it as an error if width is given multiple
375375
// times as a number (but it does for *)
376376
number = 0;
377-
for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {
378-
number = extendWidth(args, number, fchar);
377+
{ // MRI: GETNUM macro
378+
for (; offset < length && isDigit(fchar = format[offset]); offset++) {
379+
number = extendWidth(args, number, fchar);
380+
}
381+
checkOffset(args, offset, length, ERR_MALFORMED_NUM);
379382
}
380-
checkOffset(args,offset,length,ERR_MALFORMED_NUM);
381383
if (fchar == '$') {
382384
if (arg != null) {
383385
raiseArgumentError(args,"value given twice - " + number + "$");
@@ -434,10 +436,12 @@ private static boolean rubySprintfToBuffer(ByteList buf, CharSequence charFormat
434436
checkOffset(args,++offset,length,ERR_MALFORMED_STAR_NUM);
435437
mark = offset;
436438
number = 0;
437-
for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {
438-
number = extendWidth(args,number,fchar);
439+
{ // MRI: GETNUM macro
440+
for (; offset < length && isDigit(fchar = format[offset]); offset++) {
441+
number = extendWidth(args, number, fchar);
442+
}
443+
checkOffset(args, offset, length, ERR_MALFORMED_STAR_NUM);
439444
}
440-
checkOffset(args,offset,length,ERR_MALFORMED_STAR_NUM);
441445
if (fchar == '$') {
442446
precision = args.getNthInt(number);
443447
if (precision < 0) {

test/mri/excludes/TestSprintf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
exclude :test_named_untyped, "needs investigation"
99
exclude :test_named_untyped_enc, "needs investigation"
1010
exclude :test_nan, "needs investigation"
11+
exclude :test_star, "differing error message somewhere deep in GETNUM macro from MRI and our equivalents"

0 commit comments

Comments
 (0)