|
18 | 18 | import cpp |
19 | 19 | import codingstandards.cpp.autosar |
20 | 20 |
|
21 | | -bindingset[s] |
22 | | -string getCharOutsideBasicSourceCharSet(string s) { |
23 | | - result = s.regexpFind("[\\u0000-\\u007f]", _, _) and |
24 | | - not result.regexpMatch("[\\p{Alnum}\\p{Space}_{}\\[\\]#()<>%:;.?*+-/^&|~!=,\\\\\"'@]") |
25 | | - or |
26 | | - result = s.regexpFind("[\\u00c0-\\u00df][\\u0080-\\u00bf]", _, _) |
27 | | - or |
28 | | - result = s.regexpFind("[\\u00e0-\\u00ef][\\u0080-\\u00bf]{2}", _, _) |
29 | | - or |
30 | | - result = s.regexpFind("[\\u00f0-\\u00f7][\\u0080-\\u00bf]{3}", _, _) |
| 21 | +string getCharOutsideBasicSourceCharSet(Comment c) { |
| 22 | + exists(string s | s = c.getContents() | |
| 23 | + result = |
| 24 | + s.regexpFind("(?![\\p{Alnum}\\p{Space}_{}\\[\\]#()<>%:;.?*+-/^&|~!=,\\\\\"'@])[\\u0000-\\u007f]", |
| 25 | + _, _) |
| 26 | + or |
| 27 | + result = s.regexpFind("[\\u00c0-\\u00df][\\u0080-\\u00bf]", _, _) |
| 28 | + or |
| 29 | + result = s.regexpFind("[\\u00e0-\\u00ef][\\u0080-\\u00bf]{2}", _, _) |
| 30 | + or |
| 31 | + result = s.regexpFind("[\\u00f0-\\u00f7][\\u0080-\\u00bf]{3}", _, _) |
| 32 | + ) |
31 | 33 | } |
32 | 34 |
|
33 | 35 | from Comment c, string ch |
34 | 36 | where |
35 | 37 | not isExcluded(c, NamingPackage::invalidCharacterInCommentQuery()) and |
36 | | - ch = getCharOutsideBasicSourceCharSet(c.getContents()) |
| 38 | + ch = getCharOutsideBasicSourceCharSet(c) |
37 | 39 | select c, |
38 | 40 | "Comment uses the character '" + ch + "' that is outside the language basic character set." |
0 commit comments