[comp.sys.next] bug in NeXT 1.0 strtol

mrc@Tomobiki-Cho.CAC.Washington.EDU (Mark Crispin) (11/14/90)

The following little program demonstrates a bug in the strtol()
function under NeXT 1.0.  36 is output whereas the correct answer is
3.  strtol() on other systems gets this right.  atoi() works OK as
well; meaning that NeXT isn't obeying the definition of atoi() =
(int)strtol(s,(char**)NULL,10).

main ()
{
  printf ("%d\n",strtol ("3]",0,10));
}
 _____   | ____ ___|___   /__ Mark ("Gaijin") Crispin "Gaijin! Gaijin!"
 _|_|_  -|- ||   __|__   /  / R90/6 pilot, DoD #0105  "Gaijin ha doko?"
|_|_|_|  |\-++-  |===|  /  /  Atheist & Proud         "Niichan ha gaijin."
 --|--  /| ||||  |___|    /\  (206) 842-2385/543-5762 "Chigau. Omae ha gaijin."
  /|\    | |/\| _______  /  \ MRC@CAC.Washington.EDU  "Iie, boku ha nihonjin."
 / | \   | |__|  /   \  /    \ Lumchan ga suki ja!!   "Souka. Yappari gaijin!"
Hee, dakedo UNIX nanka wo tsukatte, umaku ikanaku temo shiranai yo.

hess@iuvax.cs.indiana.edu (Caleb Hess) (11/15/90)

I noticed some time ago that strtol() didn't work right on NeXT (try giving
it a large hex value - anything over 2^31 comes back as FFFFFFFF).  Then
I discovered that NeXT has no man page for strtol, so I assumed it wasn't
supported.  I used sscanf() instead.