Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!david From: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Newsgroups: comp.windows.x.motif Subject: Re: Widget Creation Library version 1.03 Now Available Message-ID: <9057@jpl-devvax.JPL.NASA.GOV> Date: 8 Aug 90 00:08:38 GMT References: <1990Aug6.140420@nontech.ctt.bellcore.com> Reply-To: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 52 guy@auspex.auspex.com (Guy Harris) writes: >david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) writes: > > if ( strstr( res_type, "Widget") > >#ifdef MOTIF > > || strstr( res_type, "Window") /* wrong: but that's a menuWidget */ > >#endif > > ) > > > >You can change the `strstr' to `strtok' and everything will work fine. > >If that's true, it's sure a lucky coincidence, as "strstr()" and >"strtok()" don't do anything very much related.... > >An N*M-time implementation of "strstr()" isn't that hard to do. OK, OK, OK! You are right, I was just lucky in my 10 second test... strtok and strstr are rather different. Here is a quick implementation of strstr which seems to work. I did not copy anybody elses, so you don't have to worry about copyleft or copyright or whatever. Please, please, please, use an ANSI C compiler (e.g., gcc) if you can. I don't want to start supporting an ANSI C library!!!!!!! For you hapless people out there who get "_strstr undefined" errors when compiling WcCallb.c in Wcl version 1.03, just compile this and include it on the load line: /* copyright David E. Smyth 1990 */ char* strstr( s1, s2 ) char* s1; char* s2; { while (*s1) { if (*s1 == *s2) { char* start = s1; char* c = s2; while (*++s1 & *++c && *s1 == *c) ; if (*c == '\0') return start; else s1 = ++start; } else { s1++ ; } } return (char*)0; }