]> git.mdlowis.com Git - projs/tide.git/commitdiff
added status return to buf_save
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 12 Sep 2018 13:38:41 +0000 (09:38 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 12 Sep 2018 13:38:41 +0000 (09:38 -0400)
inc/edit.h
lib/buf.c
tide.c

index 78042f291d9aa23765e2c24cb12edd25a97a2765..8e99967c459d597d5dfb4cc24a616e0c49e4605e 100644 (file)
@@ -37,7 +37,7 @@ typedef struct {
 void buf_init(Buf* buf);
 void buf_load(Buf* buf, char* path);
 void buf_reload(Buf* buf);
-void buf_save(Buf* buf);
+int buf_save(Buf* buf);
 size_t buf_end(Buf* buf);
 
 int buf_getrat(Buf* buf, size_t off);
index 3c80c6190fa85e96ab2d5047724c95b10f664f20..0501605c3a51aeec7d714e9da46e53b93708aea2 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -73,8 +73,8 @@ void buf_reload(Buf* buf) {
     buf_load(buf, path);
 }
 
-void buf_save(Buf* buf) {
-    if (0 == buf_end(buf)) return;
+int buf_save(Buf* buf) {
+    if (0 == buf_end(buf)) return buf->status;
     char* wptr;
     long fd, nwrite = 0, towrite = 0;
     if (buf->path && (fd = open(buf->path, O_WRONLY|O_CREAT|O_TRUNC, 0644)) >= 0) {
@@ -92,6 +92,7 @@ void buf_save(Buf* buf) {
     } else {
         buf->status = ERRORED;
     }
+    return buf->status;
 }
 
 static void buf_resize(Buf* buf, size_t sz) {
diff --git a/tide.c b/tide.c
index 03e4a1a985eff8584b04c0aa53dde9d5955ffe7f..6927760ec9a8be69cfc2f227587c68d88bfbae3f 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -265,8 +265,7 @@ static void put(char* arg) {
     if (!path) path = strdup(arg);
     free(view->buffer.path);
     view->buffer.path = path;
-    buf_save(&(view->buffer));
-    if (view->buffer.status == NORMAL) {
+    if (buf_save(&(view->buffer)) == NORMAL) {
         char* path = realpath(view->buffer.path, NULL);
         if (path) {
             free(view->buffer.path);