summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/SpellChecker/src/hunspell/suggestmgr.cxx84
-rw-r--r--plugins/SpellChecker/src/options.cpp2
-rw-r--r--plugins/SpellChecker/src/utils.cpp64
3 files changed, 69 insertions, 81 deletions
diff --git a/plugins/SpellChecker/src/hunspell/suggestmgr.cxx b/plugins/SpellChecker/src/hunspell/suggestmgr.cxx
index 843075e62f..9dfc049a99 100644
--- a/plugins/SpellChecker/src/hunspell/suggestmgr.cxx
+++ b/plugins/SpellChecker/src/hunspell/suggestmgr.cxx
@@ -253,59 +253,55 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug,
#ifdef HUNSPELL_EXPERIMENTAL
int SuggestMgr::suggest_auto(char*** slst, const char * w, int nsug)
{
- int nocompoundtwowords = 0;
- char ** wlst;
- int oldSug;
-
- char w2[MAXWORDUTF8LEN];
- const char * word = w;
-
- // word reversing wrapper for complex prefixes
- if (complexprefixes) {
- strcpy(w2, w);
- if (utf8) reverseword_utf(w2); else reverseword(w2);
- word = w2;
- }
-
- if (*slst) {
- wlst = *slst;
- } else {
- wlst = (char **) malloc(maxSug * sizeof(char *));
- if (wlst == NULL) return -1;
- }
+ char w2[MAXWORDUTF8LEN];
+ const char *word = w;
+
+ // word reversing wrapper for complex prefixes
+ if (complexprefixes) {
+ strcpy(w2, w);
+ if (utf8) reverseword_utf(w2); else reverseword(w2);
+ word = w2;
+ }
- for (int cpdsuggest=0; (cpdsuggest<2) && (nocompoundtwowords==0); cpdsuggest++) {
+ char **wlst;
+ if (*slst)
+ wlst = *slst;
+ else {
+ wlst = (char **)malloc(maxSug * sizeof(char *));
+ if (wlst == NULL) return -1;
+ }
- // limit compound suggestion
- if (cpdsuggest > 0) oldSug = nsug;
+ int oldSug = 0, nocompoundtwowords = 0;
+ for (int cpdsuggest = 0; (cpdsuggest < 2) && (nocompoundtwowords == 0); cpdsuggest++) {
+ // limit compound suggestion
+ if (cpdsuggest > 0) oldSug = nsug;
- // perhaps we made a typical fault of spelling
- if ((nsug < maxSug) && (nsug > -1))
- nsug = replchars(wlst, word, nsug, cpdsuggest);
+ // perhaps we made a typical fault of spelling
+ if ((nsug < maxSug) && (nsug > -1))
+ nsug = replchars(wlst, word, nsug, cpdsuggest);
- // perhaps we made chose the wrong char from a related set
- if ((nsug < maxSug) && (nsug > -1) && (!cpdsuggest || (nsug < oldSug + maxcpdsugs)))
- nsug = mapchars(wlst, word, nsug, cpdsuggest);
+ // perhaps we made chose the wrong char from a related set
+ if ((nsug < maxSug) && (nsug > -1) && (!cpdsuggest || (nsug < oldSug + maxcpdsugs)))
+ nsug = mapchars(wlst, word, nsug, cpdsuggest);
- if ((cpdsuggest==0) && (nsug>0)) nocompoundtwowords=1;
+ if ((cpdsuggest == 0) && (nsug > 0))
+ nocompoundtwowords = 1;
- // perhaps we forgot to hit space and two words ran together
+ // perhaps we forgot to hit space and two words ran together
- if ((nsug < maxSug) && (nsug > -1) && (!cpdsuggest || (nsug < oldSug + maxcpdsugs)) && check_forbidden(word, strlen(word))) {
- nsug = twowords(wlst, word, nsug, cpdsuggest);
- }
-
- } // repeating ``for'' statement compounding support
+ if ((nsug < maxSug) && (nsug > -1) && (!cpdsuggest || (nsug < oldSug + maxcpdsugs)) && check_forbidden(word, strlen(word)))
+ nsug = twowords(wlst, word, nsug, cpdsuggest);
+ } // repeating ``for'' statement compounding support
- if (nsug < 0) {
- for (int i=0;i<maxSug; i++)
- if (wlst[i] != NULL) free(wlst[i]);
- free(wlst);
- return -1;
- }
+ if (nsug < 0) {
+ for (int i = 0; i < maxSug; i++)
+ if (wlst[i] != NULL) free(wlst[i]);
+ free(wlst);
+ return -1;
+ }
- *slst = wlst;
- return nsug;
+ *slst = wlst;
+ return nsug;
}
#endif // END OF HUNSPELL_EXPERIMENTAL CODE
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp
index a9ab63df8b..96969bfd39 100644
--- a/plugins/SpellChecker/src/options.cpp
+++ b/plugins/SpellChecker/src/options.cpp
@@ -320,7 +320,7 @@ static void LoadReplacements(HWND hwndDlg)
EnableDisableCtrls(hwndDlg);
}
-static void SaveNewReplacements(BOOL canceled, Dictionary *dict,
+static void SaveNewReplacements(BOOL canceled, Dictionary*,
const TCHAR *find, const TCHAR *replace, BOOL useVariables,
const TCHAR *original_find, void *param)
{
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp
index b7a2dc4018..b812ff3346 100644
--- a/plugins/SpellChecker/src/utils.cpp
+++ b/plugins/SpellChecker/src/utils.cpp
@@ -162,7 +162,7 @@ public:
/// @return true when finished an word
virtual bool feed(int pos, TCHAR c) = 0;
- virtual int getFirstCharPos() = 0;
+ virtual int getFirstCharPos() = 0;
virtual void reset() = 0;
virtual void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement) = 0;
};
@@ -179,13 +179,13 @@ public:
reset();
}
- void reset()
+ virtual void reset()
{
last_pos = -1;
found_real_char = FALSE;
}
- bool feed(int pos, TCHAR c)
+ virtual bool feed(int pos, TCHAR c)
{
// Is inside a word?
if (dict->isWordChar(c) || IsNumber(c)) {
@@ -204,15 +204,12 @@ public:
return (last_pos != -1);
}
- int getFirstCharPos()
+ virtual int getFirstCharPos()
{
- if (!found_real_char)
- return -1;
- else
- return last_pos;
+ return (!found_real_char) ? -1 : last_pos;
}
- void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement)
+ virtual void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement)
{
// Is it correct?
if (dict->spell(text))
@@ -242,12 +239,12 @@ public:
reset();
}
- void reset()
+ virtual void reset()
{
last_pos = -1;
}
- bool feed(int pos, TCHAR c)
+ virtual bool feed(int pos, TCHAR c)
{
// Is inside a word?
if (ar->isWordChar(c)) {
@@ -259,12 +256,12 @@ public:
return (last_pos != -1);
}
- int getFirstCharPos()
+ virtual int getFirstCharPos()
{
return last_pos;
}
- void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement)
+ virtual void deal(const TCHAR *text, bool*, bool *replace, TCHAR **replacement)
{
*replacement = ar->autoReplace(text);
if (*replacement != NULL)
@@ -416,14 +413,13 @@ int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = NUL
SetNoUnderline(dlg->re, first_char, first_char + dlg->re->GetLineLength(line));
- if (opts.auto_replace_user)
- errors += CheckTextLine(dlg, line, &AutoReplaceParser(dlg->lang->autoReplace),
- FALSE, FALSE, TRUE,
- cur_sel, callback, param);
+ if (opts.auto_replace_user) {
+ AutoReplaceParser parser(dlg->lang->autoReplace);
+ errors += CheckTextLine(dlg, line, &parser, FALSE, FALSE, TRUE, cur_sel, callback, param);
+ }
- errors += CheckTextLine(dlg, line, &SpellParser(dlg->lang),
- opts.ignore_uppercase, opts.ignore_with_numbers, FALSE,
- cur_sel, callback, param);
+ SpellParser parser(dlg->lang);
+ errors += CheckTextLine(dlg, line, &parser, opts.ignore_uppercase, opts.ignore_with_numbers, FALSE, cur_sel, callback, param);
}
}
@@ -1195,7 +1191,7 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner)
static void AddWordToDictCallback(BOOL canceled, Dictionary *dict,
const TCHAR *find, const TCHAR *replace, BOOL useVariables,
- const TCHAR *original_find, void *param)
+ const TCHAR *, void *param)
{
if (canceled)
return;
@@ -1208,7 +1204,7 @@ static void AddWordToDictCallback(BOOL canceled, Dictionary *dict,
}
-BOOL HandleMenuSelection(Dialog *dlg, POINT pt, unsigned selection)
+BOOL HandleMenuSelection(Dialog *dlg, unsigned selection)
{
BOOL ret = FALSE;
@@ -1299,7 +1295,7 @@ int MsgWindowPopup(WPARAM, LPARAM lParam)
if (mwpd->uType == MSG_WINDOWPOPUP_SHOWING)
AddItemsToMenu(dlg, mwpd->hMenu, pt, dlg->hwnd_owner);
else if (mwpd->uType == MSG_WINDOWPOPUP_SELECTED)
- HandleMenuSelection(dlg, pt, mwpd->selection);
+ HandleMenuSelection(dlg, mwpd->selection);
return 0;
}
@@ -1338,12 +1334,11 @@ int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner)
AddItemsToMenu(dlg, hMenu, pt, hwndOwner);
// Show menu
- POINT client = pt;
ClientToScreen(hwnd, &pt);
int selection = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndOwner, NULL);
// Do action
- if (HandleMenuSelection(dlg, client, selection))
+ if (HandleMenuSelection(dlg, selection))
selection = 0;
if (create_menu)
@@ -1380,17 +1375,16 @@ int IconPressed(WPARAM hContact, LPARAM lParam)
return 0;
// Find the dialog
- HWND hwnd = NULL;
- Dialog *dlg;
+ Dialog *dlg = NULL;
for (DialogMapType::iterator it = dialogs.begin(); it != dialogs.end(); it++) {
- dlg = it->second;
- if (dlg->srmm && dlg->hContact == hContact) {
- hwnd = it->first;
+ Dialog *p = it->second;
+ if (p->srmm && p->hContact == hContact) {
+ dlg = p;
break;
}
}
- if (hwnd == NULL)
+ if (dlg == NULL)
return 0;
if ((sicd->flags & MBCF_RIGHTBUTTON) == 0) {
@@ -1418,13 +1412,11 @@ int IconPressed(WPARAM hContact, LPARAM lParam)
// Show menu
int selection = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, dlg->hwnd, NULL);
- HandleMenuSelection(dlg, sicd->clickLocation, selection);
+ HandleMenuSelection(dlg, selection);
DestroyMenu(hMenu);
}
- else {
- // Enable / disable
- HandleMenuSelection(dlg, sicd->clickLocation, 1);
- }
+ else // Enable / disable
+ HandleMenuSelection(dlg, 1);
return 0;
}