<
649dc81
diff -up lldb-3.8.0rc2.src/cmake/modules/LLDBStandalone.cmake.dave lldb-3.8.0rc2.src/cmake/modules/LLDBStandalone.cmake
649dc81
--- lldb-3.8.0rc2.src/cmake/modules/LLDBStandalone.cmake.dave	2015-11-10 13:09:14.000000000 -0500
649dc81
+++ lldb-3.8.0rc2.src/cmake/modules/LLDBStandalone.cmake	2016-02-17 23:19:05.371675721 -0500
649dc81
@@ -6,57 +6,77 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
649dc81
 
649dc81
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
649dc81
 
649dc81
-  set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
649dc81
-    "Path to LLVM source code. Not necessary if using an installed LLVM.")
649dc81
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
649dc81
-    "Path to the directory where LLVM was built or installed.")
649dc81
-
649dc81
-  set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
649dc81
-    "Path to Clang source code. Not necessary if using an installed Clang.")
649dc81
-  set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
649dc81
-    "Path to the directory where Clang was built or installed.")
649dc81
-
649dc81
-  if (LLDB_PATH_TO_LLVM_SOURCE)
649dc81
-    if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
649dc81
-      message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
649dc81
-              "directory of LLVM source code.")
649dc81
+  # Rely on llvm-config.
649dc81
+  set(CONFIG_OUTPUT)
649dc81
+  find_program(LLVM_CONFIG "llvm-config")
649dc81
+  if(LLVM_CONFIG)
649dc81
+    message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
649dc81
+    set(CONFIG_COMMAND ${LLVM_CONFIG}
649dc81
+      "--assertion-mode"
649dc81
+      "--bindir"
649dc81
+      "--libdir"
649dc81
+      "--includedir"
649dc81
+      "--prefix"
649dc81
+      "--src-root")
649dc81
+    execute_process(
649dc81
+      COMMAND ${CONFIG_COMMAND}
649dc81
+      RESULT_VARIABLE HAD_ERROR
649dc81
+      OUTPUT_VARIABLE CONFIG_OUTPUT
649dc81
+    )
649dc81
+    if(NOT HAD_ERROR)
649dc81
+      string(REGEX REPLACE
649dc81
+        "[ \t]*[\r\n]+[ \t]*" ";"
649dc81
+        CONFIG_OUTPUT ${CONFIG_OUTPUT})
649dc81
     else()
649dc81
-      get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
649dc81
-                             ABSOLUTE)
649dc81
-      set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
649dc81
-      list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
649dc81
+      string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
649dc81
+      message(STATUS "${CONFIG_COMMAND_STR}")
649dc81
+      message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
649dc81
     endif()
649dc81
-  endif()
649dc81
-
649dc81
-  if (LLDB_PATH_TO_CLANG_SOURCE)
649dc81
-      get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
649dc81
-                             ABSOLUTE)
649dc81
-      set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
649dc81
-  endif()
649dc81
-
649dc81
-  list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
649dc81
-
649dc81
-  if (LLDB_PATH_TO_LLVM_BUILD)
649dc81
-    get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
649dc81
-                           ABSOLUTE)
649dc81
   else()
649dc81
-    message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_BUILD to the root "
649dc81
-            "directory of LLVM build or install site.")
649dc81
+    message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
649dc81
   endif()
649dc81
 
649dc81
-  if (LLDB_PATH_TO_CLANG_BUILD)
649dc81
-    get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
649dc81
-                           ABSOLUTE)
649dc81
+  list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
649dc81
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
649dc81
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
649dc81
+  list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
649dc81
+  list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
649dc81
+  list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
649dc81
+
649dc81
+  if(NOT MSVC_IDE)
649dc81
+    set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
649dc81
+      CACHE BOOL "Enable assertions")
649dc81
+    # Assertions should follow llvm-config's.
649dc81
+    mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
649dc81
+  endif()
649dc81
+
649dc81
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
649dc81
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
649dc81
+  set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
649dc81
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
649dc81
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
649dc81
+
649dc81
+  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
649dc81
+    NO_DEFAULT_PATH)
649dc81
+
649dc81
+  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
649dc81
+  set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
649dc81
+  if(EXISTS ${LLVMCONFIG_FILE})
649dc81
+    list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
649dc81
+    include(${LLVMCONFIG_FILE})
649dc81
   else()
649dc81
-    message(FATAL_ERROR "Please set LLDB_PATH_TO_CLANG_BUILD to the root "
649dc81
-            "directory of Clang build or install site.")
649dc81
+    message(FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}")
649dc81
   endif()
649dc81
 
649dc81
-
649dc81
-  # These variables are used by add_llvm_library.
649dc81
+  # They are used as destination of target generators.
649dc81
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
649dc81
   set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
649dc81
-  set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
649dc81
+  if(WIN32 OR CYGWIN)
649dc81
+    # DLL platform -- put DLLs into bin.
649dc81
+    set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
649dc81
+  else()
649dc81
+    set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
649dc81
+  endif()
649dc81
 
649dc81
   include(AddLLVM)
649dc81
   include(HandleLLVMOptions)
649dc81
@@ -73,9 +93,9 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
649dc81
     message("-- Found PythonInterp: ${PYTHON_EXECUTABLE}")
649dc81
   endif()
649dc81
   # Import CMake library targets from LLVM and Clang.
649dc81
-  include("${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake")
649dc81
-  if (EXISTS "${LLDB_PATH_TO_CLANG_BUILD}/share/clang/cmake/ClangConfig.cmake")
649dc81
-      include("${LLDB_PATH_TO_CLANG_BUILD}/share/clang/cmake/ClangConfig.cmake")
649dc81
+  include("${LLVM_OBJ_ROOT}/share/llvm/cmake/LLVMConfig.cmake")
649dc81
+  if (EXISTS "${LLVM_OBJ_ROOT}/share/clang/cmake/ClangConfig.cmake")
649dc81
+      include("${LLVM_OBJ_ROOT}/share/clang/cmake/ClangConfig.cmake")
649dc81
   endif()
649dc81
 
649dc81
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
649dc81
@@ -83,13 +103,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
649dc81
   set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR})
649dc81
 
649dc81
   set(CMAKE_INCLUDE_CURRENT_DIR ON)
649dc81
-  include_directories("${PATH_TO_LLVM_BUILD}/include"
649dc81
-                      "${LLVM_MAIN_INCLUDE_DIR}"
649dc81
-                      "${PATH_TO_CLANG_BUILD}/include"
649dc81
-                      "${CLANG_MAIN_INCLUDE_DIR}"
649dc81
-                      "${CMAKE_CURRENT_SOURCE_DIR}/source")
649dc81
-  link_directories("${PATH_TO_LLVM_BUILD}/lib${LLVM_LIBDIR_SUFFIX}"
649dc81
-                   "${PATH_TO_CLANG_BUILD}/lib${LLVM_LIBDIR_SUFFIX}")
649dc81
+  include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
649dc81
+  link_directories("${LLVM_LIBRARY_DIR}")
649dc81
 
