Skip to content

Commit 2fdec44

Browse files
committed
fix pack() WIP
1 parent 103a5fb commit 2fdec44

File tree

1 file changed

+6
-1
lines changed
  • src/main/java/org/perlonjava/operators

1 file changed

+6
-1
lines changed

src/main/java/org/perlonjava/operators/Pack.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,13 @@ public static RuntimeScalar pack(RuntimeList args) {
318318
// Need to look back, skipping any modifiers and repeat counts
319319
int numericPos = i - 1;
320320

321+
// Skip back over whitespace FIRST
322+
while (numericPos >= 0 && Character.isWhitespace(template.charAt(numericPos))) {
323+
numericPos--;
324+
}
325+
321326
// Skip back over repeat counts and '*'
322-
if (numericPos > 0 && (template.charAt(numericPos) == '*' || Character.isDigit(template.charAt(numericPos)))) {
327+
if (numericPos >= 0 && (template.charAt(numericPos) == '*' || Character.isDigit(template.charAt(numericPos)))) {
323328
if (template.charAt(numericPos) == '*') {
324329
// Skip the '*' to get to the format
325330
numericPos--;

0 commit comments

Comments
 (0)