mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
getopt(): Could leave optind in undefined state if argc == 1
This commit is contained in:
@@ -6485,4 +6485,6 @@
|
|||||||
compiler option when building for a 32-bit target on a native 64-bit
|
compiler option when building for a 32-bit target on a native 64-bit
|
||||||
compiler (2014-1-18).
|
compiler (2014-1-18).
|
||||||
* include/ctype.h: Typo in macro name: iscntrol, not iscontrol (2104-1-17)
|
* include/ctype.h: Typo in macro name: iscntrol, not iscontrol (2104-1-17)
|
||||||
|
* libc/unistd/lib_getopt.c: If there are no arguments (argc == 1), then
|
||||||
|
getopt() make like the optind variable in an undefined state (2014-1-20).
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,10 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring)
|
|||||||
return noarg_ret;
|
return noarg_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Restore the initial, uninitialized state */
|
||||||
|
|
||||||
g_binitialized = false;
|
g_binitialized = false;
|
||||||
|
optind = 1;
|
||||||
|
optopt = '?';
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user