bump product version to 4.1.6.2
[LibreOffice.git] / hunspell / hunspell.rhbz918938.patch
blobf1bdbd4ff8bae4b51512cae93d1742c7ef9f9c20
1 --- misc/hunspell-1.3.2/src/hunspell/hunspell.cxx 2011-02-02 12:04:29.000000000 +0000
2 +++ misc/build/hunspell-1.3.2/src/hunspell/hunspell.cxx 2013-03-13 16:50:50.667928521 +0000
3 @@ -12,6 +12,8 @@
4 #endif
5 #include "csutil.hxx"
7 +#include <string>
9 Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key)
11 encoding = NULL;
12 @@ -1710,6 +1712,19 @@
13 return n;
16 +namespace
18 + void myrep(std::string& str, const std::string& search, const std::string& replace)
19 + {
20 + size_t pos = 0;
21 + while ((pos = str.find(search, pos)) != std::string::npos)
22 + {
23 + str.replace(pos, search.length(), replace);
24 + pos += replace.length();
25 + }
26 + }
29 int Hunspell::spellml(char*** slst, const char * word)
31 char *q, *q2;
32 @@ -1721,26 +1736,26 @@
33 q2 = strstr(q2, "<word");
34 if (!q2) return 0; // bad XML input
35 if (check_xml_par(q, "type=", "analyze")) {
36 - int n = 0, s = 0;
37 + int n = 0;
38 if (get_xml_par(cw, strchr(q2, '>'), MAXWORDUTF8LEN - 10)) n = analyze(slst, cw);
39 if (n == 0) return 0;
40 // convert the result to <code><a>ana1</a><a>ana2</a></code> format
41 - for (int i = 0; i < n; i++) s+= strlen((*slst)[i]);
42 - char * r = (char *) malloc(6 + 5 * s + 7 * n + 7 + 1); // XXX 5*s->&->&amp;
43 - if (!r) return 0;
44 - strcpy(r, "<code>");
45 + std::string r;
46 + r.append("<code>");
47 for (int i = 0; i < n; i++) {
48 - int l = strlen(r);
49 - strcpy(r + l, "<a>");
50 - strcpy(r + l + 3, (*slst)[i]);
51 - mystrrep(r + l + 3, "\t", " ");
52 - mystrrep(r + l + 3, "<", "&lt;");
53 - mystrrep(r + l + 3, "&", "&amp;");
54 - strcat(r, "</a>");
55 + r.append("<a>");
57 + std::string entry((*slst)[i]);
58 free((*slst)[i]);
59 + myrep(entry, "\t", " ");
60 + myrep(entry, "&", "&amp;");
61 + myrep(entry, "<", "&lt;");
62 + r.append(entry);
64 + r.append("</a>");
66 - strcat(r, "</code>");
67 - (*slst)[0] = r;
68 + r.append("</code>");
69 + (*slst)[0] = mystrdup(r.c_str());
70 return 1;
71 } else if (check_xml_par(q, "type=", "stem")) {
72 if (get_xml_par(cw, strchr(q2, '>'), MAXWORDUTF8LEN - 1)) return stem(slst, cw);