Hi. I just finished importing dfa.[hc] into gawk.

\s(20  THANK YOU !!! \s for all the work.  It passes make check. Attached
is a diff from grep to gawk to retain additional things I need (e.g. VMS).

FYI, I added more years in the copyright to dfa.c based on the years in
which it was published as part of gawk.

Please consider merging these into grep; they should not affect it and
then we'll be 100% in sync.

Also attached are the changes I made to xalloc.h.

I can't thank the grep team enough for making this finally happen.

Arnold
-- 
Aharon (Arnold) Robbins                         arnold AT skeeve DOT com
P.O. Box 354            Home Phone: +972  8 979-0381
Nof Ayalon              Cell Phone: +972 50  729-7545
D.N. Shimshon 99785     ISRAEL
--- /usr/local/src/Gnu/grep/src/dfa.h   2010-03-17 21:56:16.000000000 +0200
+++ dfa.h       2010-03-18 19:24:34.000000000 +0200
@@ -350,7 +350,8 @@
                                   -1 so we can count lines without wasting
                                   too many cycles.  The transition for a
                                   newline is stored separately and handled
-                                  as a special case. */
+                                  as a special case.  Newline is also used
+                                  as a sentinel at the end of the buffer. */
   struct dfamust *musts;       /* List of strings, at least one of which
                                   is known to appear in any r.e. matching
                                   the dfa. */
--- /usr/local/src/Gnu/grep/src/dfa.c   2010-03-17 21:56:16.000000000 +0200
+++ dfa.c       2010-03-18 19:27:34.000000000 +0200
@@ -1,5 +1,5 @@
 /* dfa.c - deterministic extended regexp routines for GNU
-   Copyright (C) 1988, 1998, 2000, 2002, 2004, 2008-2010 Free Software
+   Copyright (C) 1988, 1998, 2000, 2002, 2004, 2005, 2007-2010 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -20,16 +20,29 @@
 /* Written June, 1988 by Mike Haertel
    Modified July, 1988 by Arthur David Olson to assist BMG speedups  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <assert.h>
 #include <ctype.h>
 #include <stdio.h>
+
+#ifndef VMS
 #include <sys/types.h>
+#else
 #include <stddef.h>
+#endif
 #include <stdlib.h>
 #include <limits.h>
 #include <string.h>
-#include <locale.h>
+#if HAVE_SETLOCALE
+# include <locale.h>
+#endif
+#ifndef DEBUG  /* use the same approach as regex.c */
+#undef assert
+#define assert(e)
+#endif /* DEBUG */
 
 #ifndef isgraph
 #define isgraph(C) (isprint(C) && !isspace(C))
--- /usr/local/src/Gnu/grep/lib/xalloc.h        2010-03-09 21:57:00.000000000 
+0200
+++ xalloc.h    2010-03-18 23:30:01.000000000 +0200
@@ -102,6 +102,14 @@
 # define XCALLOC(n, t) \
     ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
 
+/*
+ * Gawk uses this file only to keep dfa.c happy.
+ * We're therefore safe in manually defining HAVE_INLINE to
+ * make the !...@#$%^&*() thing just work.
+ */
+#ifdef GAWK
+#define HAVE_INLINE    1       /* so there. nyah, nyah, nyah. */
+#endif
 
 # if HAVE_INLINE
 #  define static_inline static inline
@@ -126,6 +134,43 @@
   return xmalloc (n * s);
 }
 
+#ifdef GAWK
+#include <errno.h>
+/* Allocate an array of N objects, each with S bytes of memory,
+   dynamically, with error checking.  S must be nonzero.
+   Clear the contents afterwards.  */
+
+void *
+xcalloc(size_t nmemb, size_t size)
+{
+  void *p = xmalloc (nmemb * size);
+  memset(p, '\0', nmemb * size);
+  return p;
+}
+
+/* Reallocate a pointer to a new size, with error checking. */
+
+void *
+xrealloc(void *p, size_t size)
+{
+   void *new_p = realloc(p, size);
+   if (new_p ==  0)
+     xalloc_die ();
+
+   return new_p;
+}
+
+/* xalloc_die --- fatal error message when malloc fails, needed by dfa.c */
+
+void
+xalloc_die (void)
+{
+       extern void r_fatal(const char *msg, ...) ATTRIBUTE_NORETURN ;
+
+       r_fatal(_("xalloc: malloc failed: %s"), strerror(errno));
+}
+#endif
+
 /* Change the size of an allocated block of memory P to an array of N
    objects each of S bytes, with error checking.  S must be nonzero.  */
 

Reply via email to