Author | Jamozed <[email protected]> |
Date | 2020-07-02 03:20:02 |
Commit | e2d04da279f51fec216c5cbce0f7defca0f38c71 |
Parent | 09b607069aebbe75c9ccd96cf560cc7efdfef9fc |
head: Move buffer onto stack
Diffstat
M | src/head.c | | | 9 | +++++---- |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/head.c b/src/head.c index 7341a71..33e0a30 100644 --- a/src/head.c +++ b/src/head.c @@ -1,4 +1,4 @@ -// head.c, version 1.0.1 +// head.c, version 1.0.2 // OMKOV coreutils implementation of POSIX head // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -42,7 +42,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include <stdio.h> #include <string.h> -static char stdbuf[BUFSIZ * 16]; +#define VERSION "1.0.2" static uintmax_t limit = 10; static bool label; @@ -89,7 +89,8 @@ int main(int argc, char *argv[]) { } static inline int head(const char *file) { - FILE *fi; register uintmax_t l = 0; + char stdbuf[BUFSIZ * 16]; FILE *fi; + register uintmax_t l = 0; if (file[0] == '-' && file[1] == 0) { fi = stdin; } else if (!(fi = fopen(file, "r"))) { return 1; } @@ -122,7 +123,7 @@ static void help(void) { } static void version(void) { - puts("OMKOV coreutils head, version 1.0.1"); + puts("OMKOV coreutils head, version " VERSION); puts("Copyright (C) 2020, Jakob Wakeling"); puts("All rights reserved."); puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");