Bläddra i källkod

LibRegex: Don't build LibRegex/C/Regex.cpp on Lagom

This file implements the POSIX APIs from <regex.h>, and is not suitable
for inclusion in a Lagom build. If we do include it, it will override
the host's regex functions and wreak havoc if it's resolved before the
host's implementation.
Andrew Kaster 2 år sedan
förälder
incheckning
896d4e8dc1
2 ändrade filer med 5 tillägg och 8 borttagningar
  1. 1 2
      Meta/Lagom/CMakeLists.txt
  2. 4 6
      Userland/Libraries/LibRegex/C/Regex.cpp

+ 1 - 2
Meta/Lagom/CMakeLists.txt

@@ -482,10 +482,9 @@ if (BUILD_LAGOM)
     )
 
     # Regex
-    file(GLOB LIBREGEX_LIBC_SOURCES "../../Userland/Libraries/LibRegex/C/Regex.cpp")
     file(GLOB LIBREGEX_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibRegex/*.cpp")
     lagom_lib(Regex regex
-        SOURCES ${LIBREGEX_SOURCES} ${LIBREGEX_LIBC_SOURCES}
+        SOURCES ${LIBREGEX_SOURCES}
         LIBS LibUnicode
     )
 

+ 4 - 6
Userland/Libraries/LibRegex/C/Regex.cpp

@@ -6,19 +6,17 @@
 
 #include <AK/String.h>
 #include <AK/StringBuilder.h>
+#include <AK/Variant.h>
 #include <LibRegex/Regex.h>
 #include <ctype.h>
+#include <regex.h>
 #include <stdio.h>
 #include <string.h>
 
-#ifdef __serenity__
-#    include <regex.h>
-#else
-#    include <LibC/regex.h>
+#ifndef AK_OS_SERENITY
+#    error "This file is intended for use on Serenity only to implement POSIX regex.h"
 #endif
 
-#include <AK/Variant.h>
-
 struct internal_regex_t {
     u8 cflags;
     u8 eflags;