configure.ac, Makefile.am, pcre.c, regexp.c: Overhaul conditional building.
[anag] / pcre.c
diff --git a/pcre.c b/pcre.c
index 89ae8b4..5c5994c 100644 (file)
--- a/pcre.c
+++ b/pcre.c
@@ -1,13 +1,11 @@
 /* -*-c-*-
  *
- * $Id: pcre.c,v 1.1 2003/11/29 23:38:37 mdw Exp $
- *
  * Matches Perl-compatible regular expressions
  *
  * (c) 2002 Mark Wooding
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Anag: a simple wordgame helper.
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * Anag is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with Anag; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: pcre.c,v $
- * Revision 1.1  2003/11/29 23:38:37  mdw
- * Debianization.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
-#ifndef HAVE_PCRE
-  extern int dummy;
-#else
-
 #include "anag.h"
+
 #include <pcre.h>
 
 /*----- Data structures ---------------------------------------------------*/
@@ -68,12 +51,9 @@ static int n_pcre(node *nn, const char *p, size_t sz)
   int e;
 
   e = pcre_exec(n->rx, n->rx_study, p, sz, 0, 0, n->ovec, n->ovecsz);
-  if (e >= 0)
-    return (1);
-  if (e == PCRE_ERROR_NOMATCH)
-    return (0);
+  if (e >= 0) return (1);
+  if (e == PCRE_ERROR_NOMATCH) return (0);
   die("unexpected PCRE error code %d", e);
-  return (-1);
 }
 
 /* --- Node creation --- */
@@ -86,17 +66,16 @@ node *pcrenode(const char *const *av)
   int c;
 
   n->n.func = n_pcre;
-  if ((n->rx = pcre_compile(av[0], PCRE_CASELESS, &e, &eo, 0)) == 0)
-    die("bad regular expression `%s': %s", av[0], e);
+
+  n->rx = pcre_compile(av[0], PCRE_CASELESS, &e, &eo, 0);
+  if (!n->rx) die("bad regular expression `%s': %s", av[0], e);
   n->rx_study = pcre_study(n->rx, 0, &e);
-  if (e)
-    die("error studying pattern `%s': %s", av[0], e);
-  pcre_fullinfo(n->rx, n->rx_study, PCRE_INFO_BACKREFMAX, &c);
-  n->ovecsz = c * 2;
-  n->ovec = xmalloc(n->ovecsz * sizeof(*n->ovec));
+  if (e) die("error studying pattern `%s': %s", av[0], e);
+  pcre_fullinfo(n->rx, n->rx_study, PCRE_INFO_CAPTURECOUNT, &c);
+  n->ovecsz = 2*c;
+  n->ovec = xmalloc(n->ovecsz*sizeof(*n->ovec));
+
   return (&n->n);
 }
 
 /*----- That's all, folks -------------------------------------------------*/
-
-#endif