summaryrefslogtreecommitdiff
path: root/plugins/SpellChecker/src/hunspell/csutil.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SpellChecker/src/hunspell/csutil.cxx')
-rw-r--r--plugins/SpellChecker/src/hunspell/csutil.cxx59
1 files changed, 31 insertions, 28 deletions
diff --git a/plugins/SpellChecker/src/hunspell/csutil.cxx b/plugins/SpellChecker/src/hunspell/csutil.cxx
index ee78edbc40..86b75242ef 100644
--- a/plugins/SpellChecker/src/hunspell/csutil.cxx
+++ b/plugins/SpellChecker/src/hunspell/csutil.cxx
@@ -339,34 +339,37 @@ int line_tok(const char * text, char *** lines, char breakchar) {
}
// uniq line in place
-char * line_uniq(char * text, char breakchar) {
- char ** lines;
- int linenum = line_tok(text, &lines, breakchar);
- int i;
-
- if (linenum == 0)
- return NULL;
- strcpy(text, lines[0]);
- for ( i = 1; i < linenum; i++ ) {
- int dup = 0;
- for (int j = 0; j < i; j++) {
- if (strcmp(lines[i], lines[j]) == 0) {
- dup = 1;
- break;
- }
- }
- if (!dup) {
- if ((i > 1) || (*(lines[0]) != '\0')) {
- sprintf(text + strlen(text), "%c", breakchar);
- }
- strcat(text, lines[i]);
- }
- }
- for ( i = 0; i < linenum; i++ ) {
- if (lines[i]) free(lines[i]);
- }
- if (lines) free(lines);
- return text;
+char * line_uniq(char * text, char breakchar)
+{
+ char **lines;
+ int linenum = line_tok(text, &lines, breakchar);
+ int i;
+
+ if (linenum == 0)
+ text = NULL;
+ else {
+ strcpy(text, lines[0]);
+ for (i = 1; i < linenum; i++) {
+ int dup = 0;
+ for (int j = 0; j < i; j++) {
+ if (strcmp(lines[i], lines[j]) == 0) {
+ dup = 1;
+ break;
+ }
+ }
+ if (!dup) {
+ if ((i > 1) || (*(lines[0]) != '\0')) {
+ sprintf(text + strlen(text), "%c", breakchar);
+ }
+ strcat(text, lines[i]);
+ }
+ }
+ }
+ for (i = 0; i < linenum; i++) {
+ if (lines[i]) free(lines[i]);
+ }
+ if (lines) free(lines);
+ return text;
}
// uniq and boundary for compound analysis: "1\n\2\n\1" -> " ( \1 | \2 ) "