|
From: <kin...@us...> - 2025-09-22 09:22:24
|
Revision: 7464
http://sourceforge.net/p/teem/code/7464
Author: kindlmann
Date: 2025-09-22 09:22:17 +0000 (Mon, 22 Sep 2025)
Log Message:
-----------
hestParse re-write work continues, and ...
air API CHANGE:
* airParseStrT() are no longer var-args; it was a mistaken way to enforce uniformity
across parsers for different types, and it was really only airParseStrE (for
parsing airEnum values) that needed it. Then airParseStrS sneakily used it for
its final "greedy" argument, which was also a bad idea to overcome bad ideas in
hestParse(), which have since been fixed with its 2025 re-write.
* Renamed airParseStrLI, airParseStrULI --> airParseStrL, airParseStrUL
* Added airParseStrH and airParseStrUH for signed and unsigned shorts
* Removed airStrtokQuoting (another bad idea; used only for "unu make")
* Moved the airTypeT enum values from air to hest, since hest was the motivation for
creating them so they should be localized to hest. To avoid needlessly breaking code
that uses hestOptAdd(), which depends on the airTypeT enum values, those have kept
their names, except:
*** added airTypeShort and airTypeUShort
*** renamed airTypeLongInt --> airTypeLong
*** renamed airTypeULongInt --> airTypeULong
* Removed the following from air to hest, renamed them, and made them private.
They were only used to implement hest, no where else in Teem, so they never
deserved to be in air:
#define AIR_TYPE_MAX --> _HEST_TYPE_MAX
const char airTypeStr[HEST_TYPE_MAX + 1][AIR_STRLEN_SMALL + 1] --> _hestTypeStr
const size_t airTypeSize[HEST_TYPE_MAX + 1] --> _hestTypeSize
unsigned int (*const airParseStr[AIR_TYPE_MAX + 1])(void *,
const char *, *const char *,
*unsigned int);
--> _hestParseStr
hest API CHANGE
* (as noted above: airType* enum values moved to hest.h)
* removed field from hestParm in hest.h:
greedySingleString, /* when parsing a single string, whether or not to be greedy
(as per airParseStrS) */
* removed the corresponding default from defaultsHest.c
HEST_EXPORT int hestDefaultGreedySingleString;
Why: these only existed as part of a bad idea to overcome other bad ideas on how
hestParse worked; those have been addressed with the re-write.
Modified Paths:
--------------
teem/trunk/src/air/air.h
teem/trunk/src/air/miscAir.c
teem/trunk/src/air/parseAir.c
teem/trunk/src/air/string.c
teem/trunk/src/bin/unu.c
teem/trunk/src/hest/adders.c
teem/trunk/src/hest/argvHest.c
teem/trunk/src/hest/defaultsHest.c
teem/trunk/src/hest/hest.h
teem/trunk/src/hest/methodsHest.c
teem/trunk/src/hest/parseHest.c
teem/trunk/src/hest/parsest.c
teem/trunk/src/hest/privateHest.h
teem/trunk/src/hest/test/ex6.c
teem/trunk/src/hest/test/tparse.c
teem/trunk/src/hest/usage.c
teem/trunk/src/nrrd/formatVTK.c
teem/trunk/src/unrrdu/make.c
Modified: teem/trunk/src/air/air.h
===================================================================
--- teem/trunk/src/air/air.h 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/air/air.h 2025-09-22 09:22:17 UTC (rev 7464)
@@ -452,61 +452,63 @@
/* ---- END non-NrrdIO */
-/*
-******** airType
-**
-** Different types which air cares about.
-** Currently only used in the command-line parsing, but perhaps will
-** be used elsewhere in air later
-*/
-enum {
- airTypeUnknown, /* 0 */
- airTypeBool, /* 1 */
- airTypeInt, /* 2 */
- airTypeUInt, /* 3 */
- airTypeLongInt, /* 4 */
- airTypeULongInt, /* 5 */
- airTypeSize_t, /* 6 */
- airTypeFloat, /* 7 */
- airTypeDouble, /* 8 */
- airTypeChar, /* 9 */
- airTypeString, /* 10 */
- airTypeEnum, /* 11 */
- airTypeOther, /* 12 */
- airTypeLast
-};
-#define AIR_TYPE_MAX 12
+/* changes for for TeemV2:
+ *** airParseStrT() are no longer var-args; it was a mistaken way to enforce uniformity
+ * across parsers for different types, and it was really only airParseStrE (for
+ * parsing airEnum values) that needed it. Then airParseStrS sneakily used it for
+ * its final "greedy" argument, which was also a bad idea to overcome bad ideas in
+ * hestParse(), which have since been fixed with its 2025 re-write.
+ *** Renamed airParseStrLI, airParseStrULI --> airParseStrL, airParseStrUL
+ *** Added airParseStrH and airParseStrUH for signed and unsigned shorts
+ *** Removed airStrtokQuoting (another bad idea; used only for "unu make")
+ *** Moved the airTypeT enum values from air to hest, since hest was the motivation for
+ * creating them so they should be localized to hest. To avoid needlessly breaking code
+ * that uses hestOptAdd(), which depends on the airTypeT enum values, those have kept
+ * their names, except:
+ * *** added airTypeShort and airTypeUShort
+ * *** renamed airTypeLongInt --> airTypeLong
+ * *** renamed airTypeULongInt --> airTypeULong
+ *** Removed the following from air to hest, renamed them, and made them private.
+ * They were only used to implement hest, no where else in Teem, so they never
+ * deserved to be in air:
+ * #define AIR_TYPE_MAX --> _HEST_TYPE_MAX
+ * const char airTypeStr[HEST_TYPE_MAX + 1][AIR_STRLEN_SMALL + 1] --> _hestTypeStr
+ * const size_t airTypeSize[HEST_TYPE_MAX + 1] --> _hestTypeSize
+ * unsigned int (*const airParseStr[AIR_TYPE_MAX + 1])(void *,
+ const char *, *const char *,
+ *unsigned int);
+ * --> _hestParseStr
+ */
/* parseAir.c */
AIR_EXPORT double airAtod(const char *str);
AIR_EXPORT int airSingleSscanf(const char *str, const char *fmt, void *ptr);
AIR_EXPORT const airEnum *const airBool;
AIR_EXPORT unsigned int airParseStrB(int *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
+ unsigned int n);
+AIR_EXPORT unsigned int airParseStrH(short *out, const char *s, const char *ct,
+ unsigned int n);
+AIR_EXPORT unsigned int airParseStrUH(unsigned short *out, const char *s, const char *ct,
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrI(int *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrUI(unsigned int *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
-AIR_EXPORT unsigned int airParseStrLI(long int *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
-AIR_EXPORT unsigned int airParseStrULI(unsigned long int *out, const char *s,
- const char *ct, unsigned int n,
- ... /* (nothing used) */);
+ unsigned int n);
+AIR_EXPORT unsigned int airParseStrL(long int *out, const char *s, const char *ct,
+ unsigned int n);
+AIR_EXPORT unsigned int airParseStrUL(unsigned long int *out, const char *s,
+ const char *ct, unsigned int n);
AIR_EXPORT unsigned int airParseStrZ(size_t *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrF(float *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrD(double *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrC(char *out, const char *s, const char *ct,
- unsigned int n, ... /* (nothing used) */);
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrS(char **out, const char *s, const char *ct,
- unsigned int n,
- ... /* REQ'D even if n>1: int greedy */);
+ unsigned int n);
AIR_EXPORT unsigned int airParseStrE(int *out, const char *s, const char *ct,
- unsigned int n, ... /* REQUIRED: airEnum *e */);
-AIR_EXPORT unsigned int (*const airParseStr[AIR_TYPE_MAX + 1])(void *, const char *,
- const char *,
- unsigned int, ...);
+ unsigned int n, const airEnum *enm);
/* string.c */
AIR_EXPORT char *airStrdup(const char *s);
@@ -514,7 +516,6 @@
/* ---- BEGIN non-NrrdIO */
AIR_EXPORT int airStrcmp(const char *s1, const char *s2);
/* ---- END non-NrrdIO */
-AIR_EXPORT int airStrtokQuoting;
AIR_EXPORT char *airStrtok(char *s, const char *ct, char **last);
AIR_EXPORT unsigned int airStrntok(const char *s, const char *ct);
AIR_EXPORT char *airStrtrans(char *s, char from, char to);
@@ -580,8 +581,6 @@
AIR_EXPORT airULLong airIndexClampULL(double min, double val, double max, airULLong N);
AIR_EXPORT char *airDoneStr(double start, double here, double end, char *str);
AIR_EXPORT double airTime(void);
-AIR_EXPORT const char airTypeStr[AIR_TYPE_MAX + 1][AIR_STRLEN_SMALL + 1];
-AIR_EXPORT const size_t airTypeSize[AIR_TYPE_MAX + 1];
AIR_EXPORT void airEqvAdd(airArray *eqvArr, unsigned int j, unsigned int k);
AIR_EXPORT unsigned int airEqvMap(airArray *eqvArr, unsigned int *map, unsigned int len);
AIR_EXPORT unsigned int airEqvSettle(unsigned int *map, unsigned int len);
Modified: teem/trunk/src/air/miscAir.c
===================================================================
--- teem/trunk/src/air/miscAir.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/air/miscAir.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -624,42 +624,6 @@
#endif
}
-/* clang-format off */
-const char
-airTypeStr[AIR_TYPE_MAX+1][AIR_STRLEN_SMALL+1] = {
- "(unknown)",
- "bool",
- "int",
- "unsigned int",
- "long int",
- "unsigned long int",
- "size_t",
- "float",
- "double",
- "char",
- "string",
- "enum",
- "other",
-};
-
-const size_t
-airTypeSize[AIR_TYPE_MAX+1] = {
- 0,
- sizeof(int),
- sizeof(int),
- sizeof(unsigned int),
- sizeof(long int),
- sizeof(unsigned long int),
- sizeof(size_t),
- sizeof(float),
- sizeof(double),
- sizeof(char),
- sizeof(char*),
- sizeof(int),
- 0 /* we don't know anything about type "other" */
-};
-/* clang-format on */
-
/*
******** airEqvSettle()
**
Modified: teem/trunk/src/air/parseAir.c
===================================================================
--- teem/trunk/src/air/parseAir.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/air/parseAir.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -78,6 +78,8 @@
return val;
}
+// NOTE: see info n air.h about TeemV2 changes to all things airType and airParse
+
int
airSingleSscanf(const char *str, const char *fmt, void *ptr) {
char *tmp;
@@ -145,8 +147,35 @@
}
}
-#define _PARSE_STR_ARGS(type) \
- type *out, const char *_s, const char *ct, unsigned int n, ...
+unsigned int
+airParseStrB(int *out, const char *_s, const char *ct, unsigned int n) {
+ unsigned int i;
+ char *tmp, *s, *last;
+
+ /* if we got NULL, there's nothing to do */
+ if (!(out && _s && ct)) return 0;
+
+ /* copy the input so that we don't change it */
+ s = airStrdup(_s);
+
+ /* keep calling airStrtok() until we have everything */
+ for (i = 0; i < n; i++) {
+ tmp = airStrtok(i ? NULL : s, ct, &last);
+ if (!tmp) {
+ free(s);
+ return i;
+ }
+ out[i] = airEnumVal(airBool, tmp);
+ if (airEnumUnknown(airBool) == out[i]) {
+ free(s);
+ return i;
+ }
+ }
+ free(s);
+ return n;
+}
+
+#define _PARSE_STR_ARGS(type) type *out, const char *_s, const char *ct, unsigned int n
#define _PARSE_STR_BODY(format) \
unsigned int i; \
char *tmp, *s, *last; \
@@ -174,22 +203,26 @@
/*
******* airParse*()
-**
-** parse ints, floats, doubles, or single characters, from some
-** given string "s"; try to parse "n" of them, as delimited by
-** characters in "ct", and put the results in "out".
-**
-** Returns the number of things succesfully parsed- should be n;
-** there's been an error if return is < n.
-**
-** The embarrassing reason for the var-args ("...") is that I want the
-** type signature of all these functions to be the same, and I have a function
-** for parsing airEnums, in case the airEnum must be supplied as a final
-** argument.
-**
-** This uses air's thread-safe strtok() replacement: airStrtok()
+*
+* parse `n` shorts, ints, floats, doubles, or single chars, from some given string `s`;
+* the `n` of them are delimited by characters in `ct`; put the results in `out`.
+*
+* Returns the number of things succesfully parsed- should be `n`; there's been an error
+* if return is < `n`.
+*
+* This uses air's thread-safe strtok() replacement: airStrtok()
*/
unsigned int
+airParseStrH(_PARSE_STR_ARGS(short)) {
+ _PARSE_STR_BODY("%hd")
+}
+
+unsigned int
+airParseStrUH(_PARSE_STR_ARGS(unsigned short)) {
+ _PARSE_STR_BODY("%hu")
+}
+
+unsigned int
airParseStrI(_PARSE_STR_ARGS(int)) {
_PARSE_STR_BODY("%d")
}
@@ -200,12 +233,12 @@
}
unsigned int
-airParseStrLI(_PARSE_STR_ARGS(long int)) {
+airParseStrL(_PARSE_STR_ARGS(long int)) {
_PARSE_STR_BODY("%ld")
}
unsigned int
-airParseStrULI(_PARSE_STR_ARGS(unsigned long int)) {
+airParseStrUL(_PARSE_STR_ARGS(unsigned long int)) {
_PARSE_STR_BODY("%lu")
}
@@ -225,7 +258,7 @@
}
unsigned int
-airParseStrB(int *out, const char *_s, const char *ct, unsigned int n, ...) {
+airParseStrC(char *out, const char *_s, const char *ct, unsigned int n) {
unsigned int i;
char *tmp, *s, *last;
@@ -242,34 +275,6 @@
free(s);
return i;
}
- out[i] = airEnumVal(airBool, tmp);
- if (airEnumUnknown(airBool) == out[i]) {
- free(s);
- return i;
- }
- }
- free(s);
- return n;
-}
-
-unsigned int
-airParseStrC(char *out, const char *_s, const char *ct, unsigned int n, ...) {
- unsigned int i;
- char *tmp, *s, *last;
-
- /* if we got NULL, there's nothing to do */
- if (!(out && _s && ct)) return 0;
-
- /* copy the input so that we don't change it */
- s = airStrdup(_s);
-
- /* keep calling airStrtok() until we have everything */
- for (i = 0; i < n; i++) {
- tmp = airStrtok(i ? NULL : s, ct, &last);
- if (!tmp) {
- free(s);
- return i;
- }
out[i] = tmp[0];
}
free(s);
@@ -276,19 +281,15 @@
return n;
}
+/* for TeemV2: "greedy" was a dumb idea, and is gone. It used to be passed in as the last
+ * var-args argument. In the case of n==1, if greedy than the whole string was returned,
+ * else (!greedy) airStrtok() was called */
unsigned int
-airParseStrS(char **out, const char *_s, const char *ct, unsigned int n, ...) {
+airParseStrS(char **out, const char *_s, const char *ct, unsigned int n) {
unsigned int i;
- int greedy;
char *tmp, *s, *last;
airArray *mop;
- va_list ap;
- /* grab "greedy" every time, prior to error checking */
- va_start(ap, n);
- greedy = va_arg(ap, int);
- va_end(ap);
-
/* if we got NULL, there's nothing to do */
if (!(out && _s && ct)) return 0;
@@ -299,10 +300,7 @@
/* keep calling airStrtok() until we have everything */
for (i = 0; i < n; i++) {
- /* if n == 1, then with greediness, the whole string is used,
- and without greediness, we use airStrtok() to get only
- the first part of it */
- if (n > 1 || !greedy) {
+ if (n > 1) {
tmp = airStrtok(i ? NULL : s, ct, &last);
} else {
tmp = s;
@@ -323,18 +321,15 @@
}
unsigned int
-airParseStrE(int *out, const char *_s, const char *ct, unsigned int n, ...) {
+airParseStrE(int *out,
+ const char *_s,
+ const char *ct,
+ unsigned int n,
+ const airEnum *enm) {
unsigned int i;
char *tmp, *s, *last;
airArray *mop;
- va_list ap;
- airEnum *enm;
- /* grab the enum every time, prior to error checking */
- va_start(ap, n);
- enm = va_arg(ap, airEnum *);
- va_end(ap);
-
/* if we got NULL, there's nothing to do */
if (!(out && _s && ct)) {
return 0;
@@ -376,32 +371,3 @@
airMopOkay(mop);
return n;
}
-
-unsigned int (*const airParseStr[AIR_TYPE_MAX + 1])(void *, const char *, const char *,
- unsigned int, ...)
- = {
- NULL,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrB,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrI,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrUI,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrLI,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrULI,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrZ,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrF,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrD,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrC,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrS,
- (unsigned int (*)(void *, const char *, const char *, unsigned int,
- ...))airParseStrE,
- NULL /* no standard way of parsing type "other" */
-};
Modified: teem/trunk/src/air/string.c
===================================================================
--- teem/trunk/src/air/string.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/air/string.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -19,9 +19,11 @@
#include "air.h"
-/* this has to default to false in order for airStrtok to be a
- functional substitute for strtok() */
-int airStrtokQuoting = AIR_FALSE;
+/* removed for TeemV2:
+ * / * this has to default to false in order for airStrtok to be a
+ * functional substitute for strtok() * /
+ * int airStrtokQuoting = AIR_FALSE;
+ */
/*
******** airStrdup()
@@ -89,17 +91,18 @@
/* ---- END non-NrrdIO */
/*
******** airStrtok()
-**
-** thread-safe strtok() replacement. Use just like strtok(), but on
-** each call to parse a given string, pass as the last argument the
-** address of a char*, to be used for saving state while the string is
-** traversed. Like strtok(), this will alter the "s" array passed to
-** it on the first call, and like strtok(), this returns pointers into
-** this string (rather than allocating new strings for each token).
+*
+* thread-safe strtok() replacement. Use just like strtok(), but on each call to parse a
+* given string, pass as the last argument the address of a char*, to be used for saving
+* state while the string is traversed. Like strtok(), this will alter the "s" array
+* passed to it on the first call, and like strtok(), this returns pointers into this
+* string (rather than allocating new strings for each token).
+*
+* NOTE: TeemV2 removed global airStrtokQuoting and the code in here that used it.
*/
char *
airStrtok(char *s, const char *ct, char **last) {
- char *h, *e, *q;
+ char *h, *e;
if (!(ct && last)) {
/* can't do any work, bail */
@@ -108,24 +111,7 @@
h = s ? s : *last;
if (!airStrlen(h)) return NULL;
h += strspn(h, ct);
- if ('\"' == *h && airStrtokQuoting) {
- /* something is trying to be quoted, and, we'll respect that */
- /* have to find the next un-escaped '\"' */
- h++;
- q = h;
- while (*q && !('\"' == *q && '\\' != q[-1])) {
- q++;
- }
- if (*q) {
- /* we found an unescaped '\"' */
- e = q;
- } else {
- /* give up; pretend we never tried to do this quoting stuff */
- e = h + strcspn(h, ct);
- }
- } else {
- e = h + strcspn(h, ct);
- }
+ e = h + strcspn(h, ct);
if ('\0' == *e) {
*last = e;
} else {
Modified: teem/trunk/src/bin/unu.c
===================================================================
--- teem/trunk/src/bin/unu.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/bin/unu.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -70,7 +70,7 @@
hparm->respectDashDashHelp = AIR_TRUE;
/* set hparm->columns from ioctl if possible, else use unrrduDefNumColumns */
hestParmColumnsIoctl(hparm, unrrduDefNumColumns);
- hparm->greedySingleString = AIR_TRUE;
+ // Gone in TeemV2: hparm->greedySingleString = AIR_TRUE;
/* if there are no arguments, or "unu list" (or "unu all" shhh), then we give general
usage information */
Modified: teem/trunk/src/hest/adders.c
===================================================================
--- teem/trunk/src/hest/adders.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/hest/adders.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -301,10 +301,12 @@
(M, ATYP, CTYP) and applies it to all the simple scalar types */
#define MAP_T(MAC, M) \
MAC(M, Bool, int) \
+ MAC(M, Short, short int) \
+ MAC(M, UShort, unsigned short int) \
MAC(M, Int, int) \
MAC(M, UInt, unsigned int) \
- MAC(M, LongInt, long int) \
- MAC(M, ULongInt, unsigned long int) \
+ MAC(M, Long, long int) \
+ MAC(M, ULong, unsigned long int) \
MAC(M, Size_t, size_t) \
MAC(M, Float, float) \
MAC(M, Double, double) \
Modified: teem/trunk/src/hest/argvHest.c
===================================================================
--- teem/trunk/src/hest/argvHest.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/hest/argvHest.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -162,12 +162,13 @@
hinInit(void *_hin) {
hestInput *hin = (hestInput *)_hin;
hin->source = hestSourceUnknown;
- hin->dflt = NULL;
hin->argc = 0;
hin->argv = NULL;
hin->argIdx = 0;
hin->rfname = NULL;
hin->rfile = NULL;
+ hin->dfltStr = NULL;
+ hin->carIdx = 0;
hin->dashBraceComment = 0;
return;
}
@@ -183,10 +184,8 @@
static void
hinDone(void *_hin) {
hestInput *hin = (hestInput *)_hin;
- if (hin->rfile) {
- airFclose(hin->rfile);
- }
- AIR_UNUSED(hin);
+ hin->rfile = airFclose(hin->rfile);
+ hin->rfname = airFree(hin->rfname);
return;
}
Modified: teem/trunk/src/hest/defaultsHest.c
===================================================================
--- teem/trunk/src/hest/defaultsHest.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/hest/defaultsHest.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -31,5 +31,4 @@
int hestDefaultElideSingleEmptyStringDefault = AIR_FALSE;
int hestDefaultElideMultipleEmptyStringDefault = AIR_FALSE;
int hestDefaultNoArgsIsNoProblem = AIR_FALSE;
-int hestDefaultGreedySingleString = AIR_TRUE;
int hestDefaultCleverPluralizeOtherY = AIR_FALSE;
Modified: teem/trunk/src/hest/hest.h
===================================================================
--- teem/trunk/src/hest/hest.h 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/hest/hest.h 2025-09-22 09:22:17 UTC (rev 7464)
@@ -43,6 +43,44 @@
#endif
/*
+ * The airType values are here in hest as a transition hack for TeemV2. The parsing needs
+ * of hest are what motivated creating airTypes in the first place. The fresh perspective
+ * of TeemV2 recognizes they should have been in hest from the outset, not in air.
+ *
+ * The blissfully-type-unaware hestOptAdd() has always relied on the airTypeT enum values
+ * below. Since that function is not being removed, to avoid needless code breakage with
+ * TeemV2, these values now live in this hest header. hest users should instead be using
+ * the properly typed hestOptAdd_X_T functions, which have no need for airType
+ * pseudo-types.
+ *
+ * Other things that used to be in air, but which really only mattered to implement hest
+ * functions have been moved into privateHest.h, but with air --> hest renaming.
+ * #define AIR_TYPE_MAX
+ * const char airTypeStr[AIR_TYPE_MAX + 1][AIR_STRLEN_SMALL + 1];
+ * const size_t airTypeSize[AIR_TYPE_MAX + 1];
+ * unsigned int (*const airParseStr[AIR_TYPE_MAX + 1])(void *, const char *,const char
+ * unsigned int)
+ */
+enum {
+ airTypeUnknown, /* 0 */
+ airTypeBool, /* 1 */
+ airTypeShort, /* 2 (added for TeemV2) */
+ airTypeUShort, /* 3 (added for TeemV2) */
+ airTypeInt, /* 4 */
+ airTypeUInt, /* 5 */
+ airTypeLong, /* 6 (for TeemV2 renamed from airTypeLongInt) */
+ airTypeULong, /* 7 (for TeemV2 renamed from airTypeULongInt) */
+ airTypeSize_t, /* 8 */
+ airTypeFloat, /* 9 */
+ airTypeDouble, /* 10 */
+ airTypeChar, /* 11 */
+ airTypeString, /* 12 */
+ airTypeEnum, /* 13 */
+ airTypeOther, /* 14 */
+ airTypeLast
+};
+
+/*
******** hestSource* enum
**
** way of identifying where the info to satisfy a particular option came from.
@@ -49,9 +87,9 @@
*/
enum {
hestSourceUnknown, /* 0 */
- hestSourceDefault, /* 1 */
- hestSourceCommandLine, /* 2 (formerly called hestSourceUser) */
- hestSourceResponseFile, /* 3 */
+ hestSourceCommandLine, /* 1 (formerly called hestSourceUser) */
+ hestSourceResponseFile, /* 2 */
+ hestSourceDefault, /* 3 */
hestSourceLast
};
@@ -204,8 +242,6 @@
would be *ok* to invoke the problem without any further
command-line options. This is counter to pre-Teem-1.11 behavior
(for which no arguments *always* meant "show me usage info"). */
- greedySingleString, /* when parsing a single string, whether or not to be greedy
- (as per airParseStrS) */
cleverPluralizeOtherY, /* when printing the type for airTypeOther, when the min
number of items is > 1, and the type string ends with "y",
then pluralize with "ies" instead of "ys" */
@@ -248,15 +284,18 @@
// hestInput: what is the thing we're processing now to build up an arg vec
typedef struct {
int source; // from the hestSource* enum
- // ------ if source == hestSourceDefault ------
- const char *dflt; // we do NOT own
// ------ if source == hestSourceCommandLine ------
unsigned int argc;
const char **argv; // we do NOT own
unsigned int argIdx;
// ------ if source == hestSourceResponseFile ------
- const char *rfname; // we do NOT own: points into an argv or a hestArg
- FILE *rfile; // user opens and closes this
+ char *rfname; // we DO own
+ FILE *rfile; // user opens and closes this
+ // ------ if source == hestSourceDefault ------
+ const char *dfltStr; // we do NOT own
+ unsigned int dfltLen; // strlen(dfltStr)
+ // for both hestSourceResponseFile and hestSourceDefault
+ unsigned int carIdx; // which character are we on
// ------ general for all inputs ------
unsigned int dashBraceComment; /* not a boolean: how many -{ }- comment levels
deep are we currently; tracked this way to
@@ -281,7 +320,6 @@
HEST_EXPORT int hestDefaultElideSingleEmptyStringDefault;
HEST_EXPORT int hestDefaultElideMultipleEmptyStringDefault;
HEST_EXPORT int hestDefaultNoArgsIsNoProblem;
-HEST_EXPORT int hestDefaultGreedySingleString;
HEST_EXPORT int hestDefaultCleverPluralizeOtherY;
HEST_EXPORT unsigned int hestDefaultColumns;
@@ -355,10 +393,10 @@
// adders.c
HEST_EXPORT void hestOptAddDeclsPrint(FILE *f);
-/* Many many non-var-args alternatives to hestOptAdd, also usefully type-specific for the
-type of value to be parsed in a way that hestOptAdd_nva cannot match. These capture all
-the common uses (and then some) of hest within Teem. They are named according
-to kind, and according to the type T parameters to the option:
+/* The 99 (!) non-var-args alternatives to hestOptAdd, also usefully type-specific for
+the type of value to be parsed in a way that hestOptAdd_nva cannot match. These capture
+all the common uses (and then some) of hest within Teem. They are named according to
+kind, and according to the type T of the parms to be parsed for each option:
min, max function family kind description
min == max == 0 hestOptAdd_Flag 1 (stand-alone flag; no parameters)
@@ -367,17 +405,25 @@
min == 0; max == 1 hestOptAdd_1v_T 4 single variable parameter
min < max; max >= 2 hestOptAdd_Nv_T 5 multiple variable parameters
-An airEnum* is passed for _Enum options; or a hestCB* for _Other options. The number of
-parameters *sawP that hestParm saw on the command-line is passed for the _Nv_ options.
+The type T can be: Bool, Short, UShort, Int, UInt, Long, ULong, Size_t, Float, Double,
+Char, String, Enum, and Other. An airEnum* is passed with the T=Enum functions, or a
+hestCB* is passed for the T=Other functions. The number of parameters *sawP that hestParm
+saw on the command-line is passed for the _Nv_ options.
-All declarations below were automatically generated via hestOptAddDeclsPrint (followed by
-clang-format), which (like the implementation of all the functions) is done via lots of
-#define macro tricks. */
+All declarations below were automatically generated via hest/test/decls (which calls
+hestOptAddDeclsPrint), followed by clang-format. */
HEST_EXPORT unsigned int hestOptAdd_Flag(hestOpt **optP, const char *flag, int *valueP,
const char *info);
HEST_EXPORT unsigned int hestOptAdd_1v_Bool(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Short(hestOpt **hoptP, const char *flag,
+ const char *name, short int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_UShort(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned short int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1v_Int(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info);
@@ -384,13 +430,12 @@
HEST_EXPORT unsigned int hestOptAdd_1v_UInt(hestOpt **hoptP, const char *flag,
const char *name, unsigned int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1v_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, long int *valueP,
- const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1v_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name,
- unsigned long int *valueP,
- const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_Long(hestOpt **hoptP, const char *flag,
+ const char *name, long int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1v_ULong(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned long int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1v_Size_t(hestOpt **hoptP, const char *flag,
const char *name, size_t *valueP,
const char *dflt, const char *info);
@@ -417,6 +462,13 @@
HEST_EXPORT unsigned int hestOptAdd_1_Bool(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1_Short(hestOpt **hoptP, const char *flag,
+ const char *name, short int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1_UShort(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned short int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Int(hestOpt **hoptP, const char *flag,
const char *name, int *valueP,
const char *dflt, const char *info);
@@ -423,13 +475,12 @@
HEST_EXPORT unsigned int hestOptAdd_1_UInt(hestOpt **hoptP, const char *flag,
const char *name, unsigned int *valueP,
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, long int *valueP,
- const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_1_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name,
- unsigned long int *valueP,
- const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1_Long(hestOpt **hoptP, const char *flag,
+ const char *name, long int *valueP,
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_1_ULong(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned long int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_1_Size_t(hestOpt **hoptP, const char *flag,
const char *name, size_t *valueP,
const char *dflt, const char *info);
@@ -456,6 +507,13 @@
HEST_EXPORT unsigned int hestOptAdd_2_Bool(hestOpt **hoptP, const char *flag,
const char *name, int valueP[2],
const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Short(hestOpt **hoptP, const char *flag,
+ const char *name, short int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_UShort(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned short int valueP[2],
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_2_Int(hestOpt **hoptP, const char *flag,
const char *name, int valueP[2],
const char *dflt, const char *info);
@@ -462,13 +520,13 @@
HEST_EXPORT unsigned int hestOptAdd_2_UInt(hestOpt **hoptP, const char *flag,
const char *name, unsigned int valueP[2],
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_2_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, long int valueP[2],
- const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_2_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name,
- unsigned long int valueP[2],
- const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_Long(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[2],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_2_ULong(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[2],
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_2_Size_t(hestOpt **hoptP, const char *flag,
const char *name, size_t valueP[2],
const char *dflt, const char *info);
@@ -495,6 +553,13 @@
HEST_EXPORT unsigned int hestOptAdd_3_Bool(hestOpt **hoptP, const char *flag,
const char *name, int valueP[3],
const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Short(hestOpt **hoptP, const char *flag,
+ const char *name, short int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_UShort(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned short int valueP[3],
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_3_Int(hestOpt **hoptP, const char *flag,
const char *name, int valueP[3],
const char *dflt, const char *info);
@@ -501,13 +566,13 @@
HEST_EXPORT unsigned int hestOptAdd_3_UInt(hestOpt **hoptP, const char *flag,
const char *name, unsigned int valueP[3],
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_3_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, long int valueP[3],
- const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_3_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name,
- unsigned long int valueP[3],
- const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_Long(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[3],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_3_ULong(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[3],
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_3_Size_t(hestOpt **hoptP, const char *flag,
const char *name, size_t valueP[3],
const char *dflt, const char *info);
@@ -534,6 +599,13 @@
HEST_EXPORT unsigned int hestOptAdd_4_Bool(hestOpt **hoptP, const char *flag,
const char *name, int valueP[4],
const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Short(hestOpt **hoptP, const char *flag,
+ const char *name, short int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_UShort(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned short int valueP[4],
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_4_Int(hestOpt **hoptP, const char *flag,
const char *name, int valueP[4],
const char *dflt, const char *info);
@@ -540,13 +612,13 @@
HEST_EXPORT unsigned int hestOptAdd_4_UInt(hestOpt **hoptP, const char *flag,
const char *name, unsigned int valueP[4],
const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_4_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, long int valueP[4],
- const char *dflt, const char *info);
-HEST_EXPORT unsigned int hestOptAdd_4_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name,
- unsigned long int valueP[4],
- const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_Long(hestOpt **hoptP, const char *flag,
+ const char *name, long int valueP[4],
+ const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_4_ULong(hestOpt **hoptP, const char *flag,
+ const char *name,
+ unsigned long int valueP[4],
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_4_Size_t(hestOpt **hoptP, const char *flag,
const char *name, size_t valueP[4],
const char *dflt, const char *info);
@@ -573,6 +645,14 @@
HEST_EXPORT unsigned int hestOptAdd_N_Bool(hestOpt **hoptP, const char *flag,
const char *name, unsigned int N, int *valueP,
const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Short(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ short int *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_UShort(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ unsigned short int *valueP,
+ const char *dflt, const char *info);
HEST_EXPORT unsigned int hestOptAdd_N_Int(hestOpt **hoptP, const char *flag,
const char *name, unsigned int N, int *valueP,
const char *dflt, const char *info);
@@ -580,14 +660,14 @@
const char *name, unsigned int N,
unsigned int *valueP, const char *dflt,
const char *info);
-HEST_EXPORT unsigned int hestOptAdd_N_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, unsigned int N,
- long int *valueP, const char *dflt,
- const char *info);
-HEST_EXPORT unsigned int hestOptAdd_N_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name, unsigned int N,
- unsigned long int *valueP,
- const char *dflt, const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_Long(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ long int *valueP, const char *dflt,
+ const char *info);
+HEST_EXPORT unsigned int hestOptAdd_N_ULong(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int N,
+ unsigned long int *valueP, const char *dflt,
+ const char *info);
HEST_EXPORT unsigned int hestOptAdd_N_Size_t(hestOpt **hoptP, const char *flag,
const char *name, unsigned int N,
size_t *valueP, const char *dflt,
@@ -620,6 +700,15 @@
const char *name, unsigned int min, int max,
int **valueP, const char *dflt,
const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Short(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ short int **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_UShort(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min,
+ int max, unsigned short int **valueP,
+ const char *dflt, const char *info,
+ unsigned int *sawP);
HEST_EXPORT unsigned int hestOptAdd_Nv_Int(hestOpt **hoptP, const char *flag,
const char *name, unsigned int min, int max,
int **valueP, const char *dflt,
@@ -628,16 +717,15 @@
const char *name, unsigned int min, int max,
unsigned int **valueP, const char *dflt,
const char *info, unsigned int *sawP);
-HEST_EXPORT unsigned int hestOptAdd_Nv_LongInt(hestOpt **hoptP, const char *flag,
- const char *name, unsigned int min,
- int max, long int **valueP,
- const char *dflt, const char *info,
- unsigned int *sawP);
-HEST_EXPORT unsigned int hestOptAdd_Nv_ULongInt(hestOpt **hoptP, const char *flag,
- const char *name, unsigned int min,
- int max, unsigned long int **valueP,
- const char *dflt, const char *info,
- unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_Long(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ long int **valueP, const char *dflt,
+ const char *info, unsigned int *sawP);
+HEST_EXPORT unsigned int hestOptAdd_Nv_ULong(hestOpt **hoptP, const char *flag,
+ const char *name, unsigned int min, int max,
+ unsigned long int **valueP,
+ const char *dflt, const char *info,
+ unsigned int *sawP);
HEST_EXPORT unsigned int hestOptAdd_Nv_Size_t(hestOpt **hoptP, const char *flag,
const char *name, unsigned int min,
int max, size_t **valueP, const char *dflt,
Modified: teem/trunk/src/hest/methodsHest.c
===================================================================
--- teem/trunk/src/hest/methodsHest.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/hest/methodsHest.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -29,26 +29,87 @@
const char *const _hestBiffKey = "hest";
+// see note in hest.h about why airType things are here, renamed as hest
+/* clang-format off */
+const char
+_hestTypeStr[_HEST_TYPE_MAX+1][AIR_STRLEN_SMALL+1] = {
+ "(unknown)",
+ "bool",
+ "short",
+ "unsigned short",
+ "int",
+ "unsigned int",
+ "long int",
+ "unsigned long int",
+ "size_t",
+ "float",
+ "double",
+ "char",
+ "string",
+ "enum",
+ "other",
+};
+
+const size_t
+_hestTypeSize[_HEST_TYPE_MAX+1] = {
+ 0,
+ sizeof(int),
+ sizeof(short),
+ sizeof(unsigned short),
+ sizeof(int),
+ sizeof(unsigned int),
+ sizeof(long int),
+ sizeof(unsigned long int),
+ sizeof(size_t),
+ sizeof(float),
+ sizeof(double),
+ sizeof(char),
+ sizeof(char*),
+ sizeof(int),
+ 0 /* we don't know anything about type "other" */
+};
+/* clang-format on */
+
+unsigned int (*const _hestParseStr[_HEST_TYPE_MAX + 1])(void *, const char *,
+ const char *, unsigned int)
+ = {NULL,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrB,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrH,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrUH,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrI,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrUI,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrL,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrUL,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrZ,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrF,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrD,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrC,
+ (unsigned int (*)(void *, const char *, const char *, unsigned int))airParseStrS,
+ // airParseStrE needs final airEnum* arg, no longer enforceing fake uniformity
+ NULL,
+ // no uniform of parsing type "other"; handled via hestCB in hest
+ NULL};
+
// loving how C99 simplifies creating an airEnum at compile-time
static const airEnum _hestSource
= {.name = "source",
.M = 3,
.str = (const char *[]){"(unknown_source)", // 0
- "default", // 1
- "command-line", // 2
- "response-file"}, // 3
+ "command-line", // 1
+ "response-file", // 2
+ "default"}, // 3
.val = NULL,
- .desc = (const char *[]){"unknown source", //
- "default string in hestOpt", //
- "argc/argv command-line", //
- "a response file"},
- .strEqv = (const char *[]){"default", //
- "command-line", "cmdline", //
+ .desc = (const char *[]){"unknown source", //
+ "argc/argv command-line", //
+ "a response file", //
+ "default string in hestOpt"},
+ .strEqv = (const char *[]){"command-line", "cmdline", //
"response-file", "respfile", //
+ "default", //
""},
- .valEqv = (const int[]){hestSourceDefault, //
- hestSourceCommandLine, hestSourceCommandLine, //
- hestSourceResponseFile, hestSourceResponseFile},
+ .valEqv = (const int[]){hestSourceCommandLine, hestSourceCommandLine, //
+ hestSourceResponseFile, hestSourceResponseFile, //
+ hestSourceDefault},
.sense = AIR_FALSE};
const airEnum *const hestSource = &_hestSource;
@@ -75,8 +136,6 @@
hparm->responseFileEnable = hestDefaultResponseFileEnable;
hparm->elideSingleEnumType = hestDefaultElideSingleEnumType;
hparm->elideSingleOtherType = hestDefaultElideSingleOtherType;
- hparm->elideSingleOtherDefault = hestDefaultElideSingleOtherDefault;
- hparm->greedySingleString = hestDefaultGreedySingleString;
hparm->elideSingleNonExistFloatDefault = hestDefaultElideSingleNonExistFloatDefault;
hparm->elideMultipleNonExistFloatDefault
= hestDefaultElideMultipleNonExistFloatDefault;
@@ -102,7 +161,6 @@
abstaining from adding yet another default global variable */
hparm->respectDashBraceComments = AIR_TRUE;
hparm->noArgsIsNoProblem = hestDefaultNoArgsIsNoProblem;
- hparm->greedySingleString = hestDefaultGreedySingleString;
hparm->cleverPluralizeOtherY = hestDefaultCleverPluralizeOtherY;
/* here too: newer addition to hestParm avoid adding another default global */
hparm->dieLessVerbose = AIR_FALSE;
@@ -338,6 +396,11 @@
been moved to hestOptSingleSet.
Like hestOptAdd has done since 2013: returns UINT_MAX in case of error.
+
+Note: (as of 2023) you probably shouldn't use this function; instead use
+one of hestOptAdd_Flag, hestOptAdd_1_T, hestOptAdd_{2,3,4,N}_T, hestOptAdd_1v_T,
+or hestOptAdd_Nv_T for T=Bool, Int, UInt, LongInt, ULongInt, Size_t, Float, Double,
+Char, String, Enum, Other
*/
unsigned int
hestOptAdd_nva(hestOpt **optP, const char *flag, const char *name, int type,
Modified: teem/trunk/src/hest/parseHest.c
===================================================================
--- teem/trunk/src/hest/parseHest.c 2025-09-22 08:11:01 UTC (rev 7463)
+++ teem/trunk/src/hest/parseHest.c 2025-09-22 09:22:17 UTC (rev 7464)
@@ -202,7 +202,8 @@
airOneLinify(line);
incr = airStrntok(line, AIR_WHITESPACE);
if (hparm->verbosity) printf("%s: -1-> line: |%s|, incr=%d\n", me, line, incr);
- airParseStrS(newArgv + newArgc, line, AIR_WHITESPACE, incr, AIR_FALSE);
+ airParseStrS(newArgv + newArgc, line, AIR_WHITESPACE,
+ incr /*, greedy=AIR_FALSE */);
for (rgi = 0; rgi < incr; rgi++) {
/* This time, we did allocate memory. We can use airFree and
not airFreeP because these will not be reset before mopping */
@@ -240,7 +241,7 @@
other |= opt[ai].type == airTypeOther;
}
for (uint ai = airTypeUnknown + 1; ai < airTypeLast; ai++) {
- ret = AIR_MAX(ret, airStrlen(airTypeStr[ai]));
+ ret = AIR_MAX(ret, airStrlen(_hestTypeStr[ai]));
}
if (other) {
/* the callback's error() function may sprintf an error message
@@ -782,6 +783,12 @@
case airTypeBool:
return (*((int *)v) = !!i);
break;
+ case airTypeShort:
+ return (*((short *)v) = i);
+ break;
+ case airTypeUShort:
+ return (int)(*((unsigned short *)v) = i);
+ break;
case airTypeInt:
return (*((int *)v) = i);
break;
@@ -788,10 +795,10 @@
case airTypeUInt:
return (int)(*((unsigned int *)v) = i);
break;
- case airTypeLongInt:
+ case airTypeLong:
return (int)(*((long int *)v) = i);
break;
- case airTypeULongInt:
+ case airTypeULong:
return (int)(*((unsigned long int *)v) = i);
break;
case airTypeSize_t:
@@ -823,6 +830,12 @@
case airTypeBool:
return AIR_CAST(double, *((int *)v));
break;
+ case airTypeShort:
+ return AIR_CAST(double, *((short *)v));
+ break;
+ case airTypeUShort:
+ return AIR_CAST(double, *((unsigned short *)v));
+ break;
case airTypeInt:
return AIR_CAST(double, *((int *)v));
break;
@@ -829,10 +842,10 @@
case airTypeUInt:
return AIR_CAST(double, *((unsigned int *)v));
break;
- case airTypeLongInt:
+ case airTypeLong:
return AIR_CAST(double, *((long int *)v));
break;
- case airTypeULongInt:
+ case airTypeULong:
return AIR_CAST(double, *((unsigned long int *)v));
break;
case airTypeSize_t:
@@ -899,7 +912,7 @@
? sizeof(int)
: (airTypeOther == type /* */
? opt[op].CB->size
- : airTypeSize[type]));
+ : _hestTypeSize[type]));
cP = (char *)(vP = opt[op].valueP);
if (hparm->verbosity) {
printf("%s %d of %d: \"%s\": |%s| --> kind=%d, type=%d, size=%u\n", me, op,
@@ -952,10 +965,10 @@
break;
case airTypeString:
if (1
- != airParseStrS((char **)vP, optParms[op], " ", 1,
- hparm->greedySingleString)) {
+ != airParseStrS((char **)vP, optParms[op], " ", 1
+ /*, hparm->greedySingleString */)) {
sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
- optDfltd[op] ? "(default) " : "", optParms[op], airTypeStr[type],
+ optDfltd[op] ? "(default) " : "", optParms[op], _hestTypeStr[type],
ident);
return 1;
}
@@ -965,10 +978,10 @@
airMopMem(pmop, vP, airMopOnError);
break;
default:
- /* type isn't string or enum, so no last arg to airParseStr[type] */
- if (1 != airParseStr[type](vP, optParms[op], " ", 1)) {
+ /* type isn't string or enum, so no last arg to hestParseStr[type] */
+ if (1 != _hestParseStr[type](vP, optParms[op], " ", 1)) {
sprintf(err, "%scouldn't parse %s\"%s\" as %s for %s", ME,
- optDfltd[op] ? "(default) " : "", optParms[op], airTypeStr[type],
+ optDfltd[op...
[truncated message content] |