649dc81
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
649dc81
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
649dc81
diff -up lldb-3.8.0rc2.src/include/lldb/Utility/regcclass.h.dave lldb-3.8.0rc2.src/include/lldb/Utility/regcclass.h
649dc81
--- lldb-3.8.0rc2.src/include/lldb/Utility/regcclass.h.dave	2016-02-17 23:19:05.371675721 -0500
649dc81
+++ lldb-3.8.0rc2.src/include/lldb/Utility/regcclass.h	2016-02-17 23:19:05.371675721 -0500
649dc81
@@ -0,0 +1,75 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993, 1994
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)cclass.h	8.3 (Berkeley) 3/20/94
649dc81
+ */
649dc81
+
649dc81
+#ifndef LLVM_SUPPORT_REGCCLASS_H
649dc81
+#define LLVM_SUPPORT_REGCCLASS_H
649dc81
+
649dc81
+/* character-class table */
649dc81
+static struct cclass {
649dc81
+	const char *name;
649dc81
+	const char *chars;
649dc81
+	const char *multis;
649dc81
+} cclasses[] = {
649dc81
+	{ "alnum",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
649dc81
+0123456789",				""} ,
649dc81
+	{ "alpha",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
649dc81
+					""} ,
649dc81
+	{ "blank",	" \t",		""} ,
649dc81
+	{ "cntrl",	"\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
649dc81
+\25\26\27\30\31\32\33\34\35\36\37\177",	""} ,
649dc81
+	{ "digit",	"0123456789",	""} ,
649dc81
+	{ "graph",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
649dc81
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
649dc81
+					""} ,
649dc81
+	{ "lower",	"abcdefghijklmnopqrstuvwxyz",
649dc81
+					""} ,
649dc81
+	{ "print",	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
649dc81
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
649dc81
+					""} ,
649dc81
+	{ "punct",	"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
649dc81
+					""} ,
649dc81
+	{ "space",	"\t\n\v\f\r ",	""} ,
649dc81
+	{ "upper",	"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
649dc81
+					""} ,
649dc81
+	{ "xdigit",	"0123456789ABCDEFabcdef",
649dc81
+					""} ,
649dc81
+	{ NULL,		0,		"" }
649dc81
+};
649dc81
+
649dc81
+#endif
649dc81
diff -up lldb-3.8.0rc2.src/include/lldb/Utility/regcname.h.dave lldb-3.8.0rc2.src/include/lldb/Utility/regcname.h
649dc81
--- lldb-3.8.0rc2.src/include/lldb/Utility/regcname.h.dave	2016-02-17 23:19:05.371675721 -0500
649dc81
+++ lldb-3.8.0rc2.src/include/lldb/Utility/regcname.h	2016-02-17 23:19:05.371675721 -0500
649dc81
@@ -0,0 +1,144 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993, 1994
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)cname.h	8.3 (Berkeley) 3/20/94
649dc81
+ */
649dc81
+
649dc81
+#ifndef LLVM_SUPPORT_REGCNAME_H
649dc81
+#define LLVM_SUPPORT_REGCNAME_H
649dc81
+
649dc81
+/* character-name table */
649dc81
+static struct cname {
649dc81
+	const char *name;
649dc81
+	char code;
649dc81
+} cnames[] = {
649dc81
+	{ "NUL",			'\0' },
649dc81
+	{ "SOH",			'\001' },
649dc81
+	{ "STX",			'\002' },
649dc81
+	{ "ETX",			'\003' },
649dc81
+	{ "EOT",			'\004' },
649dc81
+	{ "ENQ",			'\005' },
649dc81
+	{ "ACK",			'\006' },
649dc81
+	{ "BEL",			'\007' },
649dc81
+	{ "alert",			'\007' },
649dc81
+	{ "BS",				'\010' },
649dc81
+	{ "backspace",			'\b' },
649dc81
+	{ "HT",				'\011' },
649dc81
+	{ "tab",			'\t' },
649dc81
+	{ "LF",				'\012' },
649dc81
+	{ "newline",			'\n' },
649dc81
+	{ "VT",				'\013' },
649dc81
+	{ "vertical-tab",		'\v' },
649dc81
+	{ "FF",				'\014' },
649dc81
+	{ "form-feed",			'\f' },
649dc81
+	{ "CR",				'\015' },
649dc81
+	{ "carriage-return",		'\r' },
649dc81
+	{ "SO",				'\016' },
649dc81
+	{ "SI",				'\017' },
649dc81
+	{ "DLE",			'\020' },
649dc81
+	{ "DC1",			'\021' },
649dc81
+	{ "DC2",			'\022' },
649dc81
+	{ "DC3",			'\023' },
649dc81
+	{ "DC4",			'\024' },
649dc81
+	{ "NAK",			'\025' },
649dc81
+	{ "SYN",			'\026' },
649dc81
+	{ "ETB",			'\027' },
649dc81
+	{ "CAN",			'\030' },
649dc81
+	{ "EM",				'\031' },
649dc81
+	{ "SUB",			'\032' },
649dc81
+	{ "ESC",			'\033' },
649dc81
+	{ "IS4",			'\034' },
649dc81
+	{ "FS",				'\034' },
649dc81
+	{ "IS3",			'\035' },
649dc81
+	{ "GS",				'\035' },
649dc81
+	{ "IS2",			'\036' },
649dc81
+	{ "RS",				'\036' },
649dc81
+	{ "IS1",			'\037' },
649dc81
+	{ "US",				'\037' },
649dc81
+	{ "space",			' ' },
649dc81
+	{ "exclamation-mark",		'!' },
649dc81
+	{ "quotation-mark",		'"' },
649dc81
+	{ "number-sign",		'#' },
649dc81
+	{ "dollar-sign",		'$' },
649dc81
+	{ "percent-sign",		'%' },
649dc81
+	{ "ampersand",			'&' },
649dc81
+	{ "apostrophe",			'\'' },
649dc81
+	{ "left-parenthesis",		'(' },
649dc81
+	{ "right-parenthesis",		')' },
649dc81
+	{ "asterisk",			'*' },
649dc81
+	{ "plus-sign",			'+' },
649dc81
+	{ "comma",			',' },
649dc81
+	{ "hyphen",			'-' },
649dc81
+	{ "hyphen-minus",		'-' },
649dc81
+	{ "period",			'.' },
649dc81
+	{ "full-stop",			'.' },
649dc81
+	{ "slash",			'/' },
649dc81
+	{ "solidus",			'/' },
649dc81
+	{ "zero",			'0' },
649dc81
+	{ "one",			'1' },
649dc81
+	{ "two",			'2' },
649dc81
+	{ "three",			'3' },
649dc81
+	{ "four",			'4' },
649dc81
+	{ "five",			'5' },
649dc81
+	{ "six",			'6' },
649dc81
+	{ "seven",			'7' },
649dc81
+	{ "eight",			'8' },
649dc81
+	{ "nine",			'9' },
649dc81
+	{ "colon",			':' },
649dc81
+	{ "semicolon",			';' },
649dc81
+	{ "less-than-sign",		'<' },
649dc81
+	{ "equals-sign",		'=' },
649dc81
+	{ "greater-than-sign",		'>' },
649dc81
+	{ "question-mark",		'?' },
649dc81
+	{ "commercial-at",		'@' },
649dc81
+	{ "left-square-bracket",	'[' },
649dc81
+	{ "backslash",			'\\' },
649dc81
+	{ "reverse-solidus",		'\\' },
649dc81
+	{ "right-square-bracket",	']' },
649dc81
+	{ "circumflex",			'^' },
649dc81
+	{ "circumflex-accent",		'^' },
649dc81
+	{ "underscore",			'_' },
649dc81
+	{ "low-line",			'_' },
649dc81
+	{ "grave-accent",		'`' },
649dc81
+	{ "left-brace",			'{' },
649dc81
+	{ "left-curly-bracket",		'{' },
649dc81
+	{ "vertical-line",		'|' },
649dc81
+	{ "right-brace",		'}' },
649dc81
+	{ "right-curly-bracket",	'}' },
649dc81
+	{ "tilde",			'~' },
649dc81
+	{ "DEL",			'\177' },
649dc81
+	{ NULL,				0 }
649dc81
+};
649dc81
+
649dc81
+#endif
649dc81
diff -up lldb-3.8.0rc2.src/include/lldb/Utility/regengine.inc.dave lldb-3.8.0rc2.src/include/lldb/Utility/regengine.inc
649dc81
--- lldb-3.8.0rc2.src/include/lldb/Utility/regengine.inc.dave	2016-02-17 23:19:05.371675721 -0500
649dc81
+++ lldb-3.8.0rc2.src/include/lldb/Utility/regengine.inc	2016-02-17 23:19:05.371675721 -0500
649dc81
@@ -0,0 +1,1034 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993, 1994
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)engine.c	8.5 (Berkeley) 3/20/94
649dc81
+ */
649dc81
+
649dc81
+/*
649dc81
+ * The matching engine and friends.  This file is #included by regexec.c
649dc81
+ * after suitable #defines of a variety of macros used herein, so that
649dc81
+ * different state representations can be used without duplicating masses
649dc81
+ * of code.
649dc81
+ */
649dc81
+
649dc81
+#ifdef SNAMES
649dc81
+#define	matcher	smatcher
649dc81
+#define	fast	sfast
649dc81
+#define	slow	sslow
649dc81
+#define	dissect	sdissect
649dc81
+#define	backref	sbackref
649dc81
+#define	step	sstep
649dc81
+#define	print	sprint
649dc81
+#define	at	sat
649dc81
+#define	match	smat
649dc81
+#define	nope	snope
649dc81
+#endif
649dc81
+#ifdef LNAMES
649dc81
+#define	matcher	lmatcher
649dc81
+#define	fast	lfast
649dc81
+#define	slow	lslow
649dc81
+#define	dissect	ldissect
649dc81
+#define	backref	lbackref
649dc81
+#define	step	lstep
649dc81
+#define	print	lprint
649dc81
+#define	at	lat
649dc81
+#define	match	lmat
649dc81
+#define	nope	lnope
649dc81
+#endif
649dc81
+
649dc81
+/* another structure passed up and down to avoid zillions of parameters */
649dc81
+struct match {
649dc81
+	struct re_guts *g;
649dc81
+	int eflags;
649dc81
+	llvm_regmatch_t *pmatch;	/* [nsub+1] (0 element unused) */
649dc81
+	const char *offp;		/* offsets work from here */
649dc81
+	const char *beginp;		/* start of string -- virtual NUL precedes */
649dc81
+	const char *endp;		/* end of string -- virtual NUL here */
649dc81
+	const char *coldp;		/* can be no match starting before here */
649dc81
+	const char **lastpos;		/* [nplus+1] */
649dc81
+	STATEVARS;
649dc81
+	states st;		/* current states */
649dc81
+	states fresh;		/* states for a fresh start */
649dc81
+	states tmp;		/* temporary */
649dc81
+	states empty;		/* empty set of states */
649dc81
+};
649dc81
+
649dc81
+static int matcher(struct re_guts *, const char *, size_t,
649dc81
+                   llvm_regmatch_t[], int);
649dc81
+static const char *dissect(struct match *, const char *, const char *, sopno,
649dc81
+                           sopno);
649dc81
+static const char *backref(struct match *, const char *, const char *, sopno,
649dc81
+                           sopno, sopno, int);
649dc81
+static const char *fast(struct match *, const char *, const char *, sopno, sopno);
649dc81
+static const char *slow(struct match *, const char *, const char *, sopno, sopno);
649dc81
+static states step(struct re_guts *, sopno, sopno, states, int, states);
649dc81
+#define MAX_RECURSION	100
649dc81
+#define	BOL	(OUT+1)
649dc81
+#define	EOL	(BOL+1)
649dc81
+#define	BOLEOL	(BOL+2)
649dc81
+#define	NOTHING	(BOL+3)
649dc81
+#define	BOW	(BOL+4)
649dc81
+#define	EOW	(BOL+5)
649dc81
+#define	CODEMAX	(BOL+5)		/* highest code used */
649dc81
+#define	NONCHAR(c)	((c) > CHAR_MAX)
649dc81
+#define	NNONCHAR	(CODEMAX-CHAR_MAX)
649dc81
+#ifdef REDEBUG
649dc81
+static void print(struct match *, char *, states, int, FILE *);
649dc81
+#endif
649dc81
+#ifdef REDEBUG
649dc81
+static void at(struct match *, char *, char *, char *, sopno, sopno);
649dc81
+#endif
649dc81
+#ifdef REDEBUG
649dc81
+static char *pchar(int);
649dc81
+#endif
649dc81
+
649dc81
+#ifdef REDEBUG
649dc81
+#define	SP(t, s, c)	print(m, t, s, c, stdout)
649dc81
+#define	AT(t, p1, p2, s1, s2)	at(m, t, p1, p2, s1, s2)
649dc81
+#define	NOTE(str)	{ if (m->eflags&REG_TRACE) (void)printf("=%s\n", (str)); }
649dc81
+static int nope = 0;
649dc81
+#else
649dc81
+#define	SP(t, s, c)	/* nothing */
649dc81
+#define	AT(t, p1, p2, s1, s2)	/* nothing */
649dc81
+#define	NOTE(s)	/* nothing */
649dc81
+#endif
649dc81
+
649dc81
+/*
649dc81
+ - matcher - the actual matching engine
649dc81
+ */
649dc81
+static int			/* 0 success, REG_NOMATCH failure */
649dc81
+matcher(struct re_guts *g, const char *string, size_t nmatch,
649dc81
+        llvm_regmatch_t pmatch[],
649dc81
+    int eflags)
649dc81
+{
649dc81
+	const char *endp;
649dc81
+	size_t i;
649dc81
+	struct match mv;
649dc81
+	struct match *m = &mv;
649dc81
+	const char *dp;
649dc81
+	const sopno gf = g->firststate+1;	/* +1 for OEND */
649dc81
+	const sopno gl = g->laststate;
649dc81
+	const char *start;
649dc81
+	const char *stop;
649dc81
+
649dc81
+	/* simplify the situation where possible */
649dc81
+	if (g->cflags&REG_NOSUB)
649dc81
+		nmatch = 0;
649dc81
+	if (eflags&REG_STARTEND) {
649dc81
+		start = string + pmatch[0].rm_so;
649dc81
+		stop = string + pmatch[0].rm_eo;
649dc81
+	} else {
649dc81
+		start = string;
649dc81
+		stop = start + strlen(start);
649dc81
+	}
649dc81
+	if (stop < start)
649dc81
+		return(REG_INVARG);
649dc81
+
649dc81
+	/* prescreening; this does wonders for this rather slow code */
649dc81
+	if (g->must != NULL) {
649dc81
+		for (dp = start; dp < stop; dp++)
649dc81
+			if (*dp == g->must[0] && stop - dp >= g->mlen &&
649dc81
+				memcmp(dp, g->must, (size_t)g->mlen) == 0)
649dc81
+				break;
649dc81
+		if (dp == stop)		/* we didn't find g->must */
649dc81
+			return(REG_NOMATCH);
649dc81
+	}
649dc81
+
649dc81
+	/* match struct setup */
649dc81
+	m->g = g;
649dc81
+	m->eflags = eflags;
649dc81
+	m->pmatch = NULL;
649dc81
+	m->lastpos = NULL;
649dc81
+	m->offp = string;
649dc81
+	m->beginp = start;
649dc81
+	m->endp = stop;
649dc81
+	STATESETUP(m, 4);
649dc81
+	SETUP(m->st);
649dc81
+	SETUP(m->fresh);
649dc81
+	SETUP(m->tmp);
649dc81
+	SETUP(m->empty);
649dc81
+	CLEAR(m->empty);
649dc81
+
649dc81
+	/* this loop does only one repetition except for backrefs */
649dc81
+	for (;;) {
649dc81
+		endp = fast(m, start, stop, gf, gl);
649dc81
+		if (endp == NULL) {		/* a miss */
649dc81
+			free(m->pmatch);
649dc81
+			free((void*)m->lastpos);
649dc81
+			STATETEARDOWN(m);
649dc81
+			return(REG_NOMATCH);
649dc81
+		}
649dc81
+		if (nmatch == 0 && !g->backrefs)
649dc81
+			break;		/* no further info needed */
649dc81
+
649dc81
+		/* where? */
649dc81
+		assert(m->coldp != NULL);
649dc81
+		for (;;) {
649dc81
+			NOTE("finding start");
649dc81
+			endp = slow(m, m->coldp, stop, gf, gl);
649dc81
+			if (endp != NULL)
649dc81
+				break;
649dc81
+			assert(m->coldp < m->endp);
649dc81
+			m->coldp++;
649dc81
+		}
649dc81
+		if (nmatch == 1 && !g->backrefs)
649dc81
+			break;		/* no further info needed */
649dc81
+
649dc81
+		/* oh my, they want the subexpressions... */
649dc81
+		if (m->pmatch == NULL)
649dc81
+			m->pmatch = (llvm_regmatch_t *)malloc((m->g->nsub + 1) *
649dc81
+							sizeof(llvm_regmatch_t));
649dc81
+		if (m->pmatch == NULL) {
649dc81
+			STATETEARDOWN(m);
649dc81
+			return(REG_ESPACE);
649dc81
+		}
649dc81
+		for (i = 1; i <= m->g->nsub; i++)
649dc81
+			m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
649dc81
+		if (!g->backrefs && !(m->eflags&REG_BACKR)) {
649dc81
+			NOTE("dissecting");
649dc81
+			dp = dissect(m, m->coldp, endp, gf, gl);
649dc81
+		} else {
649dc81
+			if (g->nplus > 0 && m->lastpos == NULL)
649dc81
+				m->lastpos = (const char **)malloc((g->nplus+1) *
649dc81
+							sizeof(char *));
649dc81
+			if (g->nplus > 0 && m->lastpos == NULL) {
649dc81
+				free(m->pmatch);
649dc81
+				STATETEARDOWN(m);
649dc81
+				return(REG_ESPACE);
649dc81
+			}
649dc81
+			NOTE("backref dissect");
649dc81
+			dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0);
649dc81
+		}
649dc81
+		if (dp != NULL)
649dc81
+			break;
649dc81
+
649dc81
+		/* uh-oh... we couldn't find a subexpression-level match */
649dc81
+		assert(g->backrefs);	/* must be back references doing it */
649dc81
+		assert(g->nplus == 0 || m->lastpos != NULL);
649dc81
+		for (;;) {
649dc81
+			if (dp != NULL || endp <= m->coldp)
649dc81
+				break;		/* defeat */
649dc81
+			NOTE("backoff");
649dc81
+			endp = slow(m, m->coldp, endp-1, gf, gl);
649dc81
+			if (endp == NULL)
649dc81
+				break;		/* defeat */
649dc81
+			/* try it on a shorter possibility */
649dc81
+#ifndef NDEBUG
649dc81
+			for (i = 1; i <= m->g->nsub; i++) {
649dc81
+				assert(m->pmatch[i].rm_so == -1);
649dc81
+				assert(m->pmatch[i].rm_eo == -1);
649dc81
+			}
649dc81
+#endif
649dc81
+			NOTE("backoff dissect");
649dc81
+			dp = backref(m, m->coldp, endp, gf, gl, (sopno)0, 0);
649dc81
+		}
649dc81
+		assert(dp == NULL || dp == endp);
649dc81
+		if (dp != NULL)		/* found a shorter one */
649dc81
+			break;
649dc81
+
649dc81
+		/* despite initial appearances, there is no match here */
649dc81
+		NOTE("false alarm");
649dc81
+		if (m->coldp == stop)
649dc81
+			break;
649dc81
+		start = m->coldp + 1;	/* recycle starting later */
649dc81
+	}
649dc81
+
649dc81
+	/* fill in the details if requested */
649dc81
+	if (nmatch > 0) {
649dc81
+		pmatch[0].rm_so = m->coldp - m->offp;
649dc81
+		pmatch[0].rm_eo = endp - m->offp;
649dc81
+	}
649dc81
+	if (nmatch > 1) {
649dc81
+		assert(m->pmatch != NULL);
649dc81
+		for (i = 1; i < nmatch; i++)
649dc81
+			if (i <= m->g->nsub)
649dc81
+				pmatch[i] = m->pmatch[i];
649dc81
+			else {
649dc81
+				pmatch[i].rm_so = -1;
649dc81
+				pmatch[i].rm_eo = -1;
649dc81
+			}
649dc81
+	}
649dc81
+
649dc81
+	if (m->pmatch != NULL)
649dc81
+		free((char *)m->pmatch);
649dc81
+	if (m->lastpos != NULL)
649dc81
+		free((char *)m->lastpos);
649dc81
+	STATETEARDOWN(m);
649dc81
+	return(0);
649dc81
+}
649dc81
+
649dc81
+/*
649dc81
+ - dissect - figure out what matched what, no back references
649dc81
+ */
649dc81
+static const char *			/* == stop (success) always */
649dc81
+dissect(struct match *m, const char *start, const char *stop, sopno startst,
649dc81
+        sopno stopst)
649dc81
+{
649dc81
+	int i;
649dc81
+	sopno ss;	/* start sop of current subRE */
649dc81
+	sopno es;	/* end sop of current subRE */
649dc81
+	const char *sp;	/* start of string matched by it */
649dc81
+	const char *stp;	/* string matched by it cannot pass here */
649dc81
+	const char *rest;	/* start of rest of string */
649dc81
+	const char *tail;	/* string unmatched by rest of RE */
649dc81
+	sopno ssub;	/* start sop of subsubRE */
649dc81
+	sopno esub;	/* end sop of subsubRE */
649dc81
+	const char *ssp;	/* start of string matched by subsubRE */
649dc81
+	const char *sep;	/* end of string matched by subsubRE */
649dc81
+	const char *oldssp;	/* previous ssp */
649dc81
+
649dc81
+	AT("diss", start, stop, startst, stopst);
649dc81
+	sp = start;
649dc81
+	for (ss = startst; ss < stopst; ss = es) {
649dc81
+		/* identify end of subRE */
649dc81
+		es = ss;
649dc81
+		switch (OP(m->g->strip[es])) {
649dc81
+		case OPLUS_:
649dc81
+		case OQUEST_:
649dc81
+			es += OPND(m->g->strip[es]);
649dc81
+			break;
649dc81
+		case OCH_:
649dc81
+			while (OP(m->g->strip[es]) != O_CH)
649dc81
+				es += OPND(m->g->strip[es]);
649dc81
+			break;
649dc81
+		}
649dc81
+		es++;
649dc81
+
649dc81
+		/* figure out what it matched */
649dc81
+		switch (OP(m->g->strip[ss])) {
649dc81
+		case OEND:
649dc81
+			assert(nope);
649dc81
+			break;
649dc81
+		case OCHAR:
649dc81
+			sp++;
649dc81
+			break;
649dc81
+		case OBOL:
649dc81
+		case OEOL:
649dc81
+		case OBOW:
649dc81
+		case OEOW:
649dc81
+			break;
649dc81
+		case OANY:
649dc81
+		case OANYOF:
649dc81
+			sp++;
649dc81
+			break;
649dc81
+		case OBACK_:
649dc81
+		case O_BACK:
649dc81
+			assert(nope);
649dc81
+			break;
649dc81
+		/* cases where length of match is hard to find */
649dc81
+		case OQUEST_:
649dc81
+			stp = stop;
649dc81
+			for (;;) {
649dc81
+				/* how long could this one be? */
649dc81
+				rest = slow(m, sp, stp, ss, es);
649dc81
+				assert(rest != NULL);	/* it did match */
649dc81
+				/* could the rest match the rest? */
649dc81
+				tail = slow(m, rest, stop, es, stopst);
649dc81
+				if (tail == stop)
649dc81
+					break;		/* yes! */
649dc81
+				/* no -- try a shorter match for this one */
649dc81
+				stp = rest - 1;
649dc81
+				assert(stp >= sp);	/* it did work */
649dc81
+			}
649dc81
+			ssub = ss + 1;
649dc81
+			esub = es - 1;
649dc81
+			/* did innards match? */
649dc81
+			if (slow(m, sp, rest, ssub, esub) != NULL) {
649dc81
+				const char *dp = dissect(m, sp, rest, ssub, esub);
649dc81
+				(void)dp; /* avoid warning if assertions off */
649dc81
+				assert(dp == rest);
649dc81
+			} else		/* no */
649dc81
+				assert(sp == rest);
649dc81
+			sp = rest;
649dc81
+			break;
649dc81
+		case OPLUS_:
649dc81
+			stp = stop;
649dc81
+			for (;;) {
649dc81
+				/* how long could this one be? */
649dc81
+				rest = slow(m, sp, stp, ss, es);
649dc81
+				assert(rest != NULL);	/* it did match */
649dc81
+				/* could the rest match the rest? */
649dc81
+				tail = slow(m, rest, stop, es, stopst);
649dc81
+				if (tail == stop)
649dc81
+					break;		/* yes! */
649dc81
+				/* no -- try a shorter match for this one */
649dc81
+				stp = rest - 1;
649dc81
+				assert(stp >= sp);	/* it did work */
649dc81
+			}
649dc81
+			ssub = ss + 1;
649dc81
+			esub = es - 1;
649dc81
+			ssp = sp;
649dc81
+			oldssp = ssp;
649dc81
+			for (;;) {	/* find last match of innards */
649dc81
+				sep = slow(m, ssp, rest, ssub, esub);
649dc81
+				if (sep == NULL || sep == ssp)
649dc81
+					break;	/* failed or matched null */
649dc81
+				oldssp = ssp;	/* on to next try */
649dc81
+				ssp = sep;
649dc81
+			}
649dc81
+			if (sep == NULL) {
649dc81
+				/* last successful match */
649dc81
+				sep = ssp;
649dc81
+				ssp = oldssp;
649dc81
+			}
649dc81
+			assert(sep == rest);	/* must exhaust substring */
649dc81
+			assert(slow(m, ssp, sep, ssub, esub) == rest);
649dc81
+			{
649dc81
+				const char *dp = dissect(m, ssp, sep, ssub, esub);
649dc81
+				(void)dp; /* avoid warning if assertions off */
649dc81
+				assert(dp == sep);
649dc81
+			}
649dc81
+			sp = rest;
649dc81
+			break;
649dc81
+		case OCH_:
649dc81
+			stp = stop;
649dc81
+			for (;;) {
649dc81
+				/* how long could this one be? */
649dc81
+				rest = slow(m, sp, stp, ss, es);
649dc81
+				assert(rest != NULL);	/* it did match */
649dc81
+				/* could the rest match the rest? */
649dc81
+				tail = slow(m, rest, stop, es, stopst);
649dc81
+				if (tail == stop)
649dc81
+					break;		/* yes! */
649dc81
+				/* no -- try a shorter match for this one */
649dc81
+				stp = rest - 1;
649dc81
+				assert(stp >= sp);	/* it did work */
649dc81
+			}
649dc81
+			ssub = ss + 1;
649dc81
+			esub = ss + OPND(m->g->strip[ss]) - 1;
649dc81
+			assert(OP(m->g->strip[esub]) == OOR1);
649dc81
+			for (;;) {	/* find first matching branch */
649dc81
+				if (slow(m, sp, rest, ssub, esub) == rest)
649dc81
+					break;	/* it matched all of it */
649dc81
+				/* that one missed, try next one */
649dc81
+				assert(OP(m->g->strip[esub]) == OOR1);
649dc81
+				esub++;
649dc81
+				assert(OP(m->g->strip[esub]) == OOR2);
649dc81
+				ssub = esub + 1;
649dc81
+				esub += OPND(m->g->strip[esub]);
649dc81
+				if (OP(m->g->strip[esub]) == OOR2)
649dc81
+					esub--;
649dc81
+				else
649dc81
+					assert(OP(m->g->strip[esub]) == O_CH);
649dc81
+			}
649dc81
+			{
649dc81
+				const char *dp = dissect(m, sp, rest, ssub, esub);
649dc81
+				(void)dp; /* avoid warning if assertions off */
649dc81
+				assert(dp == rest);
649dc81
+			}
649dc81
+			sp = rest;
649dc81
+			break;
649dc81
+		case O_PLUS:
649dc81
+		case O_QUEST:
649dc81
+		case OOR1:
649dc81
+		case OOR2:
649dc81
+		case O_CH:
649dc81
+			assert(nope);
649dc81
+			break;
649dc81
+		case OLPAREN:
649dc81
+			i = OPND(m->g->strip[ss]);
649dc81
+			assert(0 < i && i <= m->g->nsub);
649dc81
+			m->pmatch[i].rm_so = sp - m->offp;
649dc81
+			break;
649dc81
+		case ORPAREN:
649dc81
+			i = OPND(m->g->strip[ss]);
649dc81
+			assert(0 < i && i <= m->g->nsub);
649dc81
+			m->pmatch[i].rm_eo = sp - m->offp;
649dc81
+			break;
649dc81
+		default:		/* uh oh */
649dc81
+			assert(nope);
649dc81
+			break;
649dc81
+		}
649dc81
+	}
649dc81
+
649dc81
+	assert(sp == stop);
649dc81
+	return(sp);
649dc81
+}
649dc81
+
649dc81
+/*
649dc81
+ - backref - figure out what matched what, figuring in back references
649dc81
+ */
649dc81
+static const char *			/* == stop (success) or NULL (failure) */
649dc81
+backref(struct match *m, const char *start, const char *stop, sopno startst,
649dc81
+        sopno stopst, sopno lev, int rec)			/* PLUS nesting level */
649dc81
+{
649dc81
+	int i;
649dc81
+	sopno ss;	/* start sop of current subRE */
649dc81
+	const char *sp;	/* start of string matched by it */
649dc81
+	sopno ssub;	/* start sop of subsubRE */
649dc81
+	sopno esub;	/* end sop of subsubRE */
649dc81
+	const char *ssp;	/* start of string matched by subsubRE */
649dc81
+	const char *dp;
649dc81
+	size_t len;
649dc81
+	int hard;
649dc81
+	sop s;
649dc81
+	llvm_regoff_t offsave;
649dc81
+	cset *cs;
649dc81
+
649dc81
+	AT("back", start, stop, startst, stopst);
649dc81
+	sp = start;
649dc81
+
649dc81
+	/* get as far as we can with easy stuff */
649dc81
+	hard = 0;
649dc81
+	for (ss = startst; !hard && ss < stopst; ss++)
649dc81
+		switch (OP(s = m->g->strip[ss])) {
649dc81
+		case OCHAR:
649dc81
+			if (sp == stop || *sp++ != (char)OPND(s))
649dc81
+				return(NULL);
649dc81
+			break;
649dc81
+		case OANY:
649dc81
+			if (sp == stop)
649dc81
+				return(NULL);
649dc81
+			sp++;
649dc81
+			break;
649dc81
+		case OANYOF:
649dc81
+			cs = &m->g->sets[OPND(s)];
649dc81
+			if (sp == stop || !CHIN(cs, *sp++))
649dc81
+				return(NULL);
649dc81
+			break;
649dc81
+		case OBOL:
649dc81
+			if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
649dc81
+					(sp < m->endp && *(sp-1) == '\n' &&
649dc81
+						(m->g->cflags&REG_NEWLINE)) )
649dc81
+				{ /* yes */ }
649dc81
+			else
649dc81
+				return(NULL);
649dc81
+			break;
649dc81
+		case OEOL:
649dc81
+			if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
649dc81
+					(sp < m->endp && *sp == '\n' &&
649dc81
+						(m->g->cflags&REG_NEWLINE)) )
649dc81
+				{ /* yes */ }
649dc81
+			else
649dc81
+				return(NULL);
649dc81
+			break;
649dc81
+		case OBOW:
649dc81
+			if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
649dc81
+					(sp < m->endp && *(sp-1) == '\n' &&
649dc81
+						(m->g->cflags&REG_NEWLINE)) ||
649dc81
+					(sp > m->beginp &&
649dc81
+							!ISWORD(*(sp-1))) ) &&
649dc81
+					(sp < m->endp && ISWORD(*sp)) )
649dc81
+				{ /* yes */ }
649dc81
+			else
649dc81
+				return(NULL);
649dc81
+			break;
649dc81
+		case OEOW:
649dc81
+			if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
649dc81
+					(sp < m->endp && *sp == '\n' &&
649dc81
+						(m->g->cflags&REG_NEWLINE)) ||
649dc81
+					(sp < m->endp && !ISWORD(*sp)) ) &&
649dc81
+					(sp > m->beginp && ISWORD(*(sp-1))) )
649dc81
+				{ /* yes */ }
649dc81
+			else
649dc81
+				return(NULL);
649dc81
+			break;
649dc81
+		case O_QUEST:
649dc81
+			break;
649dc81
+		case OOR1:	/* matches null but needs to skip */
649dc81
+			ss++;
649dc81
+			s = m->g->strip[ss];
649dc81
+			do {
649dc81
+				assert(OP(s) == OOR2);
649dc81
+				ss += OPND(s);
649dc81
+			} while (OP(s = m->g->strip[ss]) != O_CH);
649dc81
+			/* note that the ss++ gets us past the O_CH */
649dc81
+			break;
649dc81
+		default:	/* have to make a choice */
649dc81
+			hard = 1;
649dc81
+			break;
649dc81
+		}
649dc81
+	if (!hard) {		/* that was it! */
649dc81
+		if (sp != stop)
649dc81
+			return(NULL);
649dc81
+		return(sp);
649dc81
+	}
649dc81
+	ss--;			/* adjust for the for's final increment */
649dc81
+
649dc81
+	/* the hard stuff */
649dc81
+	AT("hard", sp, stop, ss, stopst);
649dc81
+	s = m->g->strip[ss];
649dc81
+	switch (OP(s)) {
649dc81
+	case OBACK_:		/* the vilest depths */
649dc81
+		i = OPND(s);
649dc81
+		assert(0 < i && i <= m->g->nsub);
649dc81
+		if (m->pmatch[i].rm_eo == -1)
649dc81
+			return(NULL);
649dc81
+		assert(m->pmatch[i].rm_so != -1);
649dc81
+		len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
649dc81
+		if (len == 0 && rec++ > MAX_RECURSION)
649dc81
+			return(NULL);
649dc81
+		assert(stop - m->beginp >= len);
649dc81
+		if (sp > stop - len)
649dc81
+			return(NULL);	/* not enough left to match */
649dc81
+		ssp = m->offp + m->pmatch[i].rm_so;
649dc81
+		if (memcmp(sp, ssp, len) != 0)
649dc81
+			return(NULL);
649dc81
+		while (m->g->strip[ss] != SOP(O_BACK, i))
649dc81
+			ss++;
649dc81
+		return(backref(m, sp+len, stop, ss+1, stopst, lev, rec));
649dc81
+		break;
649dc81
+	case OQUEST_:		/* to null or not */
649dc81
+		dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
649dc81
+		if (dp != NULL)
649dc81
+			return(dp);	/* not */
649dc81
+		return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec));
649dc81
+		break;
649dc81
+	case OPLUS_:
649dc81
+		assert(m->lastpos != NULL);
649dc81
+		assert(lev+1 <= m->g->nplus);
649dc81
+		m->lastpos[lev+1] = sp;
649dc81
+		return(backref(m, sp, stop, ss+1, stopst, lev+1, rec));
649dc81
+		break;
649dc81
+	case O_PLUS:
649dc81
+		if (sp == m->lastpos[lev])	/* last pass matched null */
649dc81
+			return(backref(m, sp, stop, ss+1, stopst, lev-1, rec));
649dc81
+		/* try another pass */
649dc81
+		m->lastpos[lev] = sp;
649dc81
+		dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec);
649dc81
+		if (dp == NULL)
649dc81
+			return(backref(m, sp, stop, ss+1, stopst, lev-1, rec));
649dc81
+		else
649dc81
+			return(dp);
649dc81
+		break;
649dc81
+	case OCH_:		/* find the right one, if any */
649dc81
+		ssub = ss + 1;
649dc81
+		esub = ss + OPND(s) - 1;
649dc81
+		assert(OP(m->g->strip[esub]) == OOR1);
649dc81
+		for (;;) {	/* find first matching branch */
649dc81
+			dp = backref(m, sp, stop, ssub, esub, lev, rec);
649dc81
+			if (dp != NULL)
649dc81
+				return(dp);
649dc81
+			/* that one missed, try next one */
649dc81
+			if (OP(m->g->strip[esub]) == O_CH)
649dc81
+				return(NULL);	/* there is none */
649dc81
+			esub++;
649dc81
+			assert(OP(m->g->strip[esub]) == OOR2);
649dc81
+			ssub = esub + 1;
649dc81
+			esub += OPND(m->g->strip[esub]);
649dc81
+			if (OP(m->g->strip[esub]) == OOR2)
649dc81
+				esub--;
649dc81
+			else
649dc81
+				assert(OP(m->g->strip[esub]) == O_CH);
649dc81
+		}
649dc81
+		break;
649dc81
+	case OLPAREN:		/* must undo assignment if rest fails */
649dc81
+		i = OPND(s);
649dc81
+		assert(0 < i && i <= m->g->nsub);
649dc81
+		offsave = m->pmatch[i].rm_so;
649dc81
+		m->pmatch[i].rm_so = sp - m->offp;
649dc81
+		dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
649dc81
+		if (dp != NULL)
649dc81
+			return(dp);
649dc81
+		m->pmatch[i].rm_so = offsave;
649dc81
+		return(NULL);
649dc81
+		break;
649dc81
+	case ORPAREN:		/* must undo assignment if rest fails */
649dc81
+		i = OPND(s);
649dc81
+		assert(0 < i && i <= m->g->nsub);
649dc81
+		offsave = m->pmatch[i].rm_eo;
649dc81
+		m->pmatch[i].rm_eo = sp - m->offp;
649dc81
+		dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
649dc81
+		if (dp != NULL)
649dc81
+			return(dp);
649dc81
+		m->pmatch[i].rm_eo = offsave;
649dc81
+		return(NULL);
649dc81
+		break;
649dc81
+	default:		/* uh oh */
649dc81
+		assert(nope);
649dc81
+		break;
649dc81
+	}
649dc81
+
649dc81
+	/* "can't happen" */
649dc81
+	assert(nope);
649dc81
+	/* NOTREACHED */
649dc81
+        return NULL;
649dc81
+}
649dc81
+
649dc81
+/*
649dc81
+ - fast - step through the string at top speed
649dc81
+ */
649dc81
+static const char *			/* where tentative match ended, or NULL */
649dc81
+fast(struct match *m, const char *start, const char *stop, sopno startst,
649dc81
+     sopno stopst)
649dc81
+{
649dc81
+	states st = m->st;
649dc81
+	states fresh = m->fresh;
649dc81
+	states tmp = m->tmp;
649dc81
+	const char *p = start;
649dc81
+	int c = (start == m->beginp) ? OUT : *(start-1);
649dc81
+	int lastc;	/* previous c */
649dc81
+	int flagch;
649dc81
+	int i;
649dc81
+	const char *coldp;	/* last p after which no match was underway */
649dc81
+
649dc81
+	CLEAR(st);
649dc81
+	SET1(st, startst);
649dc81
+	st = step(m->g, startst, stopst, st, NOTHING, st);
649dc81
+	ASSIGN(fresh, st);
649dc81
+	SP("start", st, *p);
649dc81
+	coldp = NULL;
649dc81
+	for (;;) {
649dc81
+		/* next character */
649dc81
+		lastc = c;
649dc81
+		c = (p == m->endp) ? OUT : *p;
649dc81
+		if (EQ(st, fresh))
649dc81
+			coldp = p;
649dc81
+
649dc81
+		/* is there an EOL and/or BOL between lastc and c? */
649dc81
+		flagch = '\0';
649dc81
+		i = 0;
649dc81
+		if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
649dc81
+				(lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
649dc81
+			flagch = BOL;
649dc81
+			i = m->g->nbol;
649dc81
+		}
649dc81
+		if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
649dc81
+				(c == OUT && !(m->eflags&REG_NOTEOL)) ) {
649dc81
+			flagch = (flagch == BOL) ? BOLEOL : EOL;
649dc81
+			i += m->g->neol;
649dc81
+		}
649dc81
+		if (i != 0) {
649dc81
+			for (; i > 0; i--)
649dc81
+				st = step(m->g, startst, stopst, st, flagch, st);
649dc81
+			SP("boleol", st, c);
649dc81
+		}
649dc81
+
649dc81
+		/* how about a word boundary? */
649dc81
+		if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
649dc81
+					(c != OUT && ISWORD(c)) ) {
649dc81
+			flagch = BOW;
649dc81
+		}
649dc81
+		if ( (lastc != OUT && ISWORD(lastc)) &&
649dc81
+				(flagch == EOL || (c != OUT && !ISWORD(c))) ) {
649dc81
+			flagch = EOW;
649dc81
+		}
649dc81
+		if (flagch == BOW || flagch == EOW) {
649dc81
+			st = step(m->g, startst, stopst, st, flagch, st);
649dc81
+			SP("boweow", st, c);
649dc81
+		}
649dc81
+
649dc81
+		/* are we done? */
649dc81
+		if (ISSET(st, stopst) || p == stop)
649dc81
+			break;		/* NOTE BREAK OUT */
649dc81
+
649dc81
+		/* no, we must deal with this character */
649dc81
+		ASSIGN(tmp, st);
649dc81
+		ASSIGN(st, fresh);
649dc81
+		assert(c != OUT);
649dc81
+		st = step(m->g, startst, stopst, tmp, c, st);
649dc81
+		SP("aft", st, c);
649dc81
+		assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
649dc81
+		p++;
649dc81
+	}
649dc81
+
649dc81
+	assert(coldp != NULL);
649dc81
+	m->coldp = coldp;
649dc81
+	if (ISSET(st, stopst))
649dc81
+		return(p+1);
649dc81
+	else
649dc81
+		return(NULL);
649dc81
+}
649dc81
+
649dc81
+/*
649dc81
+ - slow - step through the string more deliberately
649dc81
+ */
649dc81
+static const char *			/* where it ended */
649dc81
+slow(struct match *m, const char *start, const char *stop, sopno startst,
649dc81
+     sopno stopst)
649dc81
+{
649dc81
+	states st = m->st;
649dc81
+	states empty = m->empty;
649dc81
+	states tmp = m->tmp;
649dc81
+	const char *p = start;
649dc81
+	int c = (start == m->beginp) ? OUT : *(start-1);
649dc81
+	int lastc;	/* previous c */
649dc81
+	int flagch;
649dc81
+	int i;
649dc81
+	const char *matchp;	/* last p at which a match ended */
649dc81
+
649dc81
+	AT("slow", start, stop, startst, stopst);
649dc81
+	CLEAR(st);
649dc81
+	SET1(st, startst);
649dc81
+	SP("sstart", st, *p);
649dc81
+	st = step(m->g, startst, stopst, st, NOTHING, st);
649dc81
+	matchp = NULL;
649dc81
+	for (;;) {
649dc81
+		/* next character */
649dc81
+		lastc = c;
649dc81
+		c = (p == m->endp) ? OUT : *p;
649dc81
+
649dc81
+		/* is there an EOL and/or BOL between lastc and c? */
649dc81
+		flagch = '\0';
649dc81
+		i = 0;
649dc81
+		if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
649dc81
+				(lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
649dc81
+			flagch = BOL;
649dc81
+			i = m->g->nbol;
649dc81
+		}
649dc81
+		if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
649dc81
+				(c == OUT && !(m->eflags&REG_NOTEOL)) ) {
649dc81
+			flagch = (flagch == BOL) ? BOLEOL : EOL;
649dc81
+			i += m->g->neol;
649dc81
+		}
649dc81
+		if (i != 0) {
649dc81
+			for (; i > 0; i--)
649dc81
+				st = step(m->g, startst, stopst, st, flagch, st);
649dc81
+			SP("sboleol", st, c);
649dc81
+		}
649dc81
+
649dc81
+		/* how about a word boundary? */
649dc81
+		if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
649dc81
+					(c != OUT && ISWORD(c)) ) {
649dc81
+			flagch = BOW;
649dc81
+		}
649dc81
+		if ( (lastc != OUT && ISWORD(lastc)) &&
649dc81
+				(flagch == EOL || (c != OUT && !ISWORD(c))) ) {
649dc81
+			flagch = EOW;
649dc81
+		}
649dc81
+		if (flagch == BOW || flagch == EOW) {
649dc81
+			st = step(m->g, startst, stopst, st, flagch, st);
649dc81
+			SP("sboweow", st, c);
649dc81
+		}
649dc81
+
649dc81
+		/* are we done? */
649dc81
+		if (ISSET(st, stopst))
649dc81
+			matchp = p;
649dc81
+		if (EQ(st, empty) || p == stop)
649dc81
+			break;		/* NOTE BREAK OUT */
649dc81
+
649dc81
+		/* no, we must deal with this character */
649dc81
+		ASSIGN(tmp, st);
649dc81
+		ASSIGN(st, empty);
649dc81
+		assert(c != OUT);
649dc81
+		st = step(m->g, startst, stopst, tmp, c, st);
649dc81
+		SP("saft", st, c);
649dc81
+		assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
649dc81
+		p++;
649dc81
+	}
649dc81
+
649dc81
+	return(matchp);
649dc81
+}
649dc81
+
649dc81
+
649dc81
+/*
649dc81
+ - step - map set of states reachable before char to set reachable after
649dc81
+ */
649dc81
+static states
649dc81
+step(struct re_guts *g,
649dc81
+    sopno start,		/* start state within strip */
649dc81
+    sopno stop,			/* state after stop state within strip */
649dc81
+    states bef,			/* states reachable before */
649dc81
+    int ch,			/* character or NONCHAR code */
649dc81
+    states aft)			/* states already known reachable after */
649dc81
+{
649dc81
+	cset *cs;
649dc81
+	sop s;
649dc81
+	sopno pc;
649dc81
+	onestate here;		/* note, macros know this name */
649dc81
+	sopno look;
649dc81
+	int i;
649dc81
+
649dc81
+	for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
649dc81
+		s = g->strip[pc];
649dc81
+		switch (OP(s)) {
649dc81
+		case OEND:
649dc81
+			assert(pc == stop-1);
649dc81
+			break;
649dc81
+		case OCHAR:
649dc81
+			/* only characters can match */
649dc81
+			assert(!NONCHAR(ch) || ch != (char)OPND(s));
649dc81
+			if (ch == (char)OPND(s))
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OBOL:
649dc81
+			if (ch == BOL || ch == BOLEOL)
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OEOL:
649dc81
+			if (ch == EOL || ch == BOLEOL)
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OBOW:
649dc81
+			if (ch == BOW)
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OEOW:
649dc81
+			if (ch == EOW)
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OANY:
649dc81
+			if (!NONCHAR(ch))
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OANYOF:
649dc81
+			cs = &g->sets[OPND(s)];
649dc81
+			if (!NONCHAR(ch) && CHIN(cs, ch))
649dc81
+				FWD(aft, bef, 1);
649dc81
+			break;
649dc81
+		case OBACK_:		/* ignored here */
649dc81
+		case O_BACK:
649dc81
+			FWD(aft, aft, 1);
649dc81
+			break;
649dc81
+		case OPLUS_:		/* forward, this is just an empty */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			break;
649dc81
+		case O_PLUS:		/* both forward and back */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			i = ISSETBACK(aft, OPND(s));
649dc81
+			BACK(aft, aft, OPND(s));
649dc81
+			if (!i && ISSETBACK(aft, OPND(s))) {
649dc81
+				/* oho, must reconsider loop body */
649dc81
+				pc -= OPND(s) + 1;
649dc81
+				INIT(here, pc);
649dc81
+			}
649dc81
+			break;
649dc81
+		case OQUEST_:		/* two branches, both forward */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			FWD(aft, aft, OPND(s));
649dc81
+			break;
649dc81
+		case O_QUEST:		/* just an empty */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			break;
649dc81
+		case OLPAREN:		/* not significant here */
649dc81
+		case ORPAREN:
649dc81
+			FWD(aft, aft, 1);
649dc81
+			break;
649dc81
+		case OCH_:		/* mark the first two branches */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			assert(OP(g->strip[pc+OPND(s)]) == OOR2);
649dc81
+			FWD(aft, aft, OPND(s));
649dc81
+			break;
649dc81
+		case OOR1:		/* done a branch, find the O_CH */
649dc81
+			if (ISSTATEIN(aft, here)) {
649dc81
+				for (look = 1;
649dc81
+						OP(s = g->strip[pc+look]) != O_CH;
649dc81
+						look += OPND(s))
649dc81
+					assert(OP(s) == OOR2);
649dc81
+				FWD(aft, aft, look);
649dc81
+			}
649dc81
+			break;
649dc81
+		case OOR2:		/* propagate OCH_'s marking */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			if (OP(g->strip[pc+OPND(s)]) != O_CH) {
649dc81
+				assert(OP(g->strip[pc+OPND(s)]) == OOR2);
649dc81
+				FWD(aft, aft, OPND(s));
649dc81
+			}
649dc81
+			break;
649dc81
+		case O_CH:		/* just empty */
649dc81
+			FWD(aft, aft, 1);
649dc81
+			break;
649dc81
+		default:		/* ooooops... */
649dc81
+			assert(nope);
649dc81
+			break;
649dc81
+		}
649dc81
+	}
649dc81
+
649dc81
+	return(aft);
649dc81
+}
649dc81
+
649dc81
+#ifdef REDEBUG
649dc81
+/*
649dc81
+ - print - print a set of states
649dc81
+ */
649dc81
+static void
649dc81
+print(struct match *m, char *caption, states st, int ch, FILE *d)
649dc81
+{
649dc81
+	struct re_guts *g = m->g;
649dc81
+	int i;
649dc81
+	int first = 1;
649dc81
+
649dc81
+	if (!(m->eflags&REG_TRACE))
649dc81
+		return;
649dc81
+
649dc81
+	(void)fprintf(d, "%s", caption);
649dc81
+	if (ch != '\0')
649dc81
+		(void)fprintf(d, " %s", pchar(ch));
649dc81
+	for (i = 0; i < g->nstates; i++)
649dc81
+		if (ISSET(st, i)) {
649dc81
+			(void)fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
649dc81
+			first = 0;
649dc81
+		}
649dc81
+	(void)fprintf(d, "\n");
649dc81
+}
649dc81
+
649dc81
+/* 
649dc81
+ - at - print current situation
649dc81
+ */
649dc81
+static void
649dc81
+at(struct match *m, char *title, char *start, char *stop, sopno startst,
649dc81
+    sopno stopst)
649dc81
+{
649dc81
+	if (!(m->eflags&REG_TRACE))
649dc81
+		return;
649dc81
+
649dc81
+	(void)printf("%s %s-", title, pchar(*start));
649dc81
+	(void)printf("%s ", pchar(*stop));
649dc81
+	(void)printf("%ld-%ld\n", (long)startst, (long)stopst);
649dc81
+}
649dc81
+
649dc81
+#ifndef PCHARDONE
649dc81
+#define	PCHARDONE	/* never again */
649dc81
+/*
649dc81
+ - pchar - make a character printable
649dc81
+ *
649dc81
+ * Is this identical to regchar() over in debug.c?  Well, yes.  But a
649dc81
+ * duplicate here avoids having a debugging-capable regexec.o tied to
649dc81
+ * a matching debug.o, and this is convenient.  It all disappears in
649dc81
+ * the non-debug compilation anyway, so it doesn't matter much.
649dc81
+ */
649dc81
+static char *			/* -> representation */
649dc81
+pchar(int ch)
649dc81
+{
649dc81
+	static char pbuf[10];
649dc81
+
649dc81
+	if (isprint(ch) || ch == ' ')
649dc81
+		(void)snprintf(pbuf, sizeof pbuf, "%c", ch);
649dc81
+	else
649dc81
+		(void)snprintf(pbuf, sizeof pbuf, "\\%o", ch);
649dc81
+	return(pbuf);
649dc81
+}
649dc81
+#endif
649dc81
+#endif
649dc81
+
649dc81
+#undef	matcher
649dc81
+#undef	fast
649dc81
+#undef	slow
649dc81
+#undef	dissect
649dc81
+#undef	backref
649dc81
+#undef	step
649dc81
+#undef	print
649dc81
+#undef	at
649dc81
+#undef	match
649dc81
+#undef	nope
649dc81
diff -up lldb-3.8.0rc2.src/include/lldb/Utility/regex2.h.dave lldb-3.8.0rc2.src/include/lldb/Utility/regex2.h
649dc81
--- lldb-3.8.0rc2.src/include/lldb/Utility/regex2.h.dave	2016-02-17 23:19:05.372675749 -0500
649dc81
+++ lldb-3.8.0rc2.src/include/lldb/Utility/regex2.h	2016-02-17 23:19:05.372675749 -0500
649dc81
@@ -0,0 +1,162 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993, 1994
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)regex2.h	8.4 (Berkeley) 3/20/94
649dc81
+ */
649dc81
+
649dc81
+#ifndef LLVM_SUPPORT_REGEX2_H
649dc81
+#define LLVM_SUPPORT_REGEX2_H
649dc81
+
649dc81
+/*
649dc81
+ * internals of regex_t
649dc81
+ */
649dc81
+#define	MAGIC1	((('r'^0200)<<8) | 'e')
649dc81
+
649dc81
+/*
649dc81
+ * The internal representation is a *strip*, a sequence of
649dc81
+ * operators ending with an endmarker.  (Some terminology etc. is a
649dc81
+ * historical relic of earlier versions which used multiple strips.)
649dc81
+ * Certain oddities in the representation are there to permit running
649dc81
+ * the machinery backwards; in particular, any deviation from sequential
649dc81
+ * flow must be marked at both its source and its destination.  Some
649dc81
+ * fine points:
649dc81
+ *
649dc81
+ * - OPLUS_ and O_PLUS are *inside* the loop they create.
649dc81
+ * - OQUEST_ and O_QUEST are *outside* the bypass they create.
649dc81
+ * - OCH_ and O_CH are *outside* the multi-way branch they create, while
649dc81
+ *   OOR1 and OOR2 are respectively the end and the beginning of one of
649dc81
+ *   the branches.  Note that there is an implicit OOR2 following OCH_
649dc81
+ *   and an implicit OOR1 preceding O_CH.
649dc81
+ *
649dc81
+ * In state representations, an operator's bit is on to signify a state
649dc81
+ * immediately *preceding* "execution" of that operator.
649dc81
+ */
649dc81
+typedef unsigned long sop;	/* strip operator */
649dc81
+typedef long sopno;
649dc81
+#define	OPRMASK	0xf8000000LU
649dc81
+#define	OPDMASK	0x07ffffffLU
649dc81
+#define	OPSHIFT	((unsigned)27)
649dc81
+#define	OP(n)	((n)&OPRMASK)
649dc81
+#define	OPND(n)	((n)&OPDMASK)
649dc81
+#define	SOP(op, opnd)	((op)|(opnd))
649dc81
+/* operators			   meaning	operand			*/
649dc81
+/*						(back, fwd are offsets)	*/
649dc81
+#define	OEND	(1LU<
649dc81
+#define	OCHAR	(2LU<
649dc81
+#define	OBOL	(3LU<
649dc81
+#define	OEOL	(4LU<
649dc81
+#define	OANY	(5LU<
649dc81
+#define	OANYOF	(6LU<
649dc81
+#define	OBACK_	(7LU<
649dc81
+#define	O_BACK	(8LU<
649dc81
+#define	OPLUS_	(9LU<
649dc81
+#define	O_PLUS	(10LU<
649dc81
+#define	OQUEST_	(11LU<
649dc81
+#define	O_QUEST	(12LU<
649dc81
+#define	OLPAREN	(13LU<
649dc81
+#define	ORPAREN	(14LU<
649dc81
+#define	OCH_	(15LU<
649dc81
+#define	OOR1	(16LU<
649dc81
+#define	OOR2	(17LU<
649dc81
+#define	O_CH	(18LU<
649dc81
+#define	OBOW	(19LU<
649dc81
+#define	OEOW	(20LU<
649dc81
+
649dc81
+/*
649dc81
+ * Structure for [] character-set representation.  Character sets are
649dc81
+ * done as bit vectors, grouped 8 to a byte vector for compactness.
649dc81
+ * The individual set therefore has both a pointer to the byte vector
649dc81
+ * and a mask to pick out the relevant bit of each byte.  A hash code
649dc81
+ * simplifies testing whether two sets could be identical.
649dc81
+ *
649dc81
+ * This will get trickier for multicharacter collating elements.  As
649dc81
+ * preliminary hooks for dealing with such things, we also carry along
649dc81
+ * a string of multi-character elements, and decide the size of the
649dc81
+ * vectors at run time.
649dc81
+ */
649dc81
+typedef struct {
649dc81
+	uch *ptr;		/* -> uch [csetsize] */
649dc81
+	uch mask;		/* bit within array */
649dc81
+	uch hash;		/* hash code */
649dc81
+	size_t smultis;
649dc81
+	char *multis;		/* -> char[smulti]  ab\0cd\0ef\0\0 */
649dc81
+} cset;
649dc81
+/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
649dc81
+#define	CHadd(cs, c)	((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
649dc81
+#define	CHsub(cs, c)	((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
649dc81
+#define	CHIN(cs, c)	((cs)->ptr[(uch)(c)] & (cs)->mask)
649dc81
+#define	MCadd(p, cs, cp)	mcadd(p, cs, cp)	/* llvm_regcomp() internal fns */
649dc81
+#define	MCsub(p, cs, cp)	mcsub(p, cs, cp)
649dc81
+#define	MCin(p, cs, cp)	mcin(p, cs, cp)
649dc81
+
649dc81
+/* stuff for character categories */
649dc81
+typedef unsigned char cat_t;
649dc81
+
649dc81
+/*
649dc81
+ * main compiled-expression structure
649dc81
+ */
649dc81
+struct re_guts {
649dc81
+	int magic;
649dc81
+#		define	MAGIC2	((('R'^0200)<<8)|'E')
649dc81
+	sop *strip;		/* malloced area for strip */
649dc81
+	int csetsize;		/* number of bits in a cset vector */
649dc81
+	int ncsets;		/* number of csets in use */
649dc81
+	cset *sets;		/* -> cset [ncsets] */
649dc81
+	uch *setbits;		/* -> uch[csetsize][ncsets/CHAR_BIT] */
649dc81
+	int cflags;		/* copy of llvm_regcomp() cflags argument */
649dc81
+	sopno nstates;		/* = number of sops */
649dc81
+	sopno firststate;	/* the initial OEND (normally 0) */
649dc81
+	sopno laststate;	/* the final OEND */
649dc81
+	int iflags;		/* internal flags */
649dc81
+#		define	USEBOL	01	/* used ^ */
649dc81
+#		define	USEEOL	02	/* used $ */
649dc81
+#		define	REGEX_BAD	04	/* something wrong */
649dc81
+	int nbol;		/* number of ^ used */
649dc81
+	int neol;		/* number of $ used */
649dc81
+	int ncategories;	/* how many character categories */
649dc81
+	cat_t *categories;	/* ->catspace[-CHAR_MIN] */
649dc81
+	char *must;		/* match must contain this string */
649dc81
+	int mlen;		/* length of must */
649dc81
+	size_t nsub;		/* copy of re_nsub */
649dc81
+	int backrefs;		/* does it use back references? */
649dc81
+	sopno nplus;		/* how deep does it nest +s? */
649dc81
+	/* catspace must be last */
649dc81
+	cat_t catspace[1];	/* actually [NC] */
649dc81
+};
649dc81
+
649dc81
+/* misc utilities */
649dc81
+#define	OUT	(CHAR_MAX+1)	/* a non-character value */
649dc81
+#define	ISWORD(c)	(isalnum(c&0xff) || (c) == '_')
649dc81
+
649dc81
+#endif
649dc81
diff -up lldb-3.8.0rc2.src/include/lldb/Utility/regex_impl.h.dave lldb-3.8.0rc2.src/include/lldb/Utility/regex_impl.h
649dc81
--- lldb-3.8.0rc2.src/include/lldb/Utility/regex_impl.h.dave	2016-02-17 23:19:05.372675749 -0500
649dc81
+++ lldb-3.8.0rc2.src/include/lldb/Utility/regex_impl.h	2016-02-17 23:19:05.372675749 -0500
649dc81
@@ -0,0 +1,108 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer of the University of Toronto.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)regex.h	8.1 (Berkeley) 6/2/93
649dc81
+ */
649dc81
+
649dc81
+#ifndef _REGEX_H_
649dc81
+#define	_REGEX_H_
649dc81
+
649dc81
+#include <sys/types.h>
649dc81
+typedef off_t llvm_regoff_t;
649dc81
+typedef struct {
649dc81
+  llvm_regoff_t rm_so;		/* start of match */
649dc81
+  llvm_regoff_t rm_eo;		/* end of match */
649dc81
+} llvm_regmatch_t;
649dc81
+
649dc81
+typedef struct llvm_regex {
649dc81
+  int re_magic;
649dc81
+  size_t re_nsub;		/* number of parenthesized subexpressions */
649dc81
+  const char *re_endp;	/* end pointer for REG_PEND */
649dc81
+  struct re_guts *re_g;	/* none of your business :-) */
649dc81
+} llvm_regex_t;
649dc81
+
649dc81
+/* llvm_regcomp() flags */
649dc81
+#define	REG_BASIC	0000
649dc81
+#define	REG_EXTENDED	0001
649dc81
+#define	REG_ICASE	0002
649dc81
+#define	REG_NOSUB	0004
649dc81
+#define	REG_NEWLINE	0010
649dc81
+#define	REG_NOSPEC	0020
649dc81
+#define	REG_PEND	0040
649dc81
+#define	REG_DUMP	0200
649dc81
+
649dc81
+/* llvm_regerror() flags */
649dc81
+#define	REG_NOMATCH	 1
649dc81
+#define	REG_BADPAT	 2
649dc81
+#define	REG_ECOLLATE	 3
649dc81
+#define	REG_ECTYPE	 4
649dc81
+#define	REG_EESCAPE	 5
649dc81
+#define	REG_ESUBREG	 6
649dc81
+#define	REG_EBRACK	 7
649dc81
+#define	REG_EPAREN	 8
649dc81
+#define	REG_EBRACE	 9
649dc81
+#define	REG_BADBR	10
649dc81
+#define	REG_ERANGE	11
649dc81
+#define	REG_ESPACE	12
649dc81
+#define	REG_BADRPT	13
649dc81
+#define	REG_EMPTY	14
649dc81
+#define	REG_ASSERT	15
649dc81
+#define	REG_INVARG	16
649dc81
+#define	REG_ATOI	255	/* convert name to number (!) */
649dc81
+#define	REG_ITOA	0400	/* convert number to name (!) */
649dc81
+
649dc81
+/* llvm_regexec() flags */
649dc81
+#define	REG_NOTBOL	00001
649dc81
+#define	REG_NOTEOL	00002
649dc81
+#define	REG_STARTEND	00004
649dc81
+#define	REG_TRACE	00400	/* tracing of execution */
649dc81
+#define	REG_LARGE	01000	/* force large representation */
649dc81
+#define	REG_BACKR	02000	/* force use of backref code */
649dc81
+
649dc81
+#ifdef __cplusplus
649dc81
+extern "C" {
649dc81
+#endif
649dc81
+
649dc81
+int	llvm_regcomp(llvm_regex_t *, const char *, int);
649dc81
+size_t	llvm_regerror(int, const llvm_regex_t *, char *, size_t);
649dc81
+int	llvm_regexec(const llvm_regex_t *, const char *, size_t, 
649dc81
+                     llvm_regmatch_t [], int);
649dc81
+void	llvm_regfree(llvm_regex_t *);
649dc81
+size_t  llvm_strlcpy(char *dst, const char *src, size_t siz);
649dc81
+
649dc81
+#ifdef __cplusplus
649dc81
+}
649dc81
+#endif
649dc81
+
649dc81
+#endif /* !_REGEX_H_ */
649dc81
diff -up lldb-3.8.0rc2.src/include/lldb/Utility/regutils.h.dave lldb-3.8.0rc2.src/include/lldb/Utility/regutils.h
649dc81
--- lldb-3.8.0rc2.src/include/lldb/Utility/regutils.h.dave	2016-02-17 23:19:05.372675749 -0500
649dc81
+++ lldb-3.8.0rc2.src/include/lldb/Utility/regutils.h	2016-02-17 23:19:05.372675749 -0500
649dc81
@@ -0,0 +1,58 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993, 1994
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)utils.h	8.3 (Berkeley) 3/20/94
649dc81
+ */
649dc81
+
649dc81
+#ifndef LLVM_SUPPORT_REGUTILS_H
649dc81
+#define LLVM_SUPPORT_REGUTILS_H
649dc81
+
649dc81
+/* utility definitions */
649dc81
+#define	NC		(CHAR_MAX - CHAR_MIN + 1)
649dc81
+typedef unsigned char uch;
649dc81
+
649dc81
+/* switch off assertions (if not already off) if no REDEBUG */
649dc81
+#ifndef REDEBUG
649dc81
+#ifndef NDEBUG
649dc81
+#define	NDEBUG	/* no assertions please */
649dc81
+#endif
649dc81
+#endif
649dc81
+#include <assert.h>
649dc81
+
649dc81
+/* for old systems with bcopy() but no memmove() */
649dc81
+#ifdef USEBCOPY
649dc81
+#define	memmove(d, s, c)	bcopy(s, d, c)
649dc81
+#endif
649dc81
+
649dc81
+#endif
649dc81
diff -up lldb-3.8.0rc2.src/scripts/CMakeLists.txt.dave lldb-3.8.0rc2.src/scripts/CMakeLists.txt
649dc81
--- lldb-3.8.0rc2.src/scripts/CMakeLists.txt.dave	2015-11-18 17:21:47.000000000 -0500
649dc81
+++ lldb-3.8.0rc2.src/scripts/CMakeLists.txt	2016-02-17 23:19:05.372675749 -0500
649dc81
@@ -9,6 +9,8 @@ set(SWIG_HEADERS
649dc81
   ${LLDB_SOURCE_DIR}/include/lldb/lldb-versioning.h
649dc81
 )
