Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!ux1.cso.uiuc.edu!iuvax!rutgers!bellcore!flash!sdh From: sdh@flash.bellcore.com (Stephen D Hawley) Newsgroups: comp.sys.mac.programmer Subject: Re: dead code, brain dead lilbrary Message-ID: <20148@bellcore.bellcore.com> Date: 20 Feb 90 22:01:57 GMT References: <1990Feb14.204332.24800@caen.engin.umich.edu> <20062@bellcore.bellcore.com> <10294@hoptoad.uucp> Sender: news@bellcore.bellcore.com Reply-To: sdh@flash.UUCP (Stephen D Hawley) Organization: Bellcore, Morristown, NJ Lines: 53 I write: *Ok, quiz question: *How many of you can write/have written atoi()? Tim Writes: >I have. It was a mistake. Eventually I threw it away. You should use >NumToString and StringToNum. Any "atoi" you write will almost >certainly be unfriendly in international environments. The one you >gave is. > >The proper way to write atoi on the Macintosh is: > >int atoi(StringPtr s) { long i; StringToNum(s, &i); return i; } Agreed, this is the best way to write it for a Macintosh-specific application. This, however, does not apply if you are porting *from* a UNIX environment. I wrote my atoi() to be strictly compatible with the Berkeley UNIX manual, but that is not the nit I was picking. My point was not: "who can write the shortest atoi()?", but the more important question: "when will Think C's libraries be put in a reasonable order?" Since Think's atoi() is defined using sscanf(), you bring most of the world with you no matter how smart the linker is. atoi() is not, by far, the only culprit of this. Think's ANSI library should have a far greater atomicity than it does. Applications shouldn't HAVE to be several extra K long because of this. "Sure", one might say, "memory and storage are cheap. What's a few K among friends?" It means a lot to me. I consider programmer a craft. Think's ANSI library is sloppy craftsbeingship. Consider the following program: #include main() { int i = atoi("12345"); } If you build an application from this you get the following sizes: Library App. Size in bytes Library Size in bytes ANSI-small 7,890 11,818 ANSI 20,978 27,972 my atoi() 1,272 122 I don't care about atoi(), I care about the luggage I have to haul around. Steve Hawley sdh@flash.bellcore.com A noun's a special kind of word. It's ev'ry name you ever heard. I find it quite interesting, A noun's a person place or thing.