diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-14 13:08:21 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-14 13:08:21 +0900 |
| commit | d7c686f6c488739fc9d061bb0f89d73e6445fade (patch) | |
| tree | e3b694c9e96486a13032e63e616a1ed920edd90a /crates/shirabe-php-shim | |
| parent | cfd2a4488797ddaabd0087aa0021b26892663ffb (diff) | |
| download | php-shirabe-d7c686f6c488739fc9d061bb0f89d73e6445fade.tar.gz php-shirabe-d7c686f6c488739fc9d061bb0f89d73e6445fade.tar.zst php-shirabe-d7c686f6c488739fc9d061bb0f89d73e6445fade.zip | |
refactor(pcre): return bool from preg_match shim
preg_match can only return 1 or 0 now that compile failure panics, so
return bool and update all call sites accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim')
| -rw-r--r-- | crates/shirabe-php-shim/src/preg.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs index dc91fd6..510f6ba 100644 --- a/crates/shirabe-php-shim/src/preg.rs +++ b/crates/shirabe-php-shim/src/preg.rs @@ -40,9 +40,9 @@ pub fn preg_quote(str: &str, delimiter: Option<char>) -> String { out } -// Returns 1 on match, 0 on no match; populates matches[0]=full match, matches[1..]=captures. +// Returns whether the pattern matched; populates matches[0]=full match, matches[1..]=captures. // Optional groups that did not participate in the match are stored as None. -pub fn preg_match(pattern: &str, subject: &str, matches: &mut Vec<Option<String>>) -> i64 { +pub fn preg_match(pattern: &str, subject: &str, matches: &mut Vec<Option<String>>) -> bool { let re = compile_php_pattern(pattern).unwrap_or_else(|e| panic!("invalid regex: {e}")); matches.clear(); match re.captures(subject) { @@ -50,9 +50,9 @@ pub fn preg_match(pattern: &str, subject: &str, matches: &mut Vec<Option<String> for g in 0..caps.len() { matches.push(caps.get(g).map(|m| m.as_str().to_string())); } - 1 + true } - None => 0, + None => false, } } |
