Handle wchar_t escape sequences in syntax workaround

Bug: Issue 5930
Change-Id: I10433c748f0e07ee463a138e73d6a689a23609d4
This commit is contained in:
Wyatt Allen
2017-04-04 10:55:23 -07:00
parent 74fb6a1dd9
commit 8bbb4bb80d
2 changed files with 7 additions and 2 deletions

View File

@@ -78,7 +78,7 @@
};
var CPP_DIRECTIVE_WITH_LT_PATTERN = /^\s*#(if|define).*</;
var CPP_WCHAR_PATTERN = /L\'.\'/g;
var CPP_WCHAR_PATTERN = /L\'(\\)?.\'/g;
var JAVA_PARAM_ANNOT_PATTERN = /(@[^\s]+)\(([^)]+)\)/g;
var GO_BACKSLASH_LITERAL = '\'\\\\\'';
var GLOBAL_LT_PATTERN = /</g;
@@ -360,7 +360,7 @@
* {#see https://github.com/isagalaev/highlight.js/issues/1412}
*/
if (CPP_WCHAR_PATTERN.test(line)) {
line = line.replace(CPP_WCHAR_PATTERN, 'L"."');
line = line.replace(CPP_WCHAR_PATTERN, 'L"$1."');
}
return line;

View File

@@ -456,6 +456,11 @@ limitations under the License.
line = 'wchar_t myChar = L\'#\'';
var expected = 'wchar_t myChar = L"."';
assert.equal(element._workaround('cpp', line), expected);
// Converts wchar_t character literal with escape sequence to string.
line = 'wchar_t myChar = L\'\\"\'';
expected = 'wchar_t myChar = L"\\."';
assert.equal(element._workaround('cpp', line), expected);
});
test('workaround go backslash character literals', function() {