Skip to content

3.0.0

Latest

Choose a tag to compare

@ponylang-main ponylang-main released this 03 Dec 18:31
· 4 commits to main since this release

Stop matching names and paths that are not valid UTF-8

Glob.fnmatch, Glob.fnmatchcase, Glob.filter, Glob.glob, and Glob.iglob no longer match a name that is not valid UTF-8. Glob.glob and Glob.iglob match the path of each file relative to the root, or the full path when the pattern is absolute. So they also skip every file in a directory below the root whose name is not valid UTF-8. Previously, on platforms other than Windows, such a name could match some patterns and not others. For example, the name a\xFFc matched a*c but did not match a?c. Now it matches neither.

let name = String.from_array([as U8: 'a'; 0xFF; 'c'])

// Before
Glob.fnmatchcase(name, "a*c") // true

// After
Glob.fnmatchcase(name, "a*c") // false

Update ponylang/regex dependency to 3.0.0

glob now uses ponylang/regex 3.0.0. ponylang/regex 3.0.0 changes its API. If your program also uses ponylang/regex directly, update it to 3.0.0. See the ponylang/regex 3.0.0 release for its changes.

glob now requires PCRE2 10.35 or later.

Fix ] right after [! closing a bracket expression

In a pattern, a ] right after [! now belongs to the bracket expression, as a ] right after [ already did. Before, that ] closed the bracket expression, so the pattern matched the wrong names, and often matched none at all. For example, Glob.fnmatchcase("a", "[!]]") and Glob.fnmatchcase(")", "[!]x[ab]") were false and are now true. A [!] with no closing ] now matches the literal text [!].

Fix patterns with non-ASCII characters never matching

A pattern that contained a non-ASCII character outside a [...] bracket expression never matched anything. For example, Glob.fnmatchcase("café", "café") was false, and Glob.glob found nothing for the pattern café even when a file with that name existed. A non-ASCII character in a pattern now matches the same character in a name.

Fix how patterns match names that contain a newline

** did not match a newline, and a name with one extra newline at the end matched a pattern without it. Now ** matches a newline like any other character, and a pattern must match the whole name. Glob.fnmatchcase("a\nb", "**") was false and is now true. Glob.glob with the pattern ** now finds a file whose name contains a newline. Glob.fnmatchcase("abc\n", "abc") was true and is now false.

Reduce memory use of fnmatch, fnmatchcase, filter, glob, and iglob

Glob.fnmatch, Glob.fnmatchcase, Glob.filter, Glob.glob, and Glob.iglob now free their regular expression memory as soon as they are done with it. Before, each call kept its compiled pattern in memory, and filter, glob, and iglob also kept the data for each matching name, until garbage collection collected it. Garbage collection can run only after the calling behavior ends, so this memory grew with the number of calls and matches in one behavior. In one measurement, 100,000 calls to Glob.fnmatchcase in one behavior reached a peak of about 185 MiB before and about 63 MiB now. One call to Glob.filter with 1,000,000 names that all match the pattern reached about 913 MiB before and about 715 MiB now.

Fix bracket expressions that contain POSIX class syntax or a reversed range

Some bracket expressions matched nothing or matched the wrong names. Text such as [:alpha:] inside a set was read as a POSIX character class. So Glob.fnmatchcase("a]", "[[:alpha:]]") was false and is now true, and Glob.fnmatchcase("Z", "[[:alpha:]x[ab]") was true and is now false. A range whose start comes after its end, such as z-a, made the whole pattern match nothing, so Glob.fnmatchcase("a", "[!z-a]") was false and is now true. Every character in a set is now literal except a range, and a range whose start comes after its end matches nothing.

Speed up fnmatch and fnmatchcase

Glob.fnmatch and Glob.fnmatchcase are now several times faster. Each call compiles its pattern and matches one name with it. Before, each call also JIT-compiled the pattern, and the JIT compile took more time than the single match saved. In one measurement, 100,000 calls to Glob.fnmatchcase took about 2.0 seconds before and about 0.3 seconds now.

Speed up filter for short lists of names

Glob.filter is now faster when it gets fewer than 50 names. Before, filter always JIT-compiled its pattern. A JIT compile takes more time than it saves when the pattern runs against only a few names. Now filter uses JIT only for 50 names or more. In one measurement, filtering lists of 10 names, 100,000 names in total, took about 200 milliseconds before and about 70 milliseconds now.

Require ponyc 0.78.0 or later

You now need ponyc 0.78.0 or later to use glob.

[3.0.0] - 2026-12-03

Fixed

  • Fix ] right after [! closing a bracket expression (PR #92)
  • Fix patterns with non-ASCII characters never matching (PR #94)
  • Fix how patterns match names that contain a newline (PR #95)
  • Reduce memory use of fnmatch, fnmatchcase, filter, glob, and iglob (PR #96)
  • Fix bracket expressions that contain POSIX class syntax or a reversed range (PR #98)
  • Speed up fnmatch and fnmatchcase (PR #99)
  • Speed up filter for short lists of names (PR #101)

Changed

  • Stop matching names and paths that are not valid UTF-8 (PR #90)
  • Update ponylang/regex dependency to 3.0.0 (PR #90)
  • Require ponyc 0.78.0 or later (PR #102)