|
From: <kin...@us...> - 2025-09-24 08:24:12
|
Revision: 7482
http://sourceforge.net/p/teem/code/7482
Author: kindlmann
Date: 2025-09-24 08:24:08 +0000 (Wed, 24 Sep 2025)
Log Message:
-----------
slightly better handling of function self-identification with error reporting
Modified Paths:
--------------
teem/trunk/src/hest/methodsHest.c
teem/trunk/src/hest/parsest.c
teem/trunk/src/hest/privateHest.h
teem/trunk/src/hest/test/tparse.c
Modified: teem/trunk/src/hest/methodsHest.c
===================================================================
--- teem/trunk/src/hest/methodsHest.c 2025-09-24 06:38:03 UTC (rev 7481)
+++ teem/trunk/src/hest/methodsHest.c 2025-09-24 08:24:08 UTC (rev 7482)
@@ -518,7 +518,7 @@
int
_hestOPCheck(const hestOpt *opt, const hestParm *hparm) {
if (!(opt && hparm)) {
- biffAddf(HEST, "%s: got NULL opt (%p) or hparm (%p)", __func__, AIR_VOIDP(opt),
+ biffAddf(HEST, "%s%sgot NULL opt (%p) or hparm (%p)", _ME_, AIR_VOIDP(opt),
AIR_VOIDP(hparm));
return 1;
}
@@ -526,33 +526,33 @@
uint varNum = 0; // number of variable-parameter options
for (uint opi = 0; opi < optNum; opi++) {
if (!(AIR_IN_OP(airTypeUnknown, opt[opi].type, airTypeLast))) {
- biffAddf(HEST, "%s: opt[%u].type (%d) not in valid range [%d,%d]", __func__, opi,
+ biffAddf(HEST, "%s%sopt[%u].type (%d) not in valid range [%d,%d]", _ME_, opi,
opt[opi].type, airTypeUnknown + 1, airTypeLast - 1);
return 1;
}
if (!(opt[opi].valueP)) {
- biffAddf(HEST, "%s: opt[%u]'s valueP is NULL!", __func__, opi);
+ biffAddf(HEST, "%s%sopt[%u]'s valueP is NULL!", _ME_, opi);
return 1;
}
// `kind` set by hestOptSingleSet
if (-1 == opt[opi].kind) {
- biffAddf(HEST, "%s: opt[%u]'s min (%d) and max (%d) incompatible", __func__, opi,
+ biffAddf(HEST, "%s%sopt[%u]'s min (%d) and max (%d) incompatible", _ME_, opi,
opt[opi].min, opt[opi].max);
return 1;
}
if (5 == opt[opi].kind && !(opt[opi].sawP)) {
biffAddf(HEST,
- "%s: opt[%u] has multiple variable parameters (min=%u,max=%d), "
+ "%s%sopt[%u] has multiple variable parameters (min=%u,max=%d), "
"but sawP is NULL",
- __func__, opi, opt[opi].min, opt[opi].max);
+ _ME_, opi, opt[opi].min, opt[opi].max);
return 1;
}
if (airTypeEnum == opt[opi].type) {
if (!(opt[opi].enm)) {
biffAddf(HEST,
- "%s: opt[%u] (%s) is type \"enum\", but no "
+ "%s%sopt[%u] (%s) is type \"enum\", but no "
"airEnum pointer given",
- __func__, opi, opt[opi].flag ? opt[opi].flag : "?");
+ _ME_, opi, opt[opi].flag ? opt[opi].flag : "?");
return 1;
}
}
@@ -559,29 +559,29 @@
if (airTypeOther == opt[opi].type) {
if (!(opt[opi].CB)) {
biffAddf(HEST,
- "%s: opt[%u] (%s) is type \"other\", but no "
+ "%s%sopt[%u] (%s) is type \"other\", but no "
"callbacks given",
- __func__, opi, opt[opi].flag ? opt[opi].flag : "?");
+ _ME_, opi, opt[opi].flag ? opt[opi].flag : "?");
return 1;
}
if (!(opt[opi].CB->size > 0)) {
- biffAddf(HEST, "%s: opt[%u]'s \"size\" (%u) invalid", __func__, opi,
+ biffAddf(HEST, "%s%sopt[%u]'s \"size\" (%u) invalid", _ME_, opi,
(uint)(opt[opi].CB->size));
return 1;
}
if (!(opt[opi].CB->type)) {
- biffAddf(HEST, "%s: opt[%u]'s \"type\" is NULL", __func__, opi);
+ biffAddf(HEST, "%s%sopt[%u]'s \"type\" is NULL", _ME_, opi);
return 1;
}
if (!(opt[opi].CB->parse)) {
- biffAddf(HEST, "%s: opt[%u]'s \"parse\" callback NULL", __func__, opi);
+ biffAddf(HEST, "%s%sopt[%u]'s \"parse\" callback NULL", _ME_, opi);
return 1;
}
if (opt[opi].CB->destroy && (sizeof(void *) != opt[opi].CB->size)) {
biffAddf(HEST,
- "%sopt[%u] has a \"destroy\", but size %lu isn't "
+ "%s%sopt[%u] has a \"destroy\", but size %lu isn't "
"sizeof(void*)",
- __func__, opi, (unsigned long)(opt[opi].CB->size));
+ _ME_, opi, (unsigned long)(opt[opi].CB->size));
return 1;
}
}
@@ -589,18 +589,18 @@
const char *flag = opt[opi].flag;
uint fslen = AIR_UINT(strlen(flag));
if (fslen > AIR_STRLEN_SMALL / 2) {
- biffAddf(HEST, "%s: strlen(opt[%u].flag) %u is too big", __func__, opi, fslen);
+ biffAddf(HEST, "%s%sstrlen(opt[%u].flag) %u is too big", _ME_, opi, fslen);
return 1;
}
if (strchr(flag, '-')) {
- biffAddf(HEST, "%s: opt[%u].flag \"%s\" contains '-', which will confuse things",
- __func__, opi, flag);
+ biffAddf(HEST, "%s%sopt[%u].flag \"%s\" contains '-', which will confuse things",
+ _ME_, opi, flag);
return 1;
}
for (uint chi = 0; chi < fslen; chi++) {
if (!isprint(flag[chi])) {
- biffAddf(HEST, "%s: opt[%u].flag \"%s\" char %u '%c' non-printing", __func__,
- opi, flag, chi, flag[chi]);
+ biffAddf(HEST, "%s%sopt[%u].flag \"%s\" char %u '%c' non-printing", _ME_, opi,
+ flag, chi, flag[chi]);
return 1;
}
}
@@ -612,51 +612,51 @@
*sep = '\0';
if (!(strlen(tbuff) && strlen(sep + 1))) {
biffAddf(HEST,
- "%s: either short (\"%s\") or long (\"%s\") flag"
+ "%s%seither short (\"%s\") or long (\"%s\") flag"
" of opt[%u] is zero length",
- __func__, tbuff, sep + 1, opi);
+ _ME_, tbuff, sep + 1, opi);
return (free(tbuff), 1);
}
if (hparm->respectDashDashHelp && !strcmp("help", sep + 1)) {
biffAddf(HEST,
- "%s: long \"--%s\" flag of opt[%u] is same as \"--help\" "
+ "%s%slong \"--%s\" flag of opt[%u] is same as \"--help\" "
"that requested hparm->respectDashDashHelp handles separately",
- __func__, sep + 1, opi);
+ _ME_, sep + 1, opi);
return (free(tbuff), 1);
}
if (strchr(sep + 1, MULTI_FLAG_SEP)) {
biffAddf(HEST,
- "%s: opt[%u] flag string \"%s\" has more than one instance of "
+ "%s%sopt[%u] flag string \"%s\" has more than one instance of "
"short/long separation character '%c'",
- __func__, opi, flag, MULTI_FLAG_SEP);
+ _ME_, opi, flag, MULTI_FLAG_SEP);
return (free(tbuff), 1);
}
} else {
if (!strlen(opt[opi].flag)) {
- biffAddf(HEST, "%s: opt[%u].flag is zero length", __func__, opi);
+ biffAddf(HEST, "%s%sopt[%u].flag is zero length", _ME_, opi);
return (free(tbuff), 1);
}
}
if (hparm->respectDashBraceComments && (strchr(flag, '{') || strchr(flag, '}'))) {
biffAddf(HEST,
- "%s: requested hparm->respectDashBraceComments but opt[%u]'s flag "
+ "%s%srequested hparm->respectDashBraceComments but opt[%u]'s flag "
"\"%s\" confusingly contains '{' or '}'",
- __func__, opi, flag);
+ _ME_, opi, flag);
return (free(tbuff), 1);
}
if (4 == opt[opi].kind) {
if (!opt[opi].dflt) {
biffAddf(HEST,
- "%s: flagged single variable parameter must "
+ "%s%sflagged single variable parameter must "
"specify a default",
- __func__);
+ _ME_);
return (free(tbuff), 1);
}
if (!strlen(opt[opi].dflt)) {
biffAddf(HEST,
- "%s: flagged single variable parameter default "
+ "%s%sflagged single variable parameter default "
"must be non-zero length",
- __func__);
+ _ME_);
return (free(tbuff), 1);
}
}
@@ -674,20 +674,20 @@
// ------ end of if (opt[opi].flag)
if (1 == opt[opi].kind) {
if (!opt[opi].flag) {
- biffAddf(HEST, "%s: opt[%u] flag must have a flag", __func__, opi);
+ biffAddf(HEST, "%s%sopt[%u] flag must have a flag", _ME_, opi);
return 1;
}
} else {
if (!opt[opi].name) {
- biffAddf(HEST, "%s: opt[%u] isn't a flag: must have \"name\"", __func__, opi);
+ biffAddf(HEST, "%s%sopt[%u] isn't a flag: must have \"name\"", _ME_, opi);
return 1;
}
}
if (4 == opt[opi].kind && !opt[opi].dflt) {
biffAddf(HEST,
- "%s: opt[%u] is single variable parameter, but "
+ "%s%sopt[%u] is single variable parameter, but "
"no default set",
- __func__, opi);
+ _ME_, opi);
return 1;
}
// kind 4 = single variable parm; kind 5 = multiple variable parm
@@ -694,7 +694,7 @@
varNum += (opt[opi].kind > 3 && (NULL == opt[opi].flag));
}
if (varNum > 1) {
- biffAddf(HEST, "%s: can't have %u unflagged min<max options, only one", __func__,
+ biffAddf(HEST, "%s%scan't have %u unflagged min<max options, only one", _ME_,
varNum);
return 1;
}
Modified: teem/trunk/src/hest/parsest.c
===================================================================
--- teem/trunk/src/hest/parsest.c 2025-09-24 06:38:03 UTC (rev 7481)
+++ teem/trunk/src/hest/parsest.c 2025-09-24 08:24:08 UTC (rev 7482)
@@ -32,20 +32,19 @@
static int
histPop(hestInputStack *hist, const hestParm *hparm) {
if (!(hist && hparm)) {
- biffAddf(HEST, "%s: got NULL pointer (hist %p hparm %p)", __func__, AIR_VOIDP(hist),
+ biffAddf(HEST, "%s%sgot NULL pointer (hist %p hparm %p)", _ME_, AIR_VOIDP(hist),
AIR_VOIDP(hparm));
return 1;
}
if (!(hist->len)) {
- biffAddf(HEST, "%s: cannot pop from input stack height 0", __func__);
+ biffAddf(HEST, "%s%scannot pop from input stack height 0", _ME_);
return 1;
}
hestInput *topHin = hist->hin + hist->len - 1;
if (topHin->dashBraceComment) {
biffAddf(HEST,
- "%s: %u start comment marker%s \"-{\" not balanced by equal later \"}-\"",
- __func__, topHin->dashBraceComment,
- topHin->dashBraceComment > 1 ? "s" : "");
+ "%s%s%u start comment marker%s \"-{\" not balanced by equal later \"}-\"",
+ _ME_, topHin->dashBraceComment, topHin->dashBraceComment > 1 ? "s" : "");
return 1;
}
if (hparm->verbosity) {
@@ -144,24 +143,24 @@
ret = 0;
break;
case argstSingleQ:
- biffAddf(HEST, "%s: hit input end inside single-quoted string", __func__);
+ biffAddf(HEST, "%s%shit input end inside single-quoted string", _MEV_(vrbo));
ret = 1;
break;
case argstDoubleQ:
- biffAddf(HEST, "%s: hit input end inside double-quoted string", __func__);
+ biffAddf(HEST, "%s%shit input end inside double-quoted string", _MEV_(vrbo));
ret = 1;
break;
case argstEscapeIn:
- biffAddf(HEST, "%s: hit input end after \\ escape from arg", __func__);
+ biffAddf(HEST, "%s%shit input end after \\ escape from arg", _MEV_(vrbo));
ret = 1;
break;
case argstEscapeDQ:
- biffAddf(HEST, "%s: hit input end after \\ escape from double-quoted string",
- __func__);
+ biffAddf(HEST, "%s%shit input end after \\ escape from double-quoted string",
+ _MEV_(vrbo));
ret = 1;
break;
default:
- biffAddf(HEST, "%s: hit input end in unknown state %d", __func__, *stateP);
+ biffAddf(HEST, "%s%shit input end in unknown state %d", _MEV_(vrbo), *stateP);
ret = 1;
}
return ret;
@@ -270,7 +269,7 @@
histProcNextArgTry(int *nastP, hestArg *tharg, hestInputStack *hist,
const hestParm *hparm) {
if (!(nastP && tharg && hist && hparm)) {
- biffAddf(HEST, "%s: got NULL pointer (nastP %p tharg %p hist %p hparm %p)", __func__,
+ biffAddf(HEST, "%s%sgot NULL pointer (nastP %p tharg %p hist %p hparm %p)", _ME_,
AIR_VOIDP(nastP), AIR_VOIDP(tharg), AIR_VOIDP(hist), AIR_VOIDP(hparm));
return 1;
}
@@ -300,7 +299,7 @@
} else {
// we have gotten to the end of the given argv array, pop it as input source */
if (histPop(hist, hparm)) {
- biffAddf(HEST, "%s: trouble popping %s", __func__,
+ biffAddf(HEST, "%s%strouble popping %s", _ME_,
airEnumStr(hestSource, hestSourceCommandLine));
return 1;
}
@@ -321,12 +320,12 @@
} else {
icc = fgetc(hin->rfile); // may be EOF
}
- if (argstGo(nastP, tharg, &state, icc, hparm->verbosity > 1)) {
+ if (argstGo(nastP, tharg, &state, icc, hparm->verbosity > 3)) {
if (hestSourceResponseFile == hin->source) {
- biffAddf(HEST, "%s: trouble at character %u of %s \"%s\"", __func__,
- hin->carIdx, airEnumStr(hestSource, hin->source), hin->rfname);
+ biffAddf(HEST, "%s%strouble at character %u of %s \"%s\"", _ME_, hin->carIdx,
+ airEnumStr(hestSource, hin->source), hin->rfname);
} else {
- biffAddf(HEST, "%s: trouble at character %u of %s |%s|", __func__, hin->carIdx,
+ biffAddf(HEST, "%s%strouble at character %u of %s |%s|", _ME_, hin->carIdx,
airEnumStr(hestSource, hin->source), hin->dfltStr);
}
return 1;
@@ -337,10 +336,10 @@
// we're at end; pop input; *nastP already set to nastTryAgain by argstGo()
if (histPop(hist, hparm)) {
if (hestSourceResponseFile == hin->source) {
- biffAddf(HEST, "%s: trouble popping %s \"%s\"", __func__,
+ biffAddf(HEST, "%s%strouble popping %s \"%s\"", _ME_,
airEnumStr(hestSource, hin->source), hin->rfname);
} else {
- biffAddf(HEST, "%s: trouble popping %s |%s|", __func__,
+ biffAddf(HEST, "%s%strouble popping %s |%s|", _ME_,
airEnumStr(hestSource, hin->source), hin->dfltStr);
}
return 1;
@@ -357,7 +356,7 @@
// printf("!%s: hello hist->len %u\n", __func__, hist->len);
do {
if (histProcNextArgTry(nastP, tharg, hist, hparm)) {
- biffAddf(HEST, "%s: trouble getting next arg", __func__);
+ biffAddf(HEST, "%s%strouble getting next arg", _ME_);
return 1;
}
if (hparm->verbosity > 1) {
@@ -368,16 +367,16 @@
return 0;
}
-#if 0 // not used yet
+#if 0
static int
histPushDefault(hestInputStack *hist, const char *dflt, const hestParm *hparm) {
if (!(hist && dflt && hparm)) {
- biffAddf(HEST, "%s: got NULL pointer (hist %p, dflt %p, hparm %p)", __func__,
+ biffAddf(HEST, "%s%sgot NULL pointer (hist %p, dflt %p, hparm %p)", _ME_,
AIR_VOIDP(hist), AIR_VOIDP(dflt), AIR_VOIDP(hparm));
return 1;
}
if (HIST_DEPTH_MAX == hist->len) {
- biffAddf(HEST, "%s: input stack depth already at max %u", __func__, HIST_DEPTH_MAX);
+ biffAddf(HEST, "%s%sinput stack depth already at max %u", _ME_, HIST_DEPTH_MAX);
return 1;
}
if (hparm->verbosity) {
@@ -399,12 +398,12 @@
histPushCommandLine(hestInputStack *hist, int argc, const char **argv,
const hestParm *hparm) {
if (!(hist && argv && hparm)) {
- biffAddf(HEST, "%s: got NULL pointer (hist %p, argv %p, hparm %p)", __func__,
+ biffAddf(HEST, "%s%sgot NULL pointer (hist %p, argv %p, hparm %p)", _ME_,
AIR_VOIDP(hist), AIR_VOIDP(argv), AIR_VOIDP(hparm));
return 1;
}
if (HIST_DEPTH_MAX == hist->len) {
- biffAddf(HEST, "%s: input stack depth already at max %u", __func__, HIST_DEPTH_MAX);
+ biffAddf(HEST, "%s%sinput stack depth already at max %u", _ME_, HIST_DEPTH_MAX);
return 1;
}
if (hparm->verbosity) {
@@ -426,21 +425,21 @@
static int
histPushResponseFile(hestInputStack *hist, const char *rfname, const hestParm *hparm) {
if (!(hist && rfname && hparm)) {
- biffAddf(HEST, "%s: got NULL pointer (hist %p, rfname %p, hparm %p)", __func__,
+ biffAddf(HEST, "%s%sgot NULL pointer (hist %p, rfname %p, hparm %p)", _ME_,
AIR_VOIDP(hist), AIR_VOIDP(rfname), AIR_VOIDP(hparm));
return 1;
}
if (HIST_DEPTH_MAX == hist->len) {
// HEY test this error
- biffAddf(HEST, "%s: input stack depth already at max %u", __func__, HIST_DEPTH_MAX);
+ biffAddf(HEST, "%s%sinput stack depth already at max %u", _ME_, HIST_DEPTH_MAX);
return 1;
}
if (!strlen(rfname)) {
// HEY test this error
biffAddf(HEST,
- "%s: saw arg start with response file flag \"%c\" "
+ "%s%ssaw arg start with response file flag \"%c\" "
"but no filename followed",
- __func__, RESPONSE_FILE_FLAG);
+ _ME_, RESPONSE_FILE_FLAG);
return 1;
}
// have we seen rfname before?
@@ -452,9 +451,9 @@
&& !strcmp(oldHin->rfname, rfname)) {
// HEY test this error
biffAddf(HEST,
- "%s: already reading \"%s\" as response file; "
+ "%s%salready reading \"%s\" as response file; "
"cannot recursively read it again",
- __func__, rfname);
+ _ME_, rfname);
return 1;
}
}
@@ -462,7 +461,7 @@
// are we trying to read stdin twice?
if (!strcmp("-", rfname) && hist->stdinRead) {
// HEY test this error
- biffAddf(HEST, "%s: response filename \"%s\" but previously read stdin", __func__,
+ biffAddf(HEST, "%s%sresponse filename \"%s\" but previously read stdin", _ME_,
rfname);
return 1;
}
@@ -469,7 +468,7 @@
// try to open response file
FILE *rfile = airFopen(rfname, stdin, "r");
if (!(rfile)) {
- biffAddf(HEST, "%s: couldn't fopen(\"%s\",\"r\"): %s", __func__, rfname,
+ biffAddf(HEST, "%s%scouldn't fopen(\"%s\",\"r\"): %s", _ME_, rfname,
strerror(errno));
return 1;
}
@@ -528,8 +527,7 @@
const char *srcstr = airEnumStr(hestSource, topHin->source);
// read next arg into tharg
if (histProcNextArg(&nast, tharg, hist, hparm)) {
- biffAddf(HEST, "%s: (iter %u, on %s) unable to get next arg", __func__, iters,
- srcstr);
+ biffAddf(HEST, "%s%s(iter %u, on %s) unable to get next arg", _ME_, iters, srcstr);
return 1;
}
if (nastEmpty == nast) {
@@ -550,9 +548,9 @@
continue; // since }- does not belong in havec
} else {
biffAddf(HEST,
- "%s: (iter %u, on %s) end comment marker \"}-\" not "
+ "%s%s(iter %u, on %s) end comment marker \"}-\" not "
"balanced by prior \"-{\"",
- __func__, iters, srcstr);
+ _ME_, iters, srcstr);
return 1;
}
}
@@ -581,12 +579,12 @@
for parsing results nor error messages about that process */
return 0;
} else {
- biffAddf(HEST, "%s: (iter %u, on %s) \"--help\" not expected here", __func__,
- iters, srcstr);
+ biffAddf(HEST, "%s%s(iter %u, on %s) \"--help\" not expected here", _ME_, iters,
+ srcstr);
return 1;
}
}
- if (hparm->verbosity > 1) {
+ if (hparm->verbosity > 2) {
printf("%s: (iter %u, on %s) looking at latest tharg |%s|\n", __func__, iters,
srcstr, tharg->str);
}
@@ -593,8 +591,8 @@
if (hparm->responseFileEnable && tharg->str[0] == RESPONSE_FILE_FLAG) {
// tharg->str is asking to open a response file; try pushing it
if (histPushResponseFile(hist, tharg->str + 1, hparm)) {
- biffAddf(HEST, "%s: (iter %u, on %s) unable to process response file %s",
- __func__, iters, srcstr, tharg->str);
+ biffAddf(HEST, "%s%s(iter %u, on %s) unable to process response file %s", _ME_,
+ iters, srcstr, tharg->str);
return 1;
}
// have just added response file to stack, next iter will start reading from it
@@ -610,7 +608,7 @@
havec->harg[havec->len - 1]->source = topHin->source;
}
if (hist->len && nast == nastEmpty) {
- biffAddf(HEST, "%s: non-empty stack (depth %u) can't generate args???", __func__,
+ biffAddf(HEST, "%s%snon-empty stack (depth %u) can't generate args???", _ME_,
hist->len);
return 1;
}
@@ -685,20 +683,21 @@
}
static int
-havecTransfer(hestArgVec *hvdst, hestArgVec *hvsrc, uint srcIdx, uint num) {
+havecTransfer(hestArgVec *hvdst, hestArgVec *hvsrc, uint srcIdx, uint num,
+ const hestParm *hparm) {
if (!(hvdst && hvsrc)) {
- biffAddf(HEST, "%s: got NULL dst %p or src %p", __func__, AIR_VOIDP(hvdst),
+ biffAddf(HEST, "%s%sgot NULL dst %p or src %p", _ME_, AIR_VOIDP(hvdst),
AIR_VOIDP(hvsrc));
return 1;
}
if (num) {
if (!(srcIdx < hvsrc->len)) {
- biffAddf(HEST, "%s: starting index %u in source beyond its length %u", __func__,
+ biffAddf(HEST, "%s%sstarting index %u in source beyond its length %u", _ME_,
srcIdx, hvsrc->len);
return 1;
}
if (!(srcIdx + num <= hvsrc->len)) {
- biffAddf(HEST, "%s: have only %u args but want %u starting at %u", __func__,
+ biffAddf(HEST, "%s%shave only %u args but want %u starting at %u", _ME_,
hvsrc->len, num, srcIdx);
return 1;
}
@@ -758,7 +757,7 @@
uint argIdx = 0;
hestOpt *theOpt = NULL;
while (argIdx < havec->len) { // NOTE: havec->len may decrease within an interation!
- if (hparm->verbosity) {
+ if (hparm->verbosity > 1) {
printf("%s: ------------- argIdx = %u (of %u) -> argv[argIdx] = |%s|\n", __func__,
argIdx, havec->len, havec->harg[argIdx]->str);
}
@@ -765,7 +764,7 @@
uint optIdx = whichOptFlag(opt, havec->harg[argIdx]->str, hparm);
if (UINT_MAX == optIdx) {
// havec->harg[argIdx]->str is not a flag for any option, move on to next arg
- if (hparm->verbosity) {
+ if (hparm->verbosity > 2) {
printf("%s: |%s| not a flag arg, continue\n", __func__,
havec->harg[argIdx]->str);
}
@@ -811,26 +810,26 @@
if (parmNum < theOpt->min) { // didn't get required min # parameters
if (hitEnd) {
biffAddf(HEST,
- "%s: hit end of args before getting %u parameter%s "
+ "%s%shit end of args before getting %u parameter%s "
"for %s (got %u)",
- __func__, theOpt->min, theOpt->min > 1 ? "s" : "",
- identStr(ident1, theOpt), parmNum);
+ _ME_, theOpt->min, theOpt->min > 1 ? "s" : "", identStr(ident1, theOpt),
+ parmNum);
} else if (hitVPS) {
biffAddf(HEST,
- "%s: hit \"-%c\" (variable-parameter-stop flag) before getting %u "
+ "%s%shit \"-%c\" (variable-parameter-stop flag) before getting %u "
"parameter%s for %s (got %u)",
- __func__, VAR_PARM_STOP_FLAG, theOpt->min, theOpt->min > 1 ? "s" : "",
+ _ME_, VAR_PARM_STOP_FLAG, theOpt->min, theOpt->min > 1 ? "s" : "",
identStr(ident1, theOpt), parmNum);
} else if (UINT_MAX != nextOptIdx) {
- biffAddf(HEST, "%s: saw %s before getting %u parameter%s for %s (got %d)",
- __func__, identStr(ident2, opt + nextOptIdx), theOpt->min,
+ biffAddf(HEST, "%s%ssaw %s before getting %u parameter%s for %s (got %d)", _ME_,
+ identStr(ident2, opt + nextOptIdx), theOpt->min,
theOpt->min > 1 ? "s" : "", identStr(ident1, theOpt), parmNum);
} else {
biffAddf(HEST,
- "%s: sorry, confused about not getting %u "
+ "%s%ssorry, confused about not getting %u "
"parameter%s for %s (got %d)",
- __func__, theOpt->min, theOpt->min > 1 ? "s" : "",
- identStr(ident1, theOpt), parmNum);
+ _ME_, theOpt->min, theOpt->min > 1 ? "s" : "", identStr(ident1, theOpt),
+ parmNum);
}
return 1;
}
@@ -850,8 +849,8 @@
sprintf(info, "main havec after losing argIdx %u", argIdx);
hestArgVecPrint(__func__, info, havec);
}
- if (havecTransfer(theOpt->havec, havec, argIdx, parmNum)) {
- biffAddf(HEST, "%s: trouble transferring %u args for %s", __func__, parmNum,
+ if (havecTransfer(theOpt->havec, havec, argIdx, parmNum, hparm)) {
+ biffAddf(HEST, "%s%strouble transferring %u args for %s", _ME_, parmNum,
identStr(ident1, theOpt));
return 1;
}
@@ -884,7 +883,7 @@
}
// if needs to be set but hasn't been
if (needing && hestSourceUnknown == theOpt->source) {
- biffAddf(HEST, "%s: didn't get required %s", __func__, identStr(ident1, theOpt));
+ biffAddf(HEST, "%s%sdidn't get required %s", _ME_, identStr(ident1, theOpt));
return 1;
}
}
@@ -958,8 +957,9 @@
if (hparm->verbosity) {
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__,
+ opt[opi].source = havec->harg[0]->source;
+ if (havecTransfer(opt[opi].havec, havec, 0, opt[opi].min /* min == max */, hparm)) {
+ biffAddf(HEST, "%s%strouble getting args for %s", _ME_,
identStr(ident, opt + opi));
return 1;
}
@@ -976,9 +976,9 @@
uint opi = nextUnflagged(unflagVar + 1, opt);
uint np = opt[opi].min;
biffAddf(HEST,
- "%s: remaining %u args not enough for the %u parameter%s "
+ "%s%sremaining %u args not enough for the %u parameter%s "
"needed for %s or later options",
- __func__, havec->len, np, np > 1 ? "s" : "", identStr(ident, opt + opi));
+ _ME_, havec->len, np, np > 1 ? "s" : "", identStr(ident, opt + opi));
return 1;
}
/* else we had enough args for all the unflagged options following
@@ -986,8 +986,9 @@
for (uint opi = nextUnflagged(unflagVar + 1, opt); opi < optNum;
opi = nextUnflagged(opi + 1, opt)) {
// HEY check the nvp start
- if (havecTransfer(opt[opi].havec, havec, nvp, opt[opi].min /* min == max */)) {
- biffAddf(HEST, "%s: trouble getting args for %s", __func__,
+ if (havecTransfer(opt[opi].havec, havec, nvp, opt[opi].min /* min == max */,
+ hparm)) {
+ biffAddf(HEST, "%s%strouble getting args for %s", _ME_,
identStr(ident, opt + opi));
return 1;
}
@@ -1010,13 +1011,13 @@
triggered this error message when there were zero given parms, but the default
could have supplied them */
if (nvp < AIR_INT(opt[unflagVar].min)) {
- biffAddf(HEST, "%s: didn't get minimum of %d arg%s for %s (got %d)", __func__,
+ biffAddf(HEST, "%s%sdidn't get minimum of %d arg%s for %s (got %d)", _ME_,
opt[unflagVar].min, opt[unflagVar].min > 1 ? "s" : "",
identStr(ident, opt + unflagVar), nvp);
return 1;
}
- if (havecTransfer(opt[unflagVar].havec, havec, 0, nvp)) {
- biffAddf(HEST, "%s: trouble getting args for %s", __func__,
+ if (havecTransfer(opt[unflagVar].havec, havec, 0, nvp, hparm)) {
+ biffAddf(HEST, "%s%strouble getting args for %s", _ME_,
identStr(ident, opt + unflagVar));
return 1;
}
@@ -1031,9 +1032,9 @@
}
if (havec->len) {
biffAddf(HEST,
- "%s: after handling %u unflagged opts, still have unexpected %u args "
+ "%s%safter handling %u unflagged opts, still have unexpected %u args "
"left in (starting with \"%s\")",
- __func__, unflagNum, havec->len, havec->harg[0]->str);
+ _ME_, unflagNum, havec->len, havec->harg[0]->str);
return 1;
}
return 0;
@@ -1077,11 +1078,12 @@
// error string song and dance
#define DO_ERR(WUT) \
+ biffAddf(HEST, "%s%s" WUT, _MEV_(HPARM->verbosity)); \
char *err = biffGetDone(HEST); \
if (errP) { \
*errP = err; \
} else { \
- fprintf(stderr, "%s: " WUT ":\n%s", __func__, err); \
+ fprintf(stderr, "%s: problem:\n%s", __func__, err); \
free(err); \
}
@@ -1125,6 +1127,7 @@
// --2--2--2--2--2-- extract args associated with flagged and unflagged opt
if (havecExtractFlagged(opt, havec, HPARM)
+ // this will detect extraneous args after unflaggeds are extracted
|| havecExtractUnflagged(opt, havec, HPARM)) {
DO_ERR("problem extracting args for options");
airMopError(mop);
Modified: teem/trunk/src/hest/privateHest.h
===================================================================
--- teem/trunk/src/hest/privateHest.h 2025-09-24 06:38:03 UTC (rev 7481)
+++ teem/trunk/src/hest/privateHest.h 2025-09-24 08:24:08 UTC (rev 7482)
@@ -79,6 +79,20 @@
extern int _hestMax(int max);
extern int _hestOPCheck(const hestOpt *opt, const hestParm *parm);
+/* wacky hack to use with biffAddf(HEST), so that normal hest users, who haven't
+ cranked up hestParm->verbosity to debug hest itself and don't want error messages
+ prefixed by a lot of weird hest function names:
+ In a function where hestParm *hparm is defined, the biff call should look like:
+ biffAddf(HEST, "%s%sthis is the error", _ME_, ... )
+ Note the "%s%s" start, with NO following space.
+ Or if its not hparm but some other source `verb` of a verbosity level
+ biffAddf(HEST, "%s%sthis is the error", _MEV_(verb), ... )
+ */
+#define _ME_ \
+ ((hparm) && (hparm)->verbosity ? __func__ : ""), \
+ ((hparm) && (hparm)->verbosity ? ": " : "")
+#define _MEV_(V) ((V) ? __func__ : ""), ((V) ? ": " : "")
+
#ifdef __cplusplus
}
#endif
Modified: teem/trunk/src/hest/test/tparse.c
===================================================================
--- teem/trunk/src/hest/test/tparse.c 2025-09-24 06:38:03 UTC (rev 7481)
+++ teem/trunk/src/hest/test/tparse.c 2025-09-24 08:24:08 UTC (rev 7482)
@@ -34,7 +34,7 @@
hestParm *hparm = hestParmNew();
hparm->respectDashDashHelp = AIR_TRUE;
hparm->responseFileEnable = AIR_TRUE;
- hparm->verbosity = 3;
+ hparm->verbosity = 1;
int verb;
hestOptAdd_1_Int(&opt, "v", "verb", &verb, "0", "verbosity");
@@ -44,8 +44,9 @@
unsigned int 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 *unpB;
+ unsigned int sawB;
+ hestOptAdd_Nv_Int(&opt, NULL, "B B", 1, -1, &unpB, NULL, "unflagged B", &sawB);
int flag;
hestOptAdd_Flag(&opt, "b,bingo", &flag, "a flag");
int glaf;
@@ -52,6 +53,11 @@
hestOptAdd_Flag(&opt, "c,cingo", &glaf, "a flag");
int unpC[2];
hestOptAdd_2_Int(&opt, NULL, "C C", unpC, NULL, "unflagged C");
+ /*
+ int *unpC;
+ unsigned int sawC;
+ hestOptAdd_Nv_Int(&opt, NULL, "C C", 1, 2, &unpC, NULL, "unflagged C", &sawC);
+ */
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.
|