/* 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");
}
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));
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;
}
/* 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);
}