Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@ public List<SprintfConfig> parse() {
ArgType argType = ArgType.NONE;

final int end = source.length;
int argumentIndex = 0;

for (int i = 0; i < end; ) {

@@ -132,7 +131,7 @@ public List<SprintfConfig> parse() {
config.setNamesBytes(charsToBytes(nameBytes));
i = j + 1;
checkNameArg(argType, nameBytes);
checkHash(arguments, argumentIndex);
checkHash(arguments);
argType = ArgType.NAMED;
argTypeSet = true;
if (term == '}') {
@@ -255,14 +254,13 @@ public List<SprintfConfig> parse() {
throw new InvalidFormatException("malformed format string - %" + p);
}
}
argumentIndex += 1;
}
return configs;
}

private static void checkHash(Object[] arguments, int argumentIndex) {
if(argumentIndex >= arguments.length ||
!RubyGuards.isRubyHash(arguments[argumentIndex])) {
private static void checkHash(Object[] arguments) {
if(arguments.length != 1 ||
!RubyGuards.isRubyHash(arguments[0])) {
throw new InvalidFormatException("one hash required");
}
}

0 comments on commit 5ac33ad

Please sign in to comment.