649dc81
 
649dc81
+include(FindPythonInterp)
649dc81
+
649dc81
 find_package(SWIG REQUIRED)
649dc81
 add_custom_command(
649dc81
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
649dc81
diff -up lldb-3.8.0rc2.src/source/Utility/CMakeLists.txt.dave lldb-3.8.0rc2.src/source/Utility/CMakeLists.txt
649dc81
--- lldb-3.8.0rc2.src/source/Utility/CMakeLists.txt.dave	2015-10-20 08:42:05.000000000 -0400
649dc81
+++ lldb-3.8.0rc2.src/source/Utility/CMakeLists.txt	2016-02-17 23:19:05.372675749 -0500
649dc81
@@ -1,3 +1,5 @@
649dc81
+include_directories(../../include/lldb/Utility)
649dc81
+
649dc81
 add_lldb_library(lldbUtility
649dc81
   ARM_DWARF_Registers.cpp
649dc81
   ARM64_DWARF_Registers.cpp
649dc81
@@ -17,4 +19,9 @@ add_lldb_library(lldbUtility
649dc81
   TaskPool.cpp
649dc81
   TimeSpecTimeout.cpp
649dc81
   UriParser.cpp
649dc81
+  regcomp.c
649dc81
+  regerror.c
649dc81
+  regexec.c
649dc81
+  regfree.c
649dc81
+  regstrlcpy.c
649dc81
   )
649dc81
diff -up lldb-3.8.0rc2.src/source/Utility/regcomp.c.dave lldb-3.8.0rc2.src/source/Utility/regcomp.c
649dc81
--- lldb-3.8.0rc2.src/source/Utility/regcomp.c.dave	2016-02-17 23:19:05.372675749 -0500
649dc81
+++ lldb-3.8.0rc2.src/source/Utility/regcomp.c	2016-02-17 23:19:05.372675749 -0500
649dc81
@@ -0,0 +1,1570 @@
649dc81
+/*-
649dc81
+ * This code is derived from OpenBSD's libc/regex, original license follows:
649dc81
+ *
649dc81
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
649dc81
+ * Copyright (c) 1992, 1993, 1994
649dc81
+ *	The Regents of the University of California.  All rights reserved.
649dc81
+ *
649dc81
+ * This code is derived from software contributed to Berkeley by
649dc81
+ * Henry Spencer.
649dc81
+ *
649dc81
+ * Redistribution and use in source and binary forms, with or without
649dc81
+ * modification, are permitted provided that the following conditions
649dc81
+ * are met:
649dc81
+ * 1. Redistributions of source code must retain the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer.
649dc81
+ * 2. Redistributions in binary form must reproduce the above copyright
649dc81
+ *    notice, this list of conditions and the following disclaimer in the
649dc81
+ *    documentation and/or other materials provided with the distribution.
649dc81
+ * 3. Neither the name of the University nor the names of its contributors
649dc81
+ *    may be used to endorse or promote products derived from this software
649dc81
+ *    without specific prior written permission.
649dc81
+ *
649dc81
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
649dc81
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
649dc81
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
649dc81
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
649dc81
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
649dc81
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
649dc81
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
649dc81
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
649dc81
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
649dc81
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
649dc81
+ * SUCH DAMAGE.
649dc81
+ *
649dc81
+ *	@(#)regcomp.c	8.5 (Berkeley) 3/20/94
649dc81
+ */
649dc81
+
649dc81
+#include <sys/types.h>
649dc81
+#include <stdio.h>
649dc81
+#include <string.h>
649dc81
+#include <ctype.h>
649dc81
+#include <limits.h>
649dc81
+#include <stdlib.h>
649dc81
+#include "regex_impl.h"
649dc81
+
649dc81
+#include "regutils.h"
649dc81
+#include "regex2.h"
649dc81
+
649dc81
+#include "regcclass.h"
649dc81
+#include "regcname.h"
649dc81
+
649dc81
+#include <stdint.h>
649dc81
+/* Pessimistically bound memory use */
649dc81
+#define SIZE_MAX UINT_MAX
649dc81
+
649dc81
+/*
649dc81
+ * parse structure, passed up and down to avoid global variables and
649dc81
+ * other clumsinesses
649dc81
+ */
649dc81
+struct parse {
649dc81
+	char *next;		/* next character in RE */
649dc81
+	char *end;		/* end of string (-> NUL normally) */
649dc81
+	int error;		/* has an error been seen? */
649dc81
+	sop *strip;		/* malloced strip */
649dc81
+	sopno ssize;		/* malloced strip size (allocated) */
649dc81
+	sopno slen;		/* malloced strip length (used) */
649dc81
+	int ncsalloc;		/* number of csets allocated */
649dc81
+	struct re_guts *g;
649dc81
+#	define	NPAREN	10	/* we need to remember () 1-9 for back refs */
649dc81
+	sopno pbegin[NPAREN];	/* -> ( ([0] unused) */
649dc81
+	sopno pend[NPAREN];	/* -> ) ([0] unused) */
649dc81
+};
649dc81
+
649dc81
+static void p_ere(struct parse *, int);
649dc81
+static void p_ere_exp(struct parse *);
649dc81
+static void p_str(struct parse *);
649dc81
+static void p_bre(struct parse *, int, int);
649dc81
+static int p_simp_re(struct parse *, int);
649dc81
+static int p_count(struct parse *);
649dc81
+static void p_bracket(struct parse *);
649dc81
+static void p_b_term(struct parse *, cset *);
649dc81
+static void p_b_cclass(struct parse *, cset *);
649dc81
+static void p_b_eclass(struct parse *, cset *);
649dc81
+static char p_b_symbol(struct parse *);
649dc81
+static char p_b_coll_elem(struct parse *, int);
649dc81
+static char othercase(int);
649dc81
+static void bothcases(struct parse *, int);
649dc81
+static void ordinary(struct parse *, int);
649dc81
+static void nonnewline(struct parse *);
649dc81
+static void repeat(struct parse *, sopno, int, int);
649dc81
+static int seterr(struct parse *, int);
649dc81
+static cset *allocset(struct parse *);
649dc81
+static void freeset(struct parse *, cset *);
649dc81
+static int freezeset(struct parse *, cset *);
649dc81
+static int firstch(struct parse *, cset *);
649dc81
+static int nch(struct parse *, cset *);
649dc81
+static void mcadd(struct parse *, cset *, const char *);
649dc81
+static void mcinvert(struct parse *, cset *);
649dc81
+static void mccase(struct parse *, cset *);
649dc81
+static int isinsets(struct re_guts *, int);
649dc81
+static int samesets(struct re_guts *, int, int);
649dc81
+static void categorize(struct parse *, struct re_guts *);
649dc81
+static sopno dupl(struct parse *, sopno, sopno);
649dc81
+static void doemit(struct parse *, sop, size_t);
649dc81
+static void doinsert(struct parse *, sop, size_t, sopno);
649dc81
+static void dofwd(struct parse *, sopno, sop);
649dc81
+static void enlarge(struct parse *, sopno);
649dc81
+static void stripsnug(struct parse *, struct re_guts *);
649dc81
+static void findmust(struct parse *, struct re_guts *);
649dc81
+static sopno pluscount(struct parse *, struct re_guts *);
649dc81
+
649dc81
+static char nuls[10];		/* place to point scanner in event of error */
649dc81
+
649dc81
+/*
649dc81
+ * macros for use with parse structure
649dc81
+ * BEWARE:  these know that the parse structure is named `p' !!!
649dc81
+ */
649dc81
+#define	PEEK()	(*p->next)
649dc81
+#define	PEEK2()	(*(p->next+1))
649dc81
+#define	MORE()	(p->next < p->end)
649dc81
+#define	MORE2()	(p->next+1 < p->end)
649dc81
+#define	SEE(c)	(MORE() && PEEK() == (c))
649dc81
+#define	SEETWO(a, b)	(MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
649dc81
+#define	EAT(c)	((SEE(c)) ? (NEXT(), 1) : 0)
649dc81
+#define	EATTWO(a, b)	((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
649dc81
+#define	NEXT()	(p->next++)
649dc81
+#define	NEXT2()	(p->next += 2)
649dc81
+#define	NEXTn(n)	(p->next += (n))
649dc81
+#define	GETNEXT()	(*p->next++)
649dc81
+#define	SETERROR(e)	seterr(p, (e))
649dc81
+#define	REQUIRE(co, e)	(void)((co) || SETERROR(e))
649dc81
+#define	MUSTSEE(c, e)	(REQUIRE(MORE() && PEEK() == (c), e))
649dc81
+#define	MUSTEAT(c, e)	(REQUIRE(MORE() && GETNEXT() == (c), e))
649dc81
+#define	MUSTNOTSEE(c, e)	(REQUIRE(!MORE() || PEEK() != (c), e))
649dc81
+#define	EMIT(op, sopnd)	doemit(p, (sop)(op), (size_t)(sopnd))
649dc81
+#define	INSERT(op, pos)	doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
649dc81
+#define	AHEAD(pos)		dofwd(p, pos, HERE()-(pos))
649dc81
+#define	ASTERN(sop, pos)	EMIT(sop, HERE()-pos)
649dc81
+#define	HERE()		(p->slen)
649dc81
+#define	THERE()		(p->slen - 1)
649dc81
+#define	THERETHERE()	(p->slen - 2)
649dc81
+#define	DROP(n)	(p->slen -= (n))
649dc81
+
649dc81
+#ifdef	_POSIX2_RE_DUP_MAX
649dc81
+#define	DUPMAX	_POSIX2_RE_DUP_MAX
649dc81
+#else
649dc81
+#define	DUPMAX	255
649dc81
+#endif
649dc81
+#define	INFINITY	(DUPMAX + 1)
649dc81
+
649dc81
+#ifndef NDEBUG
649dc81
+static int never = 0;		/* for use in asserts; shuts lint up */
649dc81
+#else
649dc81
+#define	never	0		/* some <assert.h>s have bugs too */
649dc81
+#endif
649dc81
+
649dc81
+/*
649dc81
+ - llvm_regcomp - interface for parser and compilation
649dc81
+ */
649dc81
+int				/* 0 success, otherwise REG_something */
649dc81
+llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
649dc81
+{
649dc81
+	struct parse pa;
649dc81
+	struct re_guts *g;
649dc81
+	struct parse *p = &pa;
649dc81
+	int i;
649dc81
+	size_t len;
649dc81
+#ifdef REDEBUG
649dc81
+#	define	GOODFLAGS(f)	(f)
649dc81
+#else
649dc81
+#	define	GOODFLAGS(f)	((f)&~REG_DUMP)
649dc81
+#endif
649dc81
+
649dc81
+	cflags = GOODFLAGS(cflags);
649dc81
+	if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
649dc81
+		return(REG_INVARG);
649dc81
+
649dc81
+	if (cflags&REG_PEND) {
649dc81
+		if (preg->re_endp < pattern)
649dc81
+			return(REG_INVARG);
649dc81
+		len = preg->re_endp - pattern;
649dc81
+	} else
649dc81
+		len = strlen((const char *)pattern);
649dc81
+
649dc81
+	/* do the mallocs early so failure handling is easy */
649dc81
+	g = (struct re_guts *)malloc(sizeof(struct re_guts) +
649dc81
+							(NC-1)*sizeof(cat_t));
649dc81
+	if (g == NULL)
649dc81
+		return(REG_ESPACE);
649dc81
+	p->ssize = len/(size_t)2*(size_t)3 + (size_t)1;	/* ugh */
649dc81
+	p->strip = (sop *)calloc(p->ssize, sizeof(sop));
649dc81
+	p->slen = 0;
649dc81
+	if (p->strip == NULL) {
649dc81
+		free((char *)g);
649dc81
+		return(REG_ESPACE);
649dc81
+	}
649dc81
+
649dc81
+	/* set things up */
649dc81
+	p->g = g;
649dc81
+	p->next = (char *)pattern;	/* convenience; we do not modify it */
649dc81
+	p->end = p->next + len;
649dc81
+	p->error = 0;
649dc81
+	p->ncsalloc = 0;
649dc81
+	for (i = 0; i < NPAREN; i++) {
649dc81
+		p->pbegin[i] = 0;
649dc81
+		p->pend[i] = 0;
649dc81
+	}
649dc81
+	g->csetsize = NC;
649dc81
+	g->sets = NULL;
649dc81
+	g->setbits = NULL;
649dc81
+	g->ncsets = 0;
649dc81
+	g->cflags = cflags;
649dc81
+	g->iflags = 0;
649dc81
+	g->nbol = 0;
649dc81
+	g->neol = 0;
649dc81
+	g->must = NULL;
649dc81
+	g->mlen = 0;
649dc81
+	g->nsub = 0;
649dc81
+	g->ncategories = 1;	/* category 0 is "everything else" */
649dc81
+	g->categories = &g->catspace[-(CHAR_MIN)];
649dc81
+	(void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));
649dc81
+	g->backrefs = 0;
649dc81
+
649dc81
+	/* do it */
649dc81
+	EMIT(OEND, 0);
649dc81
+	g->firststate = THERE();
649dc81
+	if (cflags&REG_EXTENDED)
649dc81
+		p_ere(p, OUT);
649dc81
+	else if (cflags&REG_NOSPEC)
649dc81
+		p_str(p);
649dc81
+	else
649dc81
+		p_bre(p, OUT, OUT);
649dc81
+	EMIT(OEND, 0);
649dc81
+	g->laststate = THERE();
649dc81
+
649dc81
+	/* tidy up loose ends and fill things in */
649dc81
+	categorize(p, g);
649dc81
+	stripsnug(p, g);
649dc81
+	findmust(p, g);
649dc81
+	g->nplus = pluscount(p, g);
649dc81
+	g->magic = MAGIC2;
649dc81
+	preg->re_nsub = g->nsub;
649dc81
+	preg->re_g = g;
649dc81
+	preg->re_magic = MAGIC1;
649dc81
+#ifndef REDEBUG
649dc81
+	/* not debugging, so can't rely on the assert() in llvm_regexec() */
649dc81
+	if (g->iflags&REGEX_BAD)
649dc81
+		SETERROR(REG_ASSERT);
649dc81
+#endif
649dc81
+
649dc81
+	/* win or lose, we're done */
649dc81
+	if (p->error != 0)	/* lose */
649dc81
+		llvm_regfree(preg);
649dc81
+	return(p->error);
649dc81
+}
649dc81
+
649dc81
+/*
649dc81
+ - p_ere - ERE parser top level, concatenation and alternation
649dc81
+ */
649dc81
+static void