(getopt): return -1 instead of EOF. From <art@stacken.kth.se>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7430 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -69,22 +69,22 @@ getopt(nargc, nargv, ostr)
|
|||||||
optreset = 0;
|
optreset = 0;
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return(EOF);
|
return(-1);
|
||||||
}
|
}
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
++optind;
|
++optind;
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return(EOF);
|
return(-1);
|
||||||
}
|
}
|
||||||
} /* option letter okay? */
|
} /* option letter okay? */
|
||||||
if ((optopt = (int)*place++) == (int)':' ||
|
if ((optopt = (int)*place++) == (int)':' ||
|
||||||
!(oli = strchr(ostr, optopt))) {
|
!(oli = strchr(ostr, optopt))) {
|
||||||
/*
|
/*
|
||||||
* if the user didn't specify '-' as an option,
|
* if the user didn't specify '-' as an option,
|
||||||
* assume it means EOF.
|
* assume it means -1 (EOF).
|
||||||
*/
|
*/
|
||||||
if (optopt == (int)'-')
|
if (optopt == (int)'-')
|
||||||
return(EOF);
|
return(-1);
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++optind;
|
||||||
if (opterr && *ostr != ':') {
|
if (opterr && *ostr != ':') {
|
||||||
|
Reference in New Issue
Block a user