summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fe84050)
raw | patch | inline | side by side (parent: fe84050)
author | Max Kellermann <max@duempel.org> | |
Thu, 2 Oct 2008 17:02:07 +0000 (19:02 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 2 Oct 2008 17:02:07 +0000 (19:02 +0200) |
The code did not compile when HAVE_LOCALE_H was not set. Also don't
compile all that code in charset.c, when there is no locale.h.
compile all that code in charset.c, when there is no locale.h.
src/charset.c | patch | blob | history | |
src/charset.h | patch | blob | history | |
src/main.c | patch | blob | history |
diff --git a/src/charset.c b/src/charset.c
index 42c0e60347432c2f909d97a207c4599cf741797c..095817d1502a5b2ed761cc7e036d22fc0f63502c 100644 (file)
--- a/src/charset.c
+++ b/src/charset.c
#include <string.h>
#include <glib.h>
+#ifdef HAVE_LOCALE_H
static bool noconvert = true;
static const char *charset;
{
noconvert = g_get_charset(&charset);
return charset;
+ return NULL;
}
+#endif
unsigned
utf8_width(const char *str)
{
assert(str != NULL);
+#ifdef HAVE_LOCALE_H
if (g_utf8_validate(str, -1, NULL)) {
size_t len = g_utf8_strlen(str, -1);
unsigned width = 0;
return width;
} else
+#endif
return strlen(str);
}
char *
utf8_to_locale(const char *utf8str)
{
+#ifdef HAVE_LOCALE_H
gchar *str;
GError *error;
}
return str;
+#else
+ return g_strdup(utf8str);
+#endif
}
char *
locale_to_utf8(const char *localestr)
{
+#ifdef HAVE_LOCALE_H
gchar *str;
GError *error;
}
return str;
+#else
+ return g_strdup(localestr);
+#endif
}
diff --git a/src/charset.h b/src/charset.h
index 70173d19c0ee00b070288370bbfb36df6e9e4b40..0cb69d135bece726bb9077d3e10f862b65843016 100644 (file)
--- a/src/charset.h
+++ b/src/charset.h
#ifndef CHARSET_H
#define CHARSET_H
+#include "config.h"
+
#include <stdbool.h>
#include <stddef.h>
+#ifdef HAVE_LOCALE_H
const char *
charset_init(void);
+#endif
/**
* Returns the number of terminal cells occupied by this string.
diff --git a/src/main.c b/src/main.c
index 07198e7de9abbc4e3d79e92baff0a4e699198b39..668d5aa3350a197feccaeb7ea488e08d4f9db9eb 100644 (file)
--- a/src/main.c
+++ b/src/main.c
main(int argc, const char *argv[])
{
struct sigaction act;
+#ifdef HAVE_LOCALE_H
const char *charset = NULL;
+#endif
GIOChannel *keyboard_channel;
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE,"");
/* initialize charset conversions */
charset = charset_init();
-#endif
/* initialize i18n support */
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, charset);
textdomain(GETTEXT_PACKAGE);
+#endif
#endif
/* initialize options */