tweak error reporting due to invalid numbers Use the same idiom as in the strtonum(3) manpage which produces a more readable error message. OK kn, stsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/got/got.c b/got/got.c
index 03281c0..23e3b35 100644
--- a/got/got.c
+++ b/got/got.c
@@ -4110,12 +4110,14 @@ cmd_log(int argc, char *argv[])
diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
&errstr);
if (errstr != NULL)
- err(1, "-C option %s", errstr);
+ errx(1, "number of context lines is %s: %s",
+ errstr, optarg);
break;
case 'l':
limit = strtonum(optarg, 0, INT_MAX, &errstr);
if (errstr != NULL)
- err(1, "-l option %s", errstr);
+ errx(1, "number of commits is %s: %s",
+ errstr, optarg);
break;
case 'b':
log_branches = 1;
@@ -4530,7 +4532,8 @@ cmd_diff(int argc, char *argv[])
diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
&errstr);
if (errstr != NULL)
- err(1, "-C option %s", errstr);
+ errx(1, "number of context lines is %s: %s",
+ errstr, optarg);
break;
case 'r':
repo_path = realpath(optarg, NULL);
diff --git a/tog/tog.c b/tog/tog.c
index 982154f..280413b 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -3884,7 +3884,8 @@ cmd_diff(int argc, char *argv[])
diff_context = strtonum(optarg, 0, GOT_DIFF_MAX_CONTEXT,
&errstr);
if (errstr != NULL)
- err(1, "-C option %s", errstr);
+ errx(1, "number of context lines is %s: %s",
+ errstr, errstr);
break;
case 'r':
repo_path = realpath(optarg, NULL);