Skip to content
Snippets Groups Projects
Commit ee08aa9a authored by Lewis Hyatt's avatar Lewis Hyatt
Browse files

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.
parent 15d31555
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment