forked from osmocom/wireshark
regex: Remove requirement for ssize_t
The type ssize_t is not available on Windows. Because this is used in the public API we must provide a definition for it. To avoid having to add a header to fix this use a size_t in the API instead, and assign SIZE_MAX to represent a null terminated string.
This commit is contained in:
parent
ff7a5c87e9
commit
fb0e1a4907
|
@ -293,7 +293,7 @@ cmp_matches(const fvalue_t *fv, const ws_regex_t *regex)
|
|||
data = (const char *)tvb_get_ptr(a->tvb, 0, tvb_len);
|
||||
rc = ws_regex_matches(regex, data, tvb_len);
|
||||
} else {
|
||||
rc = ws_regex_matches(regex, a->proto_string, -1);
|
||||
rc = ws_regex_matches(regex, a->proto_string, WS_REGEX_ZERO_TERMINATED);
|
||||
}
|
||||
}
|
||||
CATCH_ALL {
|
||||
|
|
|
@ -152,7 +152,7 @@ cmp_matches(const fvalue_t *fv, const ws_regex_t *regex)
|
|||
if (! regex) {
|
||||
return FALSE;
|
||||
}
|
||||
return ws_regex_matches(regex, str, -1);
|
||||
return ws_regex_matches(regex, str, WS_REGEX_ZERO_TERMINATED);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -83,13 +83,13 @@ ws_regex_compile(const char *patt, char **errmsg)
|
|||
|
||||
|
||||
static bool
|
||||
match_pcre2(pcre2_code *code, const char *subj, ssize_t subj_size)
|
||||
match_pcre2(pcre2_code *code, const char *subj, size_t subj_size)
|
||||
{
|
||||
PCRE2_SIZE length;
|
||||
pcre2_match_data *match_data;
|
||||
int rc;
|
||||
|
||||
length = subj_size < 0 ? PCRE2_ZERO_TERMINATED : (PCRE2_SIZE)subj_size;
|
||||
length = subj_size == WS_REGEX_ZERO_TERMINATED ? PCRE2_ZERO_TERMINATED : (PCRE2_SIZE)subj_size;
|
||||
|
||||
/* We don't use the matched substring but pcre2_match requires
|
||||
* at least one pair of offsets. */
|
||||
|
@ -123,7 +123,7 @@ match_pcre2(pcre2_code *code, const char *subj, ssize_t subj_size)
|
|||
|
||||
|
||||
bool
|
||||
ws_regex_matches(const ws_regex_t *re, const char *subj, ssize_t subj_size)
|
||||
ws_regex_matches(const ws_regex_t *re, const char *subj, size_t subj_size)
|
||||
{
|
||||
ws_return_val_if_null(re, FALSE);
|
||||
ws_return_val_if_null(subj, FALSE);
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include <wireshark.h>
|
||||
|
||||
#define WS_REGEX_ZERO_TERMINATED SIZE_MAX
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -23,7 +25,7 @@ WS_DLL_PUBLIC ws_regex_t *
|
|||
ws_regex_compile(const char *patt, char **errmsg);
|
||||
|
||||
WS_DLL_PUBLIC bool
|
||||
ws_regex_matches(const ws_regex_t *re, const char *subj, ssize_t subj_size);
|
||||
ws_regex_matches(const ws_regex_t *re, const char *subj, size_t subj_size);
|
||||
|
||||
WS_DLL_PUBLIC void
|
||||
ws_regex_free(ws_regex_t *re);
|
||||
|
|
Loading…
Reference in New Issue