Skip to content

Commit

Permalink
fixup! less ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
niol committed Sep 1, 2023
1 parent c66d485 commit 0dabeee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions core/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,23 @@ int uwsgi_regexp_match_ovec(uwsgi_pcre *pattern, const char *subject, int length

match_data = pcre2_match_data_create_from_pattern(pattern, NULL);
rc = pcre2_match(pattern, (const unsigned char *)subject, length, 0, 0, match_data, NULL);
#endif

/*
* Quoting PCRE{,2} spec, "The first pair of integers, ovector[0]
* and ovector[1], identify the portion of the subject string matched
* by the entire pattern. The next pair is used for the first capturing
* subpattern, and so on." Therefore, the ovector size is the number of
* capturing subpatterns (INFO_CAPTURECOUNT), from uwsgi_regexp_ovector(),
* as matching pairs, plus room for the first pair.
*/
/*
* Quoting PCRE{,2} spec, "The first pair of integers, ovector[0]
* and ovector[1], identify the portion of the subject string matched
* by the entire pattern. The next pair is used for the first capturing
* subpattern, and so on." Therefore, the ovector size is the number of
* capturing subpatterns (INFO_CAPTURECOUNT), from uwsgi_regexp_ovector(),
* as matching pairs, plus room for the first pair.
*/
if (n > 0) {
#ifdef UWSGI_PCRE2
// copy pcre2 output vector to uwsgi output vector
pcre2_ovec = pcre2_get_ovector_pointer(match_data);
for (i=0;i<(n+1)*2;i++) {
ovec[i] = pcre2_ovec[i];
}
#else
if (n > 0) {
return pcre_exec((const pcre *) pattern->p, (const pcre_extra *) pattern->extra, subject, length, 0, 0, ovec, PCRE_OVECTOR_BYTESIZE(n));
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion uwsgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ struct uwsgi_hook {
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
struct uwsgi_regexp_list {

uwsgi_pcre *pattern;
uwsgi_pcre *pattern;

uint64_t custom;
char *custom_str;
Expand Down

0 comments on commit 0dabeee

Please sign in to comment.