coreutils

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

AuthorJamozed <[email protected]>
Date2020-07-06 10:17:31
Commit3efa6c7f6ce9f154ca05ab39ad5dca42f6422b5b
Parent934dc2eef027c45b00bd594499f851f5607232e0

cksum: Use libokv error reporting

Diffstat

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

1 files changed, 11 insertions, 10 deletions

diff --git a/src/cksum.c b/src/cksum.c
index 73c6580..1db9e0f 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -1,4 +1,4 @@
-// cksum.c, version 1.0.2
+// cksum.c, version 1.0.3
 // OMKOV coreutils implementation of POSIX cksum
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -33,16 +33,15 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 */
 
-#include "error.h"
 #include "optget.h"
 
-#include <errno.h>
+#include <error.h>
+
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 
-#define VERSION "1.0.2"
+#define VERSION "1.0.3"
 
 static const uint32_t CRC[] = {
 	0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
@@ -95,7 +94,7 @@ static inline int cksum(const char *file);
 static void help(void);
 static void version(void);
 
-int main(int argc, char *argv[]) {
+int main(int ac, char *av[]) { A0 = av[0];
 	lop_t lops[] = {
 		{ "help",    ARG_NUL, 256 },
 		{ "version", ARG_NUL, 257 },
@@ -103,7 +102,7 @@ int main(int argc, char *argv[]) {
 	};
 
 	opt_t opt = OPTGET_INIT; opt.str = ""; opt.lops = lops; int o;
-	while((o = optget(&opt, argv, 1)) != -1) switch (o) {
+	while((o = optget(&opt, av, 1)) != -1) switch (o) {
 	case 256: { help(); return 0; }
 	case 257: { version(); return 0; }
 	default: { return 1; }
@@ -111,9 +110,9 @@ int main(int argc, char *argv[]) {
 
 	bool warned = false;
 
-	if (opt.ind == argc) { cksum(NULL); }
-	else for (char **p = &argv[opt.ind]; *p; ++p) if (cksum(*p)) {
-		warn("%s: %s: %s", argv[0], *p, serrno); warned = true;
+	if (opt.ind == ac) { cksum(NULL); }
+	else for (char **p = &av[opt.ind]; *p; ++p) if (cksum(*p)) {
+		warn("%s: %s", *p, serr()); warned = true;
 	}
 
 	return warned;