diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-06-20 16:21:18 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-06-20 16:21:18 +0200 |
commit | 2645de45e4aec89a468de5387cf8cfb604acf547 (patch) | |
tree | 12eed3ba2d6bd6f2da225b33a4b1eefe3a341fb5 | |
parent | 66a486ab06da9c178b47b8be1229876cdb573ec1 (diff) | |
download | lr-2645de45e4aec89a468de5387cf8cfb604acf547.tar.gz lr-2645de45e4aec89a468de5387cf8cfb604acf547.tar.xz lr-2645de45e4aec89a468de5387cf8cfb604acf547.zip |
lr: set prefixl to 0 when reading from stdin
-rw-r--r-- | lr.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lr.c b/lr.c index c95f1b8..29463a4 100644 --- a/lr.c +++ b/lr.c @@ -1434,7 +1434,9 @@ print_shquoted(const char *s) void print_noprefix(struct fileinfo *fi) { - if (strlen(fi->fpath) > fi->prefixl + 1) /* strip prefix */ + if (fi->prefixl == 0) + print_shquoted(fi->fpath); + else if (strlen(fi->fpath) > fi->prefixl + 1) /* strip prefix */ print_shquoted(fi->fpath + fi->prefixl + 1); else if (S_ISDIR(fi->sb.st_mode)) /* turn empty string into "." */ printf("."); @@ -1834,6 +1836,8 @@ traverse_file(FILE *file) struct stat st; ssize_t rd; + prefixl = 0; + while (1) { errno = 0; rd = getdelim(&line, &linelen, input_delim, file); |