Commit 3b845ef6 authored by Morten Welinder's avatar Morten Welinder

Fix thingo.

parent c2d63604
...@@ -233,15 +233,17 @@ autocorrect_set_exceptions (AutoCorrectFeature feature, GSList const *list) ...@@ -233,15 +233,17 @@ autocorrect_set_exceptions (AutoCorrectFeature feature, GSList const *list)
* Utility to replace a single character in an utf8 string. * Utility to replace a single character in an utf8 string.
*/ */
static char * static char *
replace1 (const char *src, int keepbytes, gunichar c, const char *tail) replace1 (const char *src, int keepbytes, const char *mid, const char *tail)
{ {
char *dst = g_new (char, strlen (src) + 7); int midlen = strlen (mid);
char *dst = g_new (char, strlen (src) + midlen + 2);
char *p = dst; char *p = dst;
memcpy (p, src, keepbytes); memcpy (p, src, keepbytes);
p += keepbytes; p += keepbytes;
p += g_unichar_to_utf8 (c, p); strcpy (p, mid);
p += midlen;
strcpy (p, tail); strcpy (p, tail);
return dst; return dst;
...@@ -292,7 +294,7 @@ autocorrect_initial_caps (const char *src) ...@@ -292,7 +294,7 @@ autocorrect_initial_caps (const char *src)
const char *target = g_utf8_prev_char (p); const char *target = g_utf8_prev_char (p);
const char *begin = g_utf8_prev_char (target); const char *begin = g_utf8_prev_char (target);
GSList *l; GSList *l;
char *newres; char *newres, *lotext;
for (l = autocorrect.exceptions.init_caps; l; l = l->next) { for (l = autocorrect.exceptions.init_caps; l; l = l->next) {
const char *except = l->data; const char *except = l->data;
...@@ -300,9 +302,9 @@ autocorrect_initial_caps (const char *src) ...@@ -300,9 +302,9 @@ autocorrect_initial_caps (const char *src)
continue; continue;
} }
newres = replace1 (src, target - src, lotext = g_utf8_strdown (target, 1);
g_unichar_tolower (g_utf8_get_char (target)), newres = replace1 (src, target - src, lotext, p);
p); g_free (lotext);
p = newres + (p - src); p = newres + (p - src);
g_free (res); g_free (res);
src = res = newres; src = res = newres;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment