diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/utf8.c | 5 | ||||
-rw-r--r-- | src/core/utf8.h | 2 | ||||
-rw-r--r-- | src/fe-common/core/formats.c | 8 | ||||
-rw-r--r-- | src/fe-text/gui-entry.c | 2 |
4 files changed, 9 insertions, 8 deletions
diff --git a/src/core/utf8.c b/src/core/utf8.c index d931ba19..c9303d19 100644 --- a/src/core/utf8.c +++ b/src/core/utf8.c @@ -28,9 +28,9 @@ /* Provide is_utf8(): */ #include "recode.h" -int string_advance(char const **str, gboolean utf8) +int string_advance(char const **str, int policy) { - if (utf8) { + if (policy == TREAT_STRING_AS_UTF8) { gunichar c; c = g_utf8_get_char(*str); @@ -38,6 +38,7 @@ int string_advance(char const **str, gboolean utf8) return unichar_isprint(c) ? mk_wcwidth(c) : 1; } else { + /* Assume TREAT_STRING_AS_BYTES: */ *str += 1; return 1; diff --git a/src/core/utf8.h b/src/core/utf8.h index fa11b737..f1a8f0e1 100644 --- a/src/core/utf8.h +++ b/src/core/utf8.h @@ -17,7 +17,7 @@ int mk_wcwidth(unichar c); /* Advance the str pointer one character further; return the number of columns * occupied by the skipped character. */ -int string_advance(char const **str, gboolean utf8); +int string_advance(char const **str, int policy); /* TREAT_STRING_AS_BYTES means strings are to be treated using strncpy, * strnlen, etc. diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index def03e10..3e88426f 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -425,12 +425,12 @@ int format_get_length(const char *str) { GString *tmp; int len; - gboolean utf8; + int utf8; int adv = 0; g_return_val_if_fail(str != NULL, 0); - utf8 = is_utf8() && g_utf8_validate(str, -1, NULL); + utf8 = string_policy(str); tmp = g_string_new(NULL); len = 0; @@ -464,12 +464,12 @@ int format_real_length(const char *str, int len) GString *tmp; const char *start; const char *oldstr; - gboolean utf8; + int utf8; int adv = 0; g_return_val_if_fail(str != NULL, 0); g_return_val_if_fail(len >= 0, 0); - utf8 = is_utf8() && g_utf8_validate(str, -1, NULL); + utf8 = string_policy(str); start = str; tmp = g_string_new(NULL); diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 63dda34e..beea2273 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -367,7 +367,7 @@ static int scrlen_str(const char *str) g_return_val_if_fail(str != NULL, 0); str = stripped = strip_codes(str); - if (is_utf8() && g_utf8_validate(str, -1, NULL)) { + if (string_policy(str) == TREAT_STRING_AS_UTF8) { while (*str != '\0') { gunichar c; |