|
From: <kin...@us...> - 2025-09-28 17:31:26
|
Revision: 7513
http://sourceforge.net/p/teem/code/7513
Author: kindlmann
Date: 2025-09-28 17:31:23 +0000 (Sun, 28 Sep 2025)
Log Message:
-----------
maybe working more
Modified Paths:
--------------
teem/trunk/src/hest/parsest.c
teem/trunk/src/hest/test/ex6.c
Modified: teem/trunk/src/hest/parsest.c
===================================================================
--- teem/trunk/src/hest/parsest.c 2025-09-28 09:02:02 UTC (rev 7512)
+++ teem/trunk/src/hest/parsest.c 2025-09-28 17:31:23 UTC (rev 7513)
@@ -1314,7 +1314,7 @@
--> value is set from the default
- option flag appears, but with no parm
--> default is parsed, say, as value V, then the value is set to !V
- (*this* is the "inversion" that is mentioned at places in the code)
+ (*this* is the mysterious "inversion" mentioned at places in the code)
- option flag appears, with single parm
--> value is set from parsing that parm
In any case, some string has to be parsed; we call it `strsrc` */
@@ -1352,81 +1352,20 @@
}
opt[opi].alloc = hpp->alloc;
break;
-#if 0
case 3:
/* -------- multiple required parameters -------- */
- if (optParms[opi] && valueP) {
- switch (type) {
- case airTypeEnum:
- if (opt[opi].min != /* min == max */
- airParseStrE((int *)valueP, optParms[opi], " ", opt[opi].min,
- opt[opi].enm)) {
- fprintf(stderr, "%scouldn't parse %s\"%s\" as %d %s%s for %s\n", ME,
- optDfltd[opi] ? "(default) " : "", optParms[opi], opt[opi].min,
- opt[opi].enm->name, opt[opi].min > 1 ? "s" : "", ident);
- return 1;
- }
- break;
- case airTypeOther:
- optParmsCopy = airStrdup(optParms[opi]);
- for (p = 0; p < (int)opt[opi].min; p++) { /* HEY scrutinize casts */
- tok = airStrtok(!p ? optParmsCopy : NULL, " ", &last);
- strcpy(cberr, "");
- ret = opt[opi].CB->parse(cvalueP + p * size, tok, cberr);
- if (ret) {
- if (strlen(cberr))
- fprintf(stderr,
- "%serror parsing \"%s\" (in \"%s\") as %s "
- "for %s:\n%s\n",
- ME, tok, optParms[opi], opt[opi].CB->type, ident, cberr);
- else
- fprintf(stderr,
- "%serror parsing \"%s\" (in \"%s\") as %s "
- "for %s: returned %d\n",
- ME, tok, optParms[opi], opt[opi].CB->type, ident, ret);
- free(optParmsCopy);
- return 1;
- }
- }
- free(optParmsCopy);
- if (opt[opi].CB->destroy) {
- /* vP is an array of void*s, we manage the individual void*s */
- opt[opi].alloc = 2;
- for (p = 0; p < (int)opt[opi].min; p++) { /* HEY scrutinize casts */
- airMopAdd(pmop, ((void **)valueP) + p, (airMopper)airSetNull,
- airMopOnError);
- airMopAdd(pmop, *(((void **)valueP) + p), opt[opi].CB->destroy,
- airMopOnError);
- }
- }
- break;
- case airTypeString:
- if (opt[opi].min != /* min == max */
- _hestParseStr[type](valueP, optParms[opi], " ", opt[opi].min)) {
- fprintf(stderr, "%scouldn't parse %s\"%s\" as %d %s%s for %s\n", ME,
- optDfltd[opi] ? "(default) " : "", optParms[opi], opt[opi].min,
- _hestTypeStr[type], opt[opi].min > 1 ? "s" : "", ident);
- return 1;
- }
- /* vP is an array of char*s, (a char**), and what we manage
- with airMop are the individual vP[p]. */
- opt[opi].alloc = 2;
- for (p = 0; p < (int)opt[opi].min; p++) { /* HEY scrutinize casts */
- airMopMem(pmop, &(((char **)valueP)[p]), airMopOnError);
- }
- break;
- default:
- if (opt[opi].min != /* min == max */
- _hestParseStr[type](valueP, optParms[opi], " ", opt[opi].min)) {
- fprintf(stderr, "%scouldn't parse %s\"%s\" as %d %s%s for %s\n", ME,
- optDfltd[opi] ? "(default) " : "", optParms[opi], opt[opi].min,
- _hestTypeStr[type], opt[opi].min > 1 ? "s" : "", ident);
- return 1;
- }
- break;
+ for (uint argi = 0; argi < opt[opi].havec->len; argi++) {
+ if (_hestParseSingle[type](cvalueP + size * argi,
+ opt[opi].havec->harg[argi]->str, hpp)) {
+ biffAddf(HEST, "%s%sproblem parsing arg %u (of %u) for %s[%u]: %s", _ME_, argi,
+ opt[opi].havec->len, ident, opi, hpp->err);
+ return 1;
}
}
+ // (review alloc semantics in hest.h)
+ opt[opi].alloc = 2 * hpp->alloc;
break;
+#if 0
case 5:
/* -------- multiple variadic parameters -------- */
if (optParms[opi] && valueP) {
Modified: teem/trunk/src/hest/test/ex6.c
===================================================================
--- teem/trunk/src/hest/test/ex6.c 2025-09-28 09:02:02 UTC (rev 7512)
+++ teem/trunk/src/hest/test/ex6.c 2025-09-28 17:31:23 UTC (rev 7513)
@@ -85,6 +85,7 @@
hparm->noArgsIsNoProblem = AIR_TRUE;
hparm->dieLessVerbose = AIR_TRUE;
hparm->verbosity = 0;
+ hestParmColumnsIoctl(hparm, 80);
opt = NULL;
/* going past C89 to have declarations here */
@@ -160,7 +161,6 @@
hestOptAdd_1_Other(&opt, "q1", "quat", &q1, "12.34", "test of hestOptAdd_1_Other B",
&quatCB);
-#if 0
int b2[2];
hestOptAdd_2_Bool(&opt, "b2", "bool1 bool2", b2, "true false",
"test of hestOptAdd_2_Bool");
@@ -324,6 +324,7 @@
"15.55 55.51 66.77 88.99 100.2", "test of hestOptAdd_N_Other B",
&quatCB);
+#if 0
/* HEY also try 0, -1 */
int *bv;
unsigned int bvSaw;
@@ -444,7 +445,6 @@
printf("q1 (@ %p) = %g(%s)\n", q1, q1->val, q1->str);
printf("\n");
-#if 0
printf("b2 = %d %d\n", b2[0], b2[1]);
printf("i2 = %d %d\n", i2[0], i2[1]);
printf("ui2 = %u %u\n", ui2[0], ui2[1]);
@@ -509,6 +509,7 @@
q5[1]->val, q5[1]->str, q5[2]->val, q5[2]->str, q5[3]->val, q5[3]->str,
q5[4]->val, q5[4]->str);
+#if 0
unsigned int ii;
printf("bv (%u) =", bvSaw);
for (ii = 0; ii < bvSaw; ii++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|