coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-02 03:01:15
Commitf1a3ef488dc66fefa018f87beb5e6b6027e9cadd
Parent3e21bfd4448dc1c89bf6bb076021e48cbc15d0f0

cksum: Move buffer onto stack

Diffstat

M src/cksum.c | 9 +++++----

1 files changed, 5 insertions, 4 deletions

diff --git a/src/cksum.c b/src/cksum.c
index 92b08e4..73c6580 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -1,4 +1,4 @@
-// cksum.c, version 1.0.1
+// cksum.c, version 1.0.2
 // OMKOV coreutils implementation of POSIX cksum
 // 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 const uint32_t CRC[] = {
 	0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
@@ -120,7 +120,8 @@ int main(int argc, char *argv[]) {
 }
 
 static inline int cksum(const char *file) {
-	FILE *fi; register size_t fl = 0; register uint32_t crc = 0;
+	char stdbuf[BUFSIZ * 16]; FILE *fi;
+	register size_t fl = 0; register uint32_t crc = 0;
 
 	if (!file || (file[0] == '-' && file[1] == 0)) { fi = stdin; }
 	else if (!(fi = fopen(file, "r"))) { return 1; }
@@ -151,7 +152,7 @@ static void help(void) {
 }
 
 static void version() {
-	puts("OMKOV coreutils cksum, version 1.0.1");
+	puts("OMKOV coreutils cksum, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");
 	puts("All rights reserved.");
 	puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");