From 2bd6b4a1c950b1993ac7be9268a9c54dab08d7f9 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 4 Aug 2019 17:46:38 -0400 Subject: fix missing string[number] --- strings.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/strings.c b/strings.c index 8bbabc6..e14f250 100644 --- a/strings.c +++ b/strings.c @@ -50,20 +50,19 @@ static int strings(const char *path, size_t number, char format) putchar('\n'); } count = 0; + } else if (count > number) { + putchar(c); + } else if (count < number) { + string[count++] = c; + } - } else if (count == number) { + if (count == number) { if (format) { char fmt[] = { '%', 'z', format, ' ', '\0' }; - printf(fmt, offset - count); + printf(fmt, offset - count + 1); } fwrite(string, 1, number, stdout); count++; - - } else if (count > number) { - putchar(c); - - } else { - string[count++] = c; } } -- cgit v1.2.1