pcre.c, etc.: Support the PCRE2 library.
[anag] / anagram.c
index 5fc9c80..d4eb5e7 100644 (file)
--- a/anagram.c
+++ b/anagram.c
@@ -1,13 +1,11 @@
 /* -*-c-*-
  *
- * $Id: anagram.c,v 1.1 2001/02/04 17:14:42 mdw Exp $
- *
  * Matches anagrams and subgrams
  *
  * (c) 2001 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: anagram.c,v $
- * Revision 1.1  2001/02/04 17:14:42  mdw
- * Initial checkin
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include "anag.h"
@@ -86,9 +76,12 @@ static int n_gram(node *nn, const char *p, size_t sz)
   q = p + sz;
   while (p < q) {
     i = (unsigned char)*p++;
-    if (!f[i])
+    if (f[i])
+      f[i]--;
+    else if (f['.'])
+      f['.']--;
+    else
       return (0);
-    f[i]--;
   }
   return (1);
 }