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.
This commit is contained in:
parent
3c87b95c31
commit
03f2123447
|
@ -15,7 +15,7 @@ set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
find_package (ZLIB REQUIRED)
|
find_package (ZLIB REQUIRED)
|
||||||
find_package (Ncursesw REQUIRED)
|
find_package (Ncursesw REQUIRED)
|
||||||
find_package (PkgConfig REQUIRED)
|
find_package (PkgConfig REQUIRED)
|
||||||
pkg_check_modules (dependencies REQUIRED glib-2.0 gio-2.0 pango)
|
pkg_check_modules (dependencies REQUIRED glib-2.0>=2.38 gio-2.0 pango)
|
||||||
|
|
||||||
pkg_check_modules (icu icu-uc icu-i18n)
|
pkg_check_modules (icu icu-uc icu-i18n)
|
||||||
if (NOT icu_FOUND)
|
if (NOT icu_FOUND)
|
||||||
|
|
|
@ -31,8 +31,8 @@ a package with the latest development version from Archlinux's AUR.
|
||||||
Building and Running
|
Building and Running
|
||||||
--------------------
|
--------------------
|
||||||
Build dependencies: CMake, pkg-config, asciidoctor +
|
Build dependencies: CMake, pkg-config, asciidoctor +
|
||||||
Runtime dependencies: ncursesw, zlib, ICU, termo (included),
|
Runtime dependencies: ncursesw, zlib, ICU, termo (included), glib-2.0 >= 2.38,
|
||||||
glib-2.0, pango, xcb, xcb-xfixes (the latter two optional)
|
pango, xcb, xcb-xfixes (the latter two optional)
|
||||||
|
|
||||||
$ git clone --recursive https://git.janouch.name/p/sdtui.git
|
$ git clone --recursive https://git.janouch.name/p/sdtui.git
|
||||||
$ mkdir sdtui/build
|
$ mkdir sdtui/build
|
||||||
|
|
|
@ -150,7 +150,7 @@ worker_writer (WorkerData *data)
|
||||||
|
|
||||||
stardict_iterator_next (data->iterator);
|
stardict_iterator_next (data->iterator);
|
||||||
if (fprintf (data->child_stdin, "%s\n", x) < 0)
|
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);
|
g_free (x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,8 @@ write_to_filter (StardictDict *dict, gint fd, GError **error)
|
||||||
if (write (fd, field->data, field->data_size)
|
if (write (fd, field->data, field->data_size)
|
||||||
!= (ssize_t) field->data_size)
|
!= (ssize_t) field->data_size)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
|
||||||
"%s", strerror (errno));
|
"%s", g_strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ update_from_filter (StardictDict *dict, Generator *generator,
|
||||||
gchar *end = memchr (filtered, 0, filtered_end - filtered);
|
gchar *end = memchr (filtered, 0, filtered_end - filtered);
|
||||||
if (!end)
|
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");
|
"filter seems to have ended too early");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,6 @@ main (int argc, char *argv[])
|
||||||
("input.ifo output-basename -- FILTER [ARG...]");
|
("input.ifo output-basename -- FILTER [ARG...]");
|
||||||
g_option_context_set_summary
|
g_option_context_set_summary
|
||||||
(ctx, "Transform dictionaries using a filter program.");
|
(ctx, "Transform dictionaries using a filter program.");
|
||||||
g_option_context_set_description (ctx, "Test?");
|
|
||||||
if (!g_option_context_parse (ctx, &argc, &argv, &error))
|
if (!g_option_context_parse (ctx, &argc, &argv, &error))
|
||||||
fatal ("Error: option parsing failed: %s\n", error->message);
|
fatal ("Error: option parsing failed: %s\n", error->message);
|
||||||
|
|
||||||
|
@ -202,7 +201,7 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
FILE *child_out = tmpfile ();
|
FILE *child_out = tmpfile ();
|
||||||
if (!child_out)
|
if (!child_out)
|
||||||
fatal ("tmpfile: %s\n", strerror (errno));
|
fatal ("tmpfile: %s\n", g_strerror (errno));
|
||||||
|
|
||||||
GPid pid = -1;
|
GPid pid = -1;
|
||||||
if (!g_spawn_async_with_fds (NULL /* working_directory */,
|
if (!g_spawn_async_with_fds (NULL /* working_directory */,
|
||||||
|
@ -221,7 +220,7 @@ main (int argc, char *argv[])
|
||||||
int wstatus = errno = 0;
|
int wstatus = errno = 0;
|
||||||
if (waitpid (pid, &wstatus, 0) < 1
|
if (waitpid (pid, &wstatus, 0) < 1
|
||||||
|| !WIFEXITED (wstatus) || WEXITSTATUS (wstatus) > 0)
|
|| !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),
|
GMappedFile *filtered = g_mapped_file_new_from_fd (fileno (child_out),
|
||||||
FALSE /* writable */, &error);
|
FALSE /* writable */, &error);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib/gprintf.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -107,7 +108,7 @@ fatal (const gchar *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
vfprintf (stderr, format, ap);
|
g_vfprintf (stderr, format, ap);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue