From 3afb3804320e724a1db594af21ee9007f7fef5db Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 23 Aug 2008 15:04:50 +0000 Subject: [PATCH] fix error in getopt with no arguments git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@839 42af7a65-404d-4744-a932-0658087f49c3 --- lib/lib_getopt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/lib_getopt.c b/lib/lib_getopt.c index e73ae68d54..ab770bb0df 100644 --- a/lib/lib_getopt.c +++ b/lib/lib_getopt.c @@ -103,7 +103,7 @@ static boolean g_binitialized = FALSE; int getopt(int argc, FAR char *const argv[], FAR const char *optstring) { - if (argv && optstring) + if (argv && optstring && argc > 1) { int noarg_ret = '?'; char *optchar; @@ -161,8 +161,8 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring) } /* We are starting at the beginning of argv[optind]. In this case, the - * first character must be '-' - */ + * first character must be '-' + */ g_optptr = argv[optind]; if (*g_optptr != '-')