summaryrefslogtreecommitdiff
path: root/libregexp.c
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-05-05 17:47:40 +0200
committerGitHub <noreply@github.com>2024-05-05 17:47:40 +0200
commit7a2c6f42d49e7a4003384cf54b187f16e64e47a1 (patch)
tree8cc7181520e92dd0ced15e7c3ad0c86dbab3fa94 /libregexp.c
parent1402478d8d280a1a62dfb76327dd569d6307a025 (diff)
downloadquickjs-7a2c6f42d49e7a4003384cf54b187f16e64e47a1.tar.gz
quickjs-7a2c6f42d49e7a4003384cf54b187f16e64e47a1.zip
Improve libunicode and libregexp headers (#288)
- move all `lre_xxx` functions to libunicode - use flags table `lre_ctype_bits` instead of bitmaps - simplify `lre_is_space`, `lre_js_is_ident_first` and `lre_js_is_ident_next` - simplify `simple_next_token`, handle UTF-8 correctly - simplify `is_let`, remove dead code
Diffstat (limited to 'libregexp.c')
-rw-r--r--libregexp.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/libregexp.c b/libregexp.c
index d73a19f..1091506 100644
--- a/libregexp.c
+++ b/libregexp.c
@@ -30,6 +30,7 @@
#include "cutils.h"
#include "libregexp.h"
+#include "libunicode.h"
/*
TODO:
@@ -141,32 +142,6 @@ static const uint16_t char_range_s[] = {
0xFEFF, 0xFEFF + 1,
};
-BOOL lre_is_space(int c)
-{
- int i, n, low, high;
- n = (countof(char_range_s) - 1) / 2;
- for(i = 0; i < n; i++) {
- low = char_range_s[2 * i + 1];
- if (c < low)
- return FALSE;
- high = char_range_s[2 * i + 2];
- if (c < high)
- return TRUE;
- }
- return FALSE;
-}
-
-uint32_t const lre_id_start_table_ascii[4] = {
- /* $ A-Z _ a-z */
- 0x00000000, 0x00000010, 0x87FFFFFE, 0x07FFFFFE
-};
-
-uint32_t const lre_id_continue_table_ascii[4] = {
- /* $ 0-9 A-Z _ a-z */
- 0x00000000, 0x03FF0010, 0x87FFFFFE, 0x07FFFFFE
-};
-
-
static const uint16_t char_range_w[] = {
4,
0x0030, 0x0039 + 1,
@@ -186,7 +161,7 @@ typedef enum {
CHAR_RANGE_W,
} CharRangeEnum;
-static const uint16_t *char_range_table[] = {
+static const uint16_t * const char_range_table[] = {
char_range_d,
char_range_s,
char_range_w,