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
This commit is contained in:
patacongo 2008-08-23 15:04:50 +00:00
parent e716896a18
commit 3afb380432

View File

@ -103,7 +103,7 @@ static boolean g_binitialized = FALSE;
int getopt(int argc, FAR char *const argv[], FAR const char *optstring) int getopt(int argc, FAR char *const argv[], FAR const char *optstring)
{ {
if (argv && optstring) if (argv && optstring && argc > 1)
{ {
int noarg_ret = '?'; int noarg_ret = '?';
char *optchar; 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 /* 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]; g_optptr = argv[optind];
if (*g_optptr != '-') if (*g_optptr != '-')