@@ -270,8 +270,10 @@ FormatSpecifier parseSpecifier() {
270
270
271
271
spec .endPos = pos ;
272
272
spec .raw = input .substring (spec .startPos , spec .endPos );
273
- // // ADD THIS DEBUG LINE:
274
- // System.err.println("DEBUG: spec.raw='" + spec.raw + "', vectorFlag=" + spec.vectorFlag + ", widthFromArg=" + spec.widthFromArg + ", conversionChar='" + spec.conversionChar + "'");
273
+
274
+ // Add debug here to check the state before returning
275
+ System .err .println ("DEBUG: Before return - isValid=" + spec .isValid +
276
+ ", errorMessage='" + spec .errorMessage + "'" );
275
277
276
278
// Mark as invalid if we found spaces in the format
277
279
if (hasInvalidSpace ) {
@@ -282,6 +284,10 @@ FormatSpecifier parseSpecifier() {
282
284
validateSpecifier (spec );
283
285
}
284
286
287
+ // Add debug after validation
288
+ System .err .println ("DEBUG: After validation - isValid=" + spec .isValid +
289
+ ", errorMessage='" + spec .errorMessage + "'" );
290
+
285
291
return spec ;
286
292
}
287
293
@@ -297,8 +303,9 @@ Integer parseNumber() {
297
303
}
298
304
299
305
void validateSpecifier (FormatSpecifier spec ) {
300
- // // ADD THIS DEBUG LINE:
301
- // System.err.println("DEBUG: Validating spec: raw='" + spec.raw + "', vectorFlag=" + spec.vectorFlag + ", widthFromArg=" + spec.widthFromArg);
306
+ System .err .println ("DEBUG validateSpecifier: raw='" + spec .raw +
307
+ "', vectorFlag=" + spec .vectorFlag +
308
+ ", conversionChar='" + spec .conversionChar + "'" );
302
309
// Special case: %*v formats are valid
303
310
if (spec .vectorFlag && spec .widthFromArg ) {
304
311
// This is a valid vector format with custom separator
@@ -313,11 +320,14 @@ void validateSpecifier(FormatSpecifier spec) {
313
320
return ;
314
321
}
315
322
316
- // Check for vector formats BEFORE other validations
323
+ // Check for vector formats FIRST (before %n check)
317
324
if (spec .vectorFlag ) {
318
325
// Vector flag is only valid with certain conversions
319
326
String validVectorConversions = "diouxXbBs" ;
327
+ System .err .println ("DEBUG: Checking vector conversion '" + spec .conversionChar +
328
+ "' in '" + validVectorConversions + "'" );
320
329
if (validVectorConversions .indexOf (spec .conversionChar ) < 0 ) {
330
+ System .err .println ("DEBUG: Setting invalid for vector format" );
321
331
spec .isValid = false ;
322
332
spec .errorMessage = "INVALID" ;
323
333
return ;
@@ -375,17 +385,6 @@ void validateSpecifier(FormatSpecifier spec) {
375
385
}
376
386
}
377
387
378
- // Validate vector flag combinations
379
- if (spec .vectorFlag ) {
380
- // Vector flag is only valid with certain conversions
381
- String validVectorConversions = "diouxXbBs" ;
382
- if (validVectorConversions .indexOf (spec .conversionChar ) < 0 ) {
383
- spec .isValid = false ;
384
- spec .errorMessage = "INVALID" ;
385
- return ;
386
- }
387
- }
388
-
389
388
// Validate flag combinations
390
389
validateFlags (spec );
391
390
0 commit comments