WildcardMatch broken #248

issue mikegogulski opened this issue on May 21, 2011
  1. mikegogulski commented at 1:47 AM on May 21, 2011: none

    Failing sometimes:

    bool WildcardMatch(const char* psz, const char* mask)
    {
        loop
        {
            switch (*mask)
            {
            case '\0':
                return (*psz == '\0');
            case '*':
                return WildcardMatch(psz, mask+1) || (*psz && WildcardMatch(psz+1, mask));
            case '?':
                if (*psz == '\0')
                    return false;
                break;
            default:
                if (*psz != *mask)
                    return false;
                break;
            }
            psz++;
            mask++;
        }
    }
    

    Working always:

    bool WildcardMatch(const char* psz, const char* mask) {
            loop {
                    if (*mask == '\0') return (*psz == '\0');
                    else if (*mask == '*') return WildcardMatch(psz, mask+1) || (*psz && WildcardMatch(psz+1, mask));
                    else if (*mask == '?') if (*psz == '\0') return 0;
                    else if (*psz != *mask) return 0;
                    psz++;
                    mask++;
            }
    }
    
  2. sipa commented at 1:54 PM on May 21, 2011: member

    What's the difference?

  3. TheBlueMatt commented at 11:03 AM on May 26, 2011: member

    Do you have a reliable test-case for this, something that always fails on the first and never on the last?

  4. gavinandresen commented at 6:33 PM on June 7, 2011: contributor

    Yes, test case(s) please?

  5. mikegogulski commented at 6:41 PM on November 18, 2011: none

    Whatever this was, was my fault. I think.

  6. mikegogulski closed this on Nov 18, 2011

  7. destenson referenced this in commit 42f33a4d07 on Nov 18, 2017
  8. nining referenced this in commit e0b531ed71 on Jan 3, 2018
  9. attilaaf referenced this in commit 12d88a67c4 on Jan 13, 2020
  10. Losangelosgenetics referenced this in commit 8cecc3c1f2 on Mar 12, 2020
  11. cryptapus referenced this in commit a45472b8d4 on May 3, 2021
  12. rajarshimaitra referenced this in commit 35a12ac798 on Aug 5, 2021
  13. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-20 03:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me