]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed issue where default crlf was being ignored for new files
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 28 Feb 2017 15:37:55 +0000 (10:37 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 28 Feb 2017 15:37:55 +0000 (10:37 -0500)
foo [new file with mode: 0644]
lib/buf.c
lib/filetype.c

diff --git a/foo b/foo
new file mode 100644 (file)
index 0000000..d3f5a12
--- /dev/null
+++ b/foo
@@ -0,0 +1 @@
+\r
index 58f06dff374b16646fc2b44cf71ea954fe33bfb3..b94675ca338c747e70cddc9b1b9dd4d5d64c2c91 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -206,6 +206,7 @@ unsigned buf_load(Buf* buf, char* path) {
     /* load the file and determine the character set */
     FMap file = mmap_readonly(buf->path);
     filetype(buf, file);
+
     if (buf->charset > UTF_8)
         die("Unsupported character set");
 
@@ -220,7 +221,7 @@ unsigned buf_load(Buf* buf, char* path) {
         }
         buf_insert(buf, false, buf_end(buf), r);
     }
-    
+
     /* jump to address if we got one */
     if (addr)
         off = buf_setln(buf, strtoul(addr, NULL, 0));
index 57e14ceceb179abd839d0a6171a023dd85a12812..0670c900dd4ec5bbfe013f410ee8a12db94a66e9 100644 (file)
@@ -15,7 +15,6 @@ static const char Utf8Valid[256] = {
 
 void filetype(Buf* buf, FMap file) {
     size_t crs = 0, lfs = 0, tabs = 0;
-
     /* look for bytes that are invalid in utf-8 and count tabs, carriage 
        returns,  and line feeds */
     int type = buf->charset;
@@ -30,7 +29,8 @@ void filetype(Buf* buf, FMap file) {
     }
 
     /* setup filetype attributes in the buffer */
-    buf->crlf = (crs == lfs);
+    if (crs || lfs)
+        buf->crlf = (crs == lfs);
     buf->charset = type;
     buf->expand_tabs = (tabs == 0);
 }