[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: check_version
From: |
Jim Meyering |
Subject: |
Re: check_version |
Date: |
Sat, 25 Jun 2005 13:15:30 +0200 |
Simon Josefsson <address@hidden> wrote:
> I'm using this module in all of my GNU packages. One complication
> might be that it depends on VERSION being defined. Feedback
> appreciated.
Looks useful, but sounds like a job better implemented
in a higher level language. But maybe you have constraints
(portability?) that make this approach necessary.
...
> Index: lib/check_version.c
...
> +static const char *
> +parse_version_number (const char *s, int *number)
> +{
> + int val = 0;
> +
> + if (*s == '0' && isdigit (s[1]))
> + return NULL; /* leading zeros are not allowed */
> +
> + for (; isdigit (*s); s++)
> + {
> + val *= 10;
> + val += *s - '0';
> + }
You might want to impose a limit (too arbitrary?) on the number
of digits in each component, or add some other mechanism to
protect against overflow. Otherwise, someone could conceivably
provide a version number like 1.4294967297 that would satisfy
a requirement for 1.1, or one like 1.4294967296 that would not.
Also, that function treats non-numeric strings as zero
and doesn't object (or provide a way for the caller to object)
if there is something unexpected following a numeric component.
If that is deliberate, you should add a comment saying so.
- check_version, Simon Josefsson, 2005/06/25
- Re: check_version, Simon Josefsson, 2005/06/25
- Re: check_version,
Jim Meyering <=
- Re: check_version, Simon Josefsson, 2005/06/25
- Re: check_version, Paul Eggert, 2005/06/26
- Re: check_version, Simon Josefsson, 2005/06/27
- Re: check_version, Jim Meyering, 2005/06/28
- Re: check_version, Simon Josefsson, 2005/06/28
- Re: check_version, Jim Meyering, 2005/06/28
- Re: check_version, Simon Josefsson, 2005/06/28
- Re: check_version, Derek Price, 2005/06/28