help/version patches
Joshua Daniel Franklin
joshuadfranklin@yahoo.com
Wed Feb 27 03:03:00 GMT 2002
--- Robert Collins <robert.collins@itdomain.com.au> wrote:
>
>
> > -----Original Message-----
> > From: Joshua Daniel Franklin [mailto:joshuadfranklin@yahoo.com]
>
> +const char *revision="$Revision: 1.22 $";
>
> This is suspect: The revision string can look like $Revision:$ in some
> circumstances - see man co again - which is why I had "$Revision: $ " - note
> the space after the second $ sign.
Hmm. Sounds like if -kk is used, it could be replaced with just "$Revision$",
which gives the +11 part problems. Another if...
> Likewise, the
> + /* Get version number out of the autogenerated revision string */
> + (void *) version = malloc(sizeof(revision));
> + strcpy(version, revision+11);
> + version[strlen(version)-1]= 0;
>
> Could be more robustly done as
> + version = (char *) malloc(sizeof(revision));
> + strcpy(version, revision+11);
> + {
> + char *temp=version + strlen (version);
> + while (isspace(--temp) && temp >= version);
> + temp[1]='\0';
> + }
>
> Which will munch an arbitrary amount of whitespace.
Well, except that that loop does away with the whole point--eating the
trailing '$'. Here's another go. I tested it with "$Revision$",
"$Revision:$", "$Revision: $ ", "$Revision: 1.22 $ ", and "$Revision: 1.2 2 $ "
(in the unlikely event of a version number with spaces) and it does the right
thing on each.
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.cc-patch
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020227/84452747/attachment.ksh>
More information about the Cygwin-patches
mailing list