/* * suffie 0.01, suffix mathing tool for linguistic purposes. * * Copyright (C) 2008 Jindrich Novy (jnovy@redhat.com) * * 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; either version 2 of the License, or * (at your option) any later version. * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include char *m, *bm; off_t size; char **w, **wp, **b; int words, printed_words, blacklisted; int add_word( char *word ) { int i; for (i=0; i=m?*ww:' '; ch = ch<' '?' ':ch; putchar(ch); } printf("| %s |", word); wl = word+60; for (ww=word+strlen(word); ww tolower(p2[i]) ) return 1; } if ( !isalpha(p1[i]) && !isalpha(p2[i]) ) return 0; if ( isalpha(p1[i])) return -1; return 1; } void read_blacklist( char *name ) { FILE *f = fopen(name,"rt"); off_t size, i; if (!f) { fprintf(stderr,"Unable to read %s.\n", name); return; } fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); bm = malloc(size+1); fread(bm, 1, size, f); fclose(f); for (i=0; i\n", argv[0]); return 1; } if ( argc >= 3 ) { read_blacklist(argv[2]); } { FILE *f = fopen(argv[1],"rt"); if ( !f ) { fprintf(stderr, "Error opening %s for reading.\n", argv[1]); return 1; } fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); m = malloc(size); fread(m, 1, size, f); for (i=0; i