diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-10-06 16:09:35 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-10-06 16:11:55 +0200 |
commit | 03f2123447b1a5537db1cdde016eb87eb2d2371f (patch) | |
tree | 1af7e50a4183d82bc20b488fbbb93192cb7356e5 /src | |
parent | 3c87b95c3189077aa52307a7f904d693a8b2f3cb (diff) | |
download | tdv-03f2123447b1a5537db1cdde016eb87eb2d2371f.tar.gz tdv-03f2123447b1a5537db1cdde016eb87eb2d2371f.tar.xz tdv-03f2123447b1a5537db1cdde016eb87eb2d2371f.zip |
GLib-related improvements
Now all error messages produced by tools should be in the right
encoding, even if the system isn't in UTF-8.
Diffstat (limited to 'src')
-rw-r--r-- | src/add-pronunciation.c | 2 | ||||
-rw-r--r-- | src/transform.c | 11 | ||||
-rw-r--r-- | src/utils.c | 3 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/add-pronunciation.c b/src/add-pronunciation.c index eb0d464..d409c9d 100644 --- a/src/add-pronunciation.c +++ b/src/add-pronunciation.c @@ -150,7 +150,7 @@ worker_writer (WorkerData *data) stardict_iterator_next (data->iterator); if (fprintf (data->child_stdin, "%s\n", x) < 0) - fatal ("write to eSpeak failed: %s\n", strerror (errno)); + fatal ("write to eSpeak failed: %s\n", g_strerror (errno)); g_free (x); } diff --git a/src/transform.c b/src/transform.c index f9909b7..e3e8d4d 100644 --- a/src/transform.c +++ b/src/transform.c @@ -76,8 +76,8 @@ write_to_filter (StardictDict *dict, gint fd, GError **error) if (write (fd, field->data, field->data_size) != (ssize_t) field->data_size) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "%s", strerror (errno)); + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), + "%s", g_strerror (errno)); return FALSE; } } @@ -117,7 +117,7 @@ update_from_filter (StardictDict *dict, Generator *generator, gchar *end = memchr (filtered, 0, filtered_end - filtered); if (!end) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + g_set_error (error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT, "filter seems to have ended too early"); return FALSE; } @@ -176,7 +176,6 @@ main (int argc, char *argv[]) ("input.ifo output-basename -- FILTER [ARG...]"); g_option_context_set_summary (ctx, "Transform dictionaries using a filter program."); - g_option_context_set_description (ctx, "Test?"); if (!g_option_context_parse (ctx, &argc, &argv, &error)) fatal ("Error: option parsing failed: %s\n", error->message); @@ -202,7 +201,7 @@ main (int argc, char *argv[]) FILE *child_out = tmpfile (); if (!child_out) - fatal ("tmpfile: %s\n", strerror (errno)); + fatal ("tmpfile: %s\n", g_strerror (errno)); GPid pid = -1; if (!g_spawn_async_with_fds (NULL /* working_directory */, @@ -221,7 +220,7 @@ main (int argc, char *argv[]) int wstatus = errno = 0; if (waitpid (pid, &wstatus, 0) < 1 || !WIFEXITED (wstatus) || WEXITSTATUS (wstatus) > 0) - fatal ("Filter failed (%s, status %d)\n", strerror (errno), wstatus); + fatal ("Filter failed (%s, status %d)\n", g_strerror (errno), wstatus); GMappedFile *filtered = g_mapped_file_new_from_fd (fileno (child_out), FALSE /* writable */, &error); diff --git a/src/utils.c b/src/utils.c index 89cca9a..8c63548 100644 --- a/src/utils.c +++ b/src/utils.c @@ -17,6 +17,7 @@ */ #include <glib.h> +#include <glib/gprintf.h> #include <gio/gio.h> #include <stdlib.h> #include <errno.h> @@ -107,7 +108,7 @@ fatal (const gchar *format, ...) { va_list ap; va_start (ap, format); - vfprintf (stderr, format, ap); + g_vfprintf (stderr, format, ap); exit (EXIT_FAILURE); va_end (ap); } |