Skip to content

Commit

Permalink
refactor: make the use of NGX_PCRE2 clearer.
Browse files Browse the repository at this point in the history
  • Loading branch information
lynch1981 committed Dec 27, 2023
1 parent ff7c65b commit cafa6f5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
29 changes: 15 additions & 14 deletions src/ngx_stream_lua_common.h
Expand Up @@ -35,20 +35,19 @@
#include "ngx_stream_lua_request.h"


#if defined(NGX_PCRE) && !defined(NGX_PCRE2)
#if (NGX_PCRE)
# if (NGX_PCRE2)
# define LUA_HAVE_PCRE_JIT 1
# else

#include <pcre.h>

#if (PCRE_MAJOR > 8) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21)
# define LUA_HAVE_PCRE_JIT 1
#else
# define LUA_HAVE_PCRE_JIT 0
#endif

#endif

#if (NGX_PCRE2)
# define LUA_HAVE_PCRE_JIT 1
# if (PCRE_MAJOR > 8) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21)
# define LUA_HAVE_PCRE_JIT 1
# else
# define LUA_HAVE_PCRE_JIT 0
# endif
# endif
#endif


Expand Down Expand Up @@ -193,16 +192,18 @@ struct ngx_stream_lua_main_conf_s {

ngx_connection_t *watcher; /* for watching the process exit event */

#if (NGX_PCRE || NGX_PCRE2)
#if (NGX_PCRE)
ngx_int_t regex_cache_entries;
ngx_int_t regex_cache_max_entries;
ngx_int_t regex_match_limit;
#endif

#if (LUA_HAVE_PCRE_JIT)
#if (NGX_PCRE2)
pcre2_jit_stack *jit_stack;
#elif (LUA_HAVE_PCRE_JIT)
#else
pcre_jit_stack *jit_stack;
# endif
#endif
#endif

ngx_array_t *shm_zones; /* of ngx_shm_zone_t* */
Expand Down
4 changes: 2 additions & 2 deletions src/ngx_stream_lua_pcrefix.c
Expand Up @@ -22,7 +22,7 @@
#include "ngx_stream_lua_pcrefix.h"
#include "stdio.h"

#if (NGX_PCRE || NGX_PCRE2)
#if (NGX_PCRE)

static ngx_pool_t *ngx_stream_lua_pcre_pool = NULL;

Expand Down Expand Up @@ -190,6 +190,6 @@ ngx_stream_lua_pcre_malloc_done(ngx_pool_t *old_pool)
}

#endif
#endif /* NGX_PCRE || NGX_PCRE2 */
#endif /* NGX_PCRE */

/* vi:set ft=c ts=4 sw=4 et fdm=marker: */
4 changes: 2 additions & 2 deletions src/ngx_stream_lua_pcrefix.h
Expand Up @@ -20,11 +20,11 @@
#include "ngx_stream_lua_common.h"


#if (NGX_PCRE || NGX_PCRE2)
#if (NGX_PCRE)
ngx_pool_t *ngx_stream_lua_pcre_malloc_init(ngx_pool_t *pool);
void ngx_stream_lua_pcre_malloc_done(ngx_pool_t *old_pool);

#if NGX_PCRE2
#if (NGX_PCRE2)
void *ngx_stream_lua_pcre_malloc(size_t size, void *data);
void ngx_stream_lua_pcre_free(void *ptr, void *data);
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/ngx_stream_lua_regex.c
Expand Up @@ -18,7 +18,7 @@
#include "ddebug.h"


#if (NGX_PCRE || NGX_PCRE2)
#if (NGX_PCRE)

#include "ngx_stream_lua_pcrefix.h"
#include "ngx_stream_lua_script.h"
Expand Down Expand Up @@ -338,7 +338,7 @@ ngx_int_t
ngx_stream_lua_ffi_set_jit_stack_size(int size, u_char *errstr,
size_t *errstr_size)
{
#if (NGX_PCRE2 || LUA_HAVE_PCRE_JIT)
#if (LUA_HAVE_PCRE_JIT)

ngx_stream_lua_main_conf_t *lmcf;
ngx_pool_t *pool, *old_pool;
Expand Down Expand Up @@ -982,7 +982,7 @@ ngx_stream_lua_ffi_pcre_version(void)
}


#endif /* NGX_PCRE || NGX_PCRE2 */
#endif /* NGX_PCRE */


/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

0 comments on commit cafa6f5

Please sign in to comment.