libterm: blocking client: tell user how much we've written
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Thu, 19 Feb 2015 16:58:12 +0000 (17:58 +0100)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Mon, 9 Mar 2015 14:33:15 +0000 (15:33 +0100)
This fixes the fish issue mentioned in T63, but not the AIM issue.

Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

lib/term/client/client_blocking.c

index 7e3c241..62934e4 100644 (file)
@@ -272,6 +272,9 @@ errval_t term_client_blocking_write(struct term_client *client,
     assert(outdata != NULL);
     memcpy(outdata, data, length);
 
+    /* tell user how much we've written (before applying filters) */
+    *written = length;
+
     /* apply output filters */
     term_filter_apply(client->output_filters, &outdata, &length);
 
@@ -293,6 +296,10 @@ errval_t term_client_blocking_write(struct term_client *client,
     }
 
  out:
+    /* reset amount written if error */
+    if (err_is_fail(err)) {
+        *written = 0;
+    }
     /* free data */
     free(outdata);
     return err;