Richard W.M. Jones wrote:
+#define NO_ESCAPING(c) \
+ (c_isprint ((c)) || (from_appliance && ((c) == '\n' || (c) ==
'\r')))
+
for (i = 0; i < buf_len; ++i) {
- c = buf[i];
- if (c_isprint (c) || (from_appliance && (c == '\n' || c ==
'\r')))
- putc (c, stderr);
- else {
- switch (c) {
+ if (NO_ESCAPING (buf[i])) {
+ i0 = i;
+ while (i < buf_len && NO_ESCAPING (buf[i]))
+ ++i;
+ fwrite (&buf[i0], 1, i-i0, stderr);
+ } else {
+ switch (buf[i]) {
case '\0': fputs ("\\0", stderr); break;
case '\a': fputs ("\\a", stderr); break;
case '\b': fputs ("\\b", stderr); break;
@@ -163,7 +172,7 @@ guestfs___call_callbacks_message (guestfs_h *g, uint64_t event,
case '\t': fputs ("\\t", stderr); break;
case '\v': fputs ("\\v", stderr); break;
default:
- fprintf (stderr, "\\x%x", (unsigned) c);
+ fprintf (stderr, "\\x%x", (unsigned) buf[i]);
ACK