summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--libpopt.vers1
-rw-r--r--popt.37
-rw-r--r--popt.c178
-rw-r--r--popt.h19
-rw-r--r--popthelp.c5
-rw-r--r--poptint.h1
-rw-r--r--test1.c19
-rwxr-xr-xtestit.sh65
9 files changed, 183 insertions, 113 deletions
diff --git a/CHANGES b/CHANGES
index b453538..a0025e2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,5 @@
1.15 -> 1.16:
+ - add POPT_ARG_SHORT handling.
- handle all callback traversals within a C switch (for extendability ease).
- add popt.pc.
diff --git a/libpopt.vers b/libpopt.vers
index a1eea04..b0c08d6 100644
--- a/libpopt.vers
+++ b/libpopt.vers
@@ -35,6 +35,7 @@ LIBPOPT_0
poptSaveInt;
poptSaveLong;
poptSaveLongLong;
+ poptSaveShort;
poptSaveString;
poptSetExecPath;
poptSetOtherOptionHelp;
diff --git a/popt.3 b/popt.3
index 205d913..5d5a556 100644
--- a/popt.3
+++ b/popt.3
@@ -126,6 +126,7 @@ Value Description arg Type
POPT_ARG_NONE No argument expected int
POPT_ARG_STRING No type checking to be performed char *
POPT_ARG_ARGV No type checking to be performed char **
+POPT_ARG_SHORT An short argument is expected short
POPT_ARG_INT An integer argument is expected int
POPT_ARG_LONG A long integer is expected long
POPT_ARG_LONGLONG A long long integer is expected long long
@@ -164,7 +165,7 @@ will perhaps not escape the attention of hunt-and-peck typists that
an argument, the variable that
.IR arg " points to is updated to reflect the value of the argument."
.RB "Any string is acceptable for " POPT_ARG_STRING " and " POPT_ARG_ARGV " arguments, but "
-.BR POPT_ARG_INT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", " POPT_ARG_FLOAT ", and "
+.BR POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", " POPT_ARG_FLOAT ", and "
.BR POPT_ARG_DOUBLE " are converted to the appropriate type, and an "
error returned if the conversion fails.
.sp
@@ -474,7 +475,7 @@ A parsed string has a quotation mismatch (such as a single quotation
A conversion from a string to a number (int or long) failed due
to the string containing nonnumeric characters. This occurs when
.BR poptGetNextOpt() " is processing an argument of type "
-.BR POPT_ARG_INT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
+.BR POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
.RB POPT_ARG_FLOAT ", or " POPT_ARG_DOUBLE "."
.sp
.TP
@@ -482,7 +483,7 @@ to the string containing nonnumeric characters. This occurs when
A string-to-number conversion failed because the number was too
.RB "large or too small. Like " POPT_ERROR_BADNUMBER ", this error
.RB "can occur only when " poptGetNextOpt() " is processing an "
-.RB "argument of type " POPT_ARG_INT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
+.RB "argument of type " POPT_ARG_INT ", " POPT_ARG_SHORT ", " POPT_ARG_LONG ", " POPT_ARG_LONGLONG ", "
.RB POPT_ARG_FLOAT ", or " POPT_ARG_DOUBLE "."
.sp
.TP
diff --git a/popt.c b/popt.c
index 150f824..b697a0d 100644
--- a/popt.c
+++ b/popt.c
@@ -462,13 +462,10 @@ const char * findProgramPath(/*@null@*/ const char * argv0)
}
/* If no executable was found in PATH, return NULL. */
- if (!(s && *s) && t != NULL) {
- free(t);
- t = NULL;
- }
+ if (!(s && *s) && t != NULL)
+ t = _free(t);
/*@-modobserver -observertrans -usedef @*/
- if (path != NULL)
- free(path);
+ path = _free(path);
/*@=modobserver =observertrans =usedef @*/
return t;
@@ -575,7 +572,8 @@ exit:
return ec;
}
-/*@observer@*/ /*@null@*/ static const struct poptOption *
+/*@observer@*/ /*@null@*/
+static const struct poptOption *
findOption(const struct poptOption * opt,
/*@null@*/ const char * longName, size_t longNameLen,
char shortName,
@@ -637,9 +635,9 @@ findOption(const struct poptOption * opt,
if (callback)
*callback = (cb ? cbarg.cb : NULL);
if (callbackData)
-/*@-observertrans@*/ /* FIX: typedef double indirection. */
+/*@-observertrans -dependenttrans @*/
*callbackData = (cb && !CBF_ISSET(cb, INC_DATA) ? cb->descrip : NULL);
-/*@=observertrans@*/
+/*@=observertrans =dependenttrans @*/
/*@=modobserver =mods @*/
return opt;
@@ -757,8 +755,8 @@ int poptSaveString(const char *** argvp,
{
int argc = 0;
- if (argvp == NULL)
- return -1;
+ if (argvp == NULL || val == NULL)
+ return POPT_ERROR_NULLARG;
/* XXX likely needs an upper bound on argc. */
if (*argvp != NULL)
@@ -844,18 +842,10 @@ int poptSaveLong(long * arg, unsigned int argInfo, long aLong)
if (LF_ISSET(NOT))
aLong = ~aLong;
switch (LF_ISSET(LOGICALOPS)) {
- case 0:
- *arg = aLong;
- break;
- case POPT_ARGFLAG_OR:
- *(unsigned long *)arg |= (unsigned long)aLong;
- break;
- case POPT_ARGFLAG_AND:
- *(unsigned long *)arg &= (unsigned long)aLong;
- break;
- case POPT_ARGFLAG_XOR:
- *(unsigned long *)arg ^= (unsigned long)aLong;
- break;
+ case 0: *arg = aLong; break;
+ case POPT_ARGFLAG_OR: *(unsigned long *)arg |= (unsigned long)aLong; break;
+ case POPT_ARGFLAG_AND: *(unsigned long *)arg &= (unsigned long)aLong; break;
+ case POPT_ARGFLAG_XOR: *(unsigned long *)arg ^= (unsigned long)aLong; break;
default:
return POPT_ERROR_BADOPERATION;
/*@notreached@*/ break;
@@ -885,20 +875,48 @@ int poptSaveInt(/*@null@*/ int * arg, unsigned int argInfo, long aLong)
if (LF_ISSET(NOT))
aLong = ~aLong;
switch (LF_ISSET(LOGICALOPS)) {
- case 0:
- *arg = (int) aLong;
+ case 0: *arg = (int) aLong; break;
+ case POPT_ARGFLAG_OR: *(unsigned int *)arg |= (unsigned int) aLong; break;
+ case POPT_ARGFLAG_AND: *(unsigned int *)arg &= (unsigned int) aLong; break;
+ case POPT_ARGFLAG_XOR: *(unsigned int *)arg ^= (unsigned int) aLong; break;
+ default:
+ return POPT_ERROR_BADOPERATION;
+ /*@notreached@*/ break;
+ }
+ return 0;
+}
+
+int poptSaveShort(/*@null@*/ short * arg, unsigned int argInfo, long aLong)
+{
+ /* XXX Check alignment, may fail on funky platforms. */
+ if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
+ return POPT_ERROR_NULLARG;
+
+ if (aLong != 0 && LF_ISSET(RANDOM)) {
+#if defined(HAVE_SRANDOM)
+ if (!seed) {
+ srandom((unsigned)getpid());
+ srandom((unsigned)random());
+ }
+ aLong = random() % (aLong > 0 ? aLong : -aLong);
+ aLong++;
+#else
+ /* XXX avoid adding POPT_ERROR_UNIMPLEMENTED to minimize i18n churn. */
+ return POPT_ERROR_BADOPERATION;
+#endif
+ }
+ if (LF_ISSET(NOT))
+ aLong = ~aLong;
+ switch (LF_ISSET(LOGICALOPS)) {
+ case 0: *arg = (short) aLong;
break;
- case POPT_ARGFLAG_OR:
- *(unsigned int *)arg |= (unsigned int) aLong;
+ case POPT_ARGFLAG_OR: *(unsigned short *)arg |= (unsigned short) aLong;
break;
- case POPT_ARGFLAG_AND:
- *(unsigned int *)arg &= (unsigned int) aLong;
+ case POPT_ARGFLAG_AND: *(unsigned short *)arg &= (unsigned short) aLong;
break;
- case POPT_ARGFLAG_XOR:
- *(unsigned int *)arg ^= (unsigned int) aLong;
+ case POPT_ARGFLAG_XOR: *(unsigned short *)arg ^= (unsigned short) aLong;
break;
- default:
- return POPT_ERROR_BADOPERATION;
+ default: return POPT_ERROR_BADOPERATION;
/*@notreached@*/ break;
}
return 0;
@@ -944,14 +962,12 @@ static int poptSaveArg(poptContext con, const struct poptOption * opt)
/*@modifies con, fileSystem, internalState @*/
{
poptArg arg = { .ptr = opt->arg };
+ int rc = 0; /* assume success */
switch (poptArgType(opt)) {
case POPT_ARG_ARGV:
/* XXX memory leak, application is responsible for free. */
- if (con->os->nextArg == NULL)
- return POPT_ERROR_NULLARG; /* XXX better return? */
- if (poptSaveString(arg.ptr, opt->argInfo, con->os->nextArg))
- return POPT_ERROR_BADOPERATION;
+ rc = poptSaveString(arg.ptr, opt->argInfo, con->os->nextArg);
/*@switchbreak@*/ break;
case POPT_ARG_STRING:
/* XXX memory leak, application is responsible for free. */
@@ -959,75 +975,87 @@ static int poptSaveArg(poptContext con, const struct poptOption * opt)
/*@switchbreak@*/ break;
case POPT_ARG_INT:
+ case POPT_ARG_SHORT:
case POPT_ARG_LONG:
case POPT_ARG_LONGLONG:
- { long long aNUM = 0;
+ { unsigned int argInfo = poptArgInfo(con, opt);
char *end = NULL;
- unsigned int argInfo = poptArgInfo(con, opt);
+ long long aNUM = 0;
if (con->os->nextArg) {
aNUM = strtoll(con->os->nextArg, &end, 0);
- if (!(end && *end == '\0'))
- return POPT_ERROR_BADNUMBER;
+ if (!(end && *end == '\0')) {
+ rc = POPT_ERROR_BADNUMBER;
+ break;
+ }
}
+ switch (poptArgType(opt)) {
+ case POPT_ARG_LONGLONG:
/* XXX let's not demand C99 compiler flags for <limits.h> quite yet. */
#if !defined(LLONG_MAX)
# define LLONG_MAX 9223372036854775807LL
# define LLONG_MIN (-LLONG_MAX - 1LL)
#endif
-
- if (poptArgType(opt) == POPT_ARG_LONGLONG) {
- if (aNUM == LLONG_MAX || aNUM == LLONG_MIN)
- return POPT_ERROR_OVERFLOW;
- if (poptSaveLongLong(arg.longlongp, argInfo, aNUM))
- return POPT_ERROR_BADOPERATION;
- } else
- if (poptArgType(opt) == POPT_ARG_LONG) {
- if (aNUM > (long long)LONG_MAX || aNUM < (long long)LONG_MIN)
- return POPT_ERROR_OVERFLOW;
- if (poptSaveLong(arg.longp, argInfo, (long)aNUM))
- return POPT_ERROR_BADOPERATION;
- } else
- if (poptArgType(opt) == POPT_ARG_INT) {
- if (aNUM > (long long)INT_MAX || aNUM < (long long)INT_MIN)
- return POPT_ERROR_OVERFLOW;
- if (poptSaveInt(arg.intp, argInfo, (long)aNUM))
- return POPT_ERROR_BADOPERATION;
- } else
- return POPT_ERROR_BADOPERATION;
+ rc = !(aNUM == LLONG_MIN || aNUM == LLONG_MAX)
+ ? poptSaveLongLong(arg.longlongp, argInfo, aNUM)
+ : POPT_ERROR_OVERFLOW;
+ /*@innerbreak@*/ break;
+ case POPT_ARG_LONG:
+ rc = !(aNUM < (long long)LONG_MIN || aNUM > (long long)LONG_MAX)
+ ? poptSaveLong(arg.longp, argInfo, (long)aNUM)
+ : POPT_ERROR_OVERFLOW;
+ /*@innerbreak@*/ break;
+ case POPT_ARG_INT:
+ rc = !(aNUM < (long long)INT_MIN || aNUM > (long long)INT_MAX)
+ ? poptSaveInt(arg.intp, argInfo, (long)aNUM)
+ : POPT_ERROR_OVERFLOW;
+ /*@innerbreak@*/ break;
+ case POPT_ARG_SHORT:
+ rc = !(aNUM < (long long)SHRT_MIN || aNUM > (long long)SHRT_MAX)
+ ? poptSaveShort(arg.shortp, argInfo, (long)aNUM)
+ : POPT_ERROR_OVERFLOW;
+ /*@innerbreak@*/ break;
+ }
} /*@switchbreak@*/ break;
case POPT_ARG_FLOAT:
case POPT_ARG_DOUBLE:
- { double aDouble = 0.0;
- char *end;
+ { char *end = NULL;
+ double aDouble = 0.0;
if (con->os->nextArg) {
/*@-mods@*/
int saveerrno = errno;
errno = 0;
aDouble = strtod(con->os->nextArg, &end);
- if (errno == ERANGE)
- return POPT_ERROR_OVERFLOW;
+ if (errno == ERANGE) {
+ rc = POPT_ERROR_OVERFLOW;
+ break;
+ }
errno = saveerrno;
/*@=mods@*/
- if (*end != '\0')
- return POPT_ERROR_BADNUMBER;
+ if (*end != '\0') {
+ rc = POPT_ERROR_BADNUMBER;
+ break;
+ }
}
- if (poptArgType(opt) == POPT_ARG_DOUBLE) {
+ switch (poptArgType(opt)) {
+ case POPT_ARG_DOUBLE:
arg.doublep[0] = aDouble;
- } else {
+ /*@innerbreak@*/ break;
+ case POPT_ARG_FLOAT:
#if !defined(DBL_EPSILON) && !defined(__LCLINT__)
#define DBL_EPSILON 2.2204460492503131e-16
#endif
#define POPT_ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
- if ((POPT_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
- return POPT_ERROR_OVERFLOW;
- if ((FLT_MIN - POPT_ABS(aDouble)) > DBL_EPSILON)
- return POPT_ERROR_OVERFLOW;
- arg.floatp[0] = (float) aDouble;
+ if ((FLT_MIN - POPT_ABS(aDouble)) > DBL_EPSILON
+ || (POPT_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
+ rc = POPT_ERROR_OVERFLOW;
+ else
+ arg.floatp[0] = (float) aDouble;
+ /*@innerbreak@*/ break;
}
} /*@switchbreak@*/ break;
case POPT_ARG_MAINCALL:
@@ -1041,7 +1069,7 @@ static int poptSaveArg(poptContext con, const struct poptOption * opt)
exit(EXIT_FAILURE);
/*@notreached@*/ /*@switchbreak@*/ break;
}
- return 0;
+ return rc;
}
/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
diff --git a/popt.h b/popt.h
index bd991a2..278357f 100644
--- a/popt.h
+++ b/popt.h
@@ -37,6 +37,7 @@
#define POPT_ARG_MAINCALL 16U+11U /*!< EXPERIMENTAL: return (*arg) (argc, argv) */
#define POPT_ARG_ARGV 12U /*!< dupe'd arg appended to realloc'd argv array. */
+#define POPT_ARG_SHORT 13U /*!< arg ==> short */
#define POPT_ARG_MASK 0x000000FFU
#define POPT_GROUP_MASK 0x0000FF00U
@@ -605,7 +606,7 @@ int poptStrippedArgv(poptContext con, int argc, char ** argv)
* @retval *argvp argv array
* @param argInfo (unused)
* @param val string arg to add (using strdup)
- * @return 0 always
+ * @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION
*/
/*@unused@*/
int poptSaveString(/*@null@*/ const char *** argvp, unsigned int argInfo,
@@ -646,6 +647,22 @@ int poptSaveLong(/*@null@*/ long * arg, unsigned int argInfo, long aLong)
/*@=incondefs@*/
/**
+ * Save a short integer, performing logical operation with value.
+ * @warning Alignment check may be too strict on certain platorms.
+ * @param arg short pointer, aligned on short boundary.
+ * @param argInfo logical operation (see POPT_ARGFLAG_*)
+ * @param aLong value to use
+ * @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION
+ */
+/*@-incondefs@*/
+/*@unused@*/
+int poptSaveShort(/*@null@*/ short * arg, unsigned int argInfo, long aLong)
+ /*@globals internalState @*/
+ /*@modifies *arg, internalState @*/
+ /*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
+/*@=incondefs@*/
+
+/**
* Save an integer, performing logical operation with value.
* @warning Alignment check may be too strict on certain platorms.
* @param arg integer pointer, aligned on int boundary.
diff --git a/popthelp.c b/popthelp.c
index d267f6c..52667cd 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -204,6 +204,7 @@ getArgDescrip(const struct poptOption * opt,
case POPT_ARG_VAL: return NULL;
#endif
case POPT_ARG_INT: return POPT_("INT");
+ case POPT_ARG_SHORT: return POPT_("SHORT");
case POPT_ARG_LONG: return POPT_("LONG");
case POPT_ARG_LONGLONG: return POPT_("LONGLONG");
case POPT_ARG_STRING: return POPT_("STRING");
@@ -247,6 +248,9 @@ singleOptionDefaultValue(size_t lineLength,
case POPT_ARG_INT:
le += sprintf(le, "%d", arg.intp[0]);
break;
+ case POPT_ARG_SHORT:
+ le += sprintf(le, "%hd", arg.shortp[0]);
+ break;
case POPT_ARG_LONG:
le += sprintf(le, "%ld", arg.longp[0]);
break;
@@ -422,6 +426,7 @@ static void singleOptionHelp(FILE * fp, columns_t columns,
#endif
break;
case POPT_ARG_INT:
+ case POPT_ARG_SHORT:
case POPT_ARG_LONG:
case POPT_ARG_LONGLONG:
case POPT_ARG_FLOAT:
diff --git a/poptint.h b/poptint.h
index e92f441..885f56b 100644
--- a/poptint.h
+++ b/poptint.h
@@ -58,6 +58,7 @@ typedef union poptArg_u {
/*@shared@*/
void * ptr;
int * intp;
+ short * shortp;
long * longp;
long long * longlongp;
float * floatp;
diff --git a/test1.c b/test1.c
index 3cf6ab4..c9effd5 100644
--- a/test1.c
+++ b/test1.c
@@ -38,6 +38,10 @@ static unsigned int aFlag = 0x8aceU;
static unsigned int bFlag = 0x8aceU;
/*@unchecked@*/
+static short aShort = 4523;
+/*@unchecked@*/
+static short bShort = 4523;
+/*@unchecked@*/
static int aInt = 271828;
/*@unchecked@*/
static int bInt = 271828;
@@ -126,6 +130,8 @@ static struct poptOption options[] = {
{ "int", 'i', POPT_ARG_INT | POPT_ARGFLAG_SHOW_DEFAULT, &aInt, 0,
"POPT_ARG_INT: 271828", NULL },
+ { "short", 's', POPT_ARG_SHORT | POPT_ARGFLAG_SHOW_DEFAULT, &aShort, 0,
+ "POPT_ARG_SHORT: 4523", NULL },
{ "long", 'l', POPT_ARG_LONG | POPT_ARGFLAG_SHOW_DEFAULT, &aLong, 0,
"POPT_ARG_LONG: 738905609", NULL },
{ "longlong", 'L', POPT_ARG_LONGLONG | POPT_ARGFLAG_SHOW_DEFAULT, &aLongLong, 0,
@@ -137,6 +143,8 @@ static struct poptOption options[] = {
{ "randint", '\0', POPT_ARG_INT|POPT_ARGFLAG_RANDOM, &aInt, 0,
"POPT_ARGFLAG_RANDOM: experimental", NULL },
+ { "randshort", '\0', POPT_ARG_SHORT|POPT_ARGFLAG_RANDOM, &aShort, 0,
+ "POPT_ARGFLAG_RANDOM: experimental", NULL },
{ "randlong", '\0', POPT_ARG_LONG|POPT_ARGFLAG_RANDOM, &aLong, 0,
"POPT_ARGFLAG_RANDOM: experimental", NULL },
{ "randlonglong", '\0', POPT_ARG_LONGLONG|POPT_ARGFLAG_RANDOM, &aLongLong, 0,
@@ -170,11 +178,11 @@ static struct poptOption options[] = {
static void resetVars(void)
/*@globals arg1, arg2, arg3, inc, shortopt,
- aVal, aFlag, aInt, aLong, aLongLong, aFloat, aDouble, aArgv,
- oStr, singleDash, pass2 @*/
+ aVal, aFlag, aShort, aInt, aLong, aLongLong, aFloat, aDouble,
+ aArgv, oStr, singleDash, pass2 @*/
/*@modifies arg1, arg2, arg3, inc, shortopt,
- aVal, aFlag, aInt, aLong, aLongLong, aFloat, aDouble, aArgv,
- oStr, singleDash, pass2 @*/
+ aVal, aFlag, aShort, aInt, aLong, aLongLong, aFloat, aDouble,
+ aArgv, oStr, singleDash, pass2 @*/
{
arg1 = 0;
arg2 = "(none)";
@@ -185,6 +193,7 @@ static void resetVars(void)
aVal = bVal;
aFlag = bFlag;
+ aShort = bShort;
aInt = bInt;
aLong = bLong;
aLongLong = bLongLong;
@@ -277,6 +286,8 @@ int main(int argc, const char ** argv)
fprintf(stdout, " aVal: %d", aVal);
if (aFlag != bFlag)
fprintf(stdout, " aFlag: 0x%x", aFlag);
+ if (aShort != bShort)
+ fprintf(stdout, " aShort: %d", aShort);
if (aInt != bInt)
fprintf(stdout, " aInt: %d", aInt);
if (aLong != bLong)
diff --git a/testit.sh b/testit.sh
index 0a0ba09..1f833f9 100755
--- a/testit.sh
+++ b/testit.sh
@@ -84,40 +84,43 @@ run test1 "test1 - 31" "arg1: 0 arg2: 'foo bar' rest: boggle" --grabbar boggle
run test1 "test1 - 32" "arg1: 0 arg2: (none) aInt: 123456789" -i 123456789
run test1 "test1 - 33" "arg1: 0 arg2: (none) aInt: 123456789" --int 123456789
-run test1 "test1 - 34" "arg1: 0 arg2: (none) aLong: 1123456789" -l 1123456789
-run test1 "test1 - 35" "arg1: 0 arg2: (none) aLong: 1123456789" --long 1123456789
-run test1 "test1 - 36" "arg1: 0 arg2: (none) aLongLong: 1111123456789" -L 1111123456789
-run test1 "test1 - 37" "arg1: 0 arg2: (none) aLongLong: 1111123456789" --longlong 1111123456789
-
-run test1 "test1 - 38" "arg1: 0 arg2: (none) aFloat: 10.1" -f 10.1
-run test1 "test1 - 39" "arg1: 0 arg2: (none) aFloat: 10.1" --float 10.1
-run test1 "test1 - 40" "arg1: 0 arg2: (none) aDouble: 10.1" -d 10.1
-run test1 "test1 - 41" "arg1: 0 arg2: (none) aDouble: 10.1" --double 10.1
-
-run test1 "test1 - 42" "arg1: 0 arg2: (none) oStr: (none)" --optional
-run test1 "test1 - 43" "arg1: 0 arg2: (none) oStr: yadda" --optional=yadda
-run test1 "test1 - 44" "arg1: 0 arg2: (none) oStr: yadda" --optional yadda
-run test1 "test1 - 45" "arg1: 0 arg2: (none) oStr: ping rest: pong" --optional=ping pong
-run test1 "test1 - 46" "arg1: 0 arg2: (none) oStr: ping rest: pong" --optional ping pong
-run test1 "test1 - 47" "arg1: 0 arg2: (none) aArgv: A B rest: C" --argv A --argv B C
-
-run test1 "test1 - 48" "arg1: 0 arg2: foo=bar" -2foo=bar
-run test1 "test1 - 49" "arg1: 0 arg2: foo=bar" -2=foo=bar
-
-run test1 "test1 - 50" "arg1: 0 arg2: (none) aFlag: 0xfeed" --bitxor
-run test1 "test1 - 51" "arg1: 0 arg2: (none) aFlag: 0xffff" --bitset
-run test1 "test1 - 52" "arg1: 0 arg2: (none) aFlag: 0x28c" --bitclr
-run test1 "test1 - 53" "arg1: 0 arg2: (none) aFlag: 0x8888" --nobitset
-run test1 "test1 - 54" "arg1: 0 arg2: (none) aFlag: 0xface" --nobitclr
+run test1 "test1 - 34" "arg1: 0 arg2: (none) aShort: 12345" -s 12345
+run test1 "test1 - 35" "arg1: 0 arg2: (none) aShort: 12345" --short 12345
+run test1 "test1 - 36" "arg1: 0 arg2: (none) aLong: 1123456789" -l 1123456789
+run test1 "test1 - 37" "arg1: 0 arg2: (none) aLong: 1123456789" --long 1123456789
+run test1 "test1 - 38" "arg1: 0 arg2: (none) aLongLong: 1111123456789" -L 1111123456789
+run test1 "test1 - 39" "arg1: 0 arg2: (none) aLongLong: 1111123456789" --longlong 1111123456789
+
+run test1 "test1 - 40" "arg1: 0 arg2: (none) aFloat: 10.1" -f 10.1
+run test1 "test1 - 41" "arg1: 0 arg2: (none) aFloat: 10.1" --float 10.1
+run test1 "test1 - 42" "arg1: 0 arg2: (none) aDouble: 10.1" -d 10.1
+run test1 "test1 - 43" "arg1: 0 arg2: (none) aDouble: 10.1" --double 10.1
+
+run test1 "test1 - 44" "arg1: 0 arg2: (none) oStr: (none)" --optional
+run test1 "test1 - 45" "arg1: 0 arg2: (none) oStr: yadda" --optional=yadda
+run test1 "test1 - 46" "arg1: 0 arg2: (none) oStr: yadda" --optional yadda
+run test1 "test1 - 47" "arg1: 0 arg2: (none) oStr: ping rest: pong" --optional=ping pong
+run test1 "test1 - 48" "arg1: 0 arg2: (none) oStr: ping rest: pong" --optional ping pong
+run test1 "test1 - 49" "arg1: 0 arg2: (none) aArgv: A B rest: C" --argv A --argv B C
+
+run test1 "test1 - 50" "arg1: 0 arg2: foo=bar" -2foo=bar
+run test1 "test1 - 51" "arg1: 0 arg2: foo=bar" -2=foo=bar
+
+run test1 "test1 - 52" "arg1: 0 arg2: (none) aFlag: 0xfeed" --bitxor
+run test1 "test1 - 53" "arg1: 0 arg2: (none) aFlag: 0xffff" --bitset
+run test1 "test1 - 54" "arg1: 0 arg2: (none) aFlag: 0x28c" --bitclr
+run test1 "test1 - 55" "arg1: 0 arg2: (none) aFlag: 0x8888" --nobitset
+run test1 "test1 - 56" "arg1: 0 arg2: (none) aFlag: 0xface" --nobitclr
run test1 "test1 - 55" "\
Usage: lt-test1 [-I?] [-c|--cb2=STRING] [--arg1] [-2|--arg2=ARG]
[-3|--arg3=ANARG] [-onedash] [--optional=STRING] [--val]
- [-i|--int=INT] [-l|--long=LONG] [-L|--longlong=LONGLONG]
- [-f|--float=FLOAT] [-d|--double=DOUBLE] [--randint=INT]
- [--randlong=LONG] [--randlonglong=LONGLONG] [--argv] [--bitset]
- [--bitclr] [--bitxor] [--nstr=STRING] [--lstr=STRING] [-I|--inc]
- [-c|--cb=STRING] [--longopt] [-?|--help] [--usage] [--simple=ARG]" --usage
+ [-i|--int=INT] [-s|--short=SHORT] [-l|--long=LONG]
+ [-L|--longlong=LONGLONG] [-f|--float=FLOAT] [-d|--double=DOUBLE]
+ [--randint=INT] [--randshort=SHORT] [--randlong=LONG]
+ [--randlonglong=LONGLONG] [--argv] [--bitset] [--bitclr] [--bitxor]
+ [--nstr=STRING] [--lstr=STRING] [-I|--inc] [-c|--cb=STRING]
+ [--longopt] [-?|--help] [--usage] [--simple=ARG]" --usage
run test1 "test1 - 56" "\
Usage: lt-test1 [OPTION...]
@@ -131,12 +134,14 @@ Usage: lt-test1 [OPTION...]
string argument
--val POPT_ARG_VAL: 125992 141421
-i, --int=INT POPT_ARG_INT: 271828 (default: 271828)
+ -s, --short=SHORT POPT_ARG_SHORT: 4523 (default: 4523)
-l, --long=LONG POPT_ARG_LONG: 738905609 (default: 738905609)
-L, --longlong=LONGLONG POPT_ARG_LONGLONG: 738905609 (default:
738905609)
-f, --float=FLOAT POPT_ARG_FLOAT: 3.14159 (default: 3.14159)
-d, --double=DOUBLE POPT_ARG_DOUBLE: 9.8696 (default: 9.8696)
--randint=INT POPT_ARGFLAG_RANDOM: experimental
+ --randshort=SHORT POPT_ARGFLAG_RANDOM: experimental
--randlong=LONG POPT_ARGFLAG_RANDOM: experimental
--randlonglong=LONGLONG POPT_ARGFLAG_RANDOM: experimental
--argv POPT_ARG_ARGV: append arg to array (can be