From 5c74a3bb88db0fa32c459f8494e9f5a62a821baa Mon Sep 17 00:00:00 2001 From: Xavier G Date: Fri, 13 May 2016 01:39:14 +0200 Subject: [PATCH] Move advance() from fe-common/core to core. --- src/core/utf8.c | 15 +++++++++++++++ src/core/utf8.h | 5 +++++ src/fe-common/core/formats.c | 16 ---------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/core/utf8.c b/src/core/utf8.c index 1ab6def9..6daa878a 100644 --- a/src/core/utf8.c +++ b/src/core/utf8.c @@ -26,3 +26,18 @@ #include "module.h" #include "wcwidth.c" +int advance(char const **str, gboolean utf8) +{ + if (utf8) { + gunichar c; + + c = g_utf8_get_char(*str); + *str = g_utf8_next_char(*str); + + return unichar_isprint(c) ? mk_wcwidth(c) : 1; + } else { + *str += 1; + + return 1; + } +} diff --git a/src/core/utf8.h b/src/core/utf8.h index 63261a24..09397f69 100644 --- a/src/core/utf8.h +++ b/src/core/utf8.h @@ -14,6 +14,11 @@ typedef guint32 unichar; /* Returns width for character (0-2). */ int mk_wcwidth(unichar c); +/* Advance the str pointer one character further; return the number of columns + * occupied by the skipped character. + */ +int advance(char const **str, gboolean utf8); + #define unichar_isprint(c) (((c) & ~0x80) >= 32) #define is_utf8_leading(c) (((c) & 0xc0) != 0x80) diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index ccf48394..7daecfcf 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -420,22 +420,6 @@ void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, window_find_closest(server, target, level); } -static int advance (char const **str, gboolean utf8) -{ - if (utf8) { - gunichar c; - - c = g_utf8_get_char(*str); - *str = g_utf8_next_char(*str); - - return unichar_isprint(c) ? mk_wcwidth(c) : 1; - } else { - *str += 1; - - return 1; - } -} - /* Return length of text part in string (ie. without % codes) */ int format_get_length(const char *str) {