commit a905d4c153b89f46425d071486c46f77b8ab53db
parent 182f011235b50784ab28e948e36a0c126e1c9985
Author: sin <sin@2f30.org>
Date: Tue, 30 May 2017 09:35:44 +0100
file: Don't stop at first non-printable character
This makes utf-8 encoded text work properly.
Diffstat:
1 file changed, 0 insertions(+), 6 deletions(-)
diff --git a/file.c b/file.c
@@ -1,4 +1,3 @@
-#include <ctype.h>
#include <err.h>
#include <fcntl.h>
#include <unistd.h>
@@ -27,7 +26,6 @@ fileread(void *arg, char *buf, size_t len)
char *path = arg;
ssize_t n;
int fd;
- int i;
fd = open(path, O_RDONLY);
if (fd == -1) {
@@ -40,9 +38,5 @@ fileread(void *arg, char *buf, size_t len)
return -1;
else
buf[n - 1] = '\0';
- /* stop at the first non-printable character */
- for (i = 0; i < len; i++)
- if (!isprint((unsigned char)buf[i]))
- buf[i] = '\0';
return 0;
}