Merge branch 'tiobe-tiobe/fix_UTF8_escape_in_OBJC_string_literals' into pmd/5.3.x

This commit is contained in:
Andreas Dangel 2016-02-24 21:53:16 +01:00
commit aab525196c
4 changed files with 48 additions and 2 deletions

View File

@ -375,8 +375,8 @@ TOKEN : {
| <FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])? | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])? | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])? | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]>
| <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
| <CHARACTER_LITERAL: "\'" (~["\'","\\","\n","\r"] | "\\" (["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"])) "\'">
| <STRING_LITERAL: [ "@" ] "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
| <CSTRING_LITERAL: "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
| <STRING_LITERAL: [ "@" ] "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X","u","U"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
| <CSTRING_LITERAL: "\"" ( ~["\"","\\","\n","\r"] | "\\" ["x","X","u","U"] (["0"-"9","a"-"f","A"-"F"]) | "\\" ( ["n","t","b","r","f","a","v","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"] | ( ["\n","\r"] | "\r\n")))* "\"">
}
TOKEN :

View File

@ -0,0 +1,37 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.IOException;
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
//Tests if the ObjectiveC tokenizer supports UTF-8 escapes in string literals
public class UTF8EscapesInStringLiteralObjCTokenizerTest extends AbstractTokenizerTest {
private static final String FILENAME = "FileWithUTF8EscapeInStringLiteral.m";
@Before
@Override
public void buildTokenizer() throws IOException {
this.tokenizer = new ObjectiveCTokenizer();
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), FILENAME));
}
@Override
public String getSampleCode() throws IOException {
return IOUtils.toString(ObjectiveCTokenizer.class.getResourceAsStream(FILENAME), "UTF-8");
}
@Test
public void tokenizeTest() throws IOException {
this.expectedTokenCount = 45;
super.tokenizeTest();
}
}

View File

@ -0,0 +1,8 @@
@property (nonatomic, strong) UIButton *copyrightsButton;
- (void)setupCopyrightsButton {
self.copyrightsButton = [[UIButton alloc] initWithFrame:CGRectZero];
[self.copyrightsButton setTitle:@"\u00a9" forState:UIControlStateNormal];
}
@end

View File

@ -19,6 +19,7 @@
* [#29](https://github.com/adangel/pmd/pull/29): Added support for files with UTF-8 BOM to JSP tokenizer.
* [#30](https://github.com/adangel/pmd/pull/30): Removed file filter for files that are explicitly specified on the CPD command line using the '--files' command line option.
* [#31](https://github.com/adangel/pmd/pull/31): Added file encoding detection to CPD.
* [#32](https://github.com/adangel/pmd/pull/32): Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals.
* [#79](https://github.com/pmd/pmd/pull/79): do not flag public static void main(String[]) as UseVarargs; ignore @Override for UseVarargs
* [#80](https://github.com/pmd/pmd/pull/80): Update mvn-plugin.md
* [#83](https://github.com/pmd/pmd/pull/83): Adds new Code Climate-compliant JSON renderer