Skip to content

Commit 88b2285

Browse files
committed
fix sprintf WIP - error handling
1 parent 0e4a41e commit 88b2285

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ public static RuntimeScalar printf(RuntimeList runtimeList, RuntimeScalar fileHa
271271
} catch (PerlCompilerException e) {
272272
// Change sprintf error messages to printf
273273
String message = e.getMessage();
274-
if (message != null && message.contains("Integer overflow in format string for sprintf")) {
275-
throw new PerlCompilerException("Integer overflow in format string for printf");
274+
if (message != null && message.contains("Integer overflow in format string for sprintf ")) {
275+
throw new PerlCompilerException("Integer overflow in format string for printf ");
276276
}
277277
// Re-throw other exceptions unchanged
278278
throw e;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static RuntimeScalar sprintf(RuntimeScalar runtimeScalar, RuntimeList lis
6868
// Check for impractically large width/precision values
6969
(spec.width != null && spec.width > MAX_PRACTICAL_FORMAT_SIZE) ||
7070
(spec.precision != null && spec.precision > MAX_PRACTICAL_FORMAT_SIZE)) {
71-
throw new PerlCompilerException("Integer overflow in format string for sprintf");
71+
throw new PerlCompilerException("Integer overflow in format string for sprintf ");
7272
}
7373

7474
// Check if this is an overlapping specifier (warning only, no output)
@@ -464,7 +464,7 @@ private static FormatArguments extractFormatArguments(
464464
}
465465
// Check for potential overflow from large positive or negative values
466466
if (args.width > 999999999) {
467-
throw new PerlCompilerException("Integer overflow in format string for sprintf");
467+
throw new PerlCompilerException("Integer overflow in format string for sprintf ");
468468
}
469469
} else {
470470
WarnDie.warn(new RuntimeScalar("Missing argument in sprintf"),

0 commit comments

Comments
 (0)