bump product version to 6.1.0.2
[LibreOffice.git] / external / hunspell / 0001-Hunspell-patches-for-missing-OCONV-conversion.patch
blob83d429f509796efb0a5c595858ab5961f2821837
1 From e13ff056fd65990b88d29fb9eae304b411e58234 Mon Sep 17 00:00:00 2001
2 From: Changwoo Ryu <cwryu@debian.org>
3 Date: Wed, 8 Mar 2017 14:04:26 +0900
4 Subject: [PATCH] Hunspell patches for missing OCONV conversion
6 4e2abfd Clean up PR #479
7 cc2d71e Add oconv2 test to Makefile
8 ca14fdb Avoid gotos across variable initialization
9 7e5cb62 Use goto to reduce repetitive code
10 f528192 Add missing OCONV conversion of root and morphemes output
11 ---
12 src/hunspell/hunspell.cxx | 59 +++++++++++++++++++++++++++++++++++++++--------
13 tests/test.sh | 23 +++++++++++++++---
14 2 files changed, 70 insertions(+), 12 deletions(-)
16 diff --git a/src/hunspell/hunspell.cxx b/src/hunspell/hunspell.cxx
17 index 1100a6f..87d1b4a 100644
18 --- a/src/hunspell/hunspell.cxx
19 +++ b/src/hunspell/hunspell.cxx
20 @@ -98,10 +98,13 @@ public:
21 std::vector<std::string> stem(const std::string& word);
22 std::vector<std::string> stem(const std::vector<std::string>& morph);
23 std::vector<std::string> analyze(const std::string& word);
24 + std::vector<std::string> analyze_internal(const std::string& word);
25 int get_langnum() const;
26 bool input_conv(const std::string& word, std::string& dest);
27 bool spell(const std::string& word, int* info = NULL, std::string* root = NULL);
28 + bool spell_internal(const std::string& word, int* info = NULL, std::string* root = NULL);
29 std::vector<std::string> suggest(const std::string& word);
30 + std::vector<std::string> suggest_internal(const std::string& word);
31 const std::string& get_wordchars() const;
32 const std::vector<w_char>& get_wordchars_utf16() const;
33 const std::string& get_dict_encoding() const;
34 @@ -415,6 +418,21 @@ bool Hunspell::spell(const std::string& word, int* info, std::string* root) {
37 bool HunspellImpl::spell(const std::string& word, int* info, std::string* root) {
38 + bool r = spell_internal(word, info, root);
39 + if (r && root) {
40 + // output conversion
41 + RepList* rl = (pAMgr) ? pAMgr->get_oconvtable() : NULL;
42 + if (rl) {
43 + std::string wspace;
44 + if (rl->conv(*root, wspace)) {
45 + *root = wspace;
46 + }
47 + }
48 + }
49 + return r;
52 +bool HunspellImpl::spell_internal(const std::string& word, int* info, std::string* root) {
53 struct hentry* rv = NULL;
55 int info2 = 0;
56 @@ -834,6 +852,22 @@ std::vector<std::string> Hunspell::suggest(const std::string& word) {
58 std::vector<std::string> HunspellImpl::suggest(const std::string& word) {
59 std::vector<std::string> slst;
60 + slst = suggest_internal(word);
61 + // output conversion
62 + RepList* rl = (pAMgr) ? pAMgr->get_oconvtable() : NULL;
63 + if (rl) {
64 + for (size_t i = 0; rl && i < slst.size(); ++i) {
65 + std::string wspace;
66 + if (rl->conv(slst[i], wspace)) {
67 + slst[i] = wspace;
68 + }
69 + }
70 + }
71 + return slst;
74 +std::vector<std::string> HunspellImpl::suggest_internal(const std::string& word) {
75 + std::vector<std::string> slst;
77 int onlycmpdsug = 0;
78 if (!pSMgr || m_HMgrs.empty())
79 @@ -1150,15 +1184,6 @@ std::vector<std::string> HunspellImpl::suggest(const std::string& word) {
81 slst.resize(l);
83 - // output conversion
84 - rl = (pAMgr) ? pAMgr->get_oconvtable() : NULL;
85 - for (size_t j = 0; rl && j < slst.size(); ++j) {
86 - std::string wspace;
87 - if (rl->conv(slst[j], wspace)) {
88 - slst[j] = wspace;
89 - }
90 - }
92 return slst;
95 @@ -1365,6 +1390,22 @@ std::vector<std::string> Hunspell::analyze(const std::string& word) {
97 std::vector<std::string> HunspellImpl::analyze(const std::string& word) {
98 std::vector<std::string> slst;
99 + slst = analyze_internal(word);
100 + // output conversion
101 + RepList* rl = (pAMgr) ? pAMgr->get_oconvtable() : NULL;
102 + if (rl) {
103 + for (size_t i = 0; rl && i < slst.size(); ++i) {
104 + std::string wspace;
105 + if (rl->conv(slst[i], wspace)) {
106 + slst[i] = wspace;
110 + return slst;
113 +std::vector<std::string> HunspellImpl::analyze_internal(const std::string& word) {
114 + std::vector<std::string> slst;
115 if (!pSMgr || m_HMgrs.empty())
116 return slst;
117 if (utf8) {
118 diff --git a/tests/test.sh b/tests/test.sh
119 index 22e5087..9344f82 100755
120 --- a/tests/test.sh
121 +++ b/tests/test.sh
122 @@ -112,7 +112,7 @@ if test -f $TESTDIR/$NAME.wrong; then
123 echo "============================================="
124 echo "Fail in $NAME.wrong. Bad words recognised as good:"
125 tr -d ' ' <$TESTDIR/$NAME.wrong >$TEMPDIR/$NAME.wrong.detab
126 - diff $TEMPDIR/$NAME.wrong.detab $TEMPDIR/$NAME.wrong | grep '^<' | sed 's/^..//'
127 + diff -u $TEMPDIR/$NAME.wrong.detab $TEMPDIR/$NAME.wrong | grep '^<' | sed 's/^..//'
128 rm -f $TEMPDIR/$NAME.wrong $TEMPDIR/$NAME.wrong.detab
129 exit 1
131 @@ -121,6 +121,23 @@ fi
133 check_valgrind_log "bad words"
135 +# Tests good words' root
136 +if test -f $TESTDIR/$NAME.root; then
137 + # Extract the root words of the affixed words, after '+'
138 + hunspell $* -d $TESTDIR/$NAME <$TESTDIR/$NAME.good | grep -a '^+ ' | \
139 + sed 's/^+ //' >$TEMPDIR/$NAME.root
140 + if ! cmp $TEMPDIR/$NAME.root $TESTDIR/$NAME.root >/dev/null; then
141 + echo "============================================="
142 + echo "Fail in $NAME.root. Bad prefix or suffix?"
143 + diff -u $TESTDIR/$NAME.root $TEMPDIR/$NAME.root
144 + rm -f $TEMPDIR/$NAME.root
145 + exit 1
146 + fi
147 + rm -f $TEMPDIR/$NAME.root
150 +check_valgrind_log "root"
152 # Tests morphological analysis
153 if test -f $TESTDIR/$NAME.morph; then
154 sed 's/ $//' $TESTDIR/$NAME.good >$TEMPDIR/$NAME.good
155 @@ -129,7 +146,7 @@ if test -f $TESTDIR/$NAME.morph; then
156 if ! cmp $TEMPDIR/$NAME.morph $TESTDIR/$NAME.morph >/dev/null; then
157 echo "============================================="
158 echo "Fail in $NAME.morph. Bad analysis?"
159 - diff $TESTDIR/$NAME.morph $TEMPDIR/$NAME.morph | grep '^<' | sed 's/^..//'
160 + diff -u $TESTDIR/$NAME.morph $TEMPDIR/$NAME.morph | grep '^<' | sed 's/^..//'
161 rm -f $TEMPDIR/$NAME.morph
162 exit 1
164 @@ -145,7 +162,7 @@ if test -f $TESTDIR/$NAME.sug; then
165 if ! cmp $TEMPDIR/$NAME.sug $TESTDIR/$NAME.sug >/dev/null; then
166 echo "============================================="
167 echo "Fail in $NAME.sug. Bad suggestion?"
168 - diff $TESTDIR/$NAME.sug $TEMPDIR/$NAME.sug
169 + diff -u $TESTDIR/$NAME.sug $TEMPDIR/$NAME.sug
170 rm -f $TEMPDIR/$NAME.sug
171 exit 1
174 2.7.4