From 7085c816276541ef46f89f52dcce4b8ca12f71f6 Mon Sep 17 00:00:00 2001 From: Richard Kettlewell Date: Fri, 17 Jun 2011 20:49:50 +0100 Subject: [PATCH] Rearrange argc/argv for more idiomatic access to positional arguments. --- vbig.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vbig.cc b/vbig.cc index 0051394..c656508 100644 --- a/vbig.cc +++ b/vbig.cc @@ -119,23 +119,25 @@ int main(int argc, char **argv) { fatal(0, "unknown option"); } } + argc -= optind; + argv += optind; if(mode == NONE) { fatal(0, "must specify one of --verify or --create"); exit(1); } - if(optind + 2 != argc) { + if(argc != 2) { fatal(0, "must specify a path and size"); exit(1); } - const char *path = argv[optind]; + const char *path = argv[0]; errno = 0; char *end; - long long size = strtoll(argv[optind + 1], &end, 10); + long long size = strtoll(argv[1], &end, 10); if(errno) { fatal(errno, "invalid size"); exit(1); } - if(end == argv[optind + 1]) { + if(end == argv[1]) { fatal(0, "invalid size"); exit(1); } -- 2.30.2