Path: utzoo!utgpu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!think.com!linus!philabs!ttidca!hollombe From: hollombe@ttidca.TTI.COM (The Polymath) Newsgroups: alt.hackers Subject: Re: Useful string function Message-ID: <27260@ttidca.TTI.COM> Date: 27 Jun 91 20:47:11 GMT References: <27187@ttidca.TTI.COM> <20919@crdgw1.crd.ge.com> Organization: The Cat Factory Lines: 39 Approved: yes In article <20919@crdgw1.crd.ge.com> volpe@camelback.crd.ge.com (Christopher R Volpe) writes: }In article <27187@ttidca.TTI.COM>, hollombe@ttidca.TTI.COM (The }Polymath) writes: }|>Here's a simple minor hack I threw together. It's proved so useful, I'm }|>amazed it isn't part of the standard Unix libraries. } }That's because it's part of the standard C library, and it's called }"strstr". Check the man page. Two comments, then I'm going to shut up about this and stop answering my mail. (-: 1) I'm getting mildly annoyed that so many people assume I was too stupid to RTFM before writing the above mentioned function. One more time: Neither our version of SysV nor our version of 4.3 bsd have the strstr() function in their libraries. I looked. Really. 2) So far, I've received two bug reports on the function as posted: It incorrectly returns 0 if s2 is null. (Thanks to jwahar r. bammi for finding this). It incorrectly returns -1 when looking for "ABABD" in "ABABABD". (Thanks to Pat Place). Sorry about that. Corrections for these problems, and any others, are left as an exercise for the reader. I'm not going to post version 1.1 and get my mailbox flooded all over again. I've made an appointment with my doctor to see if he can extract my foot from my mouth. ~sigh~ Didja ever have one of those years ... ? -- The Polymath (aka: Jerry Hollombe, M.A., CDP, aka: hollombe@ttidca.tti.com) Head Robot Wrangler at Citicorp Turn the rascals out! 3100 Ocean Park Blvd. (213) 450-9111, x2483 No incumbents in '92! Santa Monica, CA 90405 {rutgers|pyramid|philabs|psivax}!ttidca!hollombe