diff options
author | jbj <jbj> | 2009-07-25 22:24:29 +0000 |
---|---|---|
committer | jbj <jbj> | 2009-07-25 22:24:29 +0000 |
commit | 36fc2398334b06ebf63827f6a4e979e63c1f7713 (patch) | |
tree | 216cd412bd2f1c9bad189b02744b2c3893333fc7 /test1.c | |
parent | 11f0e2b5d4f2987eebaa244970d962c9c9e3d0b9 (diff) | |
download | libpopt-36fc2398334b06ebf63827f6a4e979e63c1f7713.tar.gz |
- add POPT_ARG_BITSET handling.
Diffstat (limited to 'test1.c')
-rw-r--r-- | test1.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -38,9 +38,9 @@ static unsigned int aFlag = 0x8aceU; static unsigned int bFlag = 0x8aceU; /*@unchecked@*/ -static short aShort = 4523; +static short aShort = (short)4523; /*@unchecked@*/ -static short bShort = 4523; +static short bShort = (short)4523; /*@unchecked@*/ static int aInt = 271828; /*@unchecked@*/ @@ -61,8 +61,11 @@ static float bFloat = 3.1415926535; static double aDouble = 9.86960440108935861883; /*@unchecked@*/ static double bDouble = 9.86960440108935861883; + /*@unchecked@*/ /*@only@*/ /*@null@*/ static const char ** aArgv = NULL; +/*@unchecked@*/ /*@only@*/ /*@null@*/ +static void * aBits = NULL; /*@unchecked@*/ /*@null@*/ static char * oStr = (char *) -1; @@ -151,7 +154,9 @@ static struct poptOption options[] = { "POPT_ARGFLAG_RANDOM: experimental", NULL }, { "argv", '\0', POPT_ARG_ARGV, &aArgv, 0, - "POPT_ARG_ARGV: append arg to array (can be used multiple times)",NULL}, + "POPT_ARG_ARGV: append string to argv array (can be used multiple times)","STRING"}, + { "bits", '\0', POPT_ARG_BITSET|POPT_ARGFLAG_DOC_HIDDEN, &aBits, 0, + "POPT_ARG_BITSET: add string to bit set (can be used multiple times)","STRING"}, { "bitset", '\0', POPT_BIT_SET | POPT_ARGFLAG_TOGGLE | POPT_ARGFLAG_SHOW_DEFAULT, &aFlag, 0x7777, "POPT_BIT_SET: |= 0x7777", 0}, @@ -179,10 +184,10 @@ static struct poptOption options[] = { static void resetVars(void) /*@globals arg1, arg2, arg3, inc, shortopt, aVal, aFlag, aShort, aInt, aLong, aLongLong, aFloat, aDouble, - aArgv, oStr, singleDash, pass2 @*/ + aArgv, aBits, oStr, singleDash, pass2 @*/ /*@modifies arg1, arg2, arg3, inc, shortopt, aVal, aFlag, aShort, aInt, aLong, aLongLong, aFloat, aDouble, - aArgv, oStr, singleDash, pass2 @*/ + aArgv, aBits, oStr, singleDash, pass2 @*/ { arg1 = 0; arg2 = "(none)"; @@ -211,6 +216,10 @@ static void resetVars(void) free(aArgv); aArgv = NULL; } + if (aBits) { + free(aBits); + aBits = NULL; + } oStr = (char *) -1; @@ -287,7 +296,7 @@ int main(int argc, const char ** argv) if (aFlag != bFlag) fprintf(stdout, " aFlag: 0x%x", aFlag); if (aShort != bShort) - fprintf(stdout, " aShort: %d", aShort); + fprintf(stdout, " aShort: %hd", aShort); if (aInt != bInt) fprintf(stdout, " aInt: %d", aInt); if (aLong != bLong) @@ -307,6 +316,9 @@ int main(int argc, const char ** argv) while ((arg = *av++) != NULL) fprintf(stdout, " %s", arg); } + if (aBits) { + fprintf(stdout, " aBits: non-null"); + } /*@-nullpass@*/ if (oStr != (char *)-1) fprintf(stdout, " oStr: %s", (oStr ? oStr : "(none)")); |