Cygwin: regex: fix type and use macro to define equivalence class marking
authorCorinna Vinschen <corinna@vinschen.de>
Thu, 9 Mar 2023 10:06:44 +0000 (11:06 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 14 Mar 2023 20:26:22 +0000 (21:26 +0100)
tre_ctype_t needs to be able to keep the equivalence marking bit.
Define the bit as macro.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/regex/regcomp.c
winsup/cygwin/regex/regexec.c
winsup/cygwin/regex/tre.h

index 2c75a43c19b3b7213dabe3a1f72af648c8b8374c..46b09af43ed940007cfd787ce41319bd85b5e19d 100644 (file)
@@ -609,7 +609,7 @@ static reg_errcode_t parse_bracket_terms(tre_parse_ctx_t *ctx, const char *s, st
                } else if (equiv && neg->negate) {
                        if (neg->len >= MAX_NEG_CLASSES)
                                return REG_ESPACE;
-                       neg->a[neg->len++] = equiv | 0x80000000;
+                       neg->a[neg->len++] = equiv | ASSERT_EQUIV_MATCH;
                } else  {
                        tre_literal_t *lit = tre_new_lit(ls);
                        if (!lit)
index 65ad36c503d95bd52b6673975866f025535b8dd9..496a4ba31202df24e2061d888902fa98b8463057 100644 (file)
@@ -124,8 +124,8 @@ static int
 tre_neg_char_classes_match(tre_ctype_t *classes, tre_cint_t wc, int icase)
 {
   while (*classes != (tre_ctype_t)0) {
-    if (*classes & 0x80000000) {
-      if (is_unicode_equiv(*classes & ~0x80000000, wc))
+    if (*classes & ASSERT_EQUIV_MATCH) {
+      if (is_unicode_equiv(*classes & ~(ASSERT_EQUIV_MATCH), wc))
        return 1;
     } else if ((!icase && tre_isctype(wc, *classes))
        || (icase && (tre_isctype(tre_toupper(wc), *classes)
index 9ffcd5efecbcbbace16a681610b871d59c4ea939..9a2fcb4978b67fb3c001a198456ec097938e6e76 100644 (file)
@@ -71,7 +71,7 @@ typedef wint_t tre_cint_t;
 #define tre_strlen  wcslen
 
 /* Use system provided iswctype() and wctype(). */
-typedef wctype_t tre_ctype_t;
+typedef wint_t tre_ctype_t;    /* wint_t required by equivalence class */
 #define tre_isctype iswctype
 #define tre_ctype   wctype
 
@@ -130,6 +130,9 @@ struct tnfa_transition {
 #define ASSERT_EQUIV_CLASS     512   /* Equivalence class in `equiv'. */
 #define ASSERT_LAST            512
 
+#define ASSERT_EQUIV_MATCH 0x80000000 /* For marking equivalence class in
+                                        `neg_classes' */
+
 /* Tag directions. */
 typedef enum {
   TRE_TAG_MINIMIZE = 0,
This page took 0.080841 seconds and 5 git commands to generate.