Xref: utzoo comp.lang.c:8033 comp.lang.misc:1198 Path: utzoo!mnetor!uunet!tektronix!zeus!teklds!daniels From: daniels@teklds.TEK.COM (Scott Daniels) Newsgroups: comp.lang.c,comp.lang.misc Subject: Re: The D Programming Language Message-ID: <2910@teklds.TEK.COM> Date: 12 Mar 88 01:56:28 GMT References: <25284@cca.CCA.COM> <700@l.cc.purdue.edu> <587@bms-at.UUCP> Reply-To: daniels@teklds.UUCP (Scott Daniels) Organization: Tektronix, Inc., Beaverton, OR. Lines: 20 In article <587@bms-at.UUCP> stuart@bms-at.UUCP (Stuart D. Gathman) writes: >Another example is string comparison. I use a string compare function >that returns the index of the first different character. I also >need the gt/lt/eq result. Fortunately, in this case it is easily >computed by recomparing the chars at the index. An alternative is the string comparison I normally use: cmpstr(s1,s2) 0: if equal >0: if s1 > s2 <0: if s1 < s2 abs(cmpstr(s1,s2)) is the number of chars compared: s1[ abs(cmpstr(s1,s2))-1 ] != s2[ abs(cmpstr(s1,s2))-1 ] if cmpstr did not return 0. Normally this function returns just about any information I need, and it is usually not very hard to make an extremely fast version in assembly. -Scott Daniels (daniels@teklds.TEK.COM)