delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2004/02/24/01:50:08

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Message-ID: <403ADB4A.ED9F77C2@yahoo.com>
Date: Tue, 24 Feb 2004 00:04:10 -0500
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: strtoul bug (was Re: Fibonacci number)
References: <d7c3a0b2 DOT 0402220759 DOT 34d6435d AT posting DOT google DOT com> <4038E8CA DOT 6491815E AT virginia DOT edu> <4039DD96 DOT 3F36F3B7 AT yahoo DOT com> <200402231458 DOT i1NEwKwm020904 AT envy DOT delorie DOT com> <403A301C DOT E8F5FE65 AT yahoo DOT com> <200402231751 DOT i1NHp5lv022894 AT envy DOT delorie DOT com> <403A5F55 DOT 7E608910 AT yahoo DOT com> <200402232034 DOT i1NKYqrt024366 AT envy DOT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com

DJ Delorie wrote:
> 
> I'm thinking something table-driven would be better; no user input
> should be needed for a test case.  How about a table like this?
> 
> struct {
>   char *input_string;
>   int base; /*
>   int expected_endp; /* index into string */
>   unsigned char expected_value[8];
>   int expected_errno;
> } tests[] = {
>   { "0", 0, 1, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0 },
>   { "10x", 8, 2, { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0 },
>   /* etc */
>   { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }, 0 }
> }
> 
> We could have one table for each function (strtol, strtoul, strtoll,
> strtoull) and pass the table, function, and size of result (4 or 8) to
> a common "test this" function.
> 
> The function should print nothing and exit(0) if they all pass, else
> print a diagnostic and exit(1) if any fail.

First I think we need a consensus as to what is in error.  I have
posted something very similar to c.l.c and c.std.c to see what
appears.  I still consider the acceptance of signs in the unsigned
varieties to be an error, but it may have been justified by the
number of such implementations in existance.  TC 2.01 does NOT
accept them! which seems sane, if non-conforming.

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019