Re: version information for cygcheck

2002-02-27 Thread Joshua Daniel Franklin

--- 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-origSun 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 ();



Re: version information for cygcheck

2002-02-27 Thread Joshua Daniel Franklin


--- 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-origSun 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 ();



Re: version information for cygcheck

2002-02-27 Thread Joshua Daniel Franklin


--- 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



Re: version information for cygcheck

2002-02-27 Thread Warren Young

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?



Re: version information for cygcheck

2002-02-24 Thread Joshua Daniel Franklin

>The usual thing to do for versions is to get the CVS version number and
>apply that.

I'm assuming that lines like this in CVS/Entries give the version numbers:

/cygcheck.cc/1.22/Tue Jan 29 03:08:42 2002/-ko/
/cygpath.cc/1.13/Thu Jan 17 16:54:01 2002/-ko/
/dump_setup.cc/1.4/Tue Jan 29 18:37:00 2002//
/dumper.cc/1.8/Fri Sep 14 15:07:31 2001//
/dumper.h/1.2/Thu Aug 30 16:47:51 2001//
/getfacl.c/1.5/Tue Jan 29 03:08:42 2002/-ko/
/kill.cc/1.10/Mon Oct  8 03:06:25 2001/-ko/
/mkgroup.c/1.9/Tue Jan 29 03:08:42 2002/-ko/
/mkpasswd.c/1.20/Thu Jan 31 12:43:29 2002/-ko/
...

I've got a problem then. Currently `cygpath --version` outputs 1.2, where it
should be 1.13 apparently. Is there a way to get the CVS version up to 1.21
with a patch? Also, if I add --version options to each util,
should I increment the version by .01 each time, so cygcheck will be v1.23,
mkgroup 1.91, etc.? I guess the question should be, does CVS automatically
increment the version by a certain amount after a patch?

Also, if I'm going to patch several files, should I tar up several 
.cc-patch files or do one big patch?

Thanks.

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



Re: version information for cygcheck

2002-02-24 Thread Robert Collins

The usual thing to do for versions is to get the CVS version number and
apply that.

Rob