summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 844bc26)
raw | patch | inline | side by side (parent: 844bc26)
author | Max Kellermann <max@duempel.org> | |
Thu, 25 Dec 2008 03:47:56 +0000 (04:47 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 25 Dec 2008 03:47:56 +0000 (04:47 +0100) |
This allows you to disable wide character support, retaining multibyte
character support.
character support.
NEWS | patch | blob | history | |
configure.ac | patch | blob | history | |
src/charset.c | patch | blob | history | |
src/options.c | patch | blob | history | |
src/wreadln.c | patch | blob | history |
index 59b8077603dc9984c184a79b7e0b1ed21d75cc61..92b426eaad3bdd090f54b4d6d9c7ef2bf6e75b11 100644 (file)
--- a/NEWS
+++ b/NEWS
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 6211f0ee6dd4216a3ff8db07c64d83fc5889a5c0..d9748b9472de4e567e0b1712ad2df4ff6a25cb25 100644 (file)
--- a/configure.ac
+++ b/configure.ac
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 b948636f03c57e4ab31789ab42c02c535bb1058a..fb22f0b685f3e6d09d779d2f3111d5035233d5da 100644 (file)
--- a/src/charset.c
+++ b/src/charset.c
{
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);
} else
#endif
return strlen(str);
+#endif
}
char *
diff --git a/src/options.c b/src/options.c
index 7c82f7cefccba74739783ef895f8741621931b70..918f3135c715abb2eabf054a34df76fd98f23007 100644 (file)
--- a/src/options.c
+++ b/src/options.c
#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 a382fcecc2d7cbc1ddb4410fcd56c52c936b4134..dccf084b4da1f92278b5944966bed389f5d3bdf7 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
#include <string.h>
#include <glib.h>
-#ifdef ENABLE_WIDE
+#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE)
#include <sys/poll.h>
#endif
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;
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;
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;
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;
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;
doupdate();
}
-#ifdef ENABLE_WIDE
+#if defined(ENABLE_WIDE) || defined(ENABLE_MULTIBYTE)
static bool
multibyte_is_complete(const char *p, size_t length)
{
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 = {