3 * Monoalphabetic matcher
5 * (c) 2003 Mark Wooding
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Anag: a simple wordgame helper.
12 * Anag is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * Anag is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with Anag; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 /*----- Header files ------------------------------------------------------*/
31 /*----- Data structures ---------------------------------------------------*/
33 typedef struct node_mono {
39 /*----- Main code ---------------------------------------------------------*/
41 /* --- Matching --- */
43 static int n_mono(node *nn, const char *p, size_t sz)
45 node_mono *n = (node_mono *)nn;
46 unsigned map[UCHAR_MAX], imap[UCHAR_MAX];
47 const unsigned char *q = n->p;
52 memset(map, 0, sizeof(map));
53 memset(imap, 0, sizeof(imap));
62 } else if (map[i] != ch)
68 /* --- Node creation --- */
70 node *mono(const char *const *av)
72 unsigned char map[UCHAR_MAX];
78 node_mono *n = xmalloc(sizeof(*n));
80 memset(map, UCHAR_MAX, sizeof(map));
95 /*----- That's all, folks -------------------------------------------------*/