Summary: | AST: StringLitteral doesn't manage correctly octal escape sequence | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Luc Bourlier <eclipse> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | ||||||
Version: | 2.1 | ||||||
Target Milestone: | 2.1 RC2 | ||||||
Hardware: | PC | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Bug Depends on: | |||||||
Bug Blocks: | 32894 | ||||||
Attachments: |
|
Description
Luc Bourlier
2003-02-27 11:40:59 EST
Created attachment 3751 [details]
StringLiteral.java
a corrected version of StringLiteral
I prefer this code. It simplifies quite a bit the existing code. public String getLiteralValue() { String s = getEscapedValue(); int len = s.length(); if (len < 2 || s.charAt(0) != '\"' || s.charAt(len-1) != '\"' ) { throw new IllegalArgumentException(); } Scanner scanner = getAST().scanner; char[] source = s.toCharArray(); scanner.setSource(source); scanner.resetTo(0, source.length); try { int tokenType = scanner.getNextToken(); switch(tokenType) { case Scanner.TokenNameStringLiteral: return new String(scanner.getCurrentTokenSourceString()); default: throw new IllegalArgumentException(); } } catch(InvalidInputException e) { throw new IllegalArgumentException(); } } Could you please confirm it works in your workspace? I added regression tests on the ASTConverter tests and they are all green. Works like a charm. Ok for releasing Fixed and released in 2.1 stream. Regression test added. Verified by Luc. |