From 36fc2398334b06ebf63827f6a4e979e63c1f7713 Mon Sep 17 00:00:00 2001 From: jbj Date: Sat, 25 Jul 2009 22:24:29 +0000 Subject: - add POPT_ARG_BITSET handling. --- test1.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'test1.c') diff --git a/test1.c b/test1.c index c9effd5..35fd376 100644 --- a/test1.c +++ b/test1.c @@ -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)")); -- cgit v1.2.1