summaryrefslogtreecommitdiff
path: root/plugins/SpellChecker
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-02-08 21:09:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-02-08 21:09:39 +0000
commit861cabec0529cc44e7d8741629bbfa9701dd40ad (patch)
treebab57f5e51b3b6e2c830ebe7bab15af8fdd05fbf /plugins/SpellChecker
parent1451c41ce6f6f6921c70bcfe0aea52ae48ffc515 (diff)
- crash fix in hunspell
- warning fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@3493 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SpellChecker')
-rw-r--r--plugins/SpellChecker/src/RichEdit.cpp2
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp6
-rw-r--r--plugins/SpellChecker/src/hunspell/hunspell.cxx15
-rw-r--r--plugins/SpellChecker/src/hunspell/hunvisapi.h2
-rw-r--r--plugins/SpellChecker/src/options.cpp2
-rw-r--r--plugins/SpellChecker/src/utils.cpp4
6 files changed, 22 insertions, 9 deletions
diff --git a/plugins/SpellChecker/src/RichEdit.cpp b/plugins/SpellChecker/src/RichEdit.cpp
index b19e037c72..0b24ce48f9 100644
--- a/plugins/SpellChecker/src/RichEdit.cpp
+++ b/plugins/SpellChecker/src/RichEdit.cpp
@@ -150,7 +150,7 @@ int RichEdit::GetLineCount() const
void RichEdit::GetLine(int line, TCHAR *text, size_t text_len) const
{
- *((WORD*)text) = text_len - 1;
+ *((WORD*)text) = WORD(text_len - 1);
unsigned size = (unsigned) SendMessage(EM_GETLINE, (WPARAM) line, (LPARAM) text);
// Sometimes it likes to return size = lineLen+1, adding an \n at the end, so we remove it here
// to make both implementations return same size
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 88ffde5215..1b36fed403 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -116,19 +116,15 @@ protected:
void toHunspell(char *hunspellWord, const TCHAR *word, size_t hunspellWordLen)
{
-
- WideCharToMultiByte(codePage, 0, word, -1, hunspellWord, hunspellWordLen, NULL, NULL);
-
+ WideCharToMultiByte(codePage, 0, word, -1, hunspellWord, (int)hunspellWordLen, NULL, NULL);
}
TCHAR * fromHunspell(const char *hunspellWord)
{
-
int len = MultiByteToWideChar(codePage, 0, hunspellWord, -1, NULL, 0);
WCHAR *ret = (WCHAR *) malloc((len + 1) * sizeof(WCHAR));
MultiByteToWideChar(codePage, 0, hunspellWord, -1, ret, len + 1);
return ret;
-
}
TCHAR * fromHunspellAndFree(char *hunspellWord)
diff --git a/plugins/SpellChecker/src/hunspell/hunspell.cxx b/plugins/SpellChecker/src/hunspell/hunspell.cxx
index 8e00e1b8cc..6b35fb51e0 100644
--- a/plugins/SpellChecker/src/hunspell/hunspell.cxx
+++ b/plugins/SpellChecker/src/hunspell/hunspell.cxx
@@ -242,10 +242,25 @@ int Hunspell::mkallcap2(char * p, w_char * u, int nc)
void Hunspell::mkallsmall(char * p)
{
+ if (utf8) {
+ w_char u[MAXWORDLEN];
+ int nc = u8_u16(u, MAXWORDLEN, p);
+ unsigned short idx;
+ for (int i = 0; i < nc; i++) {
+ idx = (u[i].h << 8) + u[i].l;
+ unsigned short low = unicodetolower(idx, langnum);
+ if (idx != low) {
+ u[i].h = (unsigned char) (low >> 8);
+ u[i].l = (unsigned char) (low & 0x00FF);
+ }
+ }
+ u16_u8(p, MAXWORDUTF8LEN, u, nc);
+ } else {
while (*p != '\0') {
*p = csconv[((unsigned char) *p)].clower;
p++;
}
+ }
}
int Hunspell::mkallsmall2(char * p, w_char * u, int nc)
diff --git a/plugins/SpellChecker/src/hunspell/hunvisapi.h b/plugins/SpellChecker/src/hunspell/hunvisapi.h
index 4712280ad2..e466db9df1 100644
--- a/plugins/SpellChecker/src/hunspell/hunvisapi.h
+++ b/plugins/SpellChecker/src/hunspell/hunvisapi.h
@@ -1,6 +1,8 @@
#ifndef _HUNSPELL_VISIBILITY_H_
#define _HUNSPELL_VISIBILITY_H_
+#pragma warning(disable:4267)
+
#if defined(HUNSPELL_STATIC)
# define LIBHUNSPELL_DLL_EXPORTED
#elif defined(_MSC_VER)
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp
index 5a1f8e29b7..844ec42390 100644
--- a/plugins/SpellChecker/src/options.cpp
+++ b/plugins/SpellChecker/src/options.cpp
@@ -312,7 +312,7 @@ static void LoadReplacements(HWND hwndDlg)
item.iItem = i;
item.iSubItem = 0;
item.pszText = (TCHAR *) it->first.c_str();
- item.cchTextMax = it->first.length();
+ item.cchTextMax = (int)it->first.length();
item.lParam = i;
ListView_InsertItem(hList, &item);
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp
index bcb3fde5a8..5b46486e6f 100644
--- a/plugins/SpellChecker/src/utils.cpp
+++ b/plugins/SpellChecker/src/utils.cpp
@@ -1135,7 +1135,7 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL
InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + suggestions.count, TranslateT("Other..."));
if (suggestions.count > 0) {
InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0);
- for (int i = suggestions.count-1; i >= 0; i--)
+ for (int i = (int)suggestions.count-1; i >= 0; i--)
InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + i, suggestions.words[i]);
}
@@ -1155,7 +1155,7 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL
hSubMenu = hMenu;
}
- for (int i = suggestions.count - 1; i >= 0; i--)
+ for (int i = (int)suggestions.count - 1; i >= 0; i--)
InsertMenu(hSubMenu, 0, MF_BYPOSITION, base + i, suggestions.words[i]);
}