🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #291

strto[dl]

#291
From: Steve Summit
Date: Thu, 06 Jul 1989 04:12
18 lines
1432 bytes
Microsoft's implementation of strtol (or was it strtod?  I
forget) returns, when given the string " x", a 0, with the "end
pointer" argument pointing to the 'x'.  I think this is a bug.
One of the significant advantages that strto[dl] have over ato[fl]
ought to be that you can determine, by comparing the returned end
pointer with the initial string pointer, whether a number was
actually converted and if so, where it ended.  By returning a
pointer which has been stepped over leading whitespace even
though no number was converted, it becomes impossible to
distinguish between the strings " x" and " 0" (without inspecting
the characters yourself, which you shouldn't have to do).  Does
the wording in the standard make the correct behavior in this
case clear?  (For now, I've written my own strtoi, which behaves
as I'd like it to, and also returns ints instead of longs or
doubles.)

                                            Steve Summit
                                            scs@adam.pika.mit.edu
Technical Details
Message-ID: <12458@bloom-beacon.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!usc!bloom-beacon!avarice.pika.mit.edu!scs

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!usc!bloom-beacon!avarice.pika.mit.edu!scs
From: scs@avarice.pika.mit.edu (Steve Summit)
Newsgroups: comp.std.c
Subject: strto[dl]
Summary: error return?
Message-ID: <12458@bloom-beacon.MIT.EDU>
Date: 6 Jul 89 04:12:59 GMT
Sender: daemon@bloom-beacon.MIT.EDU
Reply-To: scs@adam.pika.mit.edu (Steve Summit)
Distribution: usa
Lines: 18