[Bug] I see ghosts: std.string.inPattern

Andrew Edwards via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 5 17:05:38 PDT 2016


I encountered the following bug in std.string.inPattern:

         import std.stdio;

         void main()
         {
             foreach (c; ' ' .. '~')
                 writeln(inPattern(c, " -~"));
         }

Which is caused by this:

         else if (range)
         {
             range = 0;
             if (lastc <= c && c <= p || c == p)
                 return !result;
         }
         else if (p == '-' && i > result && i + 1 < pattern.length)
         {
             range = 1;
             continue;
         }

Before submitting the bug report and what I believe to be the fix 
(simply deleting these lines from the implementation), I would 
like to seek clarification on what exactly is being attempted 
here. Why is would we conclude that arbitrary range of characters 
were located after encountering an embedded '-' in any pattern 
that's at least 3 characters long and pattern[0] < 
pattern[indexOf['-'] + 1]?

Andrew


More information about the Digitalmars-d mailing list