xref: /freebsd/contrib/less/pattern.h (revision c77c488926555ca344ae3a417544cf7a720e1de1)
1f0be0a1fSXin LI /*
2*c77c4889SXin LI  * Copyright (C) 1984-2024  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 
1795270f73SXin 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
2895270f73SXin LI #define re_handles_caseless      TRUE
29f0be0a1fSXin LI #endif
30f0be0a1fSXin LI 
3195270f73SXin 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
3695270f73SXin LI #define re_handles_caseless      TRUE
37f0be0a1fSXin LI #endif
38f0be0a1fSXin LI 
3995270f73SXin 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
4595270f73SXin LI #define re_handles_caseless      TRUE
46b7780dbeSXin LI #endif
47b7780dbeSXin LI 
4895270f73SXin LI /* ---- RE_COMP  ---- */
49f0be0a1fSXin LI #if HAVE_RE_COMP
50*c77c4889SXin LI constant char *re_comp(constant char*);
51*c77c4889SXin LI int re_exec(constant char*);
52f6b74a7dSXin LI #define PATTERN_TYPE             int
532235c7feSXin LI #define SET_NULL_PATTERN(name)   name = 0
54f0be0a1fSXin LI #endif
55f0be0a1fSXin LI 
5695270f73SXin LI /* ---- REGCMP  ---- */
57f0be0a1fSXin LI #if HAVE_REGCMP
58d713e089SXin LI char *regcmp(char*);
59d713e089SXin LI char *regex(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 
6595270f73SXin 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 
7395270f73SXin LI /* ---- NONE  ---- */
7496e55cc7SXin LI #if NO_REGEX
75f6b74a7dSXin LI #define PATTERN_TYPE             void *
762235c7feSXin LI #define SET_NULL_PATTERN(name)
7796e55cc7SXin LI #endif
7895270f73SXin LI 
7995270f73SXin LI #ifndef re_handles_caseless
8095270f73SXin LI #define re_handles_caseless      FALSE
8195270f73SXin LI #endif
82