summaryrefslogtreecommitdiff
path: root/libs/hunspell/src/phonet.c++
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-10-01 13:24:29 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-10-01 13:24:29 +0300
commit93babaf1665bd2b706a096057fdd06572c159622 (patch)
treeefa9da647497149233facb88a422d9d31564bb4b /libs/hunspell/src/phonet.c++
parent13627600541c19643b96bd4c7b3a3d9fd92040f9 (diff)
fixes #3696 (Update hunspell to 1.7.2)
Diffstat (limited to 'libs/hunspell/src/phonet.c++')
-rw-r--r--libs/hunspell/src/phonet.c++22
1 files changed, 10 insertions, 12 deletions
diff --git a/libs/hunspell/src/phonet.c++ b/libs/hunspell/src/phonet.c++
index c81d890a21..74102fd673 100644
--- a/libs/hunspell/src/phonet.c++
+++ b/libs/hunspell/src/phonet.c++
@@ -27,18 +27,16 @@
Porting from Aspell to Hunspell using C-like structs
*/
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
+#include <cctype>
#include "csutil.hxx"
#include "phonet.hxx"
void init_phonet_hash(phonetable& parms) {
- for (int i = 0; i < HASHSIZE; i++) {
- parms.hash[i] = -1;
- }
+ memset(parms.hash, 0xff, HASHSIZE * sizeof(int));
for (int i = 0; parms.rules[i][0] != '\0'; i += 2) {
/** set hash value **/
@@ -70,14 +68,13 @@ static int myisalpha(char ch) {
/* convert string to uppercase before this call */
std::string phonet(const std::string& inword, phonetable& parms) {
- int i, k = 0, p, z;
- int k0, n0, p0 = -333;
+ int i, k = 0, p, z, k0, n0, p0 = -333;
char c;
typedef unsigned char uchar;
size_t len = inword.size();
if (len > MAXPHONETUTF8LEN)
- return std::string();
+ return {};
char word[MAXPHONETUTF8LEN + 1];
strncpy(word, inword.c_str(), MAXPHONETUTF8LEN);
word[MAXPHONETUTF8LEN] = '\0';
@@ -108,9 +105,10 @@ std::string phonet(const std::string& inword, phonetable& parms) {
if (myisalpha(word[i + k]) // ...could be implied?
&& strchr(s + 1, word[i + k]) != NULL) {
k++;
- while (*s != ')')
+ while (*s && *s != ')')
+ s++;
+ if (*s == ')')
s++;
- s++;
}
}
p0 = (int)*s;