wildcard matching

Steve Summit scs at adam.mit.edu
Wed Jan 2 12:14:26 AEST 1991


In article <4739.277BA2FB at urchin.fidonet.org> Tony.Bielobockie at urchin.fidonet.org (Tony Bielobockie) writes:
>I think that the recursive call is unnessicary.  Consider that anything
>trailing the '*' character is ignored anyway, at least in MS-DOS, and
>OS/2. What need is there for further checking if a '*' character is
>encountered?  Does that hold true in the UNIX would too?

Oh, dear.  While I don't believe that computer "science" is a
hard enough science that those without formal training in it
should be deprecated, it is nevertheless the case that those
whose only exposure to it is through MS-DOS or other Microsoft
"operating systems" should realize that those "systems" are so
mind-bogglingly behind the state-of-the-art that extrapolation
based on them is bound to be embarrassingly futile.  For a long
time I had assumed that DOS's notion that "anything trailing the
'*' character is ignored anyway" was an outright bug in its
implementation, because most DOS manuals imply that a * matches
anything anywhere, not just at the end.

I'll keep a firm rein on myself and not let this turn into an
all-out DOS flame.  Its wildcard matching "algorithm" is only one
of a bewildering number of appalling misfeatures.  I have never
even tried to figure out exactly how DOS fails to implement
wildcards correctly.  (Obviously whoever implemented them didn't
really know what they were good for, and was limiting himself to
assembly language programming on a spineless processor, where a
correct implementation might have been somewhat more difficult.)

In classic regular expressions, and in every computer system I
have ever used (needless to say this includes Unix), a pattern
can certainly continue past a '*'; the utility of doing so would
only be mysterious to someone with the misfortune to have first
encountered wildcards under a "system" with as trivialized and
impotent an implementation as our beloved DOS.

>The following function will return the same results, with the exceptional
>case being when the '*' character is not the last character in the
>wildcard string.

Please, don't _ever_ implement a wildcard matcher with this
"exception."  It is not an "exceptional case" for the '*' not
to be the last character in the pattern; it is an absolute
requirement, and to leave it out should never have been
contemplated.

                                            Steve Summit
                                            scs at adam.mit.edu



More information about the Comp.lang.c mailing list