diff options
author | Steven Schubiger <stsc@refcnt.org> | 2013-12-01 18:05:54 +0100 |
---|---|---|
committer | Steven Schubiger <stsc@refcnt.org> | 2013-12-01 18:05:54 +0100 |
commit | 3670d233d1dd376d13ad73f14212cc83d5a4ecbf (patch) | |
tree | 0117803d827fa209478e3af0d366966c8e184156 /colorize.c | |
parent | 6df8f3534b2f5a99c43fdeefacf33b439591cccc (diff) | |
download | colorize-3670d233d1dd376d13ad73f14212cc83d5a4ecbf.tar.gz colorize-3670d233d1dd376d13ad73f14212cc83d5a4ecbf.tar.bz2 |
Read multiple of 1024 bytes from stream
Diffstat (limited to 'colorize.c')
-rw-r--r-- | colorize.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -56,7 +56,7 @@ #define free_null(ptr) free_wrap((void **)&ptr) #define xstrdup(str) strdup_wrap(str) -#if BUF_SIZE <= 1 /* BUF_SIZE - 1 */ +#if BUF_SIZE <= 0 # undef BUF_SIZE #endif #ifndef BUF_SIZE @@ -635,7 +635,7 @@ process_file_arg (const char *file_string, const char **file, FILE **stream) static void read_print_stream (bool bold, const struct color **colors, const char *file, FILE *stream) { - char buf[BUF_SIZE], *part_line = NULL; + char buf[BUF_SIZE + 1], *part_line = NULL; unsigned int flags = 0; while (!feof (stream)) @@ -643,10 +643,10 @@ read_print_stream (bool bold, const struct color **colors, const char *file, FIL size_t bytes_read; char *eol; const char *line; - memset (buf, '\0', BUF_SIZE); - bytes_read = fread (buf, 1, BUF_SIZE - 1, stream); - if (bytes_read != (BUF_SIZE - 1) && ferror (stream)) - vfprintf_fail (formats[FMT_ERROR], BUF_SIZE - 1, "read"); + memset (buf, '\0', BUF_SIZE + 1); + bytes_read = fread (buf, 1, BUF_SIZE, stream); + if (bytes_read != BUF_SIZE && ferror (stream)) + vfprintf_fail (formats[FMT_ERROR], BUF_SIZE, "read"); line = buf; while ((eol = strpbrk (line, "\n\r"))) { |