From 20cd751db12c400c98533c1b98fa984a9aecf9db Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 25 Dec 2008 04:47:56 +0100 Subject: [PATCH] configure.ac: added --disable-multibyte This allows you to disable wide character support, retaining multibyte character support. --- NEWS | 3 +++ configure.ac | 15 +++++++++++++++ src/charset.c | 4 ++++ src/options.c | 3 +++ src/wreadln.c | 16 ++++++++-------- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 59b8077..92b426e 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ ncmpc 0.13 - not yet released * added output configuration screen, default hotkey F8 * new --disable-locale configure option + * new --disable-multibyte configure option; this allows you to + disable wide character support, retaining multibyte character + support ncmpc 0.12 - 2008-12-05 diff --git a/configure.ac b/configure.ac index 6211f0e..d9748b9 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,21 @@ if test "x$enable_wide" = "xyes" ; then AC_DEFINE([ENABLE_WIDE], [1], [Enable wide character support]) fi +dnl multi-byte character support + +AC_ARG_ENABLE([multibyte], + AC_HELP_STRING([--disable-multibyte], + [Disable multibyte character support (default: enabled)]), + [enable_multibyte=$enableval], + [enable_multibyte=$disable_mini]) + +if test x$enable_multibyte = xyes; then + AC_DEFINE([ENABLE_MULTIBYTE], [1], [Enable multibyte character support]) +else + if test x$enable_wide = xyes; then + AC_MSG_WARN(wide characters without multibyte characters makes little sense) + fi +fi dnl Check for glib-2.4 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.4],, diff --git a/src/charset.c b/src/charset.c index b948636..fb22f0b 100644 --- a/src/charset.c +++ b/src/charset.c @@ -41,6 +41,9 @@ utf8_width(const char *str) { assert(str != NULL); +#if defined(ENABLE_MULTIBYTE) && !defined(ENABLE_WIDE) + return g_utf8_strlen(str, -1); +#else #ifdef ENABLE_WIDE if (g_utf8_validate(str, -1, NULL)) { size_t len = g_utf8_strlen(str, -1); @@ -57,6 +60,7 @@ utf8_width(const char *str) } else #endif return strlen(str); +#endif } char * diff --git a/src/options.c b/src/options.c index 7c82f7c..918f313 100644 --- a/src/options.c +++ b/src/options.c @@ -166,6 +166,9 @@ handle_option(int c, const char *arg) #ifndef NDEBUG " debug" #endif +#ifdef ENABLE_MULTIBYTE + " multibyte" +#endif #ifdef ENABLE_WIDE " wide" #endif diff --git a/src/wreadln.c b/src/wreadln.c index a382fce..dccf084 100644 --- a/src/wreadln.c +++ b/src/wreadln.c @@ -26,7 +26,7 @@ #include #include -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) #include #endif @@ -82,7 +82,7 @@ wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL; static unsigned byte_to_screen(const gchar *data, size_t x) { -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) gchar *dup; char *p; unsigned width; @@ -109,7 +109,7 @@ byte_to_screen(const gchar *data, size_t x) static size_t screen_to_bytes(const gchar *data, unsigned width) { -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) size_t length = strlen(data); gchar *dup = g_strdup(data); char *p; @@ -149,7 +149,7 @@ cursor_column(const struct wreadln *wr) static inline size_t right_align_bytes(const gchar *data, size_t right, unsigned width) { -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) gchar *dup; size_t start = 0; @@ -191,7 +191,7 @@ right_align_bytes(const gchar *data, size_t right, unsigned width) static inline size_t next_char_size(const gchar *data) { -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) char *p = locale_to_utf8(data), *q; gunichar c; size_t size; @@ -216,7 +216,7 @@ next_char_size(const gchar *data) static inline size_t prev_char_size(const gchar *data, size_t x) { -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) char *p = locale_to_utf8(data), *q; gunichar c; size_t size; @@ -300,7 +300,7 @@ static inline void drawline(const struct wreadln *wr) doupdate(); } -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) static bool multibyte_is_complete(const char *p, size_t length) { @@ -321,7 +321,7 @@ static void wreadln_insert_byte(struct wreadln *wr, gint key) { size_t rest = strlen(wr->line + wr->cursor) + 1; -#ifdef ENABLE_WIDE +#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE) char buffer[32] = { key }; size_t length = 1; struct pollfd pfd = { -- 2.30.2