Skip to content

Commit cafa6f5

Browse files
authored
refactor: make the use of NGX_PCRE2 clearer.
1 parent ff7c65b commit cafa6f5

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

src/ngx_stream_lua_common.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,19 @@
3535
#include "ngx_stream_lua_request.h"
3636

3737

38-
#if defined(NGX_PCRE) && !defined(NGX_PCRE2)
38+
#if (NGX_PCRE)
39+
# if (NGX_PCRE2)
40+
# define LUA_HAVE_PCRE_JIT 1
41+
# else
3942

4043
#include <pcre.h>
4144

42-
#if (PCRE_MAJOR > 8) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21)
43-
# define LUA_HAVE_PCRE_JIT 1
44-
#else
45-
# define LUA_HAVE_PCRE_JIT 0
46-
#endif
47-
48-
#endif
49-
50-
#if (NGX_PCRE2)
51-
# define LUA_HAVE_PCRE_JIT 1
45+
# if (PCRE_MAJOR > 8) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21)
46+
# define LUA_HAVE_PCRE_JIT 1
47+
# else
48+
# define LUA_HAVE_PCRE_JIT 0
49+
# endif
50+
# endif
5251
#endif
5352

5453

@@ -193,16 +192,18 @@ struct ngx_stream_lua_main_conf_s {
193192

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

196-
#if (NGX_PCRE || NGX_PCRE2)
195+
#if (NGX_PCRE)
197196
ngx_int_t regex_cache_entries;
198197
ngx_int_t regex_cache_max_entries;
199198
ngx_int_t regex_match_limit;
199+
#endif
200200

201+
#if (LUA_HAVE_PCRE_JIT)
201202
#if (NGX_PCRE2)
202203
pcre2_jit_stack *jit_stack;
203-
#elif (LUA_HAVE_PCRE_JIT)
204+
#else
204205
pcre_jit_stack *jit_stack;
205-
# endif
206+
#endif
206207
#endif
207208

208209
ngx_array_t *shm_zones; /* of ngx_shm_zone_t* */

src/ngx_stream_lua_pcrefix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "ngx_stream_lua_pcrefix.h"
2323
#include "stdio.h"
2424

25-
#if (NGX_PCRE || NGX_PCRE2)
25+
#if (NGX_PCRE)
2626

2727
static ngx_pool_t *ngx_stream_lua_pcre_pool = NULL;
2828

@@ -190,6 +190,6 @@ ngx_stream_lua_pcre_malloc_done(ngx_pool_t *old_pool)
190190
}
191191

192192
#endif
193-
#endif /* NGX_PCRE || NGX_PCRE2 */
193+
#endif /* NGX_PCRE */
194194

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

src/ngx_stream_lua_pcrefix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
#include "ngx_stream_lua_common.h"
2121

2222

23-
#if (NGX_PCRE || NGX_PCRE2)
23+
#if (NGX_PCRE)
2424
ngx_pool_t *ngx_stream_lua_pcre_malloc_init(ngx_pool_t *pool);
2525
void ngx_stream_lua_pcre_malloc_done(ngx_pool_t *old_pool);
2626

27-
#if NGX_PCRE2
27+
#if (NGX_PCRE2)
2828
void *ngx_stream_lua_pcre_malloc(size_t size, void *data);
2929
void ngx_stream_lua_pcre_free(void *ptr, void *data);
3030
#endif

src/ngx_stream_lua_regex.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "ddebug.h"
1919

2020

21-
#if (NGX_PCRE || NGX_PCRE2)
21+
#if (NGX_PCRE)
2222

2323
#include "ngx_stream_lua_pcrefix.h"
2424
#include "ngx_stream_lua_script.h"
@@ -338,7 +338,7 @@ ngx_int_t
338338
ngx_stream_lua_ffi_set_jit_stack_size(int size, u_char *errstr,
339339
size_t *errstr_size)
340340
{
341-
#if (NGX_PCRE2 || LUA_HAVE_PCRE_JIT)
341+
#if (LUA_HAVE_PCRE_JIT)
342342

343343
ngx_stream_lua_main_conf_t *lmcf;
344344
ngx_pool_t *pool, *old_pool;
@@ -982,7 +982,7 @@ ngx_stream_lua_ffi_pcre_version(void)
982982
}
983983

984984

985-
#endif /* NGX_PCRE || NGX_PCRE2 */
985+
#endif /* NGX_PCRE */
986986

987987

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

0 commit comments

Comments
 (0)