summaryrefslogtreecommitdiff
path: root/test1.c
diff options
context:
space:
mode:
authorjbj <jbj>2009-07-25 18:52:36 +0000
committerjbj <jbj>2009-07-25 18:52:36 +0000
commit11f0e2b5d4f2987eebaa244970d962c9c9e3d0b9 (patch)
treec0d0a6ca4b073e86eb5040a3742195050548af32 /test1.c
parent8d10e06e834414ac7dfba42e582f4dcab97dfe85 (diff)
downloadlibpopt-11f0e2b5d4f2987eebaa244970d962c9c9e3d0b9.tar.gz
- add POPT_ARG_SHORT handling.
Diffstat (limited to 'test1.c')
-rw-r--r--test1.c19
1 files changed, 15 insertions, 4 deletions
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)