diff --git a/goldlib/gall/gdefs.h b/goldlib/gall/gdefs.h index 7253f9d..38d14cc 100644 --- a/goldlib/gall/gdefs.h +++ b/goldlib/gall/gdefs.h @@ -27,13 +27,18 @@ Basic definitions and types. ------------------------------------------------------------------ */ -#ifndef __goldall_h -#define __goldall_h +#ifndef __gdefs_h +#define __gdefs_h /* ------------------------------------------------------------------ */ #include +#ifdef __WIN32__ #include +#define G_HAS_VSNPRINTF +#else +typedef char TCHAR; +#endif #ifdef __cplusplus # include #endif diff --git a/goldlib/gall/gfile.h b/goldlib/gall/gfile.h index b5bfc0e..f871a94 100644 --- a/goldlib/gall/gfile.h +++ b/goldlib/gall/gfile.h @@ -25,8 +25,8 @@ // File I/O class. // ------------------------------------------------------------------ -#ifndef __gfilbase_h -#define __gfilbase_h +#ifndef __gfile_h +#define __gfile_h // ------------------------------------------------------------------ diff --git a/goldlib/gall/gfilutil.h b/goldlib/gall/gfilutil.h index 5789e1d..17cdf6c 100644 --- a/goldlib/gall/gfilutil.h +++ b/goldlib/gall/gfilutil.h @@ -155,7 +155,7 @@ inline bool is_dir(const std::string &path) { return is_dir(path.c_str()); } #if defined(_taccess_s) inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess_s(filename, R_OK)) && !is_dir(filename)) : false; } #else -inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess(filename, R_OK)) && !is_dir(filename)) : false; } +inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (access(filename, R_OK)) && !is_dir(filename)) : false; } #endif inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); } @@ -197,8 +197,8 @@ int strschg_environ(std::string& s); char* MapPath(char* map, bool reverse = false); // gcarea.cpp inline char* ReMapPath(char* map) { return MapPath(map, true); } -inline long lseekset(int fh, long offset) { return _lseek(fh, offset, SEEK_SET); } -inline long lseekset(int fh, long record, long recordsize) { return _lseek(fh, record*recordsize, SEEK_SET); } +inline long lseekset(int fh, long offset) { return lseek(fh, offset, SEEK_SET); } +inline long lseekset(int fh, long record, long recordsize) { return lseek(fh, record*recordsize, SEEK_SET); } int gchdir(const char* dir); diff --git a/goldlib/gall/gstrall.h b/goldlib/gall/gstrall.h index 19c3c6b..bf23649 100644 --- a/goldlib/gall/gstrall.h +++ b/goldlib/gall/gstrall.h @@ -105,10 +105,10 @@ char* strunrevname(char* unreversedname, const char* name); inline char* strbtrim(char* st) { return strtrim(strltrim(st)); } -inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcscmp (str1, str2)); } -inline bool strieql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcsicmp (str1, str2)); } -inline bool strneql (const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsncmp (str1, str2, n)); } -inline bool strnieql(const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsnicmp(str1, str2, n)); } +inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == strcmp (str1, str2)); } +inline bool strieql (const TCHAR *str1, const TCHAR *str2) { return (0 == stricmp (str1, str2)); } +inline bool strneql (const TCHAR *str1, const TCHAR *str2, int n) { return (0 == strncmp (str1, str2, n)); } +inline bool strnieql(const TCHAR *str1, const TCHAR *str2, int n) { return (0 == strnicmp(str1, str2, n)); } inline const char* strskip_to(const char* p, char* s) { return p+strcspn(p, s); } inline char* strskip_to(char* p, char* s) { return p+strcspn(p, s); } @@ -163,8 +163,8 @@ public: TCHAR *First(TCHAR *buf) { token = _tcstok_s(buf, separator, &next_token); return token; } TCHAR *Next() { token = _tcstok_s(NULL, separator, &next_token); return token; } #else - TCHAR *First(TCHAR *buf) { token = _tcstok(buf, separator); return token; } - TCHAR *Next() { token = _tcstok(NULL, separator); return token; } + TCHAR *First(TCHAR *buf) { token = strtok(buf, separator); return token; } + TCHAR *Next() { token = strtok(NULL, separator); return token; } #endif TCHAR *Token() { return token; } }; diff --git a/goldlib/gall/gstrarr.h b/goldlib/gall/gstrarr.h index 8a2d24d..8ef7b88 100644 --- a/goldlib/gall/gstrarr.h +++ b/goldlib/gall/gstrarr.h @@ -52,7 +52,7 @@ inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NU TCHAR *next_token; TCHAR *token = _tcstok_s(tmp, delim, &next_token); #else - TCHAR *token = _tcstok(tmp, delim); + TCHAR *token = strtok(tmp, delim); #endif while (NULL != token) @@ -61,7 +61,7 @@ inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NU #if defined(_tcstok_s) token = _tcstok_s(NULL, delim, &next_token); #else - token = _tcstok(NULL, delim); + token = strtok(NULL, delim); #endif } diff --git a/goldlib/gall/gstrutil.cpp b/goldlib/gall/gstrutil.cpp index 1c3996b..dd2280a 100644 --- a/goldlib/gall/gstrutil.cpp +++ b/goldlib/gall/gstrutil.cpp @@ -573,7 +573,7 @@ TCHAR *strxcpy(TCHAR *d, const TCHAR *s, size_t n) #else if (n) { - _tcsncpy(d, s, n-1); + strncpy(d, s, n-1); d[n-1] = NUL; } else @@ -636,7 +636,11 @@ int gsprintf(TCHAR* buffer, size_t sizeOfBuffer, const TCHAR* __file, int __line if (ret < 0) #else buffer[sizeOfBuffer-1] = 0; - ret = _vsntprintf(buffer, sizeOfBuffer, format, argptr); + #if defined( G_HAS_VSNPRINTF ) + ret = _vsnprintf(buffer, sizeOfBuffer, format, argptr); + #else + ret = vsprintf(buffer, format, argptr); + #endif if ((ret < 0) || buffer[sizeOfBuffer-1]) #endif { diff --git a/goldlib/gall/gtimall.h b/goldlib/gall/gtimall.h index abbad7a..7f541a1 100644 --- a/goldlib/gall/gtimall.h +++ b/goldlib/gall/gtimall.h @@ -181,7 +181,7 @@ inline void gctime(TCHAR *buffer, size_t sizeInChars, const time32_t *timep) _tctime_s(buffer, sizeInChars, &zero); } #else - const char *time = _tctime(&temp); + const char *time = ctime(&temp); #if defined(__WIN32__) if (NULL == time) { diff --git a/goldlib/glibc/regex.cpp b/goldlib/glibc/regex.cpp index 2230c32..957e246 100644 --- a/goldlib/glibc/regex.cpp +++ b/goldlib/glibc/regex.cpp @@ -193,7 +193,7 @@ init_syntax_once () for (c = 0; c < 256; c++) re_syntax_table[c] = isxalnum(c) ? Sword : 0; - re_syntax_table['_'] = Sword; + re_syntax_table[int('_')] = Sword; done = 1; } diff --git a/goldlib/gmb3/gmohuds.h b/goldlib/gmb3/gmohuds.h index c399168..be8f269 100644 --- a/goldlib/gmb3/gmohuds.h +++ b/goldlib/gmb3/gmohuds.h @@ -157,8 +157,16 @@ struct HudsToIdx { // ------------------------------------------------------------------ -typedef word HudsLast[HUDS_MAXBOARD] __attribute__((packed)); -typedef word GoldLast[GOLD_MAXBOARD] __attribute__((packed)); +typedef word HudsLast[HUDS_MAXBOARD] +#ifndef __DJGPP__ + __attribute__((packed)) +#endif +; +typedef word GoldLast[GOLD_MAXBOARD] +#ifndef __DJGPP__ + __attribute__((packed)) +#endif +; // ------------------------------------------------------------------ @@ -170,7 +178,7 @@ typedef word GoldLast[GOLD_MAXBOARD] __attribute__((packed)); // ------------------------------------------------------------------ -struct HudsScan { +struct HudsScan { uint count; uint active; uint32_t lastread; @@ -286,7 +294,7 @@ protected: int load_message(int __mode, gmsg* __msg, HudsHdr& __hdr); void save_message(int __mode, gmsg* __msg, HudsHdr& __hdr); - + public: _HudsArea() { wide = NULL; } @@ -297,7 +305,7 @@ public: // ---------------------------------------------------------------- // Messagebase member functions - + void open(); void close(); diff --git a/goldlib/hunspell/affixmgr.cxx b/goldlib/hunspell/affixmgr.cxx index 53099f6..2520b10 100644 --- a/goldlib/hunspell/affixmgr.cxx +++ b/goldlib/hunspell/affixmgr.cxx @@ -16,7 +16,7 @@ using namespace std; #endif -AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr) +AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr) { // register hash manager and load affix data from aff file pHMgr = ptr; @@ -68,9 +68,9 @@ AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr) havecontclass=0; // flags of possible continuing classes (double affix) // LEMMA_PRESENT: not put root into the morphological output. Lemma presents // in morhological description in dictionary file. It's often combined with PSEUDOROOT. - lemma_present = FLAG_NULL; - circumfix = FLAG_NULL; - onlyincompound = FLAG_NULL; + lemma_present = FLAG_NULL; + circumfix = FLAG_NULL; + onlyincompound = FLAG_NULL; flag_mode = FLAG_CHAR; // default one-character flags in affix and dic file maxngramsugs = -1; // undefined nosplitsugs = 0; @@ -102,9 +102,9 @@ AffixMgr::AffixMgr(const char * affpath, HashMgr* ptr) } -AffixMgr::~AffixMgr() +AffixMgr::~AffixMgr() { - + // pass through linked prefix entries and clean up for (int i=0; i < SETSIZE ;i++) { pFlag[i] = NULL; @@ -115,7 +115,7 @@ AffixMgr::~AffixMgr() delete(ptr); ptr = nptr; nptr = NULL; - } + } } // pass through linked suffix entries and clean up @@ -136,14 +136,14 @@ AffixMgr::~AffixMgr() trystring=NULL; if (encoding) free(encoding); encoding=NULL; - if (maptable) { + if (maptable) { for (int j=0; j < nummap; j++) { if (maptable[j].set) free(maptable[j].set); if (maptable[j].set_utf16) free(maptable[j].set_utf16); maptable[j].set = NULL; maptable[j].len = 0; } - free(maptable); + free(maptable); maptable = NULL; } nummap = 0; @@ -152,37 +152,37 @@ AffixMgr::~AffixMgr() if (breaktable[j]) free(breaktable[j]); breaktable[j] = NULL; } - free(breaktable); + free(breaktable); breaktable = NULL; } numbreak = 0; - if (reptable) { + if (reptable) { for (int j=0; j < numrep; j++) { free(reptable[j].pattern); free(reptable[j].pattern2); reptable[j].pattern = NULL; reptable[j].pattern2 = NULL; } - free(reptable); + free(reptable); reptable = NULL; } - if (defcpdtable) { + if (defcpdtable) { for (int j=0; j < numdefcpd; j++) { free(defcpdtable[j].def); defcpdtable[j].def = NULL; } - free(defcpdtable); + free(defcpdtable); defcpdtable = NULL; } numrep = 0; - if (checkcpdtable) { + if (checkcpdtable) { for (int j=0; j < numcheckcpd; j++) { free(checkcpdtable[j].pattern); free(checkcpdtable[j].pattern2); checkcpdtable[j].pattern = NULL; checkcpdtable[j].pattern2 = NULL; } - free(checkcpdtable); + free(checkcpdtable); checkcpdtable = NULL; } numcheckcpd = 0; @@ -199,7 +199,7 @@ AffixMgr::~AffixMgr() FREE_FLAG(lemma_present); FREE_FLAG(circumfix); FREE_FLAG(onlyincompound); - + cpdwordmax = 0; pHMgr = NULL; cpdmin = 0; @@ -217,16 +217,16 @@ AffixMgr::~AffixMgr() } -// read in aff file and build up prefix and suffix entry objects +// read in aff file and build up prefix and suffix entry objects int AffixMgr::parse_file(const char * affpath) { // io buffers char line[MAXLNLEN+1]; - + // affix type char ft; - + // checking flag duplication char dupflags[CONTSIZE]; char dupflags_ini = 1; @@ -522,7 +522,7 @@ int AffixMgr::parse_file(const char * affpath) process_pfx_tree_to_list(); process_sfx_tree_to_list(); - // now we can speed up performance greatly taking advantage of the + // now we can speed up performance greatly taking advantage of the // relationship between the affixes and the idea of "subsets". // View each prefix as a potential leading subset of another and view @@ -535,14 +535,14 @@ int AffixMgr::parse_file(const char * affpath) // The same argument goes for suffix string that are reversed. // Then to top this off why not examine the first char of the word to quickly - // limit the set of prefixes to examine (i.e. the prefixes to examine must + // limit the set of prefixes to examine (i.e. the prefixes to examine must // be leading supersets of the first character of the word (if they exist) - + // To take advantage of this "subset" relationship, we need to add two links // from entry. One to take next if the current prefix is found (call it nexteq) // and one to take next if the current prefix is not found (call it nextne). - // Since we have built ordered lists, all that remains is to properly intialize + // Since we have built ordered lists, all that remains is to properly intialize // the nextne and nexteq pointers that relate them process_pfx_order(); @@ -576,7 +576,7 @@ int AffixMgr::parse_file(const char * affpath) // we want to be able to quickly access prefix information -// both by prefix flag, and sorted by prefix string itself +// both by prefix flag, and sorted by prefix string itself // so we need to set up two indexes int AffixMgr::build_pfxtree(AffEntry* pfxptr) @@ -610,8 +610,8 @@ int AffixMgr::build_pfxtree(AffEntry* pfxptr) unsigned char sp = *((const unsigned char *)key); ptr = (PfxEntry*)pStart[sp]; - - // handle the first insert + + // handle the first insert if (!ptr) { pStart[sp] = (AffEntry*)ep; return 0; @@ -675,8 +675,8 @@ int AffixMgr::build_sfxtree(AffEntry* sfxptr) unsigned char sp = *((const unsigned char *)key); ptr = (SfxEntry*)sStart[sp]; - - // handle the first insert + + // handle the first insert if (!ptr) { sStart[sp] = (AffEntry*)ep; return 0; @@ -757,7 +757,7 @@ int AffixMgr::process_pfx_order() ptr = (PfxEntry*)pStart[i]; // look through the remainder of the list - // and find next entry with affix that + // and find next entry with affix that // the current one is not a subset of // mark that as destination for NextNE // use next in list that you are a subset @@ -771,7 +771,7 @@ int AffixMgr::process_pfx_order() } ptr->setNextNE(nptr); ptr->setNextEQ(NULL); - if ((ptr->getNext()) && isSubset(ptr->getKey() , (ptr->getNext())->getKey())) + if ((ptr->getNext()) && isSubset(ptr->getKey() , (ptr->getNext())->getKey())) ptr->setNextEQ(ptr->getNext()); } @@ -806,7 +806,7 @@ int AffixMgr::process_sfx_order() ptr = (SfxEntry *) sStart[i]; // look through the remainder of the list - // and find next entry with affix that + // and find next entry with affix that // the current one is not a subset of // mark that as destination for NextNE // use next in list that you are a subset @@ -819,7 +819,7 @@ int AffixMgr::process_sfx_order() } ptr->setNextNE(nptr); ptr->setNextEQ(NULL); - if ((ptr->getNext()) && isSubset(ptr->getKey(),(ptr->getNext())->getKey())) + if ((ptr->getNext()) && isSubset(ptr->getKey(),(ptr->getNext())->getKey())) ptr->setNextEQ(ptr->getNext()); } @@ -904,12 +904,12 @@ int AffixMgr::encodeit(struct affentry * ptr, char * cs) c = 0; } - // end of condition + // end of condition if (c != 0) { ec = 1; } - if (ec) { + if (ec) { if (!utf8) { if (grp == 1) { if (neg == 0) { @@ -927,7 +927,7 @@ int AffixMgr::encodeit(struct affentry * ptr, char * cs) } } neg = 0; - grp = 0; + grp = 0; nm = 0; } else { // not a group so just set the proper bit for this char @@ -935,7 +935,7 @@ int AffixMgr::encodeit(struct affentry * ptr, char * cs) if (c == '.') { // wild card character so set them all for (j=0;jconds.base[j] = ptr->conds.base[j] | (1 << n); - } else { + } else { ptr->conds.base[(unsigned int) c] = ptr->conds.base[(unsigned int)c] | (1 << n); } } @@ -971,7 +971,7 @@ int AffixMgr::encodeit(struct affentry * ptr, char * cs) } } neg = 0; - grp = 0; + grp = 0; nm = 0; ptr->conds.utf8.wlen[n] = wpos - wmbr; if ((wpos - wmbr) != 0) { @@ -1007,7 +1007,7 @@ int AffixMgr::encodeit(struct affentry * ptr, char * cs) n++; ec = 0; neg = 0; - } + } } i++; @@ -1036,7 +1036,7 @@ struct hentry * AffixMgr::prefix_check(const char * word, int len, char in_compo pfx = NULL; pfxappnd = NULL; sfxappnd = NULL; - + // first handle the special case of 0 length prefixes PfxEntry * pe = (PfxEntry *) pStart[0]; while (pe) { @@ -1055,7 +1055,7 @@ struct hentry * AffixMgr::prefix_check(const char * word, int len, char in_compo } pe = pe->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)word); PfxEntry * pptr = (PfxEntry *)pStart[sp]; @@ -1080,7 +1080,7 @@ struct hentry * AffixMgr::prefix_check(const char * word, int len, char in_compo pptr = pptr->getNextNE(); } } - + return NULL; } @@ -1092,16 +1092,16 @@ struct hentry * AffixMgr::prefix_check_twosfx(const char * word, int len, pfx = NULL; sfxappnd = NULL; - + // first handle the special case of 0 length prefixes PfxEntry * pe = (PfxEntry *) pStart[0]; - + while (pe) { rv = pe->check_twosfx(word, len, in_compound, needflag); if (rv) return rv; pe = pe->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)word); PfxEntry * pptr = (PfxEntry *)pStart[sp]; @@ -1118,7 +1118,7 @@ struct hentry * AffixMgr::prefix_check_twosfx(const char * word, int len, pptr = pptr->getNextNE(); } } - + return NULL; } @@ -1134,7 +1134,7 @@ char * AffixMgr::prefix_check_morph(const char * word, int len, char in_compound pfx = NULL; sfxappnd = NULL; - + // first handle the special case of 0 length prefixes PfxEntry * pe = (PfxEntry *) pStart[0]; while (pe) { @@ -1146,7 +1146,7 @@ char * AffixMgr::prefix_check_morph(const char * word, int len, char in_compound // if (rv) return rv; pe = pe->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)word); PfxEntry * pptr = (PfxEntry *)pStart[sp]; @@ -1156,7 +1156,7 @@ char * AffixMgr::prefix_check_morph(const char * word, int len, char in_compound st = pptr->check_morph(word,len,in_compound, needflag); if (st) { // fogemorpheme - if ((in_compound != IN_CPD_NOT) || !((pptr->getCont() && + if ((in_compound != IN_CPD_NOT) || !((pptr->getCont() && (TESTAFF(pptr->getCont(), onlyincompound, pptr->getContLen()))))) { strcat(result, st); pfx = (AffEntry *)pptr; @@ -1168,7 +1168,7 @@ char * AffixMgr::prefix_check_morph(const char * word, int len, char in_compound pptr = pptr->getNextNE(); } } - + if (*result) return mystrdup(result); return NULL; } @@ -1185,7 +1185,7 @@ char * AffixMgr::prefix_check_twosfx_morph(const char * word, int len, pfx = NULL; sfxappnd = NULL; - + // first handle the special case of 0 length prefixes PfxEntry * pe = (PfxEntry *) pStart[0]; while (pe) { @@ -1196,7 +1196,7 @@ char * AffixMgr::prefix_check_twosfx_morph(const char * word, int len, } pe = pe->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)word); PfxEntry * pptr = (PfxEntry *)pStart[sp]; @@ -1214,7 +1214,7 @@ char * AffixMgr::prefix_check_twosfx_morph(const char * word, int len, pptr = pptr->getNextNE(); } } - + if (*result) return mystrdup(result); return NULL; } @@ -1286,7 +1286,7 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** short btpp[MAXWORDLEN]; // metacharacter (*, ?) positions for backtracking short btwp[MAXWORDLEN]; // word positions for metacharacters int btnum[MAXWORDLEN]; // number of matched characters in metacharacter positions - short bt = 0; + short bt = 0; int i; int ok; int w = 0; @@ -1312,7 +1312,7 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** btpp[bt] = pp; btwp[bt] = wp; while (wp <= wend) { - if (!(*words)[wp]->alen || + if (!(*words)[wp]->alen || !TESTAFF((*words)[wp]->astr, defcpdtable[i].def[pp-2], (*words)[wp]->alen)) { ok2 = 0; break; @@ -1325,7 +1325,7 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** if (ok2) break; } else { ok2 = 1; - if (!(*words)[wp] || !(*words)[wp]->alen || + if (!(*words)[wp] || !(*words)[wp]->alen || !TESTAFF((*words)[wp]->astr, defcpdtable[i].def[pp], (*words)[wp]->alen)) { ok = 0; break; @@ -1335,12 +1335,12 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** if ((defcpdtable[i].len == pp) && !(wp > wnum)) ok = 0; } } - if (ok && ok2) { + if (ok && ok2) { int r = pp; while ((defcpdtable[i].len > r) && ((r+1) < defcpdtable[i].len) && ((defcpdtable[i].def[r+1] == '*') || (defcpdtable[i].def[r+1] == '?'))) r+=2; if (defcpdtable[i].len <= r) return 1; - } + } // backtrack if (bt) do { ok = 1; @@ -1350,7 +1350,7 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** } while ((btnum[bt - 1] < 0) && --bt); } while (bt); - if (ok && ok2 && (!all || (defcpdtable[i].len <= pp))) return 1; + if (ok && ok2 && (!all || (defcpdtable[i].len <= pp))) return 1; // check zero ending while (ok && ok2 && (defcpdtable[i].len > pp) && ((pp+1) < defcpdtable[i].len) && ((defcpdtable[i].def[pp+1] == '*') || (defcpdtable[i].def[pp+1] == '?'))) pp+=2; @@ -1364,13 +1364,13 @@ int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** inline int AffixMgr::candidate_check(const char * word, int len) { struct hentry * rv=NULL; - + rv = lookup(word); if (rv) return 1; // rv = prefix_check(word,len,1); // if (rv) return 1; - + rv = affix_check(word,len); if (rv) return 1; return 0; @@ -1380,7 +1380,7 @@ inline int AffixMgr::candidate_check(const char * word, int len) int AffixMgr::get_syllable(const char * word, int wlen) { if (cpdmaxsyllable==0) return 0; - + int num=0; if (!utf8) { @@ -1400,7 +1400,7 @@ int AffixMgr::get_syllable(const char * word, int wlen) // check if compound word is correctly spelled // hu_mov_rule = spec. Hungarian rule (XXX) -struct hentry * AffixMgr::compound_check(const char * word, int len, +struct hentry * AffixMgr::compound_check(const char * word, int len, short wordnum, short numsyllable, short maxwordnum, short wnum, hentry ** words = NULL, char hu_mov_rule = 0, int * cmpdstemnum = NULL, int * cmpdstem = NULL, char is_sug = 0) { @@ -1413,7 +1413,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, char ch; int cmin; int cmax; - + int checked_prefix; #ifdef HUNSTEM @@ -1459,7 +1459,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, sfx = NULL; pfx = NULL; - + // FIRST WORD rv = lookup(st); // perhaps without prefix @@ -1480,14 +1480,14 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, } if (!rv) { - if (compoundflag && + if (compoundflag && !(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { if ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && ((SfxEntry*)sfx)->getCont() && - ((compoundforbidflag && TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, + ((compoundforbidflag && TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, ((SfxEntry*)sfx)->getContLen())) || (compoundend && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; } @@ -1502,7 +1502,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, ) checked_prefix = 1; // else check forbiddenwords and pseudoroot } else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || - TESTAFF(rv->astr, pseudoroot, rv->alen) || + TESTAFF(rv->astr, pseudoroot, rv->alen) || (is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)) )) { st[i] = ch; @@ -1512,10 +1512,10 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, // check non_compound flag in suffix and prefix if ((rv) && !hu_mov_rule && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; } @@ -1523,24 +1523,24 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, // check compoundend flag in suffix and prefix if ((rv) && !checked_prefix && compoundend && !hu_mov_rule && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundend, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundend, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; } - + // check compoundmiddle flag in suffix and prefix if ((rv) && !checked_prefix && (wordnum==0) && compoundmiddle && !hu_mov_rule && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundmiddle, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundmiddle, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundmiddle, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundmiddle, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; - } + } // check forbiddenwords if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || @@ -1549,13 +1549,13 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, } // increment word number, if the second root has a compoundroot flag - if ((rv) && compoundroot && + if ((rv) && compoundroot && (TESTAFF(rv->astr, compoundroot, rv->alen))) { wordnum++; } // first word is acceptable in compound words? - if (((rv) && + if (((rv) && ( checked_prefix || (words && words[wnum]) || (compoundflag && TESTAFF(rv->astr, compoundflag, rv->alen)) || ((oldwordnum == 0) && compoundbegin && TESTAFF(rv->astr, compoundbegin, rv->alen)) || @@ -1573,15 +1573,15 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, ) && ! (( checkcompoundtriple && // test triple letters (word[i-1]==word[i]) && ( - ((i>1) && (word[i-1]==word[i-2])) || + ((i>1) && (word[i-1]==word[i-2])) || ((word[i-1]==word[i+1])) // may be word[i+1] == '\0' ) ) || - ( + ( // test CHECKCOMPOUNDPATTERN numcheckcpd && cpdpat_check(word, i) ) || - ( + ( checkcompoundcase && cpdcase_check(word, i) )) ) @@ -1590,7 +1590,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, (sfx && ((SfxEntry*)sfx)->getCont() && ( // XXX hardwired Hungarian dic. codes TESTAFF(((SfxEntry*)sfx)->getCont(), (unsigned short) 'x', ((SfxEntry*)sfx)->getContLen()) || TESTAFF(((SfxEntry*)sfx)->getCont(), (unsigned short) '%', ((SfxEntry*)sfx)->getContLen()) - ) + ) ) ) // END of LANG_hu section @@ -1598,7 +1598,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, // LANG_hu section: spec. Hungarian rule if (langnum == LANG_hu) { - // calculate syllable number of the word + // calculate syllable number of the word numsyllable += get_syllable(st, i); // + 1 word, if syllable number of the prefix > 1 (hungarian convention) @@ -1634,7 +1634,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, // END of LANG_hu section // increment word number, if the second root has a compoundroot flag - if ((rv) && (compoundroot) && + if ((rv) && (compoundroot) && (TESTAFF(rv->astr, compoundroot, rv->alen))) { wordnum++; } @@ -1653,8 +1653,8 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, (compoundend && TESTAFF(rv->astr, compoundend, rv->alen)) ) && ( - ((cpdwordmax==0) || (wordnum+1word,rv->wlen)<=cpdmaxsyllable)) ) && ( @@ -1679,19 +1679,19 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, pfx = NULL; rv = affix_check((word+i),strlen(word+i), compoundend, IN_CPD_END); } - + if (!rv && numdefcpd && words) { rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END); if (rv && defcpd_check(&words, wnum + 1, rv, NULL, 1)) return rv; } // check non_compound flag in suffix and prefix - if ((rv) && + if ((rv) && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; } @@ -1708,7 +1708,7 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, if (langnum == LANG_hu) { // calculate syllable number of the word numsyllable += get_syllable(word + i, strlen(word + i)); - + // - affix syllable num. // XXX only second suffix (inflections, not derivations) if (sfxappnd) { @@ -1716,13 +1716,13 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, numsyllable -= get_syllable(tmp, strlen(tmp)); free(tmp); } - + // + 1 word, if syllable number of the prefix > 1 (hungarian convention) if (pfx && (get_syllable(((PfxEntry *)pfx)->getKey(),strlen(((PfxEntry *)pfx)->getKey())) > 1)) wordnum++; // increment syllable num, if last word has a SYLLABLENUM flag // and the suffix is beginning `s' - + if (cpdsyllablenum) { switch (sfxflag) { case 'c': { numsyllable+=2; break; } @@ -1731,9 +1731,9 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, } } } - + // increment word number, if the second word has a compoundroot flag - if ((rv) && (compoundroot) && + if ((rv) && (compoundroot) && (TESTAFF(rv->astr, compoundroot, rv->alen))) { wordnum++; } @@ -1742,10 +1742,10 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, // hungarian conventions: compounding is acceptable, // when compound forms consist 2 word, otherwise // the syllable number of root words is 6, or lesser. - if ((rv) && + if ((rv) && ( - ((cpdwordmax ==0 ) || (wordnum + 1 < cpdwordmax)) || - ((cpdmaxsyllable == 0) || + ((cpdwordmax ==0 ) || (wordnum + 1 < cpdwordmax)) || + ((cpdmaxsyllable == 0) || (numsyllable <= cpdmaxsyllable)) ) && ( @@ -1783,14 +1783,14 @@ struct hentry * AffixMgr::compound_check(const char * word, int len, wordnum = oldwordnum; numsyllable = oldnumsyllable; } - + return NULL; -} +} // check if compound word is correctly spelled // hu_mov_rule = spec. Hungarian rule (XXX) -int AffixMgr::compound_check_morph(const char * word, int len, +int AffixMgr::compound_check_morph(const char * word, int len, short wordnum, short numsyllable, short maxwordnum, short wnum, hentry ** words, char hu_mov_rule = 0, char ** result = NULL, char * partresult = NULL) { @@ -1802,13 +1802,13 @@ int AffixMgr::compound_check_morph(const char * word, int len, struct hentry * rwords[MAXWORDLEN]; // buffer for COMPOUND pattern checking char st [MAXWORDUTF8LEN + 4]; char ch; - + int checked_prefix; char presult[MAXLNLEN]; int cmin; int cmax; - + if (utf8) { for (cmin = 0, i = 0; (i < cpdmin) && word[cmin]; i++) { cmin++; @@ -1847,7 +1847,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, rv = lookup(st); // perhaps without prefix // search homonym with compound flag - while ((rv) && !hu_mov_rule && + while ((rv) && !hu_mov_rule && ((pseudoroot && TESTAFF(rv->astr, pseudoroot, rv->alen)) || !((compoundflag && !words && TESTAFF(rv->astr, compoundflag, rv->alen)) || (compoundbegin && !wordnum && @@ -1868,21 +1868,21 @@ int AffixMgr::compound_check_morph(const char * word, int len, strcat(presult, rv->description); } } - + if (!rv) { - if (compoundflag && + if (compoundflag && !(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { if ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && ((SfxEntry*)sfx)->getCont() && - ((compoundforbidflag && TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, + ((compoundforbidflag && TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, ((SfxEntry*)sfx)->getContLen())) || (compoundend && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; } } - + if (rv || (((wordnum == 0) && compoundbegin && ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundbegin, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) || @@ -1898,7 +1898,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, if ((wordnum == 0) && compoundbegin) { p = affix_check_morph(st, i, compoundbegin); } else if ((wordnum > 0) && compoundmiddle) { - p = affix_check_morph(st, i, compoundmiddle); + p = affix_check_morph(st, i, compoundmiddle); } } if (*p != '\0') { @@ -1927,10 +1927,10 @@ int AffixMgr::compound_check_morph(const char * word, int len, // check non_compound flag in suffix and prefix if ((rv) && !hu_mov_rule && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, ((SfxEntry*)sfx)->getContLen())))) { continue; } @@ -1938,10 +1938,10 @@ int AffixMgr::compound_check_morph(const char * word, int len, // check compoundend flag in suffix and prefix if ((rv) && !checked_prefix && compoundend && !hu_mov_rule && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundend, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundend, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundend, ((SfxEntry*)sfx)->getContLen())))) { continue; } @@ -1949,29 +1949,29 @@ int AffixMgr::compound_check_morph(const char * word, int len, // check compoundmiddle flag in suffix and prefix if ((rv) && !checked_prefix && (wordnum==0) && compoundmiddle && !hu_mov_rule && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundmiddle, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundmiddle, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundmiddle, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundmiddle, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; - } + } // check forbiddenwords if ((rv) && (rv->astr) && TESTAFF(rv->astr, forbiddenword, rv->alen)) continue; // increment word number, if the second root has a compoundroot flag - if ((rv) && (compoundroot) && + if ((rv) && (compoundroot) && (TESTAFF(rv->astr, compoundroot, rv->alen))) { wordnum++; } // first word is acceptable in compound words? - if (((rv) && + if (((rv) && ( checked_prefix || (words && words[wnum]) || (compoundflag && TESTAFF(rv->astr, compoundflag, rv->alen)) || ((oldwordnum == 0) && compoundbegin && TESTAFF(rv->astr, compoundbegin, rv->alen)) || - ((oldwordnum > 0) && compoundmiddle && TESTAFF(rv->astr, compoundmiddle, rv->alen)) + ((oldwordnum > 0) && compoundmiddle && TESTAFF(rv->astr, compoundmiddle, rv->alen)) // LANG_hu section: spec. Hungarian rule || ((langnum == LANG_hu) && // hu_mov_rule hu_mov_rule && ( @@ -1984,7 +1984,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, ) && ! (( checkcompoundtriple && // test triple letters (word[i-1]==word[i]) && ( - ((i>1) && (word[i-1]==word[i-2])) || + ((i>1) && (word[i-1]==word[i-2])) || ((word[i-1]==word[i+1])) // may be word[i+1] == '\0' ) ) || @@ -1992,7 +1992,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, // test CHECKCOMPOUNDPATTERN numcheckcpd && cpdpat_check(word, i) ) || - ( + ( checkcompoundcase && cpdcase_check(word, i) )) ) @@ -2001,7 +2001,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, (sfx && ((SfxEntry*)sfx)->getCont() && ( TESTAFF(((SfxEntry*)sfx)->getCont(), (unsigned short) 'x', ((SfxEntry*)sfx)->getContLen()) || TESTAFF(((SfxEntry*)sfx)->getCont(), (unsigned short) '%', ((SfxEntry*)sfx)->getContLen()) - ) + ) ) ) // END of LANG_hu section @@ -2032,7 +2032,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, if (rv && words && words[wnum + 1]) { strcat(*result, presult); if (complexprefixes && rv->description) strcat(*result, rv->description); - if (rv->description && ((!rv->astr) || + if (rv->description && ((!rv->astr) || !TESTAFF(rv->astr, lemma_present, rv->alen))) strcat(*result, rv->word); if (!complexprefixes && rv->description) strcat(*result, rv->description); @@ -2050,7 +2050,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, } // END of LANG_hu section // increment word number, if the second root has a compoundroot flag - if ((rv) && (compoundroot) && + if ((rv) && (compoundroot) && (TESTAFF(rv->astr, compoundroot, rv->alen))) { wordnum++; } @@ -2060,7 +2060,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, st[i] = ch; continue; } - + // second word is acceptable, as a root? // hungarian conventions: compounding is acceptable, // when compound forms consist of 2 words, or if more, @@ -2070,8 +2070,8 @@ int AffixMgr::compound_check_morph(const char * word, int len, (compoundend && TESTAFF(rv->astr, compoundend, rv->alen)) ) && ( - ((cpdwordmax==0) || (wordnum+1word,rv->wlen)<=cpdmaxsyllable)) ) && ( @@ -2081,7 +2081,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, { // bad compound word strcat(*result, presult); - + if (rv->description) { if (complexprefixes) strcat(*result, rv->description); if ((!rv->astr) || !TESTAFF(rv->astr, lemma_present, rv->alen)) @@ -2130,12 +2130,12 @@ int AffixMgr::compound_check_morph(const char * word, int len, } // check non_compound flag in suffix and prefix - if ((rv) && + if ((rv) && ((pfx && ((PfxEntry*)pfx)->getCont() && - TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, + TESTAFF(((PfxEntry*)pfx)->getCont(), compoundforbidflag, ((PfxEntry*)pfx)->getContLen())) || (sfx && ((SfxEntry*)sfx)->getCont() && - TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, + TESTAFF(((SfxEntry*)sfx)->getCont(), compoundforbidflag, ((SfxEntry*)sfx)->getContLen())))) { rv = NULL; } @@ -2175,7 +2175,7 @@ int AffixMgr::compound_check_morph(const char * word, int len, } // increment word number, if the second word has a compoundroot flag - if ((rv) && (compoundroot) && + if ((rv) && (compoundroot) && (TESTAFF(rv->astr, compoundroot, rv->alen))) { wordnum++; } @@ -2183,10 +2183,10 @@ int AffixMgr::compound_check_morph(const char * word, int len, // hungarian conventions: compounding is acceptable, // when compound forms consist 2 word, otherwise // the syllable number of root words is 6, or lesser. - if ((rv) && + if ((rv) && ( - ((cpdwordmax==0) || (wordnum+1getContLen())) && (se->getCont() && (TESTAFF(se->getCont(),circumfix,se->getContLen()))))) && // fogemorpheme - (in_compound || + (in_compound || !((se->getCont() && (TESTAFF(se->getCont(), onlyincompound, se->getContLen()))))) && // pseudoroot on prefix or first suffix - (cclass || + (cclass || !(se->getCont() && TESTAFF(se->getCont(), pseudoroot, se->getContLen())) || (ppfx && !((ep->getCont()) && TESTAFF(ep->getCont(), pseudoroot, @@ -2288,7 +2288,7 @@ struct hentry * AffixMgr::suffix_check (const char * word, int len, } se = se->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)(word + len - 1)); SfxEntry * sptr = (SfxEntry *) sStart[sp]; @@ -2310,10 +2310,10 @@ struct hentry * AffixMgr::suffix_check (const char * word, int len, circumfix, ep->getContLen())) && (sptr->getCont() && (TESTAFF(sptr->getCont(),circumfix,sptr->getContLen()))))) && // fogemorpheme - (in_compound || + (in_compound || !((sptr->getCont() && (TESTAFF(sptr->getCont(), onlyincompound, sptr->getContLen()))))) && // pseudoroot on prefix or first suffix - (cclass || + (cclass || !(sptr->getCont() && TESTAFF(sptr->getCont(), pseudoroot, sptr->getContLen())) || (ppfx && !((ep->getCont()) && TESTAFF(ep->getCont(), pseudoroot, @@ -2348,7 +2348,7 @@ struct hentry * AffixMgr::suffix_check (const char * word, int len, // check word for two-level suffixes -struct hentry * AffixMgr::suffix_check_twosfx(const char * word, int len, +struct hentry * AffixMgr::suffix_check_twosfx(const char * word, int len, int sfxopts, AffEntry * ppfx, const FLAG needflag) { struct hentry * rv = NULL; @@ -2363,7 +2363,7 @@ struct hentry * AffixMgr::suffix_check_twosfx(const char * word, int len, } se = se->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)(word + len - 1)); SfxEntry * sptr = (SfxEntry *) sStart[sp]; @@ -2389,13 +2389,13 @@ struct hentry * AffixMgr::suffix_check_twosfx(const char * word, int len, } -char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len, +char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len, int sfxopts, AffEntry * ppfx, const FLAG needflag) { char result[MAXLNLEN]; char result2[MAXLNLEN]; char result3[MAXLNLEN]; - + char * st; result[0] = '\0'; @@ -2420,14 +2420,14 @@ char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len, } se = se->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)(word + len - 1)); SfxEntry * sptr = (SfxEntry *) sStart[sp]; while (sptr) { if (isRevSubset(sptr->getKey(), word + len - 1, len)) { - if (contclasses[sptr->getFlag()]) + if (contclasses[sptr->getFlag()]) { st = sptr->check_twosfx_morph(word,len, sfxopts, ppfx, needflag); if (st) { @@ -2443,8 +2443,8 @@ char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len, if (flag_mode == FLAG_NUM) { sprintf(result3, "%d", sptr->getKey()); } else if (flag_mode == FLAG_LONG) { - sprintf(result3, "%c%c", flagch[0], flagch[1]); - } else sprintf(result3, "%c", flagch[1]); + sprintf(result3, "%c%c", flagch[0], flagch[1]); + } else sprintf(result3, "%c", flagch[1]); strcat(result3, ":"); #endif if (sptr->getMorph()) strcat(result3, sptr->getMorph()); @@ -2462,11 +2462,11 @@ char * AffixMgr::suffix_check_twosfx_morph(const char * word, int len, return NULL; } -char * AffixMgr::suffix_check_morph(const char * word, int len, +char * AffixMgr::suffix_check_morph(const char * word, int len, int sfxopts, AffEntry * ppfx, const FLAG cclass, const FLAG needflag, char in_compound) { char result[MAXLNLEN]; - + struct hentry * rv = NULL; result[0] = '\0'; @@ -2491,10 +2491,10 @@ char * AffixMgr::suffix_check_morph(const char * word, int len, circumfix, ep->getContLen())) && (se->getCont() && (TESTAFF(se->getCont(),circumfix,se->getContLen()))))) && // fogemorpheme - (in_compound || + (in_compound || !((se->getCont() && (TESTAFF(se->getCont(), onlyincompound, se->getContLen()))))) && // pseudoroot on prefix or first suffix - (cclass || + (cclass || !(se->getCont() && TESTAFF(se->getCont(), pseudoroot, se->getContLen())) || (ppfx && !((ep->getCont()) && TESTAFF(ep->getCont(), pseudoroot, @@ -2507,7 +2507,7 @@ char * AffixMgr::suffix_check_morph(const char * word, int len, if (((PfxEntry *) ppfx)->getMorph()) strcat(result, ((PfxEntry *) ppfx)->getMorph()); } if (complexprefixes && rv->description) strcat(result, rv->description); - if (rv->description && ((!rv->astr) || + if (rv->description && ((!rv->astr) || !TESTAFF(rv->astr, lemma_present, rv->alen))) strcat(result, rv->word); if (!complexprefixes && rv->description) strcat(result, rv->description); @@ -2518,7 +2518,7 @@ char * AffixMgr::suffix_check_morph(const char * word, int len, } se = se->getNext(); } - + // now handle the general case unsigned char sp = *((const unsigned char *)(word + len - 1)); SfxEntry * sptr = (SfxEntry *) sStart[sp]; @@ -2540,18 +2540,18 @@ char * AffixMgr::suffix_check_morph(const char * word, int len, circumfix, ep->getContLen())) && (sptr->getCont() && (TESTAFF(sptr->getCont(),circumfix,sptr->getContLen()))))) && // fogemorpheme - (in_compound || + (in_compound || !((sptr->getCont() && (TESTAFF(sptr->getCont(), onlyincompound, sptr->getContLen()))))) && // pseudoroot on first suffix - (cclass || !(sptr->getCont() && + (cclass || !(sptr->getCont() && TESTAFF(sptr->getCont(), pseudoroot, sptr->getContLen()))) )) rv = sptr->check(word,len, sfxopts, ppfx, NULL, 0, 0, cclass, needflag); while (rv) { if (ppfx) { if (((PfxEntry *) ppfx)->getMorph()) strcat(result, ((PfxEntry *) ppfx)->getMorph()); - } + } if (complexprefixes && rv->description) strcat(result, rv->description); - if (rv->description && ((!rv->astr) || + if (rv->description && ((!rv->astr) || !TESTAFF(rv->astr, lemma_present, rv->alen))) strcat(result, rv->word); if (!complexprefixes && rv->description) strcat(result, rv->description); #ifdef DEBUG @@ -2560,8 +2560,8 @@ char * AffixMgr::suffix_check_morph(const char * word, int len, if (flag_mode == FLAG_NUM) { sprintf(result2, "%d", sptr->getKey()); } else if (flag_mode == FLAG_LONG) { - sprintf(result2, "%c%c", flagch[0], flagch[1]); - } else sprintf(result2, "%c", flagch[1]); + sprintf(result2, "%c%c", flagch[0], flagch[1]); + } else sprintf(result2, "%c", flagch[1]); strcat(result2, ":"); strcat(result, result2); #endif @@ -2588,7 +2588,7 @@ struct hentry * AffixMgr::affix_check (const char * word, int len, const FLAG ne if (derived) free(derived); derived = NULL; - // check all prefixes (also crossed with suffixes if allowed) + // check all prefixes (also crossed with suffixes if allowed) rv = prefix_check(word, len, in_compound, needflag); if (rv) return rv; @@ -2616,15 +2616,15 @@ char * AffixMgr::affix_check_morph(const char * word, int len, const FLAG needfl char * st = NULL; *result = '\0'; - - // check all prefixes (also crossed with suffixes if allowed) + + // check all prefixes (also crossed with suffixes if allowed) st = prefix_check_morph(word, len, in_compound); if (st) { strcat(result, st); free(st); } - // if still not found check all suffixes + // if still not found check all suffixes st = suffix_check_morph(word, len, 0, NULL, '\0', needflag, in_compound); if (st) { strcat(result, st); @@ -2648,7 +2648,7 @@ char * AffixMgr::affix_check_morph(const char * word, int len, const FLAG needfl free(st); } } - + return mystrdup(result); } @@ -2675,16 +2675,16 @@ int AffixMgr::expand_rootword(struct guessword * wlst, int maxn, const char * ts if (!sptr->getKeyLen() || ((badl > sptr->getKeyLen()) && (strcmp(sptr->getAffix(), bad + badl - sptr->getKeyLen()) == 0)) && // check pseudoroot flag - !(sptr->getCont() && ((pseudoroot && + !(sptr->getCont() && ((pseudoroot && TESTAFF(sptr->getCont(), pseudoroot, sptr->getContLen())) || - (onlyincompound && + (onlyincompound && TESTAFF(sptr->getCont(), onlyincompound, sptr->getContLen())))) ) { char * newword = sptr->add(ts, wl); if (newword) { if (nh < maxn) { wlst[nh].word = newword; - wlst[nh].allow = sptr->allowCross(); + wlst[nh].allow = sptr->allowCross(); nh++; } else { free(newword); @@ -2732,9 +2732,9 @@ int AffixMgr::expand_rootword(struct guessword * wlst, int maxn, const char * ts if (!ptr->getKeyLen() || ((badl > ptr->getKeyLen()) && (strncmp(ptr->getKey(), bad, ptr->getKeyLen()) == 0)) && // check pseudoroot flag - !(ptr->getCont() && ((pseudoroot && + !(ptr->getCont() && ((pseudoroot && TESTAFF(ptr->getCont(), pseudoroot, ptr->getContLen())) || - (onlyincompound && + (onlyincompound && TESTAFF(ptr->getCont(), onlyincompound, ptr->getContLen())))) ) { char * newword = ptr->add(ts, wl); @@ -2745,7 +2745,7 @@ int AffixMgr::expand_rootword(struct guessword * wlst, int maxn, const char * ts nh++; } else { free(newword); - } + } } } ptr = (PfxEntry *)ptr ->getFlgNxt(); @@ -2999,7 +2999,7 @@ int AffixMgr::parse_try(char * line) if (np != 2) { fprintf(stderr,"error: missing TRY information\n"); return 1; - } + } return 0; } @@ -3019,7 +3019,7 @@ int AffixMgr::parse_set(char * line) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { encoding = mystrdup(piece); + case 1: { encoding = mystrdup(piece); if (strcmp(encoding, "UTF-8") == 0) { unicode_info * uni = get_utf_cs(); utf8 = 1; @@ -3050,7 +3050,7 @@ int AffixMgr::parse_set(char * line) if (np != 2) { fprintf(stderr,"error: missing SET information\n"); return 1; - } + } return 0; } @@ -3069,7 +3069,7 @@ int AffixMgr::parse_flag(char * line, unsigned short * out, char * name) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { *out = pHMgr->decode_flag(piece); np++; break; @@ -3083,7 +3083,7 @@ int AffixMgr::parse_flag(char * line, unsigned short * out, char * name) if (np != 2) { fprintf(stderr,"error: missing %s information\n", name); return 1; - } + } return 0; } @@ -3098,7 +3098,7 @@ int AffixMgr::parse_num(char * line, int * out, char * name) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { *out = atoi(piece); np++; break; @@ -3112,7 +3112,7 @@ int AffixMgr::parse_num(char * line, int * out, char * name) if (np != 2) { fprintf(stderr,"error: missing %s information\n", name); return 1; - } + } return 0; } @@ -3157,7 +3157,7 @@ int AffixMgr::parse_wordchars(char * line) if (np != 2) { fprintf(stderr,"error: missing WORDCHARS information\n"); return 1; - } + } return 0; } @@ -3245,7 +3245,7 @@ int AffixMgr::parse_reptable(char * line, FILE * af) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { numrep = atoi(piece); if (numrep < 1) { fprintf(stderr,"incorrect number of entries in replacement table\n"); @@ -3266,8 +3266,8 @@ int AffixMgr::parse_reptable(char * line, FILE * af) if (np != 2) { fprintf(stderr,"error: missing replacement table information\n"); return 1; - } - + } + /* now parse the numrep lines to read in the remainder of the table */ char * nl = line; for (int j=0; j < numrep; j++) { @@ -3319,7 +3319,7 @@ int AffixMgr::parse_checkcpdtable(char * line, FILE * af) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { numcheckcpd = atoi(piece); if (numcheckcpd < 1) { fprintf(stderr,"incorrect number of entries in compound pattern table\n"); @@ -3340,8 +3340,8 @@ int AffixMgr::parse_checkcpdtable(char * line, FILE * af) if (np != 2) { fprintf(stderr,"error: missing compound pattern table information\n"); return 1; - } - + } + /* now parse the numcheckcpd lines to read in the remainder of the table */ char * nl = line; for (int j=0; j < numcheckcpd; j++) { @@ -3393,7 +3393,7 @@ int AffixMgr::parse_defcpdtable(char * line, FILE * af) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { numdefcpd = atoi(piece); if (numdefcpd < 1) { fprintf(stderr,"incorrect number of entries in compound rule table\n"); @@ -3414,8 +3414,8 @@ int AffixMgr::parse_defcpdtable(char * line, FILE * af) if (np != 2) { fprintf(stderr,"error: missing compound rule table information\n"); return 1; - } - + } + /* now parse the numdefcpd lines to read in the remainder of the table */ char * nl = line; for (int j=0; j < numdefcpd; j++) { @@ -3435,10 +3435,10 @@ int AffixMgr::parse_defcpdtable(char * line, FILE * af) } break; } - case 1: { - defcpdtable[j].len = + case 1: { + defcpdtable[j].len = pHMgr->decode_flags(&(defcpdtable[j].def), piece); - break; + break; } default: break; } @@ -3470,7 +3470,7 @@ int AffixMgr::parse_maptable(char * line, FILE * af) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { nummap = atoi(piece); if (nummap < 1) { fprintf(stderr,"incorrect number of entries in map table\n"); @@ -3491,8 +3491,8 @@ int AffixMgr::parse_maptable(char * line, FILE * af) if (np != 2) { fprintf(stderr,"error: missing map table information\n"); return 1; - } - + } + /* now parse the nummap lines to read in the remainder of the table */ char * nl = line; for (int j=0; j < nummap; j++) { @@ -3518,7 +3518,7 @@ int AffixMgr::parse_maptable(char * line, FILE * af) maptable[j].set = NULL; maptable[j].set_utf16 = NULL; if (!utf8) { - maptable[j].set = mystrdup(piece); + maptable[j].set = mystrdup(piece); maptable[j].len = strlen(maptable[j].set); } else { w_char w[MAXWORDLEN]; @@ -3561,7 +3561,7 @@ int AffixMgr::parse_breaktable(char * line, FILE * af) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { numbreak = atoi(piece); if (numbreak < 1) { fprintf(stderr,"incorrect number of entries in BREAK table\n"); @@ -3582,8 +3582,8 @@ int AffixMgr::parse_breaktable(char * line, FILE * af) if (np != 2) { fprintf(stderr,"error: missing word breakpoint table information\n"); return 1; - } - + } + /* now parse the numbreak lines to read in the remainder of the table */ char * nl = line; for (int j=0; j < numbreak; j++) { @@ -3635,11 +3635,11 @@ int AffixMgr::parse_lang(char * line) if (*piece != '\0') { switch(i) { case 0: { np++; break; } - case 1: { + case 1: { lang = mystrdup(piece); langnum = get_lang_num(piece); set_spec_utf8_encoding(); - np++; break; + np++; break; } default: break; } @@ -3684,7 +3684,9 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag int i = 0; // checking lines with bad syntax +#if DEBUG int basefieldnum = 0; +#endif // split affix header line into pieces @@ -3694,9 +3696,9 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag switch(i) { // piece 1 - is type of affix case 0: { np++; break; } - + // piece 2 - is affix char - case 1: { + case 1: { np++; aflag = pHMgr->decode_flag(piece); if (((at == 'S') && (dupflags[aflag] & dupSFX)) || @@ -3705,15 +3707,15 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag // return 1; XXX permissive mode for bad dictionaries } dupflags[aflag] += ((at == 'S') ? dupSFX : dupPFX); - break; + break; } - // piece 3 - is cross product indicator + // piece 3 - is cross product indicator case 2: { np++; if (*piece == 'Y') ff = aeXPRODUCT; break; } // piece 4 - is number of affentries - case 3: { + case 3: { np++; - numents = atoi(piece); + numents = atoi(piece); if (numents == 0) { char * err = pHMgr->encode_flag(aflag); fprintf(stderr, "error: affix %s header has incorrect entry count in line %s\n", @@ -3738,13 +3740,13 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag } // check to make sure we parsed enough pieces if (np != 4) { - char * err = pHMgr->encode_flag(aflag); + char * err = pHMgr->encode_flag(aflag); fprintf(stderr, "error: affix %s header has insufficient data in line %s\n", err, nl); free(err); free(ptr); return 1; } - + // store away ptr to first affentry nptr = ptr; @@ -3761,14 +3763,14 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag if (*piece != '\0') { switch(i) { // piece 1 - is type - case 0: { + case 0: { np++; if (nptr != ptr) nptr->opts = ptr->opts; break; } // piece 2 - is affix char - case 1: { + case 1: { np++; if (pHMgr->decode_flag(piece) != aflag) { char * err = pHMgr->encode_flag(aflag); @@ -3783,8 +3785,8 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag break; } - // piece 3 - is string to strip or 0 for null - case 2: { + // piece 3 - is string to strip or 0 for null + case 2: { np++; if (complexprefixes) { if (utf8) reverseword_utf(piece); else reverseword(piece); @@ -3795,12 +3797,12 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag free(nptr->strip); nptr->strip=mystrdup(""); nptr->stripl = 0; - } - break; + } + break; } // piece 4 - is affix string or 0 for null - case 3: { + case 3: { char * dash; nptr->morphcode = NULL; nptr->contclass = NULL; @@ -3813,7 +3815,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag if (utf8) reverseword_utf(piece); else reverseword(piece); } nptr->appnd = mystrdup(piece); - + if (pHMgr->is_aliasf()) { int index = atoi(dash + 1); nptr->contclasslen = pHMgr->get_aliasf(index, &(nptr->contclass)); @@ -3831,20 +3833,20 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag if (complexprefixes) { if (utf8) reverseword_utf(piece); else reverseword(piece); } - nptr->appnd = mystrdup(piece); + nptr->appnd = mystrdup(piece); } - + nptr->appndl = strlen(nptr->appnd); if (strcmp(nptr->appnd,"0") == 0) { free(nptr->appnd); nptr->appnd=mystrdup(""); nptr->appndl = 0; - } - break; + } + break; } // piece 5 - is the conditions descriptions - case 4: { + case 4: { np++; if (complexprefixes) { int neg = 0; @@ -3878,7 +3880,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag if (encodeit(nptr,piece)) return 1; break; } - + case 5: { np++; if (pHMgr->is_aliasm()) { @@ -3890,7 +3892,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag } nptr->morphcode = mystrdup(piece); } - break; + break; } case 6: { @@ -3913,7 +3915,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag } } break; - + } default: break; @@ -3935,7 +3937,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag // detect unnecessary fields, excepting comments if (basefieldnum) { int fieldnum = !(nptr->morphcode) ? 5 : ((*(nptr->morphcode)=='#') ? 5 : 6); - if (fieldnum != basefieldnum) + if (fieldnum != basefieldnum) fprintf(stderr, "warning - bad field number:\n%s\n", nl); } else { basefieldnum = !(nptr->morphcode) ? 5 : ((*(nptr->morphcode)=='#') ? 5 : 6); @@ -3943,7 +3945,7 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag #endif nptr++; } - + // now create SfxEntry or PfxEntry objects and use links to // build an ordered (sorted by affix string) list nptr = ptr; @@ -3953,10 +3955,10 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag build_pfxtree((AffEntry *)pfxptr); } else { SfxEntry * sfxptr = new SfxEntry(this,nptr); - build_sfxtree((AffEntry *)sfxptr); + build_sfxtree((AffEntry *)sfxptr); } nptr++; - } + } free(ptr); return 0; } @@ -3965,7 +3967,7 @@ void AffixMgr::set_spec_utf8_encoding() { if (utf8) { // In Azeri and Turkish, I and i dictinct letters: // There are a dotless lower case i pair of upper `I', - // and an upper I with dot pair of lower `i'. + // and an upper I with dot pair of lower `i'. if ((langnum == LANG_az) || (langnum == LANG_tr)) { utf_tbl[0x0049].clower = 0x0131; utf_tbl[0x0069].cupper = 0x0130; @@ -4001,7 +4003,7 @@ int AffixMgr::redundant_condition(char ft, char * strip, int stripl, const char } if ((!neg && !in) || (neg && in)) { fprintf(stderr, "warning - incompatible stripping characters and condition:\n%s\n", line); - return 0; + return 0; } } } @@ -4029,12 +4031,12 @@ int AffixMgr::redundant_condition(char ft, char * strip, int stripl, const char neg = (cond[j+1] == '^') ? 1 : 0; if ((!neg && !in) || (neg && in)) { fprintf(stderr, "warning - incompatible stripping characters and condition:\n%s\n", line); - return 0; + return 0; } } } if (j < 0) return 1; - } + } } return 0; } diff --git a/goldlib/hunspell/hunspell.cxx b/goldlib/hunspell/hunspell.cxx index 44fa537..482ac17 100644 --- a/goldlib/hunspell/hunspell.cxx +++ b/goldlib/hunspell/hunspell.cxx @@ -63,20 +63,20 @@ Hunspell::~Hunspell() // make a copy of src at destination while removing all leading // blanks and removing any trailing periods after recording // their presence with the abbreviation flag -// also since already going through character by character, +// also since already going through character by character, // set the capitalization type // return the length of the "cleaned" (and UTF-8 encoded) word -int Hunspell::cleanword2(char * dest, const char * src, +int Hunspell::cleanword2(char * dest, const char * src, w_char * dest_utf, int * nc, int * pcaptype, int * pabbrev) -{ +{ unsigned char * p = (unsigned char *) dest; const unsigned char * q = (const unsigned char * ) src; int firstcap = 0; // first skip over any leading blanks while ((*q != '\0') && (*q == ' ')) q++; - + // now strip off any trailing periods (recording their presence) *pabbrev = 0; int nl = strlen((const char *)q); @@ -84,9 +84,9 @@ int Hunspell::cleanword2(char * dest, const char * src, nl--; (*pabbrev)++; } - + // if no characters are left it can't be capitalized - if (nl <= 0) { + if (nl <= 0) { *pcaptype = NOCAP; *p = '\0'; return 0; @@ -141,18 +141,18 @@ int Hunspell::cleanword2(char * dest, const char * src, *pcaptype = HUHCAP; } return strlen(dest); -} +} -int Hunspell::cleanword(char * dest, const char * src, +int Hunspell::cleanword(char * dest, const char * src, int * pcaptype, int * pabbrev) -{ +{ unsigned char * p = (unsigned char *) dest; const unsigned char * q = (const unsigned char * ) src; int firstcap = 0; // first skip over any leading blanks while ((*q != '\0') && (*q == ' ')) q++; - + // now strip off any trailing periods (recording their presence) *pabbrev = 0; int nl = strlen((const char *)q); @@ -160,9 +160,9 @@ int Hunspell::cleanword(char * dest, const char * src, nl--; (*pabbrev)++; } - + // if no characters are left it can't be capitalized - if (nl <= 0) { + if (nl <= 0) { *pcaptype = NOCAP; *p = '\0'; return 0; @@ -213,8 +213,8 @@ int Hunspell::cleanword(char * dest, const char * src, *pcaptype = HUHCAP; } return strlen(dest); -} - +} + void Hunspell::mkallcap(char * p) { @@ -231,7 +231,7 @@ void Hunspell::mkallcap(char * p) } u16_u8(p, MAXWORDUTF8LEN, u, nc); } else { - while (*p != '\0') { + while (*p != '\0') { *p = csconv[((unsigned char) *p)].cupper; p++; } @@ -250,9 +250,9 @@ int Hunspell::mkallcap2(char * p, w_char * u, int nc) } } u16_u8(p, MAXWORDUTF8LEN, u, nc); - return strlen(p); + return strlen(p); } else { - while (*p != '\0') { + while (*p != '\0') { *p = csconv[((unsigned char) *p)].cupper; p++; } @@ -263,7 +263,7 @@ int Hunspell::mkallcap2(char * p, w_char * u, int nc) void Hunspell::mkallsmall(char * p) { - while (*p != '\0') { + while (*p != '\0') { *p = csconv[((unsigned char) *p)].clower; p++; } @@ -283,7 +283,7 @@ int Hunspell::mkallsmall2(char * p, w_char * u, int nc) u16_u8(p, MAXWORDUTF8LEN, u, nc); return strlen(p); } else { - while (*p != '\0') { + while (*p != '\0') { *p = csconv[((unsigned char) *p)].clower; p++; } @@ -308,10 +308,10 @@ hentry * Hunspell::spellsharps(char * base, char * pos, int n, int repnum, char hentry * h; *pos = 'Ã'; *(pos + 1) = 'Ÿ'; - if (h = spellsharps(base, pos + 2, n + 1, repnum + 1, tmp)) return h; + if ((h = spellsharps(base, pos + 2, n + 1, repnum + 1, tmp))) return h; *pos = 's'; *(pos + 1) = 's'; - if (h = spellsharps(base, pos + 2, n + 1, repnum, tmp)) return h; + if ((h = spellsharps(base, pos + 2, n + 1, repnum, tmp))) return h; } else if (repnum > 0) { if (utf8) return check(base); return check(sharps_u8_l1(tmp, base)); @@ -347,7 +347,7 @@ int Hunspell::spell(const char * word) char wspace[MAXWORDUTF8LEN + 4]; w_char unicw[MAXWORDLEN + 1]; int nc = strlen(word); - int wl2; + int wl2=0; if (utf8) { if (nc >= MAXWORDUTF8LEN) return 0; } else { @@ -363,11 +363,11 @@ int Hunspell::spell(const char * word) enum { NBEGIN, NNUM, NSEP }; int nstate = NBEGIN; int i; - - for (i = 0; (i < wl) && + + for (i = 0; (i < wl) && (((cw[i] <= '9') && (cw[i] >= '0') && (nstate = NNUM)) || ((nstate == NNUM) && ((cw[i] == ',') || - (cw[i] == '.') || (cw[i] == '-')) && (nstate = NSEP))); i++); + (cw[i] == '.') || (cw[i] == '-')) && (nstate = NSEP))); i++); if ((i == wl) && (nstate == NNUM)) return 1; // LANG_hu section: number(s) + (percent or degree) with suffixes @@ -377,10 +377,10 @@ int Hunspell::spell(const char * word) // END of LANG_hu section switch(captype) { - case HUHCAP: - case HUHINITCAP: - case NOCAP: { - rv = check(cw); + case HUHCAP: + case HUHINITCAP: + case NOCAP: { + rv = check(cw); if ((abbv) && !(rv)) { memcpy(wspace,cw,wl); *(wspace+wl) = '.'; @@ -422,14 +422,14 @@ int Hunspell::spell(const char * word) if (rv) break; } } - case INITCAP: { + case INITCAP: { wl = mkallsmall2(cw, unicw, nc); - memcpy(wspace,cw,(wl+1)); + memcpy(wspace,cw,(wl+1)); rv = check(wspace); if (!rv || (is_keepcase(rv) && !((captype == INITCAP) && // if CHECKSHARPS: KEEPCASE words with ß are allowed // in INITCAP form, too. - pAMgr->get_checksharps() && ((utf8 && strstr(wspace, "ß")) || + pAMgr->get_checksharps() && ((utf8 && strstr(wspace, "ß")) || (!utf8 && strchr(wspace, 'ß')))))) { wl2 = mkinitcap2(cw, unicw, nc); rv = check(cw); @@ -448,9 +448,9 @@ int Hunspell::spell(const char * word) } } break; - } + } } - + if (rv) return 1; // recursive breaking at break points (not good for morphological analysis) @@ -458,7 +458,7 @@ int Hunspell::spell(const char * word) char * s; char r; for (int i = 0; i < pAMgr->get_numbreak(); i++) { - if (s=(char *) strstr(cw, wordbreak[i])) { + if ((s=(char *) strstr(cw, wordbreak[i]))) { r = *s; *s = '\0'; // examine 2 sides of the break point @@ -488,7 +488,7 @@ int Hunspell::spell(const char * word) *dash = 'â'; } if ((dash=(char *) strchr(cw,'-'))) { - *dash='\0'; + *dash='\0'; // examine 2 sides of the dash if (dash[1] == '\0') { // base word ending with dash if (spell(cw)) return 1; @@ -581,17 +581,17 @@ struct hentry * Hunspell::check(const char * w) } prevroot = he->word; } else if (pAMgr->get_compound()) { - he = pAMgr->compound_check(word, len, + he = pAMgr->compound_check(word, len, 0,0,100,0,NULL,0,NULL,NULL,0); // LANG_hu section: `moving rule' with last dash if ((!he) && (langnum == LANG_hu) && (word[len-1]=='-')) { char * dup = mystrdup(word); dup[len-1] = '\0'; - he = pAMgr->compound_check(dup, len-1, + he = pAMgr->compound_check(dup, len-1, -5,0,100,0,NULL,1,NULL,NULL,0); free(dup); } - // end of LANG speficic region + // end of LANG speficic region if (he) { prevroot = he->word; prevcompound = 1; @@ -625,12 +625,12 @@ int Hunspell::suggest(char*** slst, const char * word) int ngramsugs = 0; switch(captype) { - case NOCAP: { + case NOCAP: { ns = pSMgr->suggest(slst, cw, ns); break; } - case INITCAP: { + case INITCAP: { capwords = 1; ns = pSMgr->suggest(slst, cw, ns); if (ns == -1) break; @@ -641,7 +641,7 @@ int Hunspell::suggest(char*** slst, const char * word) } case HUHINITCAP: capwords = 1; - case HUHCAP: { + case HUHCAP: { ns = pSMgr->suggest(slst, cw, ns); if (ns != -1) { int prevns; @@ -664,7 +664,7 @@ int Hunspell::suggest(char*** slst, const char * word) // aNew -> "a New" (instead of "a new") for (int j = prevns; j < ns; j++) { char * space; - if (space = strchr((*slst)[j],' ')) { + if ( (space = strchr((*slst)[j],' ')) ) { int slen = strlen(space + 1); // different case after space (need capitalisation) if ((slen < wl) && strcmp(cw + wl - slen, space + 1)) { @@ -683,7 +683,7 @@ int Hunspell::suggest(char*** slst, const char * word) break; } - case ALLCAP: { + case ALLCAP: { memcpy(wspace, cw, (wl+1)); mkallsmall2(wspace, unicw, nc); ns = pSMgr->suggest(slst, wspace, ns); @@ -696,12 +696,12 @@ int Hunspell::suggest(char*** slst, const char * word) if (pAMgr && pAMgr->get_checksharps()) { char * pos; if (utf8) { - while (pos = strstr((*slst)[j], "ß")) { + while ( (pos = strstr((*slst)[j], "ß")) ) { *pos = 'S'; *(pos+1) = 'S'; } } else { - while (pos = strchr((*slst)[j], 'ß')) { + while ( (pos = strchr((*slst)[j], 'ß')) ) { (*slst)[j] = (char *) realloc((*slst)[j], strlen((*slst)[j]) + 2); mystrrep((*slst)[j], "ß", "SS"); } @@ -735,7 +735,7 @@ int Hunspell::suggest(char*** slst, const char * word) ns = pSMgr->ngsuggest(*slst, wspace, pHMgr); break; } - case INITCAP: { + case INITCAP: { capwords = 1; memcpy(wspace,cw,(wl+1)); mkallsmall2(wspace, unicw, nc); @@ -746,7 +746,7 @@ int Hunspell::suggest(char*** slst, const char * word) memcpy(wspace,cw,(wl+1)); mkallsmall2(wspace, unicw, nc); ns = pSMgr->ngsuggest(*slst, wspace, pHMgr); - for (int j=0; j < ns; j++) + for (int j=0; j < ns; j++) mkallcap((*slst)[j]); break; } @@ -790,13 +790,13 @@ int Hunspell::suggest(char*** slst, const char * word) strcpy(s, (*slst)[j]); len = strlen(s); } - int wl = mkallsmall2(s, w, len); - free((*slst)[j]); + mkallsmall2(s, w, len); + free((*slst)[j]); if (spell(s)) { (*slst)[l] = mystrdup(s); l++; } else { - int wl = mkinitcap2(s, w, len); + mkinitcap2(s, w, len); if (spell(s)) { (*slst)[l] = mystrdup(s); l++; @@ -805,7 +805,7 @@ int Hunspell::suggest(char*** slst, const char * word) } else { (*slst)[l] = (*slst)[j]; l++; - } + } } ns = l; } @@ -845,15 +845,15 @@ int Hunspell::suggest_auto(char*** slst, const char * word) if (wl == 0) return 0; int ns = 0; *slst = NULL; // HU, nsug in pSMgr->suggest - + switch(captype) { - case NOCAP: { + case NOCAP: { ns = pSMgr->suggest_auto(slst, cw, ns); if (ns>0) break; break; } - case INITCAP: { + case INITCAP: { memcpy(wspace,cw,(wl+1)); mkallsmall(wspace); ns = pSMgr->suggest_auto(slst, wspace, ns); @@ -861,10 +861,10 @@ int Hunspell::suggest_auto(char*** slst, const char * word) mkinitcap((*slst)[j]); ns = pSMgr->suggest_auto(slst, cw, ns); break; - + } - case HUHCAP: { + case HUHCAP: { ns = pSMgr->suggest_auto(slst, cw, ns); if (ns == 0) { memcpy(wspace,cw,(wl+1)); @@ -874,7 +874,7 @@ int Hunspell::suggest_auto(char*** slst, const char * word) break; } - case ALLCAP: { + case ALLCAP: { memcpy(wspace,cw,(wl+1)); mkallsmall(wspace); ns = pSMgr->suggest_auto(slst, wspace, ns); @@ -929,14 +929,14 @@ int Hunspell::stem(char*** slst, const char * word) int abbv = 0; wl = cleanword(cw, word, &captype, &abbv); if (wl == 0) return 0; - + int ns = 0; *slst = NULL; // HU, nsug in pSMgr->suggest - + switch(captype) { case HUHCAP: - case NOCAP: { + case NOCAP: { ns = pSMgr->suggest_stems(slst, cw, ns); if ((abbv) && (ns == 0)) { @@ -949,7 +949,7 @@ int Hunspell::stem(char*** slst, const char * word) break; } - case INITCAP: { + case INITCAP: { ns = pSMgr->suggest_stems(slst, cw, ns); @@ -967,15 +967,15 @@ int Hunspell::stem(char*** slst, const char * word) *(wspace+wl+1) = '\0'; ns = pSMgr->suggest_stems(slst, wspace, ns); } - + break; - + } - case ALLCAP: { + case ALLCAP: { ns = pSMgr->suggest_stems(slst, cw, ns); if (ns != 0) break; - + memcpy(wspace,cw,(wl+1)); mkallsmall(wspace); ns = pSMgr->suggest_stems(slst, wspace, ns); @@ -997,7 +997,7 @@ int Hunspell::stem(char*** slst, const char * word) break; } } - + return ns; } @@ -1016,14 +1016,14 @@ int Hunspell::suggest_pos_stems(char*** slst, const char * word) int abbv = 0; wl = cleanword(cw, word, &captype, &abbv); if (wl == 0) return 0; - + int ns = 0; // ns=0 = normalized input *slst = NULL; // HU, nsug in pSMgr->suggest - + switch(captype) { case HUHCAP: - case NOCAP: { + case NOCAP: { ns = pSMgr->suggest_pos_stems(slst, cw, ns); if ((abbv) && (ns == 0)) { @@ -1036,7 +1036,7 @@ int Hunspell::suggest_pos_stems(char*** slst, const char * word) break; } - case INITCAP: { + case INITCAP: { ns = pSMgr->suggest_pos_stems(slst, cw, ns); @@ -1045,15 +1045,15 @@ int Hunspell::suggest_pos_stems(char*** slst, const char * word) mkallsmall(wspace); ns = pSMgr->suggest_pos_stems(slst, wspace, ns); } - + break; - + } - case ALLCAP: { + case ALLCAP: { ns = pSMgr->suggest_pos_stems(slst, cw, ns); if (ns != 0) break; - + memcpy(wspace,cw,(wl+1)); mkallsmall(wspace); ns = pSMgr->suggest_pos_stems(slst, wspace, ns); @@ -1206,7 +1206,7 @@ char * Hunspell::morph(const char * word) char result[MAXLNLEN]; char * st = NULL; - + *result = '\0'; int n = 0; @@ -1216,11 +1216,11 @@ char * Hunspell::morph(const char * word) // test numbers // LANG_hu section: set dash information for suggestions if (langnum == LANG_hu) { - while ((n < wl) && + while ((n < wl) && (((cw[n] <= '9') && (cw[n] >= '0')) || (((cw[n] == '.') || (cw[n] == ',')) && (n > 0)))) { n++; if ((cw[n] == '.') || (cw[n] == ',')) { - if (((n2 == 0) && (n > 3)) || + if (((n2 == 0) && (n > 3)) || ((n2 > 0) && ((cw[n-1] == '.') || (cw[n-1] == ',')))) break; n2++; n3 = n; @@ -1257,9 +1257,9 @@ char * Hunspell::morph(const char * word) } } // END OF LANG_hu section - + switch(captype) { - case NOCAP: { + case NOCAP: { st = pSMgr->suggest_morph(cw); if (st) { strcat(result, st); @@ -1278,14 +1278,14 @@ char * Hunspell::morph(const char * word) } break; } - case INITCAP: { + case INITCAP: { memcpy(wspace,cw,(wl+1)); mkallsmall(wspace); st = pSMgr->suggest_morph(wspace); if (st) { strcat(result, st); free(st); - } + } st = pSMgr->suggest_morph(cw); if (st) { if (*result) strcat(result, "\n"); @@ -1313,7 +1313,7 @@ char * Hunspell::morph(const char * word) } break; } - case HUHCAP: { + case HUHCAP: { st = pSMgr->suggest_morph(cw); if (st) { strcat(result, st); @@ -1331,13 +1331,13 @@ char * Hunspell::morph(const char * word) #endif break; } - case ALLCAP: { + case ALLCAP: { memcpy(wspace,cw,(wl+1)); st = pSMgr->suggest_morph(wspace); if (st) { strcat(result, st); free(st); - } + } mkallsmall(wspace); st = pSMgr->suggest_morph(wspace); if (st) { @@ -1361,7 +1361,7 @@ char * Hunspell::morph(const char * word) if (st) { strcat(result, st); free(st); - } + } mkallsmall(wspace); st = pSMgr->suggest_morph(wspace); if (st) { @@ -1394,7 +1394,7 @@ char * Hunspell::morph(const char * word) int nresult = 0; // LANG_hu section: set dash information for suggestions if ((langnum == LANG_hu) && (dash=(char *) strchr(cw,'-'))) { - *dash='\0'; + *dash='\0'; // examine 2 sides of the dash if (dash[1] == '\0') { // base word ending with dash if (spell(cw)) return pSMgr->suggest_morph(cw); @@ -1438,7 +1438,7 @@ char * Hunspell::morph(const char * word) } } // affixed number in correct word - if (nresult && (dash > cw) && (((*(dash-1)<='9') && + if (nresult && (dash > cw) && (((*(dash-1)<='9') && (*(dash-1)>='0')) || (*(dash-1)=='.'))) { *dash='-'; n = 1; @@ -1487,12 +1487,12 @@ char * Hunspell::morph_with_correction(const char * word) char result[MAXLNLEN]; char * st = NULL; - + *result = '\0'; - - + + switch(captype) { - case NOCAP: { + case NOCAP: { st = pSMgr->suggest_morph_for_spelling_error(cw); if (st) { strcat(result, st); @@ -1511,14 +1511,14 @@ char * Hunspell::morph_with_correction(const char * word) } break; } - case INITCAP: { + case INITCAP: { memcpy(wspace,cw,(wl+1)); mkallsmall(wspace); st = pSMgr->suggest_morph_for_spelling_error(wspace); if (st) { strcat(result, st); free(st); - } + } st = pSMgr->suggest_morph_for_spelling_error(cw); if (st) { if (*result) strcat(result, "\n"); @@ -1546,7 +1546,7 @@ char * Hunspell::morph_with_correction(const char * word) } break; } - case HUHCAP: { + case HUHCAP: { st = pSMgr->suggest_morph_for_spelling_error(cw); if (st) { strcat(result, st); @@ -1559,16 +1559,16 @@ char * Hunspell::morph_with_correction(const char * word) if (*result) strcat(result, "\n"); strcat(result, st); free(st); - } + } break; } - case ALLCAP: { + case ALLCAP: { memcpy(wspace,cw,(wl+1)); st = pSMgr->suggest_morph_for_spelling_error(wspace); if (st) { strcat(result, st); free(st); - } + } mkallsmall(wspace); st = pSMgr->suggest_morph_for_spelling_error(wspace); if (st) { @@ -1592,7 +1592,7 @@ char * Hunspell::morph_with_correction(const char * word) if (st) { strcat(result, st); free(st); - } + } mkallsmall(wspace); st = pSMgr->suggest_morph_for_spelling_error(wspace); if (st) { @@ -1617,7 +1617,7 @@ char * Hunspell::morph_with_correction(const char * word) } /* analyze word - * return line count + * return line count * XXX need a better data structure for morphological analysis */ int Hunspell::analyze(char ***out, const char *word) { int n = 0; @@ -1635,7 +1635,7 @@ int Hunspell::analyze(char ***out, const char *word) { strncpy((*out)[n++], m + p, i - p + 1); if (m[i] == '\n') (*out)[n++][i - p] = '\0'; if(!m[i+1]) break; - p = i + 1; + p = i + 1; } } free(m); diff --git a/goldlib/hunspell/suggmgr.cxx b/goldlib/hunspell/suggmgr.cxx index 0411237..ff16332 100644 --- a/goldlib/hunspell/suggmgr.cxx +++ b/goldlib/hunspell/suggmgr.cxx @@ -13,11 +13,11 @@ using namespace std; #endif -SuggestMgr::SuggestMgr(const char * tryme, int maxn, +SuggestMgr::SuggestMgr(const char * tryme, int maxn, AffixMgr * aptr) { - // register affix manager and check in string of chars to + // register affix manager and check in string of chars to // try when building candidate suggestions pAMgr = aptr; @@ -44,9 +44,9 @@ SuggestMgr::SuggestMgr(const char * tryme, int maxn, complexprefixes = pAMgr->get_complexprefixes(); } - if (tryme) { + if (tryme) { if (utf8) { - w_char t[MAXSWL]; + w_char t[MAXSWL]; ctryl = u8_u16(t, MAXSWL, tryme); ctry_utf = (w_char *) malloc(ctryl * sizeof(w_char)); memcpy(ctry_utf, t, ctryl * sizeof(w_char)); @@ -77,9 +77,9 @@ SuggestMgr::~SuggestMgr() int SuggestMgr::suggest(char*** slst, const char * w, int nsug) { int nocompoundtwowords = 0; - char ** wlst; + char ** wlst; w_char word_utf[MAXSWL]; - int wl; + int wl=0; char w2[MAXWORDUTF8LEN]; const char * word = w; @@ -90,7 +90,7 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug) if (utf8) reverseword_utf(w2); else reverseword(w2); word = w2; } - + if (*slst) { wlst = *slst; } else { @@ -98,7 +98,7 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug) if (wlst == NULL) return -1; for (int i = 0; i < maxSug; i++) wlst[i] = NULL; } - + if (utf8) { wl = u8_u16(word_utf, MAXSWL, word); } @@ -201,7 +201,7 @@ int SuggestMgr::suggest_auto(char*** slst, const char * w, int nsug) if ((nsug < maxSug) && (nsug > -1) && check_forbidden(word, strlen(word))) { nsug = twowords(wlst, word, nsug, cpdsuggest); } - + } // repeating ``for'' statement compounding support if (nsug < 0) { @@ -221,7 +221,7 @@ int SuggestMgr::mapchars(char** wlst, const char * word, int ns, int cpdsuggest) { time_t timelimit; int timer; - + int wl = strlen(word); if (wl < 2 || ! pAMgr) return ns; @@ -242,13 +242,13 @@ int SuggestMgr::mapchars(char** wlst, const char * word, int ns, int cpdsuggest) int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns, const mapentry* maptable, int nummap, int * timer, time_t * timelimit) { - char c = *(word + i); + char c = *(word + i); if (c == 0) { int cwrd = 1; int wl; for (int m=0; m < ns; m++) if (strcmp(word,wlst[m]) == 0) cwrd = 0; - if ((cwrd) && (wl = strlen(word)) && (check(word, wl, 0, timer, timelimit) || + if ((cwrd) && (wl = strlen(word)) && (check(word, wl, 0, timer, timelimit) || check(word, wl, 1, timer, timelimit))) { if (ns < maxSug) { wlst[ns] = mystrdup(word); @@ -257,7 +257,7 @@ int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns, } } return ns; - } + } int in_map = 0; for (int j = 0; j < nummap; j++) { if (strchr(maptable[j].set,c) != 0) { @@ -279,7 +279,7 @@ int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns, } int SuggestMgr::map_related_utf(w_char * word, int len, int i, char** wlst, int ns, - const mapentry* maptable, int nummap, int * timer, time_t * timelimit) + const mapentry* maptable, int nummap, int * timer, time_t * timelimit) { if (i == len) { int cwrd = 1; @@ -288,7 +288,7 @@ int SuggestMgr::map_related_utf(w_char * word, int len, int i, char** wlst, int u16_u8(s, MAXSWUTF8L, word, len); for (int m=0; m < ns; m++) if (strcmp(s,wlst[m]) == 0) cwrd = 0; - if ((cwrd) && (wl = strlen(s)) && (check(s, wl, 0, timer, timelimit) || + if ((cwrd) && (wl = strlen(s)) && (check(s, wl, 0, timer, timelimit) || check(s, wl, 1, timer, timelimit))) { if (ns < maxSug) { wlst[ns] = mystrdup(s); @@ -297,7 +297,7 @@ int SuggestMgr::map_related_utf(w_char * word, int len, int i, char** wlst, int } } return ns; - } + } int in_map = 0; unsigned short c = *((unsigned short *) word + i); for (int j = 0; j < nummap; j++) { @@ -449,7 +449,7 @@ int SuggestMgr::badchar_utf(char ** wlst, const w_char * word, int wl, int ns, i int cwrd; time_t timelimit = time(NULL); int timer = MINTIMER; - + memcpy(candidate_utf, word, wl * sizeof(w_char)); // swap out each char one by one and try all the tryme @@ -477,7 +477,7 @@ int SuggestMgr::badchar_utf(char ** wlst, const w_char * word, int wl, int ns, i return ns; } -// error is word has an extra letter it does not need +// error is word has an extra letter it does not need int SuggestMgr::extrachar_utf(char** wlst, const w_char * word, int wl, int ns, int cpdsuggest) { char candidate[MAXSWUTF8L]; @@ -493,7 +493,7 @@ int SuggestMgr::extrachar_utf(char** wlst, const w_char * word, int wl, int ns, memcpy(candidate_utf, word + 1, (wl - 1) * sizeof(w_char)); for (p = word, r = candidate_utf; p < word + wl; ) { cwrd = 1; - u16_u8(candidate, MAXSWUTF8L, candidate_utf, wl - 1); + u16_u8(candidate, MAXSWUTF8L, candidate_utf, wl - 1); for (int k=0; k < ns; k++) if (strcmp(candidate,wlst[k]) == 0) cwrd = 0; if ((cwrd) && check(candidate, strlen(candidate), cpdsuggest, NULL, NULL)) { @@ -501,14 +501,14 @@ int SuggestMgr::extrachar_utf(char** wlst, const w_char * word, int wl, int ns, wlst[ns] = mystrdup(candidate); if (wlst[ns] == NULL) return -1; ns++; - } else return ns; + } else return ns; } *r++ = *p++; } return ns; } -// error is word has an extra letter it does not need +// error is word has an extra letter it does not need int SuggestMgr::extrachar(char** wlst, const char * word, int ns, int cpdsuggest) { char candidate[MAXSWUTF8L]; @@ -530,7 +530,7 @@ int SuggestMgr::extrachar(char** wlst, const char * word, int ns, int cpdsuggest wlst[ns] = mystrdup(candidate); if (wlst[ns] == NULL) return -1; ns++; - } else return ns; + } else return ns; } *r++ = *p++; } @@ -563,7 +563,7 @@ int SuggestMgr::forgotchar(char ** wlst, const char * word, int ns, int cpdsugge wlst[ns] = mystrdup(candidate); if (wlst[ns] == NULL) return -1; ns++; - } else return ns; + } else return ns; } if (!timelimit) return ns; } @@ -612,7 +612,7 @@ int SuggestMgr::forgotchar_utf(char ** wlst, const w_char * word, int wl, int ns wlst[ns] = mystrdup(candidate); if (wlst[ns] == NULL) return -1; ns++; - } else return ns; + } else return ns; } if (!timelimit) return ns; } @@ -648,7 +648,7 @@ int SuggestMgr::twowords(char ** wlst, const char * word, int ns, int cpdsuggest int wl=strlen(word); if (wl < 3) return ns; - + if (pAMgr->get_langnum() == LANG_hu) forbidden = check_forbidden(word, wl); strcpy(candidate + 1, word); @@ -797,13 +797,13 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr) int col = -1; while ((hp = pHMgr->walk_hashtable(col, hp))) { // check forbidden words - if ((hp->astr) && (pAMgr) && + if ((hp->astr) && (pAMgr) && (TESTAFF(hp->astr, pAMgr->get_forbiddenword(), hp->alen) || TESTAFF(hp->astr, pAMgr->get_nosuggest(), hp->alen) || TESTAFF(hp->astr, pAMgr->get_onlyincompound(), hp->alen))) continue; sc = ngram(3, word, hp->word, NGRAM_LONGER_WORSE); if (sc > scores[lp]) { - scores[lp] = sc; + scores[lp] = sc; roots[lp] = hp; int lval = sc; for (j=0; j < MAX_ROOTS; j++) @@ -811,7 +811,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr) lp = j; lval = scores[j]; } - } + } } // find minimum threshhold for a passable suggestion @@ -868,7 +868,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr) lp = j; lval = gscore[j]; } - } else free (glst[k].word); + } else free (glst[k].word); } else free(glst[k].word); } } @@ -877,7 +877,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr) // now we are done generating guesses // sort in order of decreasing score - + bubblesort(&guess[0], &gscore[0], MAX_GUESS); // weight suggestions with a similarity index, based on @@ -907,7 +907,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr) gscore[i] += 2000; break; } - + // heuristic weigthing of ngram scores gscore[i] += // length of longest common subsequent minus lenght difference @@ -935,7 +935,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr) if (gscore[i] > 1000) same = 1; for (j=0; j < ns; j++) // don't suggest previous suggestions or a previous suggestion with prefixes or affixes - if (strstr(guess[i], wlst[j]) || + if (strstr(guess[i], wlst[j]) || // check forbidden words !check(guess[i], strlen(guess[i]), 0, NULL, NULL)) unique = 0; if (unique) wlst[ns++] = guess[i]; else free(guess[i]); @@ -957,7 +957,7 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t { struct hentry * rv=NULL; int nosuffix = 0; - + // check time limit if (timer) { (*timer)--; @@ -969,8 +969,8 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t *timer = MAXPLUSTIMER; } } - - if (pAMgr) { + + if (pAMgr) { if (cpdsuggest==1) { if (pAMgr->get_compound()) { rv = pAMgr->compound_check(word,len,0,0,0,0,NULL,0,NULL,NULL,1); @@ -987,7 +987,7 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t if (rv->astr && (TESTAFF(rv->astr,pAMgr->get_pseudoroot(),rv->alen) || TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) rv = NULL; } else rv = pAMgr->prefix_check(word, len, 0); // only prefix, and prefix + suffix XXX - + if (rv) { nosuffix=1; } else { @@ -1004,9 +1004,9 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t || TESTAFF(rv->astr,pAMgr->get_nosuggest(),rv->alen) || TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) return 0; - if (rv) { // XXX obsolote - if ((pAMgr->get_compoundflag()) && - TESTAFF(rv->astr, pAMgr->get_compoundflag(), rv->alen)) return 2 + nosuffix; + if (rv) { // XXX obsolote + if ((pAMgr->get_compoundflag()) && + TESTAFF(rv->astr, pAMgr->get_compoundflag(), rv->alen)) return 2 + nosuffix; return 1; } } @@ -1017,7 +1017,7 @@ int SuggestMgr::check_forbidden(const char * word, int len) { struct hentry * rv = NULL; - if (pAMgr) { + if (pAMgr) { rv = pAMgr->lookup(word); if (rv && rv->astr && (TESTAFF(rv->astr,pAMgr->get_pseudoroot(),rv->alen) || TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) rv = NULL; @@ -1033,7 +1033,7 @@ int SuggestMgr::check_forbidden(const char * word, int len) int SuggestMgr::suggest_stems(char*** slst, const char * w, int nsug) { char buf[MAXSWUTF8L]; - char ** wlst; + char ** wlst; int prevnsug = nsug; char w2[MAXWORDUTF8LEN]; @@ -1054,7 +1054,7 @@ int SuggestMgr::suggest_stems(char*** slst, const char * w, int nsug) } // perhaps there are a fix stem in the dictionary if ((nsug < maxSug) && (nsug > -1)) { - + nsug = fixstems(wlst, word, nsug); if (nsug == prevnsug) { char * s = mystrdup(word); @@ -1080,7 +1080,7 @@ int SuggestMgr::suggest_stems(char*** slst, const char * w, int nsug) free(s); } } - + if (nsug < 0) { for (int i=0;ilookup(word); if (rv) { dicstem = 0; } else { - // try stripping off affixes + // try stripping off affixes rv = pAMgr->affix_check(word, wl); // else try check compound word @@ -1139,7 +1139,7 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns) } // XXX obsolote, will be a general solution for stemming - if ((prefix) && (strncmp(prefix, "leg", 3)==0)) prefix[0] = '\0'; // (HU) + if ((prefix) && (strncmp(prefix, "leg", 3)==0)) prefix[0] = '\0'; // (HU) } } @@ -1147,10 +1147,10 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns) if ((rv) && (ns < maxSug)) { - + // check fixstem flag and not_valid_stem flag // first word - if ((ns < maxSug) && (dicstem < 2)) { + if ((ns < maxSug) && (dicstem < 2)) { strcpy(buf, prefix); if ((dicstem > 0) && pAMgr->get_derived()) { // XXX obsolote @@ -1162,7 +1162,7 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns) } else { // special stem in affix description const char * wordchars = pAMgr->get_wordchars(); - if (rv->description && + if (rv->description && (strchr(wordchars, *(rv->description)))) { char * desc = (rv->description) + 1; while (strchr(wordchars, *desc)) desc++; @@ -1190,7 +1190,7 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns) } else { // special stem in affix description const char * wordchars = pAMgr->get_wordchars(); - if (rv->description && + if (rv->description && (strchr(wordchars, *(rv->description)))) { char * desc = (rv->description) + 1; while (strchr(wordchars, *desc)) desc++; @@ -1243,19 +1243,19 @@ while (rv) { rv = rv2; - } else return ns; + } else return ns; } else { strcpy(fix, "__"); strcat(fix, rv->word); rv = NULL; rv2 = pAMgr->lookup(fix); - if ((rv2) && (rv2->astr) && (ns < maxSug)) - if ((rv2) && (rv2->astr) && (ns < maxSug)) + if ((rv2) && (rv2->astr) && (ns < maxSug)) + if ((rv2) && (rv2->astr) && (ns < maxSug)) if (0) { char buf2[MAXSWUTF8L]; strcpy(buf2, prefix); - + if (*(rv2->astr) == '-') { strcat(buf2, ""); } else { @@ -1325,7 +1325,7 @@ return ns; // suggest possible stems int SuggestMgr::suggest_pos_stems(char*** slst, const char * w, int nsug) { - char ** wlst; + char ** wlst; struct hentry * rv = NULL; @@ -1386,12 +1386,12 @@ char * SuggestMgr::suggest_morph(const char * w) } rv = pAMgr->lookup(word); - + while (rv) { if ((!rv->astr) || !(TESTAFF(rv->astr, pAMgr->get_forbiddenword(), rv->alen) || TESTAFF(rv->astr, pAMgr->get_pseudoroot(), rv->alen) || TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) { - if (rv->description && ((!rv->astr) || + if (rv->description && ((!rv->astr) || !TESTAFF(rv->astr, pAMgr->get_lemma_present(), rv->alen))) strcat(result, word); if (rv->description) strcat(result, rv->description); @@ -1399,7 +1399,7 @@ char * SuggestMgr::suggest_morph(const char * w) } rv = rv->next_homonym; } - + st = pAMgr->affix_check_morph(word,strlen(word)); if (st) { strcat(result, st); @@ -1409,7 +1409,7 @@ char * SuggestMgr::suggest_morph(const char * w) if (pAMgr->get_compound() && (*result == '\0')) pAMgr->compound_check_morph(word, strlen(word), 0, 0, 100, 0,NULL, 0, &r, NULL); - + return (*result) ? mystrdup(line_uniq(delete_zeros(result))) : NULL; } @@ -1425,7 +1425,7 @@ char * SuggestMgr::suggest_morph_for_spelling_error(const char * word) free(wlst[maxSug - 1]); } if (wlst) free(wlst); - return p; + return p; } @@ -1468,7 +1468,7 @@ int SuggestMgr::ngram(int n, char * s1, const char * s2, int uselen) nscore = nscore + ns; if (ns < 2) break; } - } else { + } else { char t[MAXSWUTF8L]; l1 = strlen(s1); l2 = strlen(s2); diff --git a/goldlib/smblib/smblib.cpp b/goldlib/smblib/smblib.cpp index 0f42587..a0855be 100644 --- a/goldlib/smblib/smblib.cpp +++ b/goldlib/smblib/smblib.cpp @@ -72,6 +72,9 @@ #define SMB_VERSION 0x0121 /* SMB format version */ /* High byte major, low byte minor */ +#define U_MODE 777 /* permitions for the new files (real: U_MODE XOR UMASK) */ + /* This is required for sopen(,,,) */ + #ifndef __gtimall_h time32_t gtime(time32_t *timep) { @@ -109,7 +112,7 @@ int SMBCALL smb_open(smb_t* smb) smb->shd_fp=smb->sdt_fp=smb->sid_fp=NULL; smb->last_error[0]=0; sprintf(str,"%s.shd",smb->file); - if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO))==-1) { + if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO,U_MODE))==-1) { sprintf(smb->last_error,"%d opening %s",errno,str); return(2); } @@ -156,7 +159,7 @@ int SMBCALL smb_open(smb_t* smb) setvbuf(smb->shd_fp,smb->shd_buf,_IOFBF,SHD_BLOCK_LEN); sprintf(str,"%s.sdt",smb->file); - if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO))==-1) { + if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO,U_MODE))==-1) { sprintf(smb->last_error,"%d opening %s",errno,str); smb_close(smb); return(1); @@ -172,7 +175,7 @@ int SMBCALL smb_open(smb_t* smb) setvbuf(smb->sdt_fp,NULL,_IOFBF,2*1024); sprintf(str,"%s.sid",smb->file); - if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO))==-1) { + if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO,U_MODE))==-1) { sprintf(smb->last_error,"%d opening %s",errno,str); smb_close(smb); return(3); @@ -219,7 +222,7 @@ int SMBCALL smb_open_da(smb_t* smb) sprintf(str,"%s.sda",smb->file); while(1) { - if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW))!=-1) + if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,U_MODE))!=-1) break; if(errno!=EACCES && errno!=EAGAIN) { sprintf(smb->last_error,"%d opening %s",errno,str); @@ -264,7 +267,7 @@ int SMBCALL smb_open_ha(smb_t* smb) sprintf(str,"%s.sha",smb->file); while(1) { - if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW))!=-1) + if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,U_MODE))!=-1) break; if(errno!=EACCES && errno!=EAGAIN) { sprintf(smb->last_error,"%d opening %s",errno,str); @@ -1010,7 +1013,7 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc) sprintf(str,"%s.sch",smb->file); while(1) { - if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW))!=-1) + if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,U_MODE))!=-1) break; if(errno!=EACCES && errno!=EAGAIN) { sprintf(smb->last_error,"%d opening %s", errno, str);