--------------------- PatchSet 10519 Date: 2008/04/27 09:36:45 Author: serassio Branch: nt Tag: (none) Log: Ran indent Members: lib/getopt.c:1.1.124.3->1.1.124.4 port/win32/include/getopt.h:1.1.38.2->1.1.38.3 Index: squid/lib/getopt.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/Attic/getopt.c,v retrieving revision 1.1.124.3 retrieving revision 1.1.124.4 diff -u -r1.1.124.3 -r1.1.124.4 --- squid/lib/getopt.c 27 Apr 2008 09:33:03 -0000 1.1.124.3 +++ squid/lib/getopt.c 27 Apr 2008 09:36:45 -0000 1.1.124.4 @@ -1,6 +1,6 @@ /* * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -39,11 +39,11 @@ #include #include -int opterr = 1, /* if error message should be printed */ - optind = 1, /* index into parent argv vector */ - optopt, /* character checked for validity */ - optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define BADARG (int)':' @@ -51,66 +51,64 @@ /* * getopt -- - * Parse argc/argv argument vector. + * Parse argc/argv argument vector. */ int getopt(nargc, nargv, ostr) - int nargc; - char * const *nargv; - const char *ostr; + int nargc; + char *const *nargv; + const char *ostr; { - static char *place = EMSG; /* option letter processing */ - char *oli; /* option letter list index */ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ - if (optreset || !*place) { /* update scanning pointer */ - optreset = 0; - if (optind >= nargc || *(place = nargv[optind]) != '-') { - place = EMSG; - return (-1); - } - if (place[1] && *++place == '-') { /* found "--" */ - ++optind; - place = EMSG; - return (-1); - } - } /* option letter okay? */ - if ((optopt = (int)*place++) == (int)':' || - !(oli = strchr(ostr, optopt))) { - /* - * if the user didn't specify '-' as an option, - * assume it means -1. - */ - if (optopt == (int)'-') - return (-1); - if (!*place) - ++optind; - if (opterr && *ostr != ':') - (void)fprintf(stderr, - "%s: illegal option -- %c\n", __FILE__, optopt); - return (BADCH); + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); } - if (*++oli != ':') { /* don't need argument */ - optarg = NULL; - if (!*place) - ++optind; + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return (-1); } - else { /* need an argument */ - if (*place) /* no white space */ - optarg = place; - else if (nargc <= ++optind) { /* no arg */ - place = EMSG; - if (*ostr == ':') - return (BADARG); - if (opterr) - (void)fprintf(stderr, - "%s: option requires an argument -- %c\n", - __FILE__, optopt); - return (BADCH); - } - else /* white space */ - optarg = nargv[optind]; - place = EMSG; - ++optind; - } - return (optopt); /* dump back option letter */ + } /* option letter okay? */ + if ((optopt = (int) *place++) == (int) ':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int) '-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void) fprintf(stderr, + "%s: illegal option -- %c\n", __FILE__, optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void) fprintf(stderr, + "%s: option requires an argument -- %c\n", + __FILE__, optopt); + return (BADCH); + } else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ } Index: squid/port/win32/include/getopt.h =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/include/Attic/getopt.h,v retrieving revision 1.1.38.2 retrieving revision 1.1.38.3 diff -u -r1.1.38.2 -r1.1.38.3 --- squid/port/win32/include/getopt.h 27 Apr 2008 09:33:04 -0000 1.1.38.2 +++ squid/port/win32/include/getopt.h 27 Apr 2008 09:36:45 -0000 1.1.38.3 @@ -1,6 +1,6 @@ /* * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -38,16 +38,16 @@ extern "C" { #endif -extern int opterr; /* if error message should be printed */ -extern int optind; /* index into parent argv vector */ -extern int optopt; /* character checked for validity */ -extern int optreset; /* reset getopt */ -extern char *optarg; /* argument associated with option */ + extern int opterr; /* if error message should be printed */ + extern int optind; /* index into parent argv vector */ + extern int optopt; /* character checked for validity */ + extern int optreset; /* reset getopt */ + extern char *optarg; /* argument associated with option */ -int getopt(int nargc, char * const *nargv, const char *ostr); + int getopt(int nargc, char *const *nargv, const char *ostr); #ifdef __cplusplus } -#endif #endif +#endif