svn commit: r225717 - user/gabor/grep/trunk/regex

Gabor Kovesdan gabor at FreeBSD.org
Wed Sep 21 19:48:28 UTC 2011


Author: gabor
Date: Wed Sep 21 19:48:27 2011
New Revision: 225717
URL: http://svn.freebsd.org/changeset/base/225717

Log:
  - Add forgotten files
  
  Reported by:	aakuusta at gmail.com

Added:
  user/gabor/grep/trunk/regex/config.h   (contents, props changed)
  user/gabor/grep/trunk/regex/tre-compile.c   (contents, props changed)

Added: user/gabor/grep/trunk/regex/config.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/gabor/grep/trunk/regex/config.h	Wed Sep 21 19:48:27 2011	(r225717)
@@ -0,0 +1,156 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `isascii' function. */
+#define HAVE_ISASCII 1
+
+/* Define to 1 if you have the `isblank' function. */
+#define HAVE_ISBLANK 1
+
+/* Define to 1 if you have the `iswascii' function or macro. */
+#define HAVE_ISWASCII 1
+
+/* Define to 1 if you have the `iswblank' function or macro. */
+#define HAVE_ISWBLANK 1
+
+/* Define to 1 if you have the `iswctype' function or macro. */
+#define HAVE_ISWCTYPE 1
+
+/* Define to 1 if you have the `iswlower' function or macro. */
+#define HAVE_ISWLOWER 1
+
+/* Define to 1 if you have the `iswupper' function or macro. */
+#define HAVE_ISWUPPER 1
+
+/* Define to 1 if you have the `mbrtowc' function or macro. */
+#define HAVE_MBRTOWC 1
+
+/* Define to 1 if the system has the type `mbstate_t'. */
+#define HAVE_MBSTATE_T 1
+
+/* Define to 1 if you have the `mbtowc' function or macro. */
+#define HAVE_MBTOWC 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `towlower' function or macro. */
+#define HAVE_TOWLOWER 1
+
+/* Define to 1 if you have the `towupper' function or macro. */
+#define HAVE_TOWUPPER 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if the system has the type `wchar_t'. */
+#define HAVE_WCHAR_T 1
+
+/* Define to 1 if you have the `wcschr' function or macro. */
+#define HAVE_WCSCHR 1
+
+/* Define to 1 if you have the `wcscpy' function or macro. */
+#define HAVE_WCSCPY 1
+
+/* Define to 1 if you have the `wcslen' function or macro. */
+#define HAVE_WCSLEN 1
+
+/* Define to 1 if you have the `wcsncpy' function or macro. */
+#define HAVE_WCSNCPY 1
+
+/* Define to 1 if you have the `wcsrtombs' function or macro. */
+#define HAVE_WCSRTOMBS 1
+
+/* Define to 1 if you have the `wcstombs' function or macro. */
+#define HAVE_WCSTOMBS 1
+
+/* Define to 1 if you have the `wctype' function or macro. */
+#define HAVE_WCTYPE 1
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#define HAVE_WCTYPE_H 1
+
+/* Define to 1 if the system has the type `wint_t'. */
+#define HAVE_WINT_T 1
+
+/* Define if you want to disable debug assertions. */
+#define NDEBUG 1
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define if you want to enable approximate matching functionality. */
+#undef TRE_APPROX
+
+/* Define to enable multibyte character set support. */
+#define TRE_MULTIBYTE 1
+
+/* Define to a field in the regex_t struct where TRE should store a pointer to
+   the internal tre_tnfa_t structure */
+#define TRE_REGEX_T_FIELD value
+
+/* Define if you want TRE to use alloca() instead of malloc() when allocating
+   memory needed for regexec operations. */
+#define TRE_USE_ALLOCA 1
+
+/* TRE version string. */
+#define TRE_VERSION "0.8.0"
+
+/* TRE version level 1. */
+#define TRE_VERSION_1 0
+
+/* TRE version level 2. */
+#define TRE_VERSION_2 8
+
+/* TRE version level 3. */
+#define TRE_VERSION_3 0
+
+/* Define to enable wide character (wchar_t) support. */
+#define TRE_WCHAR 1
+
+/* Version number of package */
+#define VERSION "0.8.0"

Added: user/gabor/grep/trunk/regex/tre-compile.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/gabor/grep/trunk/regex/tre-compile.c	Wed Sep 21 19:48:27 2011	(r225717)
@@ -0,0 +1,100 @@
+#include "glue.h"
+
+#include <stdio.h>
+#include <assert.h>
+#include <regex.h>
+#include <string.h>
+#include <wchar.h>
+
+#include "xmalloc.h"
+
+int
+tre_convert_pattern(const char *regex, size_t n, tre_char_t **w,
+		    size_t *wn)
+{
+#if TRE_WCHAR
+  tre_char_t *wregex;
+  size_t wlen;
+
+  wregex = xmalloc(sizeof(tre_char_t) * (n + 1));
+  if (wregex == NULL)
+    return REG_ESPACE;
+
+  /* If the current locale uses the standard single byte encoding of
+     characters, we don't do a multibyte string conversion.  If we did,
+     many applications which use the default locale would break since
+     the default "C" locale uses the 7-bit ASCII character set, and
+     all characters with the eighth bit set would be considered invalid. */
+#if TRE_MULTIBYTE
+  if (TRE_MB_CUR_MAX == 1)
+#endif /* TRE_MULTIBYTE */
+    {
+      unsigned int i;
+      const unsigned char *str = (const unsigned char *)regex;
+      tre_char_t *wstr = wregex;
+
+      for (i = 0; i < n; i++)
+	*(wstr++) = *(str++);
+      wlen = n;
+    }
+#if TRE_MULTIBYTE
+  else
+    {
+      int consumed;
+      tre_char_t *wcptr = wregex;
+#ifdef HAVE_MBSTATE_T
+      mbstate_t state;
+      memset(&state, '\0', sizeof(state));
+#endif /* HAVE_MBSTATE_T */
+      while (n > 0)
+	{
+	  consumed = tre_mbrtowc(wcptr, regex, n, &state);
+
+	  switch (consumed)
+	    {
+	    case 0:
+	      if (*regex == '\0')
+		consumed = 1;
+	      else
+		{
+		  xfree(wregex);
+		  return REG_BADPAT;
+		}
+	      break;
+	    case -1:
+	      DPRINT(("mbrtowc: error %d: %s.\n", errno, strerror(errno)));
+	      xfree(wregex);
+	      return REG_BADPAT;
+	    case -2:
+	      /* The last character wasn't complete.  Let's not call it a
+		 fatal error. */
+	      consumed = n;
+	      break;
+	    }
+	  regex += consumed;
+	  n -= consumed;
+	  wcptr++;
+	}
+      wlen = wcptr - wregex;
+    }
+#endif /* TRE_MULTIBYTE */
+  wregex[wlen] = L'\0';
+  *w = wregex;
+  *wn = n;
+  return REG_OK;
+#else /* !TRE_WCHAR */
+  {
+    *w = (tre_char_t * const *)regex;
+    *wn = n;
+    return REG_OK;
+  }
+#endif /* !TRE_WCHAR */
+}
+
+void
+tre_free_pattern(tre_char_t *wregex)
+{
+#if TRE_WCHAR
+  xfree(wregex);
+#endif
+}


More information about the svn-src-user mailing list