Xref: utzoo comp.sys.atari.st:17749 comp.lang.c:19909 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcvax!hp4nl!phigate!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.sys.atari.st,comp.lang.c Subject: Re: string comparisons in C Keywords: C, atari st, mark williams Message-ID: <1056@philmds.UUCP> Date: 14 Jul 89 11:54:51 GMT References: <44672745.14a1f@gtephx.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 28 In article <44672745.14a1f@gtephx.UUCP> covertr@gtephx.UUCP (Richard E. Covert) writes: | But, I was browsing thru the MWC manual, and lo and behold I see |pnmatch(). Now pnmatch is a wonderful little function which does string |comparisons. And it even accepts wildcards, so I was in business. I just |build an array of strings such as "*.PI1", and then by looping thru the |array I can string compare a user inputted filename against the list of |legal filetypes. Pretty neat solution. | | So, the moral of this little ditty, is READ YOUR MANUAL!! | |P.S. Does anyone know if pnmatch() is implemented on other C compilers?? Lattice C has stcpm() and stcpma() for unanchored and anchored pattern matching. The BSD C libraries have regcomp() and regex() for regular expression pattern matching (which probably goes a lot further than any of pnmatch(), stcpm() or stcpma()). The drawback of all these wonderful functions is that they are hardly standardized, so you loose if portability is at stake (and it is more often than you'd hope for). For maximum portability, use the functions that are in the ANSI draft, and create your own library for functions like pnmatch() that aren't there (it is very easy to make a general wildcard pattern matcher). You'll be grateful for this advice when you switch to another compiler, or your vendor doesn't support this neat little function in the next release, or you're porting to a different system, or ... Leo.