]> git.mdlowis.com Git - projs/tide.git/commitdiff
Only add the newline for new files. Existing files without eols should not get eols...
authorMike Lowis <mike.lowis@gentex.com>
Fri, 7 Oct 2016 15:08:23 +0000 (11:08 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Fri, 7 Oct 2016 15:08:23 +0000 (11:08 -0400)
buf.c
foo [new file with mode: 0644]

diff --git a/buf.c b/buf.c
index 93851132c91fa4df6814cf934931c8583527063d..dbfa318324f0b3bba1918d0e9d82ac53e49b8d10 100644 (file)
--- a/buf.c
+++ b/buf.c
@@ -13,10 +13,9 @@ void buf_load(Buf* buf, char* path) {
         while (RUNE_EOF != (r = fgetrune(in)))
             buf_ins(buf, i++, r);
         fclose(in);
-    }
-    /* Make sure it ends with a newline */
-    if (r != '\n')
+    } else {
         buf_ins(buf, i, (Rune)'\n');
+    }
     buf->insert_mode = false;
 }
 
@@ -122,7 +121,7 @@ unsigned buf_byrune(Buf* buf, unsigned pos, int count) {
         if (move < 0) {
             if (pos > 0) pos--;
         } else {
-            if (pos < buf_end(buf)-1) pos++;
+            if (pos < buf_end(buf)) pos++;
         }
     return pos;
 }
diff --git a/foo b/foo
new file mode 100644 (file)
index 0000000..1910281
--- /dev/null
+++ b/foo
@@ -0,0 +1 @@
+foo
\ No newline at end of file