- printf("%s%s", c_meta, prefix);
- quote_c_style(path, NULL, stdout, 0);
- printf("%s\n", c_reset);
+ static struct strbuf buf = STRBUF_INIT;
+
+ strbuf_reset(&buf);
+ strbuf_addstr(&buf, c_meta);
+ strbuf_addstr(&buf, head);
+ if (quote_c_style(prefix, NULL, NULL, 0) ||
+ quote_c_style(path, NULL, NULL, 0)) {
+ strbuf_addch(&buf, '"');
+ quote_c_style(prefix, &buf, NULL, 1);
+ quote_c_style(path, &buf, NULL, 1);
+ strbuf_addch(&buf, '"');
+ } else {
+ strbuf_addstr(&buf, prefix);
+ strbuf_addstr(&buf, path);
+ }
+ strbuf_addstr(&buf, c_reset);
+ puts(buf.buf);