mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
Get len using strlen() if arg is negative in the Win32 code, too.
2001-01-06 Tor Lillqvist <tml@iki.fi> * gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using strlen() if arg is negative in the Win32 code, too. * giowin32.c: Changes necessary to be able to run mainloop-test. We can't close the fd that our (internal) reader thread is sitting doing a blocking read() from. We must terminate the thread first. Keep track of thread handle, and close it when thread is dying. Start reader thread with the lower-level CreateThread() instead of _beginthreadex() from the C runtime, in order to be able to use TerminateThread(). Hopefuly this isn't harmful. * glib.def: Update. * tests/makefile.{mingw,msc}.in (TESTS): Add mainloop-test and unicode-encoding. * tests/mainloop-test.c: Portability: <unistd.h>, need <fcntl.h> on Win32. * tests/unicode-encoding.c (process): Add missing "line" argument to fail(). On Win32, convert UTF-16LE, as libiconv'c ivonf always converts to UTF-16BE if we ask for unspecific UTF-16. (main) Handle also '\r'.
This commit is contained in:
committed by
Tor Lillqvist
parent
956f00ed96
commit
deb68e1592
@@ -192,7 +192,13 @@ process (gint line,
|
||||
gint n_chars;
|
||||
gchar *utf8_result;
|
||||
|
||||
if (!(utf16_expected_tmp = (gunichar2 *)g_convert (utf8, -1, "UTF-16", "UTF-8",
|
||||
#ifdef G_OS_WIN32
|
||||
#define TARGET "UTF-16LE"
|
||||
#else
|
||||
#define TARGET "UTF-16"
|
||||
#endif
|
||||
|
||||
if (!(utf16_expected_tmp = (gunichar2 *)g_convert (utf8, -1, TARGET, "UTF-8",
|
||||
NULL, &bytes_written, NULL)))
|
||||
{
|
||||
fail ("line %d: could not convert to UTF-16 via g_convert\n", line);
|
||||
@@ -210,7 +216,7 @@ process (gint line,
|
||||
}
|
||||
else if (utf16_expected_tmp[0] == 0xfffe) /* ANTI-BOM */
|
||||
{
|
||||
fail ("line %d: conversion via iconv to \"UTF-16\" is not native-endian\n");
|
||||
fail ("line %d: conversion via iconv to \"UTF-16\" is not native-endian\n", line);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -315,7 +321,7 @@ main (int argc, char **argv)
|
||||
if (!srcdir)
|
||||
srcdir = ".";
|
||||
|
||||
testfile = g_strconcat (srcdir, "/", "utf8.txt", NULL);
|
||||
testfile = g_strconcat (srcdir, G_DIR_SEPARATOR_S "utf8.txt", NULL);
|
||||
|
||||
g_file_get_contents (testfile, &contents, NULL, &error);
|
||||
if (error)
|
||||
@@ -332,10 +338,10 @@ main (int argc, char **argv)
|
||||
p++;
|
||||
|
||||
end = p;
|
||||
while (*end && *end != '\n')
|
||||
while (*end && (*end != '\r' && *end != '\n'))
|
||||
end++;
|
||||
|
||||
if (!*p || *p == '#' || *p == '\n')
|
||||
if (!*p || *p == '#' || *p == '\r' || *p == '\n')
|
||||
goto next_line;
|
||||
|
||||
tmp = g_strstrip (g_strndup (p, end - p));
|
||||
@@ -401,6 +407,8 @@ main (int argc, char **argv)
|
||||
|
||||
next_line:
|
||||
p = end;
|
||||
if (*p && *p == '\r')
|
||||
p++;
|
||||
if (*p && *p == '\n')
|
||||
p++;
|
||||
|
||||
|
Reference in New Issue
Block a user