MCPcopy Create free account
hub / github.com/git/git / append_quoted_string

Function append_quoted_string

json-writer.c:21–47  ·  view source on GitHub ↗

* Append JSON-quoted version of the given string to 'out'. */

Source from the content-addressed store, hash-verified

19 * Append JSON-quoted version of the given string to 'out'.
20 */
21static void append_quoted_string(struct strbuf *out, const char *in)
22{
23 unsigned char c;
24
25 strbuf_addch(out, '"');
26 while ((c = *in++) != '\0') {
27 if (c == '"')
28 strbuf_addstr(out, "\\\"");
29 else if (c == '\\')
30 strbuf_addstr(out, "\\\\");
31 else if (c == '\n')
32 strbuf_addstr(out, "\\n");
33 else if (c == '\r')
34 strbuf_addstr(out, "\\r");
35 else if (c == '\t')
36 strbuf_addstr(out, "\\t");
37 else if (c == '\f')
38 strbuf_addstr(out, "\\f");
39 else if (c == '\b')
40 strbuf_addstr(out, "\\b");
41 else if (c < 0x20)
42 strbuf_addf(out, "\\u%04x", c);
43 else
44 strbuf_addch(out, c);
45 }
46 strbuf_addch(out, '"');
47}
48
49static void indent_pretty(struct json_writer *jw)
50{

Callers 3

object_commonFunction · 0.85
jw_object_stringFunction · 0.85
jw_array_stringFunction · 0.85

Calls 3

strbuf_addchFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_addfFunction · 0.85

Tested by

no test coverage detected