Ver Fonte

fix: implement non_bmp_regex handling

Sam Jaffe há 3 meses atrás
pai
commit
b5bf3254af
2 ficheiros alterados com 4 adições e 3 exclusões
  1. 1 1
      Makefile
  2. 3 2
      include/jvalidate/detail/string.h

+ 1 - 1
Makefile

@@ -26,7 +26,7 @@ TEST_OBJECTS := $(patsubst %.cxx, .build/%.o, $(TEST_SOURCES))
 TEST_BINARIES := .build/bin/selfvalidate .build/bin/annotation_test
 EXECUTE_TESTS := $(patsubst %, %.done, $(TEST_BINARIES))
 
-EXCLUDED_TESTS := format* content ecmascript_regex zeroTerminatedFloats non_bmp_regex
+EXCLUDED_TESTS := format* content ecmascript_regex zeroTerminatedFloats
 EXCLUDED_TESTS := $(shell printf ":*optional_%s" $(EXCLUDED_TESTS) | cut -c2-)
 
 all: run-test

+ 3 - 2
include/jvalidate/detail/string.h

@@ -9,6 +9,7 @@
 #include <unicode/brkiter.h>
 #include <unicode/unistr.h>
 #endif
+#include <iostream>
 
 namespace jvalidate::detail {
 /**
@@ -74,12 +75,12 @@ inline std::string regex_escape(std::string_view arg) {
     // This could be optimized to only operate when on a multibyte character
     if (std::strchr("?*+", ucs.charAt(end))) {
       rval.append('(');
-      rval.append(ucs, start, end - 1);
+      rval.append(ucs, start, end - start);
       rval.append(')');
       rval.append(ucs.char32At(end));
       end = iter->next();
     } else {
-      rval.append(ucs, start, end - 1);
+      rval.append(ucs, start, end - start);
     }
     start = end;
     end = iter->next();