aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-12-25 21:22:59 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-12-25 21:36:56 +0100
commitb7dd384048c9c8fa916cd4651b0341f037a16f02 (patch)
treedd08b58982a6689a324e883b813caa881f863104
parente101afab380d3a2253dd726719c1057191bbd6d1 (diff)
downloadxK-b7dd384048c9c8fa916cd4651b0341f037a16f02.tar.gz
xK-b7dd384048c9c8fa916cd4651b0341f037a16f02.tar.xz
xK-b7dd384048c9c8fa916cd4651b0341f037a16f02.zip
degesch: little step towards localisation
We don't use LC_MESSAGES, though, so it doesn't really matter as of now. liberty currently isn't prepared for non-ASCII errors or filenames, and just silently expects everything to be in the same all-compatible encoding. degesch further expects the encoding to be UTF-8. All strings should ideally be converted to UTF-8 as soon as possible.
-rw-r--r--degesch.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/degesch.c b/degesch.c
index 09f5d69..12c1345 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2548,6 +2548,7 @@ irc_to_term (struct app_context *ctx, const char *text)
// Format strings use a #-quoted notation, to differentiate from printf:
// #s inserts a string (expected to be in UTF-8)
// #d inserts a signed integer
+// #l inserts a locale-encoded string
//
// #S inserts a string from the server with unknown encoding
// #m inserts a mIRC-formatted string (auto-resets at boundaries)
@@ -2767,6 +2768,14 @@ restart:
case 's':
str_append (buf, (s = va_arg (*ap, char *)));
break;
+ case 'l':
+ if (!(tmp = iconv_xstrdup (self->ctx->term_to_utf8,
+ (s = va_arg (*ap, char *)), -1, NULL)))
+ print_error ("character conversion failed for: %s", "output");
+ else
+ str_append (buf, tmp);
+ free (tmp);
+ break;
case 'S':
tmp = irc_to_utf8 (self->ctx, (s = va_arg (*ap, char *)));
@@ -3228,7 +3237,7 @@ buffer_open_log_file (struct app_context *ctx, struct buffer *buffer)
char *path = buffer_get_log_path (buffer);
if (!(buffer->log_file = fopen (path, "ab")))
- log_global_error (ctx, "Couldn't open log file `#s': #s",
+ log_global_error (ctx, "Couldn't open log file `#s': #l",
path, strerror (errno));
else
set_cloexec (fileno (buffer->log_file));
@@ -9664,7 +9673,7 @@ process_input (struct app_context *ctx, char *user_input)
{
char *input;
if (!(input = iconv_xstrdup (ctx->term_to_utf8, user_input, -1, NULL)))
- print_error ("character conversion failed for `%s'", "user input");
+ print_error ("character conversion failed for: %s", "user input");
else
{
struct str_vector lines;
@@ -10173,7 +10182,7 @@ launch_backlog_helper (struct app_context *ctx, FILE *backlog)
"Failed to launch backlog helper", strerror (errno));
_exit (EXIT_FAILURE);
case -1:
- log_global_error (ctx, "#s: #s",
+ log_global_error (ctx, "#s: #l",
"Failed to launch backlog helper", strerror (errno));
break;
default:
@@ -10187,7 +10196,7 @@ display_backlog (struct app_context *ctx)
FILE *backlog = tmpfile ();
if (!backlog)
{
- log_global_error (ctx, "#s: #s",
+ log_global_error (ctx, "#s: #l",
"Failed to create a temporary file", strerror (errno));
return;
}
@@ -10211,7 +10220,7 @@ display_full_log (struct app_context *ctx)
if (!full_log)
{
- log_global_error (ctx, "Failed to open log file for #s: #s",
+ log_global_error (ctx, "Failed to open log file for #s: #l",
ctx->current_buffer->name, strerror (errno));
return;
}
@@ -10280,7 +10289,7 @@ launch_input_editor (struct app_context *ctx)
"Failed to launch editor", strerror (errno));
_exit (EXIT_FAILURE);
case -1:
- log_global_error (ctx, "#s: #s",
+ log_global_error (ctx, "#s: #l",
"Failed to launch editor", strerror (errno));
free (filename);
break;
@@ -10310,7 +10319,7 @@ process_edited_input (struct app_context *ctx)
"could not re-insert the modified text");
if (unlink (ctx->editor_filename))
- log_global_error (ctx, "Could not unlink `#s': #s",
+ log_global_error (ctx, "Could not unlink `#s': #l",
ctx->editor_filename, strerror (errno));
free (ctx->editor_filename);