diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-10-10 15:48:10 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-10-10 15:48:10 -0400 |
commit | 0dc96ee9ccd374cbd8606b9a39884f10b74e0918 (patch) | |
tree | 9eaaefb9a256572843221006f457a2350aea8b86 /instr-client.c | |
parent | 2f3e00c9d356a4ae679c6252dd5dedff9a4aa2d4 (diff) |
strip out redundant newlines and carriage returns
Diffstat (limited to 'instr-client.c')
-rw-r--r-- | instr-client.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/instr-client.c b/instr-client.c index fa876fb..fdb5ca2 100644 --- a/instr-client.c +++ b/instr-client.c @@ -75,11 +75,20 @@ stdinAvailable (GIOChannel *source, GIOCondition condition, gpointer data) GError* error = NULL; - written = g_pollable_output_stream_write_nonblocking(out, tmp, size, NULL, &error); + // strip out duplicated newlines and carriage returns + GRegex *regex = g_regex_new ("[\\n\\r]+", 0, 0, NULL); + gchar *filt = g_regex_replace_literal (regex, tmp, -1, 0, "\n", 0, NULL); + g_regex_unref (regex); + written = g_pollable_output_stream_write_nonblocking(out, filt, size, NULL, &error); + +// written = g_pollable_output_stream_write_nonblocking(out, tmp, size, NULL, &error); + if(error != NULL && error->message) { g_print("Got error: %s\n", error->message); } + g_free (filt); + if (written != size || written <= 0) { g_print("Could not write. blocking. Written: %d\n", written); return FALSE; |