TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Paul Edwards
date: 1996-06-11 01:31:58
subject: Find a word

FA> Yes, they are. But i thought re-writing standard library functions 
FA> would be a no-no, 

You aren't rewriting standard library functions, since there is
no case-insensitive strstr() in the standard library!

FA> Btw, perhaps you've posted the wrong one, that was case sensitive.

That was the only one I had.

FA> I've pinched your variable names, hope you don't mind, but it makes
FA> it more readable than the way it was with mine.

It is public domain, I don't care what you do with it.  Actually,
if your strstr() is better than mine, I might use yours in
PDPCLIB.  BFN.  Paul.

P.S. I used it, but it didn't work properly.  Wanna modify this
(formatted) version so that it works?

/* strstr by Frank Adam */

char *strstr(const char *s1, const char *s2)
{
    const char *p = s1, *p1 = s2, *p2;
    
    while (*p++)   /* this ++ is suspicous */
    {
        if (*p == *p1)
        {
            p2 = p;
            while (*p++ == *p1 && *p1++) ;
            if (!*p1) 
            {
                return (char *)p2;
            }
            p = ++p2;
            p1 = s2;
        }
    }
    return NULL;
}
@EOT:

---
* Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.