summaryrefslogtreecommitdiff
path: root/src/myspell/affixmgr.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/myspell/affixmgr.cxx')
-rw-r--r--src/myspell/affixmgr.cxx227
1 files changed, 130 insertions, 97 deletions
diff --git a/src/myspell/affixmgr.cxx b/src/myspell/affixmgr.cxx
index d3e36be..1bcec78 100644
--- a/src/myspell/affixmgr.cxx
+++ b/src/myspell/affixmgr.cxx
@@ -20,15 +20,17 @@
#include "csutil.hxx"
#ifndef MOZILLA_CLIENT
-#ifndef W32
+#ifndef WIN32
using namespace std;
#endif
#endif
-AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr)
+AffixMgr::AffixMgr(const char * affpath, HashMgr** ptr, int * md, const char * key)
{
// register hash manager and load affix data from aff file
- pHMgr = ptr;
+ pHMgr = ptr[0];
+ alldic = ptr;
+ maxdic = md;
keystring = NULL;
trystring = NULL;
encoding=NULL;
@@ -107,7 +109,7 @@ AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr)
contclasses[j] = 0;
}
- if (parse_file(affpath)) {
+ if (parse_file(affpath, key)) {
HUNSPELL_WARNING(stderr, "Failure loading aff file %s\n",affpath);
}
@@ -244,14 +246,10 @@ AffixMgr::~AffixMgr()
// read in aff file and build up prefix and suffix entry objects
-int AffixMgr::parse_file(const char * affpath)
+int AffixMgr::parse_file(const char * affpath, const char * key)
{
-
- // io buffers
- char line[MAXLNLEN+1];
-
- // affix type
- char ft;
+ char * line; // io buffers
+ char ft; // affix type
// checking flag duplication
char dupflags[CONTSIZE];
@@ -261,8 +259,7 @@ int AffixMgr::parse_file(const char * affpath)
int firstline = 1;
// open the affix file
- FILE * afflst;
- afflst = fopen(affpath,"r");
+ FileMgr * afflst = new FileMgr(affpath, key);
if (!afflst) {
HUNSPELL_WARNING(stderr, "error: could not open affix description file %s\n",affpath);
return 1;
@@ -271,10 +268,9 @@ int AffixMgr::parse_file(const char * affpath)
// step one is to parse the affix file building up the internal
// affix data structures
-
// read in each line ignoring any that do not
// start with a known line type indicator
- while (fgets(line,MAXLNLEN,afflst)) {
+ while ((line = afflst->getline())) {
mychomp(line);
/* remove byte order mark */
@@ -289,7 +285,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the keyboard string */
if (strncmp(line,"KEY",3) == 0) {
if (parse_string(line, &keystring, "KEY")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -297,7 +293,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the try string */
if (strncmp(line,"TRY",3) == 0) {
if (parse_string(line, &trystring, "TRY")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -305,7 +301,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the name of the character set used by the .dict and .aff */
if (strncmp(line,"SET",3) == 0) {
if (parse_string(line, &encoding, "SET")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
if (strcmp(encoding, "UTF-8") == 0) {
@@ -325,7 +321,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by the controlled compound words */
if (strncmp(line,"COMPOUNDFLAG",12) == 0) {
if (parse_flag(line, &compoundflag, "COMPOUNDFLAG")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -334,12 +330,12 @@ int AffixMgr::parse_file(const char * affpath)
if (strncmp(line,"COMPOUNDBEGIN",13) == 0) {
if (complexprefixes) {
if (parse_flag(line, &compoundend, "COMPOUNDBEGIN")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
} else {
if (parse_flag(line, &compoundbegin, "COMPOUNDBEGIN")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -348,7 +344,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by compound words */
if (strncmp(line,"COMPOUNDMIDDLE",14) == 0) {
if (parse_flag(line, &compoundmiddle, "COMPOUNDMIDDLE")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -356,12 +352,12 @@ int AffixMgr::parse_file(const char * affpath)
if (strncmp(line,"COMPOUNDEND",11) == 0) {
if (complexprefixes) {
if (parse_flag(line, &compoundbegin, "COMPOUNDEND")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
} else {
if (parse_flag(line, &compoundend, "COMPOUNDEND")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -370,7 +366,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the data used by compound_check() method */
if (strncmp(line,"COMPOUNDWORDMAX",15) == 0) {
if (parse_num(line, &cpdwordmax, "COMPOUNDWORDMAX")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -378,7 +374,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag sign compounds in dictionary */
if (strncmp(line,"COMPOUNDROOT",12) == 0) {
if (parse_flag(line, &compoundroot, "COMPOUNDROOT")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -386,7 +382,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by compound_check() method */
if (strncmp(line,"COMPOUNDPERMITFLAG",18) == 0) {
if (parse_flag(line, &compoundpermitflag, "COMPOUNDPERMITFLAG")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -394,7 +390,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by compound_check() method */
if (strncmp(line,"COMPOUNDFORBIDFLAG",18) == 0) {
if (parse_flag(line, &compoundforbidflag, "COMPOUNDFORBIDFLAG")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -417,7 +413,7 @@ int AffixMgr::parse_file(const char * affpath)
if (strncmp(line,"NOSUGGEST",9) == 0) {
if (parse_flag(line, &nosuggest, "NOSUGGEST")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -425,7 +421,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by forbidden words */
if (strncmp(line,"FORBIDDENWORD",13) == 0) {
if (parse_flag(line, &forbiddenword, "FORBIDDENWORD")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -433,7 +429,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by forbidden words */
if (strncmp(line,"LEMMA_PRESENT",13) == 0) {
if (parse_flag(line, &lemma_present, "LEMMA_PRESENT")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -441,7 +437,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by circumfixes */
if (strncmp(line,"CIRCUMFIX",9) == 0) {
if (parse_flag(line, &circumfix, "CIRCUMFIX")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -449,7 +445,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by fogemorphemes */
if (strncmp(line,"ONLYINCOMPOUND",14) == 0) {
if (parse_flag(line, &onlyincompound, "ONLYINCOMPOUND")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -457,7 +453,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by `needaffixs' */
if (strncmp(line,"PSEUDOROOT",10) == 0) {
if (parse_flag(line, &needaffix, "PSEUDOROOT")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -465,7 +461,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by `needaffixs' */
if (strncmp(line,"NEEDAFFIX",9) == 0) {
if (parse_flag(line, &needaffix, "NEEDAFFIX")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -473,7 +469,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the minimal length for words in compounds */
if (strncmp(line,"COMPOUNDMIN",11) == 0) {
if (parse_num(line, &cpdmin, "COMPOUNDMIN")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
if (cpdmin < 1) cpdmin = 1;
@@ -482,7 +478,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the max. words and syllables in compounds */
if (strncmp(line,"COMPOUNDSYLLABLE",16) == 0) {
if (parse_cpdsyllable(line)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -490,7 +486,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by compound_check() method */
if (strncmp(line,"SYLLABLENUM",11) == 0) {
if (parse_string(line, &cpdsyllablenum, "SYLLABLENUM")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -503,7 +499,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the extra word characters */
if (strncmp(line,"WORDCHARS",9) == 0) {
if (parse_array(line, &wordchars, &wordchars_utf16, &wordchars_utf16_len, "WORDCHARS", utf8)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -511,7 +507,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the ignored characters (for example, Arabic optional diacretics charachters */
if (strncmp(line,"IGNORE",6) == 0) {
if (parse_array(line, &ignorechars, &ignorechars_utf16, &ignorechars_utf16_len, "IGNORE", utf8)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -519,7 +515,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the typical fault correcting table */
if (strncmp(line,"REP",3) == 0) {
if (parse_reptable(line, afflst)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -527,7 +523,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the phonetic translation table */
if (strncmp(line,"PHONE",5) == 0) {
if (parse_phonetable(line, afflst)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -535,7 +531,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the checkcompoundpattern table */
if (strncmp(line,"CHECKCOMPOUNDPATTERN",20) == 0) {
if (parse_checkcpdtable(line, afflst)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -543,7 +539,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the defcompound table */
if (strncmp(line,"COMPOUNDRULE",12) == 0) {
if (parse_defcpdtable(line, afflst)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -551,7 +547,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the related character map table */
if (strncmp(line,"MAP",3) == 0) {
if (parse_maptable(line, afflst)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -559,7 +555,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the word breakpoints table */
if (strncmp(line,"BREAK",5) == 0) {
if (parse_breaktable(line, afflst)) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -567,7 +563,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the language for language specific codes */
if (strncmp(line,"LANG",4) == 0) {
if (parse_string(line, &lang, "LANG")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
langnum = get_lang_num(lang);
@@ -575,14 +571,14 @@ int AffixMgr::parse_file(const char * affpath)
if (strncmp(line,"VERSION",7) == 0) {
if (parse_string(line, &version, "VERSION")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
if (strncmp(line,"MAXNGRAMSUGS",12) == 0) {
if (parse_num(line, &maxngramsugs, "MAXNGRAMSUGS")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -598,7 +594,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by forbidden words */
if (strncmp(line,"KEEPCASE",8) == 0) {
if (parse_flag(line, &keepcase, "KEEPCASE")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -606,7 +602,7 @@ int AffixMgr::parse_file(const char * affpath)
/* parse in the flag used by the affix generator */
if (strncmp(line,"SUBSTANDARD",11) == 0) {
if (parse_flag(line, &substandard, "SUBSTANDARD")) {
- fclose(afflst);
+ delete afflst;
return 1;
}
}
@@ -625,7 +621,7 @@ int AffixMgr::parse_file(const char * affpath)
dupflags_ini = 0;
}
if (parse_affix(line, ft, afflst, dupflags)) {
- fclose(afflst);
+ delete afflst;
process_pfx_tree_to_list();
process_sfx_tree_to_list();
return 1;
@@ -633,7 +629,7 @@ int AffixMgr::parse_file(const char * affpath)
}
}
- fclose(afflst);
+ delete afflst;
// convert affix trees to sorted list
process_pfx_tree_to_list();
@@ -671,6 +667,23 @@ int AffixMgr::parse_file(const char * affpath)
free(enc);
enc = NULL;
+#ifdef WINSHELL
+ char expw[MAXLNLEN];
+ if (wordchars) {
+ strcpy(expw, wordchars);
+ free(wordchars);
+ } else *expw = '\0';
+
+ for (int i = 0; i <= 255; i++) {
+ if ( (csconv[i].cupper != csconv[i].clower) &&
+ (! strchr(expw, (char) i))) {
+ *(expw + strlen(expw) + 1) = '\0';
+ *(expw + strlen(expw)) = (char) i;
+ }
+ }
+
+ wordchars = mystrdup(expw);
+#endif
// temporary BREAK definition for German dash handling (OOo issue 64400)
if ((langnum == LANG_de) && (!breaktable)) {
breaktable = (char **) malloc(sizeof(char *));
@@ -950,6 +963,15 @@ int AffixMgr::process_sfx_order()
return 0;
}
+// add flags to the result for dictionary debugging
+void AffixMgr::debugflag(char * result, unsigned short flag) {
+ char * st = encode_flag(flag);
+ strcat(result, " ");
+ strcat(result, MORPH_FLAG);
+ strcat(result, st);
+ free(st);
+}
+
// calculate the character length of the condition
int AffixMgr::condlen(char * st)
{
@@ -969,7 +991,7 @@ int AffixMgr::condlen(char * st)
int AffixMgr::encodeit(struct affentry * ptr, char * cs)
{
if (strcmp(cs,".") != 0) {
- ptr->numconds = condlen(cs);
+ ptr->numconds = (char) condlen(cs);
strncpy(ptr->c.conds, cs, MAXCONDLEN);
// long condition (end of conds padded by strncpy)
if (ptr->c.conds[MAXCONDLEN - 1] && cs[MAXCONDLEN]) {
@@ -1313,7 +1335,7 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry **
ok = 1;
btnum[bt - 1]--;
pp = btpp[bt - 1];
- wp = btwp[bt - 1] + btnum[bt - 1];
+ wp = btwp[bt - 1] + (signed short) btnum[bt - 1];
} while ((btnum[bt - 1] < 0) && --bt);
} while (bt);
@@ -2415,14 +2437,14 @@ char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len,
if (((PfxEntry *) ppfx)->getMorph()) {
strcat(result, ((PfxEntry *) ppfx)->getMorph());
strcat(result, " ");
- }
+ } else debugflag(result, ((PfxEntry *) ppfx)->getFlag());
}
strcat(result, st);
free(st);
if (se->getMorph()) {
strcat(result, " ");
strcat(result, se->getMorph());
- }
+ } else debugflag(result, se->getFlag());
strcat(result, "\n");
}
}
@@ -2457,7 +2479,7 @@ char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len,
if (sptr->getMorph()) {
strcat(result3, " ");
strcat(result3, sptr->getMorph());
- }
+ } else debugflag(result3, sptr->getFlag());
strlinecat(result2, result3);
strcat(result2, "\n");
strcat(result, result2);
@@ -2517,7 +2539,7 @@ char * AffixMgr::suffix_check_morph(const char * word, int len,
if (((PfxEntry *) ppfx)->getMorph()) {
strcat(result, ((PfxEntry *) ppfx)->getMorph());
strcat(result, " ");
- }
+ } else debugflag(result, ((PfxEntry *) ppfx)->getFlag());
}
if (complexprefixes && HENTRY_DATA(rv)) strcat(result, HENTRY_DATA(rv));
if (! HENTRY_FIND(rv, MORPH_STEM)) {
@@ -2529,13 +2551,13 @@ char * AffixMgr::suffix_check_morph(const char * word, int len,
// sprintf(result + strlen(result), " %s%p", MORPH_HENTRY, rv);
if (!complexprefixes && HENTRY_DATA(rv)) {
- strcat(result, " ");
- strcat(result, HENTRY_DATA(rv));
+ strcat(result, " ");
+ strcat(result, HENTRY_DATA(rv));
}
if (se->getMorph()) {
strcat(result, " ");
strcat(result, se->getMorph());
- }
+ } else debugflag(result, se->getFlag());
strcat(result, "\n");
rv = se->get_next_homonym(rv, sfxopts, ppfx, cclass, needflag);
}
@@ -2575,7 +2597,7 @@ char * AffixMgr::suffix_check_morph(const char * word, int len,
if (((PfxEntry *) ppfx)->getMorph()) {
strcat(result, ((PfxEntry *) ppfx)->getMorph());
strcat(result, " ");
- }
+ } else debugflag(result, ((PfxEntry *) ppfx)->getFlag());
}
if (complexprefixes && HENTRY_DATA(rv)) strcat(result, HENTRY_DATA(rv));
if (! HENTRY_FIND(rv, MORPH_STEM)) {
@@ -2603,7 +2625,7 @@ char * AffixMgr::suffix_check_morph(const char * word, int len,
if (sptr->getMorph()) {
strcat(result, " ");
strcat(result, sptr->getMorph());
- }
+ } else debugflag(result, sptr->getFlag());
strcat(result, "\n");
rv = sptr->get_next_homonym(rv, sfxopts, ppfx, cclass, needflag);
}
@@ -2731,7 +2753,7 @@ char * AffixMgr::morphgen(char * ts, int wl, const unsigned short * ap,
if (cmp == 0) {
char * newword = sptr->add(ts, wl);
if (newword) {
- hentry * check = pHMgr->lookup(newword);
+ hentry * check = pHMgr->lookup(newword); // XXX extra dic
if (!check || !check->astr ||
!TESTAFF(check->astr, forbiddenword, check->alen)) {
return newword;
@@ -2767,7 +2789,7 @@ char * AffixMgr::morphgen(char * ts, int wl, const unsigned short * ap,
int AffixMgr::expand_rootword(struct guessword * wlst, int maxn, const char * ts,
int wl, const unsigned short * ap, unsigned short al, char * bad, int badl,
- char * phone)
+ char * phon)
{
int nh=0;
// first add root word to list
@@ -2778,8 +2800,8 @@ int AffixMgr::expand_rootword(struct guessword * wlst, int maxn, const char * ts
wlst[nh].orig = NULL;
nh++;
// add special phonetic version
- if (phone && (nh < maxn)) {
- wlst[nh].word = mystrdup(phone);
+ if (phon && (nh < maxn)) {
+ wlst[nh].word = mystrdup(phon);
wlst[nh].allow = (1 == 0);
wlst[nh].orig = mystrdup(ts);
nh++;
@@ -2809,11 +2831,11 @@ int AffixMgr::expand_rootword(struct guessword * wlst, int maxn, const char * ts
wlst[nh].orig = NULL;
nh++;
// add special phonetic version
- if (phone && (nh < maxn)) {
+ if (phon && (nh < maxn)) {
char st[MAXWORDUTF8LEN];
- strcpy(st, phone);
+ strcpy(st, phon);
strcat(st, sptr->getKey());
- reverseword(st + strlen(phone));
+ reverseword(st + strlen(phon));
wlst[nh].word = mystrdup(st);
wlst[nh].allow = (1 == 0);
wlst[nh].orig = mystrdup(newword);
@@ -2969,6 +2991,12 @@ int AffixMgr::get_checksharps()
return checksharps;
}
+char * AffixMgr::encode_flag(unsigned short aflag)
+{
+ return pHMgr->encode_flag(aflag);
+}
+
+
// return the preferred ignore string for suggestions
char * AffixMgr::get_ignore()
{
@@ -3097,8 +3125,12 @@ FLAG AffixMgr::get_lemma_present()
// utility method to look up root words in hash table
struct hentry * AffixMgr::lookup(const char * word)
{
- if (! pHMgr) return NULL;
- return pHMgr->lookup(word);
+ int i;
+ struct hentry * he = NULL;
+ for (i = 0; i < *maxdic && !he; i++) {
+ he = (alldic[i])->lookup(word);
+ }
+ return he;
}
// return the value of suffix
@@ -3203,7 +3235,7 @@ int AffixMgr::parse_cpdsyllable(char * line)
}
/* parse in the typical fault correcting table */
-int AffixMgr::parse_reptable(char * line, FILE * af)
+int AffixMgr::parse_reptable(char * line, FileMgr * af)
{
if (numrep != 0) {
HUNSPELL_WARNING(stderr, "error: duplicate REP tables used\n");
@@ -3243,9 +3275,9 @@ int AffixMgr::parse_reptable(char * line, FILE * af)
}
/* now parse the numrep lines to read in the remainder of the table */
- char * nl = line;
+ char * nl;
for (int j=0; j < numrep; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3283,7 +3315,7 @@ int AffixMgr::parse_reptable(char * line, FILE * af)
}
/* parse in the typical fault correcting table */
-int AffixMgr::parse_phonetable(char * line, FILE * af)
+int AffixMgr::parse_phonetable(char * line, FileMgr * af)
{
if (phone) {
HUNSPELL_WARNING(stderr, "error: duplicate PHONE tables used\n");
@@ -3302,7 +3334,7 @@ int AffixMgr::parse_phonetable(char * line, FILE * af)
phone = (phonetable *) malloc(sizeof(struct phonetable));
phone->num = atoi(piece);
phone->rules = NULL;
- phone->utf8 = utf8;
+ phone->utf8 = (char) utf8;
if (!phone) return 1;
if (phone->num < 1) {
HUNSPELL_WARNING(stderr, "incorrect number of entries in phonelacement table\n");
@@ -3327,9 +3359,9 @@ int AffixMgr::parse_phonetable(char * line, FILE * af)
}
/* now parse the phone->num lines to read in the remainder of the table */
- char * nl = line;
+ char * nl;
for (int j=0; j < phone->num; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3370,7 +3402,7 @@ int AffixMgr::parse_phonetable(char * line, FILE * af)
}
/* parse in the checkcompoundpattern table */
-int AffixMgr::parse_checkcpdtable(char * line, FILE * af)
+int AffixMgr::parse_checkcpdtable(char * line, FileMgr * af)
{
if (numcheckcpd != 0) {
HUNSPELL_WARNING(stderr, "error: duplicate compound pattern tables used\n");
@@ -3410,9 +3442,9 @@ int AffixMgr::parse_checkcpdtable(char * line, FILE * af)
}
/* now parse the numcheckcpd lines to read in the remainder of the table */
- char * nl = line;
+ char * nl;
for (int j=0; j < numcheckcpd; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3450,7 +3482,7 @@ int AffixMgr::parse_checkcpdtable(char * line, FILE * af)
}
/* parse in the compound rule table */
-int AffixMgr::parse_defcpdtable(char * line, FILE * af)
+int AffixMgr::parse_defcpdtable(char * line, FileMgr * af)
{
if (numdefcpd != 0) {
HUNSPELL_WARNING(stderr, "error: duplicate compound rule tables used\n");
@@ -3490,9 +3522,9 @@ int AffixMgr::parse_defcpdtable(char * line, FILE * af)
}
/* now parse the numdefcpd lines to read in the remainder of the table */
- char * nl = line;
+ char * nl;
for (int j=0; j < numdefcpd; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3533,7 +3565,7 @@ int AffixMgr::parse_defcpdtable(char * line, FILE * af)
/* parse in the character map table */
-int AffixMgr::parse_maptable(char * line, FILE * af)
+int AffixMgr::parse_maptable(char * line, FileMgr * af)
{
if (nummap != 0) {
HUNSPELL_WARNING(stderr, "error: duplicate MAP tables used\n");
@@ -3573,9 +3605,9 @@ int AffixMgr::parse_maptable(char * line, FILE * af)
}
/* now parse the nummap lines to read in the remainder of the table */
- char * nl = line;
+ char * nl;
for (int j=0; j < nummap; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3630,7 +3662,7 @@ int AffixMgr::parse_maptable(char * line, FILE * af)
}
/* parse in the word breakpoint table */
-int AffixMgr::parse_breaktable(char * line, FILE * af)
+int AffixMgr::parse_breaktable(char * line, FileMgr * af)
{
if (numbreak != 0) {
HUNSPELL_WARNING(stderr, "error: duplicate word breakpoint tables used\n");
@@ -3670,9 +3702,9 @@ int AffixMgr::parse_breaktable(char * line, FILE * af)
}
/* now parse the numbreak lines to read in the remainder of the table */
- char * nl = line;
+ char * nl;
for (int j=0; j < numbreak; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3734,7 +3766,7 @@ void AffixMgr::reverse_condition(char * piece) {
}
}
-int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflags)
+int AffixMgr::parse_affix(char * line, const char at, FileMgr * af, char * dupflags)
{
int numents = 0; // number of affentry structures to parse
@@ -3745,7 +3777,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
struct affentry * nptr= NULL;
char * tp = line;
- char * nl = line;
+ char * nl = NULL;
char * piece;
int i = 0;
@@ -3773,7 +3805,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
HUNSPELL_WARNING(stderr, "error: duplicate affix flag %s in line %s\n", piece, nl);
// return 1; XXX permissive mode for bad dictionaries
}
- dupflags[aflag] += ((at == 'S') ? dupSFX : dupPFX);
+ dupflags[aflag] += (char) ((at == 'S') ? dupSFX : dupPFX);
break;
}
// piece 3 - is cross product indicator
@@ -3820,7 +3852,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
// now parse numents affentries for this affix
for (int j=0; j < numents; j++) {
- if (!fgets(nl,MAXLNLEN,af)) return 1;
+ if (!(nl = af->getline())) return 1;
mychomp(nl);
tp = nl;
i = 0;
@@ -3835,7 +3867,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
case 0: {
np++;
if (nptr != ptr) nptr->opts = ptr->opts &
- (aeXPRODUCT + aeUTF8 + aeALIASF + aeALIASM);
+ (char) (aeXPRODUCT + aeUTF8 + aeALIASF + aeALIASM);
break;
}
@@ -3898,6 +3930,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
if (pHMgr->is_aliasf()) {
int index = atoi(dash + 1);
nptr->contclasslen = (unsigned short) pHMgr->get_aliasf(index, &(nptr->contclass));
+ if (!nptr->contclasslen) HUNSPELL_WARNING(stderr, "error: bad affix flag alias: \"%s\"\n", dash+1);
} else {
nptr->contclasslen = (unsigned short) pHMgr->decode_flags(&(nptr->contclass), dash + 1);
flag_qsort(nptr->contclass, 0, nptr->contclasslen);