Simon Josefsson <[EMAIL PROTECTED]> 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.


_______________________________________________
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib

Reply via email to