|
From: <kin...@us...> - 2025-09-24 06:38:05
|
Revision: 7481
http://sourceforge.net/p/teem/code/7481
Author: kindlmann
Date: 2025-09-24 06:38:03 +0000 (Wed, 24 Sep 2025)
Log Message:
-----------
fewer bugs
Modified Paths:
--------------
teem/trunk/src/hest/parsest.c
teem/trunk/src/hest/test/tparse.c
Modified: teem/trunk/src/hest/parsest.c
===================================================================
--- teem/trunk/src/hest/parsest.c 2025-09-24 06:06:44 UTC (rev 7480)
+++ teem/trunk/src/hest/parsest.c 2025-09-24 06:38:03 UTC (rev 7481)
@@ -697,9 +697,9 @@
srcIdx, hvsrc->len);
return 1;
}
- if (!(srcIdx + num < hvsrc->len)) {
- biffAddf(HEST, "%s: %u args starting at index %u |%s| goes past length %u",
- __func__, num, srcIdx, hvsrc->harg[srcIdx]->str, hvsrc->len);
+ if (!(srcIdx + num <= hvsrc->len)) {
+ biffAddf(HEST, "%s: have only %u args but want %u starting at %u", __func__,
+ hvsrc->len, num, srcIdx);
return 1;
}
// okay now do the work, starting with empty destination
@@ -947,7 +947,9 @@
ensured that there is at most one of these), then unflagVar is its index in opt[].
If there is no variable parameter unflagged opt, unflagVar is optNum. */
if (hparm->verbosity) {
- printf("%s: unflagVar %d\n", __func__, unflagVar);
+ printf("%s: unflagVar %u %s\n", __func__, unflagVar,
+ (unflagVar == optNum ? "==> there is no unflagged var parm opt"
+ : "is index of single unflagged var parm opt"));
}
/* grab parameters for all unflagged opts before opt[unflagVar] */
@@ -954,11 +956,12 @@
for (uint opi = nextUnflagged(0, opt); opi < unflagVar;
opi = nextUnflagged(opi + 1, opt)) {
if (hparm->verbosity) {
- printf("%s: looking at opi = %u (unflagVar = %u)\n", __func__, opi, unflagVar);
+ printf("%s: looking at opi = %u kind %d\n", __func__, opi, opt[opi].kind);
}
if (havecTransfer(opt[opi].havec, havec, 0, opt[opi].min /* min == max */)) {
biffAddf(HEST, "%s: trouble getting args for %s", __func__,
identStr(ident, opt + opi));
+ return 1;
}
}
/* we skip over the variable parameter unflagged option, subtract from havec->len the
@@ -986,6 +989,7 @@
if (havecTransfer(opt[opi].havec, havec, nvp, opt[opi].min /* min == max */)) {
biffAddf(HEST, "%s: trouble getting args for %s", __func__,
identStr(ident, opt + opi));
+ return 1;
}
}
@@ -1014,6 +1018,7 @@
if (havecTransfer(opt[unflagVar].havec, havec, 0, nvp)) {
biffAddf(HEST, "%s: trouble getting args for %s", __func__,
identStr(ident, opt + unflagVar));
+ return 1;
}
}
} else {
Modified: teem/trunk/src/hest/test/tparse.c
===================================================================
--- teem/trunk/src/hest/test/tparse.c 2025-09-24 06:06:44 UTC (rev 7480)
+++ teem/trunk/src/hest/test/tparse.c 2025-09-24 06:38:03 UTC (rev 7481)
@@ -39,13 +39,19 @@
int verb;
hestOptAdd_1_Int(&opt, "v", "verb", &verb, "0", "verbosity");
int *res;
+ int unpA[2];
+ hestOptAdd_2_Int(&opt, NULL, "A A", unpA, NULL, "unflagged A");
unsigned int slen;
- hestOptAdd_Nv_Int(&opt, "s,sizes", "sx sy", 2, -1, &res, NULL, "image resolutions",
- &slen);
+ hestOptAdd_Nv_Int(&opt, "s,sizes", "sx sy", 2, -1, &res, "640 480",
+ "image resolutions", &slen);
+ int unpB[2];
+ hestOptAdd_2_Int(&opt, NULL, "B B", unpB, NULL, "unflagged B");
int flag;
hestOptAdd_Flag(&opt, "b,bingo", &flag, "a flag");
int glaf;
hestOptAdd_Flag(&opt, "c,cingo", &glaf, "a flag");
+ int unpC[2];
+ hestOptAdd_2_Int(&opt, NULL, "C C", unpC, NULL, "unflagged C");
char *err = NULL;
if (hestParse2(opt, argc - 1, argv + 1, &err, hparm)) {
fprintf(stderr, "%s: problem:\n%s\n", argv[0], err);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|