diff --git a/src/onigposix.h b/src/onigposix.h index b42f568c..3514f80e 100644 --- a/src/onigposix.h +++ b/src/onigposix.h @@ -74,12 +74,12 @@ extern "C" { #define REG_POSIX_ENCODING_UTF16_LE 5 -typedef int regoff_t; +typedef int onig_posix_regoff_t; typedef struct { - regoff_t rm_so; - regoff_t rm_eo; -} regmatch_t; + onig_posix_regoff_t rm_so; + onig_posix_regoff_t rm_eo; +} onig_posix_regmatch_t; /* POSIX regex_t */ typedef struct { @@ -161,7 +161,7 @@ ONIG_EXTERN int onig_end P_((void)); ONIG_EXTERN int onig_posix_regcomp P_((onig_posix_regex_t* reg, const char* pat, int options)); -ONIG_EXTERN int onig_posix_regexec P_((onig_posix_regex_t* reg, const char* str, size_t nmatch, regmatch_t* matches, int options)); +ONIG_EXTERN int onig_posix_regexec P_((onig_posix_regex_t* reg, const char* str, size_t nmatch, onig_posix_regmatch_t* matches, int options)); ONIG_EXTERN void onig_posix_regfree P_((onig_posix_regex_t* reg)); ONIG_EXTERN size_t onig_posix_regerror P_((int code, const onig_posix_regex_t* reg, char* buf, size_t size)); @@ -173,7 +173,9 @@ ONIG_EXTERN int onig_posix_reg_number_of_names P_((onig_posix_regex_t* reg)); /* aliases */ -#define regex_t onig_posix_regex_t +#define regex_t onig_posix_regex_t +#define regmatch_t onig_posix_regmatch_t +#define regoff_t onig_posix_regoff_t #define regcomp onig_posix_regcomp #define regexec onig_posix_regexec diff --git a/src/regposerr.c b/src/regposerr.c index 6ead905a..e5b78992 100644 --- a/src/regposerr.c +++ b/src/regposerr.c @@ -38,6 +38,8 @@ #include "onigposix.h" #undef regex_t +#undef regmatch_t +#undef regoff_t #undef regcomp #undef regexec #undef regfree diff --git a/src/regposix.c b/src/regposix.c index 178618d5..87b28195 100644 --- a/src/regposix.c +++ b/src/regposix.c @@ -34,6 +34,8 @@ #include "onigposix.h" #undef regex_t +#undef regmatch_t +#undef regoff_t #undef regcomp #undef regexec #undef regfree @@ -190,11 +192,11 @@ onig_posix_regcomp(onig_posix_regex_t* reg, const char* pattern, int posix_optio extern int onig_posix_regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch, - regmatch_t pmatch[], int posix_options) + onig_posix_regmatch_t pmatch[], int posix_options) { int r, i, len; UChar* end; - regmatch_t* pm; + onig_posix_regmatch_t* pm; OnigOptionType options; options = ONIG_OPTION_POSIX_REGION; @@ -202,11 +204,11 @@ onig_posix_regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch, if ((posix_options & REG_NOTEOL) != 0) options |= ONIG_OPTION_NOTEOL; if (nmatch == 0 || (reg->comp_options & REG_NOSUB) != 0) { - pm = (regmatch_t* )NULL; + pm = (onig_posix_regmatch_t* )NULL; nmatch = 0; } else if ((int )nmatch < ONIG_C(reg)->num_mem + 1) { - pm = (regmatch_t* )xmalloc(sizeof(regmatch_t) + pm = (onig_posix_regmatch_t* )xmalloc(sizeof(onig_posix_regmatch_t) * (ONIG_C(reg)->num_mem + 1)); if (pm == NULL) return REG_ESPACE; @@ -223,7 +225,7 @@ onig_posix_regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch, if (r >= 0) { r = 0; /* Match */ if (pm != pmatch && pm != NULL) { - xmemcpy(pmatch, pm, sizeof(regmatch_t) * nmatch); + xmemcpy(pmatch, pm, sizeof(onig_posix_regmatch_t) * nmatch); } } else if (r == ONIG_MISMATCH) { @@ -342,7 +344,7 @@ regcomp(onig_posix_regex_t* reg, const char* pattern, int posix_options) extern int regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch, - regmatch_t pmatch[], int posix_options) + onig_posix_regmatch_t pmatch[], int posix_options) { return onig_posix_regexec(reg, str, nmatch, pmatch, posix_options); }