vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit d4ab8d60c073d08a3ac4bf2cff4b5b178e383753 parent 16b86c1a3472d36afdd8331273165558a7049e64 Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 28 Sep 2014 12:18:04 +0200 More helpful error when trying to open a non file This is not really correct e.g. vis /dev/zero will print a misleading error. Diffstat:
| M | text.c | | | 4 | +++- |
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/text.c b/text.c @@ -664,8 +664,10 @@ Text *text_load(const char *filename) { goto out; if (fstat(txt->fd, &txt->info) == -1) goto out; - if (!S_ISREG(txt->info.st_mode)) + if (!S_ISREG(txt->info.st_mode)) { + errno = EISDIR; goto out; + } // XXX: use lseek(fd, 0, SEEK_END); instead? txt->buf.size = txt->info.st_size; if (txt->buf.size != 0) {