Print this page
5218 posix definition of NULL
correct unistd.h and iso/stddef_iso.h
update gate source affected


 182         char    *cp;
 183         int     longopt;
 184         char    *longoptarg;
 185 
 186         /*
 187          * Has the end of the options been encountered?  The following
 188          * implements the SUS requirements:
 189          *
 190          * If, when getopt() is called:
 191          *      argv[optind]    is a null pointer
 192          *      *argv[optind]   is not the character '-'
 193          *      argv[optind]    points to the string "-"
 194          * getopt() returns -1 without changing optind. If
 195          *      argv[optind]    points to the string "--"
 196          * getopt() returns -1 after incrementing optind.
 197          */
 198         if (_sp == 1) {
 199                 if (optind >= argc || argv[optind][0] != '-' ||
 200                     argv[optind] == NULL || argv[optind][1] == '\0')
 201                         return (EOF);
 202                 else if (strcmp(argv[optind], "--") == NULL) {
 203                         optind++;
 204                         return (EOF);
 205                 }
 206         }
 207 
 208         /*
 209          * Getting this far indicates that an option has been encountered.
 210          * Note that the syntax of optstring applies special meanings to
 211          * the characters ':' and '(', so they are not permissible as
 212          * option letters. A special meaning is also applied to the ')'
 213          * character, but its meaning can be determined from context.
 214          * Note that the specification only requires that the alnum
 215          * characters be accepted.
 216          *
 217          * If the second character of the argument is a '-' this must be
 218          * a long-option, otherwise it must be a short option.  Scan for
 219          * the option in optstring by the appropriate algorithm. Either
 220          * scan will return a pointer to the short-option character in
 221          * optstring if the option is found and NULL otherwise.
 222          *




 182         char    *cp;
 183         int     longopt;
 184         char    *longoptarg;
 185 
 186         /*
 187          * Has the end of the options been encountered?  The following
 188          * implements the SUS requirements:
 189          *
 190          * If, when getopt() is called:
 191          *      argv[optind]    is a null pointer
 192          *      *argv[optind]   is not the character '-'
 193          *      argv[optind]    points to the string "-"
 194          * getopt() returns -1 without changing optind. If
 195          *      argv[optind]    points to the string "--"
 196          * getopt() returns -1 after incrementing optind.
 197          */
 198         if (_sp == 1) {
 199                 if (optind >= argc || argv[optind][0] != '-' ||
 200                     argv[optind] == NULL || argv[optind][1] == '\0')
 201                         return (EOF);
 202                 else if (strcmp(argv[optind], "--") == 0) {
 203                         optind++;
 204                         return (EOF);
 205                 }
 206         }
 207 
 208         /*
 209          * Getting this far indicates that an option has been encountered.
 210          * Note that the syntax of optstring applies special meanings to
 211          * the characters ':' and '(', so they are not permissible as
 212          * option letters. A special meaning is also applied to the ')'
 213          * character, but its meaning can be determined from context.
 214          * Note that the specification only requires that the alnum
 215          * characters be accepted.
 216          *
 217          * If the second character of the argument is a '-' this must be
 218          * a long-option, otherwise it must be a short option.  Scan for
 219          * the option in optstring by the appropriate algorithm. Either
 220          * scan will return a pointer to the short-option character in
 221          * optstring if the option is found and NULL otherwise.
 222          *