--- Warren Young <[EMAIL PROTECTED]> wrote: > Joshua Daniel Franklin wrote: > > > > -z, --version output version information and exit > > > > I used -z since -v is --verbose. It could also have no character > > option if that would be better. > > Why not -V?
No no no. Makes much too much sense. You'd think I was adding version information for the users or someting. Lastest patch: corrects copyright dates version now -V, not -z I think this one's going to work, so here's a changelog: 2001-02-27 Joshua Daniel Franklin <[EMAIL PROTECTED]> * cygcheck.cc: added -V --version option, corrected -h to output to stdout __________________________________________________ Do You Yahoo!? Yahoo! Greetings - Send FREE e-cards for every occasion! http://greetings.yahoo.com
--- cygcheck.cc-orig Sun Feb 24 13:28:27 2002 +++ cygcheck.cc Wed Feb 27 11:57:32 2002 @@ -1,6 +1,6 @@ /* cygcheck.cc - Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. + Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. This file is part of Cygwin. @@ -33,6 +33,8 @@ typedef __int64 longlong; void dump_setup (int, char **, bool); +const char *revision="$Revision: 1.22 $ "; + const char *known_env_vars[] = { "c_include_path", "compiler_path", @@ -1216,17 +1218,19 @@ check_keys () } void -usage () +usage (FILE *stream, int status) { - fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n"); - fprintf (stderr, " -c, --check-setup = check packages installed via setup.exe\n"); - fprintf (stderr, " -s, --sysinfo = system information (not with -k)\n"); - fprintf (stderr, " -v, --verbose = verbose output (indented) (for -s or programs)\n"); - fprintf (stderr, " -r, --registry = registry search (requires -s)\n"); - fprintf (stderr, " -k, --keycheck = perform a keyboard check session (not with -s)\n"); - fprintf (stderr, " -h, --help = give help about the info (not with -c)\n"); - fprintf (stderr, "You must at least give either -s or -k or a program name\n"); - exit (1); + fprintf (stream, "\ +Usage: cygcheck [OPTIONS] [program ...]\n\ + -c, --check-setup check packages installed via setup.exe\n\ + -s, --sysinfo system information (not with -k)\n\ + -v, --verbose verbose output (indented) (for -s or programs)\n\ + -r, --registry registry search (requires -s)\n\ + -k, --keycheck perform a keyboard check session (not with -s)\n\ + -h, --help give help about the info (not with -c)\n\ + -V, --version output version information and exit\n\ +You must at least give either -s or -k or a program name\n"); + exit (status); } struct option longopts[] = { @@ -1236,15 +1240,32 @@ struct option longopts[] = { {"verbose", no_argument, NULL, 'v'}, {"keycheck", no_argument, NULL, 'k'}, {"help", no_argument, NULL, 'h'}, + {"version", no_argument, 0, 'V'}, {0, no_argument, NULL, 0} }; -char opts[] = "srvkhc"; +char opts[] = "chkrsvV"; int main (int argc, char **argv) { int i; + char *version; + + /* Get version number out of the autogenerated revision string */ + (void *) version = malloc(sizeof(revision)); + strcpy(version, revision+9); + if (version[0] != ':') + *version=0; + else + { + version = version+2; + char *temp=version + strlen (version); + while (isspace((int)*--temp) || *temp=='$' && temp >= version) + temp[1]='\0'; + } + + version[strlen(version)-1]= 0; while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF) switch (i) @@ -1267,17 +1288,27 @@ main (int argc, char **argv) case 'h': givehelp = 1; break; + case 'V': + printf ("cygcheck (cygwin) %s\n", version); + printf ("System Checker\n"); + printf ("Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n"); + fputs ("Compiled "__DATE__"\n", stdout); + exit (0); default: - usage (); + usage (stderr, 1); /*NOTREACHED*/} argc -= optind; argv += optind; - if (argc == 0 && !sysinfo && !keycheck && !check_setup) - usage (); + if (argc == 0 && !sysinfo && !keycheck && !check_setup) { + if (givehelp) + usage (stdout, 0); + else + usage (stderr, 1); + } if ((check_setup || sysinfo) && keycheck) - usage (); + usage (stderr, 1); if (keycheck) return check_keys ();