]> the.earth.li Git - onak.git/blobdiff - wordlist.c
Add ability to drop overly large packets
[onak.git] / wordlist.c
index 0c2cb62c8154b22540ce749a940493fcc4c3d572..0feeb8217833eb6b375a9fce8d5c81de42dcf5e9 100644 (file)
@@ -1,18 +1,29 @@
 /*
  * wordlist.c - Routines for manipulating word lists
  *
- * Jonathan McDowell <noodles@earth.li>
+ * Copyright 2004 Jonathan McDowell <noodles@earth.li>
  *
- * Copyright 2004 Project Purple
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program 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
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "ll.h"
 #include "decodekey.h"
-#include "log.h"
+#include "keystructs.h"
 #include "wordlist.h"
 
 /**
@@ -40,11 +51,11 @@ struct ll *makewordlist(struct ll *wordlist, char *word)
        end = word;
        while (end != NULL && *end != 0) {
                start = end;
-               while (*start != 0 && !isalnum(*start)) {
+               while (*start != 0 && (ispunct(*start) || isspace (*start))) {
                        start++;
                }
                end = start;
-               while (*end != 0 && isalnum(*end)) {
+               while (*end != 0 && (!ispunct(*end) && !isspace (*end))) {
                        *end = tolower(*end);
                        end++;
                }
@@ -86,7 +97,7 @@ struct ll *makewordlistfromkey(struct ll *wordlist,
        struct ll  *wl = NULL;
 
        uids = keyuids(key, NULL);
-       for (i = 0; uids[i] != NULL; ++i) {
+       for (i = 0; uids != NULL && uids[i] != NULL; ++i) {
                words = makewordlist(NULL, uids[i]);
                for (wl = words; wl != NULL; wl = wl->next) {
                        if (llfind(wordlist, wl->object,