| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef LIBREGEXP_H |
| 25 |
#define LIBREGEXP_H |
| 26 |
|
| 27 |
#include <stddef.h> |
| 28 |
|
| 29 |
#include "libunicode.h" |
| 30 |
|
| 31 |
#define LRE_BOOL int |
| 32 |
|
| 33 |
#define LRE_FLAG_GLOBAL (1 << 0) |
| 34 |
#define LRE_FLAG_IGNORECASE (1 << 1) |
| 35 |
#define LRE_FLAG_MULTILINE (1 << 2) |
| 36 |
#define LRE_FLAG_DOTALL (1 << 3) |
| 37 |
#define LRE_FLAG_UTF16 (1 << 4) |
| 38 |
#define LRE_FLAG_STICKY (1 << 5) |
| 39 |
#define LRE_FLAG_INDICES (1 << 6) |
| 40 |
|
| 41 |
#define LRE_FLAG_NAMED_GROUPS (1 << 7) |
| 42 |
|
| 43 |
uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size, |
| 44 |
const char *buf, size_t buf_len, int re_flags, |
| 45 |
void *opaque); |
| 46 |
int lre_get_capture_count(const uint8_t *bc_buf); |
| 47 |
int lre_get_flags(const uint8_t *bc_buf); |
| 48 |
const char *lre_get_groupnames(const uint8_t *bc_buf); |
| 49 |
int lre_exec(uint8_t **capture, |
| 50 |
const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen, |
| 51 |
int cbuf_type, void *opaque); |
| 52 |
|
| 53 |
int lre_parse_escape(const uint8_t **pp, int allow_utf16); |
| 54 |
LRE_BOOL lre_is_space(int c); |
| 55 |
|
| 56 |
|
| 57 |
LRE_BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size); |
| 58 |
void *lre_realloc(void *opaque, void *ptr, size_t size); |
| 59 |
|
| 60 |
|
| 61 |
extern uint32_t const lre_id_start_table_ascii[4]; |
| 62 |
extern uint32_t const lre_id_continue_table_ascii[4]; |
| 63 |
|
| 64 |
static inline int lre_js_is_ident_first(int c) |
| 65 |
{ |
| 66 |
if ((uint32_t)c < 128) { |
| 67 |
return (lre_id_start_table_ascii[c >> 5] >> (c & 31)) & 1; |
| 68 |
} else { |
| 69 |
#ifdef CONFIG_ALL_UNICODE |
| 70 |
return lre_is_id_start(c); |
| 71 |
#else |
| 72 |
return !lre_is_space(c); |
| 73 |
#endif |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
static inline int lre_js_is_ident_next(int c) |
| 78 |
{ |
| 79 |
if ((uint32_t)c < 128) { |
| 80 |
return (lre_id_continue_table_ascii[c >> 5] >> (c & 31)) & 1; |
| 81 |
} else { |
| 82 |
|
| 83 |
#ifdef CONFIG_ALL_UNICODE |
| 84 |
return lre_is_id_continue(c) || c == 0x200C || c == 0x200D; |
| 85 |
#else |
| 86 |
return !lre_is_space(c) || c == 0x200C || c == 0x200D; |
| 87 |
#endif |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
#undef LRE_BOOL |
| 92 |
|
| 93 |
#endif |