From a51bfc11169adc42c383754dfbd88c9cf455341b Mon Sep 17 00:00:00 2001
From: cancel <cancel@cancel.fm>
Date: Sat, 4 Jan 2020 00:09:53 +0900
Subject: [PATCH] Change to use fwrite for cboard pipe write

Also fixes wrong newline ending check
---
 cboard.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cboard.c b/cboard.c
index c1f0b0c..7cf44c3 100644
--- a/cboard.c
+++ b/cboard.c
@@ -11,10 +11,8 @@ Cboard_error cboard_copy(Glyph const* gbuffer, Usz field_height,
     return Cboard_error_popen_failed;
   for (Usz iy = 0; iy < rect_h; iy++) {
     Glyph const* row = gbuffer + (rect_y + iy) * field_width + rect_x;
-    for (Usz ix = 0; ix < rect_w; ix++) {
-      fputc(row[ix], fp);
-    }
-    if (iy < rect_h + 1)
+    fwrite(row, sizeof(Glyph), rect_w, fp);
+    if (iy + 1 < rect_h)
       fputc('\n', fp);
   }
   int status = pclose(fp);