Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jan 2002 17:40:02 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Chad David <davidc@acns.ab.ca>
Cc:        Alexey Zelkin <phantom@FreeBSD.ORG>, "Andrey A. Chernov" <ache@nagual.pp.ru>, "Brian F. Feldman" <green@FreeBSD.ORG>, <arch@FreeBSD.ORG>
Subject:   Re: strtod()
Message-ID:  <20020128173725.W41376-100000@gamplex.bde.org>
In-Reply-To: <20020127131125.B42735@colnta.acns.ab.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 27 Jan 2002, Chad David wrote:

> The differences between 1.3 are pretty minor though, and they do not
> affect this.
>
> colnta->cvs diff -ud -r 1.3 localeconv.c
> Index: localeconv.c
> ===================================================================
> RCS file: /mnt1/ncvs/src/lib/libc/locale/localeconv.c,v
> retrieving revision 1.3
> retrieving revision 1.9
> diff -u -d -r1.3 -r1.9
> --- localeconv.c        10 Feb 2001 02:00:56 -0000      1.3
> +++ localeconv.c        20 Dec 2001 15:30:02 -0000      1.9
>
> [cut copyright]
>
> @@ -29,11 +36,13 @@
>  #if 0
>  static char sccsid[] = "@(#)localeconv.c       8.1 (Berkeley) 6/4/93";
>  #endif
> -static char rcsid[] = "$FreeBSD: src/lib/libc/locale/localeconv.c,v 1.3 2001/02/10 02:00:56 ache Exp $";
> +static char rcsid[] =
> +  "$FreeBSD: src/lib/libc/locale/localeconv.c,v 1.9 2001/12/20 15:30:02 phantom Exp $";
>  #endif /* LIBC_SCCS and not lint */
>
>  #include <locale.h>
>  #include <stdlib.h>
> +#include <limits.h>
>  #include "lmonetary.h"
>  #include "lnumeric.h"
>
> @@ -51,7 +60,10 @@
>
>  static char
>  cnv(char *str) {
> -       return (char)strtol(str, NULL, 0);
> +       int i = strtol(str, NULL, 10);
> +       if (i == -1)
> +               i = CHAR_MAX;
> +       return (char)i;
>  }
>
> This change here detected that strtol() was failing, but didn't fix errno.

This change actually adds 3 style bugs and a magic conversion, but doesn't
detect that strtol() fails.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020128173725.W41376-100000>