summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-08-02 23:34:01 +0200
committerLouis Burda <quent.burda@gmail.com>2023-08-02 23:34:01 +0200
commitfed613ed3d2fb9e60644f829d9df0521b41b319e (patch)
treeeb0e2a9e8cb112716662fd830eb042a522b7dd8b
parent6d2f9ef18968724bbcdc08eeaf32951e99f20601 (diff)
downloadtmpl-fed613ed3d2fb9e60644f829d9df0521b41b319e.tar.gz
tmpl-fed613ed3d2fb9e60644f829d9df0521b41b319e.zip
Fix empty line check in perline
-rw-r--r--tmpl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tmpl.c b/tmpl.c
index e0201b5..334089b 100644
--- a/tmpl.c
+++ b/tmpl.c
@@ -194,7 +194,7 @@ perline(const char *path, int nonempty, void (*process)(char *))
while (fgets(linebuf, 4096, f)) {
len = strlen(linebuf);
if (len && linebuf[len - 1] == '\n') {
- linebuf[len - 1] = '\0';
+ linebuf[--len] = '\0';
} else if (len && !feof(f)) {
die("fgets '%s': line too long", path);
}