gnu /
gcc /
ee08aa9ab4100b8774d149bb235b00bddebd4b89 diagnostics: Remove null-termination requirement for json::string
json::string currently handles null-terminated data and so can't work with
data that may contain embedded null bytes or that is not null-terminated.
Supporting such data will make json::string more robust in some contexts, such
as SARIF output, which uses it to output user source code that may contain
embedded null bytes.
gcc/ChangeLog:
* json.h (class string): Add M_LEN member to store the length of
the data. Add constructor taking an explicit length.
* json.cc (string::string): Implement the new constructor.
(string::print): Support printing strings that are not
null-terminated. Escape embdedded null bytes on output.
(test_writing_strings): Test the new null-byte-related features of
json::string.
2 files changed