Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!julius.cs.uiuc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!spool2.mu.edu!uunet!cbmvax!jesup From: jesup@cbmvax.commodore.com (Randell Jesup) Newsgroups: comp.sys.amiga.programmer Subject: Re: AmigaDOS patterns with '~' Keywords: pattern matcher Message-ID: <17879@cbmvax.commodore.com> Date: 22 Jan 91 02:14:37 GMT References: <04348.AA04348@ami-cg.UUCP> Reply-To: jesup@cbmvax.commodore.com (Randell Jesup) Organization: Commodore, West Chester, PA Lines: 24 In article <04348.AA04348@ami-cg.UUCP> cg@ami-cg.UUCP (Chris Gray) writes: >I recall hearing that the 2.0 DOS pattern matcher handles the '~' operator >to mean 'not'. I vaguely recall someone saying that it was easy to add. >Well, I took a quick try and it didn't work out. Could someone send me >the changes necessary to add the '~' to one of the versions of the matcher >that was floating around? Thanks. It does support it (though earlier versions of 2.0 had a few problems with ~, it works very well now). Are you talking about some package? It's not clear from your message. The trick to implementing ~ is to consider it to be #? if the pattern "not-ed" doesn't match. I.e ~a matches all files that are not exactly "a", not just 1-character files that are not "a". The easiest implementation is to have a not-end token, and call the matcher recursively on the not-ed part. the not-end token will cause the match routine to return immediately success, regardless if the strings have not all been used yet. If the recursive call matches, kick out with an error, else go to the routine which handles #?. -- Randell Jesup, Keeper of AmigaDos, Commodore Engineering. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com BIX: rjesup The compiler runs Like a swift-flowing river I wait in silence. (From "The Zen of Programming") ;-)