<< Back to previous view

[CLJ-924] Error reporting of invalid digit in unicode character literal Created: 05/Feb/12  Updated: 23/Mar/12  Resolved: 23/Mar/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.2, Release 1.3
Fix Version/s: Release 1.4

Type: Defect Priority: Minor
Reporter: Cosmin Stejerean Assignee: Unassigned
Resolution: Completed Votes: 1
Labels: None

Attachments: Text File CLJ-924-unicode-invalid-digit.patch     Text File clj-924-unicode-invalid-digit-patch2.txt    
Patch: Code
Approval: Ok

 Description   

I ran across the following code when reading unicode character literals in readUnicodeChar(String token, int offset, int length, int base)

 
int d = Character.digit(token.charAt(i), base);
if(d == -1)
    throw new IllegalArgumentException("Invalid digit: " + (char) d);

Casting -1 to a char doesn't seem to produce anything useful. I'm guessing the appropriate code might look like

 
int d = Character.digit(token.charAt(i), base);
if(d == -1)
    throw new IllegalArgumentException("Invalid digit: " + token.charAt(i));

For comparison, the code in the other readUnicodeCharacter used when reading strings handles this correctly with:

int d = Character.digit(ch, base);
if(d == -1)
    throw new IllegalArgumentException("Invalid digit: " + (char) ch); 


 Comments   
Comment by Cosmin Stejerean [ 05/Feb/12 1:09 AM ]

Attached a patch with the minor code fix.

Comment by Stuart Sierra [ 24/Feb/12 3:00 PM ]

Screened. I can't demonstrate this code being called by the reader, but it seems to be correct.

Comment by Andy Fingerhut [ 27/Feb/12 10:08 PM ]

Sorry to disturb things after this has been screened, but clj-924-unicode-invalid-digit-patch2.txt has some added tests that cause the problem to occur, as well as one other similar one nearby in LispReader.java, which is also fixed, in addition to Cosmin's fix.

Generated at Wed Apr 23 17:36:50 CDT 2014 using JIRA 4.4#649-r158309.