Skip to content

Commit

Permalink
add configure option --enable-binary-compatible-posix-api
Browse files Browse the repository at this point in the history
  • Loading branch information
kkos committed Sep 30, 2020
1 parent f7ca475 commit 2f03e14
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ case "${enableval}" in
*) AC_MSG_ERROR(bad value for --enable-posix-api) ;;
esac],
enable_posix_api=no)

dnl check for Binary compatible POSIX API
AC_ARG_ENABLE([binary-compatible-posix-api],
[AS_HELP_STRING([--enable-binary-compatible-posix-api],
[turn on to Binary compatible POSIX API [default=no]])],
[\
case "${enableval}" in
yes) enable_binary_compatible_posix_api=yes; enable_posix_api=yes ;;
no) enable_binary_compatible_posix_api=no ;;
*) AC_MSG_ERROR(bad value for --enable-binary-compatible-posix-api) ;;
esac],
enable_binary_compatible_posix_api=no)

AM_CONDITIONAL(ENABLE_BINARY_COMPATIBLE_POSIX_API, test x"${enable_binary_compatible_posix_api}" = xyes)
AM_CONDITIONAL(ENABLE_POSIX_API, test x"${enable_posix_api}" = xyes)


Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ else
posix_sources =
endif

if ENABLE_BINARY_COMPATIBLE_POSIX_API
AM_CFLAGS += -DUSE_BINARY_COMPATIBLE_POSIX_API
endif


lib_LTLIBRARIES = $(libname)

Expand Down
11 changes: 11 additions & 0 deletions src/regposerr.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,14 @@ onig_posix_regerror(int posix_ecode, const onig_posix_regex_t* reg ARG_UNUSED,
}
return len;
}

#ifdef USE_BINARY_COMPATIBLE_POSIX_API

extern size_t
regerror(int posix_ecode, const onig_posix_regex_t* reg ARG_UNUSED,
char* buf, size_t size)
{
return onig_posix_regerror(posix_ecode, reg, buf, size);
}

#endif
45 changes: 45 additions & 0 deletions src/regposix.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,48 @@ onig_posix_reg_number_of_names(onig_posix_regex_t* reg)
{
return onig_number_of_names(ONIG_C(reg));
}


#ifdef USE_BINARY_COMPATIBLE_POSIX_API

extern int
regcomp(onig_posix_regex_t* reg, const char* pattern, int posix_options)
{
return onig_posix_regcomp(reg, pattern, posix_options);
}

extern int
regexec(onig_posix_regex_t* reg, const char* str, size_t nmatch,
regmatch_t pmatch[], int posix_options)
{
return onig_posix_regexec(reg, str, nmatch, pmatch, posix_options);
}

extern void
regfree(onig_posix_regex_t* reg)
{
onig_posix_regfree(reg);
}

extern void
reg_set_encoding(int mb_code)
{
onig_posix_reg_set_encoding(mb_code);
}

extern int
reg_name_to_group_numbers(onig_posix_regex_t* reg,
const unsigned char* name, const unsigned char* name_end, int** nums)
{
return onig_posix_reg_name_to_group_numbers(reg, name, name_end, nums);
}

extern int
reg_foreach_name(onig_posix_regex_t* reg,
int (*func)(const unsigned char*, const unsigned char*,int,int*,onig_posix_regex_t*,void*),
void* arg)
{
return onig_posix_reg_foreach_name(reg, func, arg);
}

#endif

0 comments on commit 2f03e14

Please sign in to comment.