Author | Jamozed <[email protected]> |
Date | 2020-07-06 10:20:44 |
Commit | fed70f89e108ba5487efa83ac10d2dabde6cd0cb |
Parent | 3efa6c7f6ce9f154ca05ab39ad5dca42f6422b5b |
crc32: Use libokv error reporting
Diffstat
M | src/crc32.c | | | 19 | +++++++++---------- |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/crc32.c b/src/crc32.c index 0b34a1c..11a376a 100644 --- a/src/crc32.c +++ b/src/crc32.c @@ -1,4 +1,4 @@ -// crc32.c, version 1.0.1 +// crc32.c, version 1.0.2 // OMKOV coreutils crc32 // 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.1" +#define VERSION "1.0.2" static const uint32_t CRC32[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, @@ -95,7 +94,7 @@ static inline int crc32(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) { crc32(NULL); } - else for (char **p = &argv[opt.ind]; *p; ++p) if (crc32(*p)) { - warn("%s: %s: %s", argv[0], *p, serrno); warned = true; + if (opt.ind == ac) { crc32(NULL); } + else for (char **p = &av[opt.ind]; *p; ++p) if (crc32(*p)) { + warn("%s: %s", *p, serr()); warned = true; } return warned;