xref: /freebsd/contrib/less/pattern.h (revision 95270f73baf6fa95ae529bc2eb6a61f5c79f32c0)
1f0be0a1fSXin LI /*
2*95270f73SXin LI  * Copyright (C) 1984-2022  Mark Nudelman
3f0be0a1fSXin LI  *
4f0be0a1fSXin LI  * You may distribute under the terms of either the GNU General Public
5f0be0a1fSXin LI  * License or the Less License, as specified in the README file.
6f0be0a1fSXin LI  *
796e55cc7SXin LI  * For more information, see the README file.
8f0be0a1fSXin LI  */
9f0be0a1fSXin LI 
1096e55cc7SXin LI #if HAVE_GNU_REGEX
1196e55cc7SXin LI #define __USE_GNU 1
1296e55cc7SXin LI #include <regex.h>
13f6b74a7dSXin LI #define PATTERN_TYPE             struct re_pattern_buffer *
142235c7feSXin LI #define SET_NULL_PATTERN(name)   name = NULL
1596e55cc7SXin LI #endif
1696e55cc7SXin LI 
17*95270f73SXin LI /* ---- POSIX ---- */
18f0be0a1fSXin LI #if HAVE_POSIX_REGCOMP
19f0be0a1fSXin LI #include <regex.h>
20f0be0a1fSXin LI #ifdef REG_EXTENDED
21f0be0a1fSXin LI extern int less_is_more;
22f0be0a1fSXin LI #define REGCOMP_FLAG    (less_is_more ? 0 : REG_EXTENDED)
23f0be0a1fSXin LI #else
24f0be0a1fSXin LI #define REGCOMP_FLAG             0
25f0be0a1fSXin LI #endif
26f6b74a7dSXin LI #define PATTERN_TYPE             regex_t *
272235c7feSXin LI #define SET_NULL_PATTERN(name)   name = NULL
28*95270f73SXin LI #define re_handles_caseless      TRUE
29f0be0a1fSXin LI #endif
30f0be0a1fSXin LI 
31*95270f73SXin LI /* ---- PCRE ---- */
32f0be0a1fSXin LI #if HAVE_PCRE
33f0be0a1fSXin LI #include <pcre.h>
34f6b74a7dSXin LI #define PATTERN_TYPE             pcre *
352235c7feSXin LI #define SET_NULL_PATTERN(name)   name = NULL
36*95270f73SXin LI #define re_handles_caseless      TRUE
37f0be0a1fSXin LI #endif
38f0be0a1fSXin LI 
39*95270f73SXin LI /* ---- PCRE2 ---- */
40b7780dbeSXin LI #if HAVE_PCRE2
41b7780dbeSXin LI #define PCRE2_CODE_UNIT_WIDTH 8
42b7780dbeSXin LI #include <pcre2.h>
43b7780dbeSXin LI #define PATTERN_TYPE             pcre2_code *
442235c7feSXin LI #define SET_NULL_PATTERN(name)   name = NULL
45*95270f73SXin LI #define re_handles_caseless      TRUE
46b7780dbeSXin LI #endif
47b7780dbeSXin LI 
48*95270f73SXin LI /* ---- RE_COMP  ---- */
49f0be0a1fSXin LI #if HAVE_RE_COMP
50b2ea2440SXin LI char *re_comp LESSPARAMS ((char*));
51b2ea2440SXin LI int re_exec LESSPARAMS ((char*));
52f6b74a7dSXin LI #define PATTERN_TYPE             int
532235c7feSXin LI #define SET_NULL_PATTERN(name)   name = 0
54f0be0a1fSXin LI #endif
55f0be0a1fSXin LI 
56*95270f73SXin LI /* ---- REGCMP  ---- */
57f0be0a1fSXin LI #if HAVE_REGCMP
58b2ea2440SXin LI char *regcmp LESSPARAMS ((char*));
59b2ea2440SXin LI char *regex LESSPARAMS ((char**, char*));
60f0be0a1fSXin LI extern char *__loc1;
61f6b74a7dSXin LI #define PATTERN_TYPE             char **
622235c7feSXin LI #define SET_NULL_PATTERN(name)   name = NULL
63f0be0a1fSXin LI #endif
64f0be0a1fSXin LI 
65*95270f73SXin LI /* ---- REGCOMP  ---- */
66f0be0a1fSXin LI #if HAVE_V8_REGCOMP
67f0be0a1fSXin LI #include "regexp.h"
68a15691bfSXin LI extern int reg_show_error;
69f6b74a7dSXin LI #define PATTERN_TYPE             struct regexp *
702235c7feSXin LI #define SET_NULL_PATTERN(name)   name = NULL
71f0be0a1fSXin LI #endif
72f0be0a1fSXin LI 
73*95270f73SXin LI /* ---- NONE  ---- */
7496e55cc7SXin LI #if NO_REGEX
75f6b74a7dSXin LI #define PATTERN_TYPE             void *
762235c7feSXin LI #define SET_NULL_PATTERN(name)
7796e55cc7SXin LI #endif
78*95270f73SXin LI 
79*95270f73SXin LI #ifndef re_handles_caseless
80*95270f73SXin LI #define re_handles_caseless      FALSE
81*95270f73SXin LI #endif
82