Skip to content

Commit 1434422

Browse files
Josh V [Apple]pull[bot]
Josh V [Apple]
authored andcommitted
Fix cpp string literal when next character is between [0-F] (#16245)
* Allow all characters with excape hex to be listeral string in C++ * Generated Code.
1 parent 9c4d81f commit 1434422

File tree

4 files changed

+42
-45
lines changed

4 files changed

+42
-45
lines changed

src/app/zap-templates/common/ClusterTestGeneration.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,9 @@ function octetStringEscapedForCLiteral(value)
734734
// Escape control characters, things outside the ASCII range, and single
735735
// quotes (because that's our string terminator).
736736
return value.replace(/\p{Control}|\P{ASCII}|"/gu, ch => {
737-
let code = ch.charCodeAt(0);
738-
code = code.toString(16);
739-
if (code.length == 1) {
740-
code = "0" + code;
741-
}
742-
return "\\x" + code;
737+
var code = ch.charCodeAt(0).toString(8)
738+
return "\\" +
739+
"0".repeat(3 - code.length) + code;
743740
});
744741
}
745742

src/darwin/Framework/CHIPTests/CHIPClustersTests.m

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)