Commit da422c00 authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

Remove support for Windows 9x/ME, as will be done also in Pango and GTK+.

2006-08-29  Tor Lillqvist  <tml@novell.com>

	Remove support for Windows 9x/ME, as will be done also in Pango
	and GTK+. GTK+ hasn't worked on Win9x since 2.6 or 2.8 anyway, so
	it's pretty pointless to keep the Win9x code in here either. If
	somebody is interested, the code can always be found in older GLib
	versions, and in CVS.

	* glib/gdir.c
	* glib/gfileutils.c
	* glib/gspawn-win32-helper.c
	* glib/gspawn-win32.c
	* glib/gstdio.c
	* glib/gutils.c
	* glib/gwin32.c
	* glib/gwin32.h: Remove the G_WIN32_IS_NT_BASED() and
	G_WIN32_HAVE_WIDECHAR_API() tests and their false (Win9x)
	branches, and any variables or static functions used only by the
	Win9x branches.

	* glib/gwin32.c (g_win32_windows_version_init): Call g_error() if
	run on Win9x.
parent 08e3a830
2006-08-29 Tor Lillqvist <tml@novell.com>
Remove support for Windows 9x/ME, as will be done also in Pango
and GTK+. GTK+ hasn't worked on Win9x since 2.6 or 2.8 anyway, so
it's pretty pointless to keep the Win9x code in here either. If
somebody is interested, the code can always be found in older GLib
versions, and in CVS.
* glib/gdir.c
* glib/gfileutils.c
* glib/gspawn-win32-helper.c
* glib/gspawn-win32.c
* glib/gstdio.c
* glib/gutils.c
* glib/gwin32.c
* glib/gwin32.h: Remove the G_WIN32_IS_NT_BASED() and
G_WIN32_HAVE_WIDECHAR_API() tests and their false (Win9x)
branches, and any variables or static functions used only by the
Win9x branches.
* glib/gwin32.c (g_win32_windows_version_init): Call g_error() if
run on Win9x.
2006-08-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Fix pthread compiler flag detection.
......
......@@ -25,7 +25,8 @@
#include "config.h"
#include <errno.h>
#include <string.h> /* strcmp */
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_DIRENT_H
#include <sys/types.h>
......@@ -41,12 +42,11 @@
struct _GDir
{
union {
DIR *dirp;
#ifdef G_OS_WIN32
_WDIR *wdirp;
_WDIR *wdirp;
#else
DIR *dirp;
#endif
} u;
#ifdef G_OS_WIN32
gchar utf8_buf[FILENAME_MAX*4];
#endif
......@@ -74,44 +74,27 @@ g_dir_open (const gchar *path,
GError **error)
{
GDir *dir;
#ifndef G_OS_WIN32
#ifdef G_OS_WIN32
wchar_t *wpath;
#else
gchar *utf8_path;
#endif
g_return_val_if_fail (path != NULL, NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, error);
if (wpath == NULL)
return NULL;
dir = g_new (GDir, 1);
dir->u.wdirp = _wopendir (wpath);
g_free (wpath);
if (dir->u.wdirp)
return dir;
}
else
{
gchar *cp_path = g_locale_from_utf8 (path, -1, NULL, NULL, error);
wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, error);
if (cp_path == NULL)
return NULL;
dir = g_new (GDir, 1);
if (wpath == NULL)
return NULL;
dir->u.dirp = opendir (cp_path);
dir = g_new (GDir, 1);
g_free (cp_path);
dir->wdirp = _wopendir (wpath);
g_free (wpath);
if (dir->u.dirp)
return dir;
}
if (dir->wdirp)
return dir;
/* error case */
......@@ -127,9 +110,9 @@ g_dir_open (const gchar *path,
#else
dir = g_new (GDir, 1);
dir->u.dirp = opendir (path);
dir->dirp = opendir (path);
if (dir->u.dirp)
if (dir->dirp)
return dir;
/* error case */
......@@ -193,70 +176,43 @@ g_dir_open (const gchar *path,
G_CONST_RETURN gchar*
g_dir_read_name (GDir *dir)
{
#ifdef G_OS_WIN32
gchar *utf8_name;
struct _wdirent *wentry;
#else
struct dirent *entry;
#endif
g_return_val_if_fail (dir != NULL, NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
while (1)
{
gchar *utf8_name;
struct _wdirent *wentry;
wentry = _wreaddir (dir->wdirp);
while (wentry
&& (0 == wcscmp (wentry->d_name, L".") ||
0 == wcscmp (wentry->d_name, L"..")))
wentry = _wreaddir (dir->wdirp);
while (1)
{
wentry = _wreaddir (dir->u.wdirp);
while (wentry
&& (0 == wcscmp (wentry->d_name, L".") ||
0 == wcscmp (wentry->d_name, L"..")))
wentry = _wreaddir (dir->u.wdirp);
if (wentry == NULL)
return NULL;
utf8_name = g_utf16_to_utf8 (wentry->d_name, -1, NULL, NULL, NULL);
if (utf8_name == NULL)
continue; /* Huh, impossible? Skip it anyway */
strcpy (dir->utf8_buf, utf8_name);
g_free (utf8_name);
return dir->utf8_buf;
}
}
else
{
while (1)
{
gchar *utf8_name;
entry = readdir (dir->u.dirp);
while (entry
&& (0 == strcmp (entry->d_name, ".") ||
0 == strcmp (entry->d_name, "..")))
entry = readdir (dir->u.dirp);
if (entry == NULL)
return NULL;
utf8_name = g_locale_to_utf8 (entry->d_name, -1, NULL, NULL, NULL);
if (utf8_name != NULL)
{
strcpy (dir->utf8_buf, utf8_name);
g_free (utf8_name);
return dir->utf8_buf;
}
}
if (wentry == NULL)
return NULL;
utf8_name = g_utf16_to_utf8 (wentry->d_name, -1, NULL, NULL, NULL);
if (utf8_name == NULL)
continue; /* Huh, impossible? Skip it anyway */
strcpy (dir->utf8_buf, utf8_name);
g_free (utf8_name);
return dir->utf8_buf;
}
#else
entry = readdir (dir->u.dirp);
entry = readdir (dir->dirp);
while (entry
&& (0 == strcmp (entry->d_name, ".") ||
0 == strcmp (entry->d_name, "..")))
entry = readdir (dir->u.dirp);
entry = readdir (dir->dirp);
if (entry)
return entry->d_name;
......@@ -311,14 +267,10 @@ g_dir_rewind (GDir *dir)
g_return_if_fail (dir != NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
_wrewinddir (dir->u.wdirp);
return;
}
_wrewinddir (dir->wdirp);
#else
rewinddir (dir->dirp);
#endif
rewinddir (dir->u.dirp);
}
/**
......@@ -333,15 +285,10 @@ g_dir_close (GDir *dir)
g_return_if_fail (dir != NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
_wclosedir (dir->u.wdirp);
g_free (dir);
return;
}
_wclosedir (dir->wdirp);
#else
closedir (dir->dirp);
#endif
closedir (dir->u.dirp);
g_free (dir);
}
......
......@@ -191,29 +191,14 @@ g_file_test (const gchar *filename,
# define FILE_ATTRIBUTE_DEVICE 64
# endif
int attributes;
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
if (wfilename == NULL)
return FALSE;
attributes = GetFileAttributesW (wfilename);
if (wfilename == NULL)
return FALSE;
g_free (wfilename);
}
else
{
gchar *cpfilename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
attributes = GetFileAttributesW (wfilename);
if (cpfilename == NULL)
return FALSE;
attributes = GetFileAttributesA (cpfilename);
g_free (cpfilename);
}
g_free (wfilename);
if (attributes == INVALID_FILE_ATTRIBUTES)
return FALSE;
......
......@@ -160,7 +160,6 @@ WinMain (struct HINSTANCE__ *hInstance,
int no_error = CHILD_NO_ERROR;
int zero = 0;
gint argv_zero_offset = ARG_PROGRAM;
gchar **new_argv;
wchar_t **new_wargv;
int argc;
wchar_t **wargv, **wenvp;
......@@ -168,17 +167,14 @@ WinMain (struct HINSTANCE__ *hInstance,
g_assert (__argc >= ARG_COUNT);
if (G_WIN32_HAVE_WIDECHAR_API ())
{
/* Fetch the wide-char argument vector */
__wgetmainargs (&argc, &wargv, &wenvp, 0, &si);
/* We still have the system codepage args in __argv. We can look
* at the first args in which gspawn-win32.c passes us flags and
* fd numbers in __argv, as we know those are just ASCII anyway.
*/
g_assert (argc == __argc);
}
/* Fetch the wide-char argument vector */
__wgetmainargs (&argc, &wargv, &wenvp, 0, &si);
/* We still have the system codepage args in __argv. We can look
* at the first args in which gspawn-win32.c passes us flags and
* fd numbers in __argv, as we know those are just ASCII anyway.
*/
g_assert (argc == __argc);
/* argv[ARG_CHILD_ERR_REPORT] is the file descriptor number onto
* which write error messages.
......@@ -266,10 +262,7 @@ WinMain (struct HINSTANCE__ *hInstance,
if (__argv[ARG_WORKING_DIRECTORY][0] == '-' &&
__argv[ARG_WORKING_DIRECTORY][1] == 0)
; /* Nothing */
else if ((G_WIN32_HAVE_WIDECHAR_API () &&
_wchdir (wargv[ARG_WORKING_DIRECTORY]) < 0) ||
(!G_WIN32_HAVE_WIDECHAR_API () &&
chdir (__argv[ARG_WORKING_DIRECTORY]) < 0))
else if (_wchdir (wargv[ARG_WORKING_DIRECTORY]) < 0)
write_err_and_exit (child_err_report_fd, CHILD_CHDIR_FAILED);
/* __argv[ARG_CLOSE_DESCRIPTORS] is "y" if file descriptors from 3
......@@ -297,24 +290,12 @@ WinMain (struct HINSTANCE__ *hInstance,
/* For the program name passed to spawnv(), don't use the quoted
* version.
*/
if (G_WIN32_HAVE_WIDECHAR_API ())
{
protect_wargv (wargv + argv_zero_offset, &new_wargv);
protect_wargv (wargv + argv_zero_offset, &new_wargv);
if (__argv[ARG_USE_PATH][0] == 'y')
handle = _wspawnvp (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
else
handle = _wspawnv (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
}
if (__argv[ARG_USE_PATH][0] == 'y')
handle = _wspawnvp (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
else
{
protect_argv (__argv + argv_zero_offset, &new_argv);
if (__argv[ARG_USE_PATH][0] == 'y')
handle = spawnvp (mode, __argv[ARG_PROGRAM], (const char **) new_argv);
else
handle = spawnv (mode, __argv[ARG_PROGRAM], (const char **) new_argv);
}
handle = _wspawnv (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
saved_errno = errno;
......
......@@ -108,6 +108,10 @@ enum {
ARG_COUNT = ARG_PROGRAM
};
#ifndef GSPAWN_HELPER
#define HELPER_PROCESS "gspawn-win32-helper"
static gchar *
protect_argv_string (const gchar *string)
{
......@@ -192,10 +196,6 @@ protect_argv (gchar **argv,
return argc;
}
#ifndef GSPAWN_HELPER
#define HELPER_PROCESS "gspawn-win32-helper"
GQuark
g_spawn_error_quark (void)
{
......@@ -400,43 +400,6 @@ utf8_charv_to_wcharv (char **utf8_charv,
return TRUE;
}
static gboolean
utf8_charv_to_cp_charv (char **utf8_charv,
gchar ***cp_charv,
int *error_index,
GError **error)
{
char **retval = NULL;
*cp_charv = NULL;
if (utf8_charv != NULL)
{
int n = 0, i;
while (utf8_charv[n])
n++;
retval = g_new (char *, n + 1);
for (i = 0; i < n; i++)
{
retval[i] = g_locale_from_utf8 (utf8_charv[i], -1, NULL, NULL, error);
if (retval[i] == NULL)
{
if (error_index)
*error_index = i;
while (i)
g_free (retval[--i]);
g_free (retval);
return FALSE;
}
}
retval[n] = NULL;
}
*cp_charv = retval;
return TRUE;
}
static gboolean
do_spawn_directly (gint *exit_status,
gboolean do_return_handle,
......@@ -455,120 +418,61 @@ do_spawn_directly (gint *exit_status,
int saved_errno;
GError *conv_error = NULL;
gint conv_error_index;
wchar_t *wargv0, **wargv, **wenvp;
new_argv = (flags & G_SPAWN_FILE_AND_ARGV_ZERO) ? protected_argv + 1 : protected_argv;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wargv0, **wargv, **wenvp;
wargv0 = g_utf8_to_utf16 (argv[0], -1, NULL, NULL, &conv_error);
if (wargv0 == NULL)
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid program name: %s"),
conv_error->message);
g_error_free (conv_error);
return FALSE;
}
if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in argument vector at %d: %s"),
conv_error_index, conv_error->message);
g_error_free (conv_error);
g_free (wargv0);
return FALSE;
}
if (!utf8_charv_to_wcharv (envp, &wenvp, NULL, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in environment: %s"),
conv_error->message);
g_error_free (conv_error);
g_free (wargv0);
g_strfreev ((gchar **) wargv);
return FALSE;
}
if (child_setup)
(* child_setup) (user_data);
if (flags & G_SPAWN_SEARCH_PATH)
if (wenvp != NULL)
rc = _wspawnvpe (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
else
rc = _wspawnvp (mode, wargv0, (const wchar_t **) wargv);
else
if (wenvp != NULL)
rc = _wspawnve (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
else
rc = _wspawnv (mode, wargv0, (const wchar_t **) wargv);
wargv0 = g_utf8_to_utf16 (argv[0], -1, NULL, NULL, &conv_error);
if (wargv0 == NULL)
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid program name: %s"),
conv_error->message);
g_error_free (conv_error);
g_free (wargv0);
g_strfreev ((gchar **) wargv);
g_strfreev ((gchar **) wenvp);
return FALSE;
}
else
if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
{
char *cpargv0, **cpargv, **cpenvp;
cpargv0 = g_locale_from_utf8 (argv[0], -1, NULL, NULL, &conv_error);
if (cpargv0 == NULL)
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid program name: %s"),
conv_error->message);
g_error_free (conv_error);
return FALSE;
}
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in argument vector at %d: %s"),
conv_error_index, conv_error->message);
g_error_free (conv_error);
g_free (wargv0);
if (!utf8_charv_to_cp_charv (new_argv, &cpargv, &conv_error_index, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in argument vector at %d: %s"),
conv_error_index, conv_error->message);
g_error_free (conv_error);
g_free (cpargv0);
return FALSE;
}
return FALSE;
}
if (!utf8_charv_to_wcharv (envp, &wenvp, NULL, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in environment: %s"),
conv_error->message);
g_error_free (conv_error);
g_free (wargv0);
g_strfreev ((gchar **) wargv);
if (!utf8_charv_to_cp_charv (envp, &cpenvp, NULL, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in environment: %s"),
conv_error->message);
g_error_free (conv_error);
g_free (cpargv0);
g_strfreev (cpargv);
return FALSE;
}
return FALSE;
}
if (child_setup)
(* child_setup) (user_data);
if (child_setup)
(* child_setup) (user_data);
if (flags & G_SPAWN_SEARCH_PATH)
if (wenvp != NULL)
rc = _wspawnvpe (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
else
rc = _wspawnvp (mode, wargv0, (const wchar_t **) wargv);
else
if (wenvp != NULL)
rc = _wspawnve (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
else
rc = _wspawnv (mode, wargv0, (const wchar_t **) wargv);
if (flags & G_SPAWN_SEARCH_PATH)
if (cpenvp != NULL)
rc = spawnvpe (mode, cpargv0, (const char **) cpargv, (const char **) cpenvp);
else
rc = spawnvp (mode, cpargv0, (const char **) cpargv);
else
if (envp != NULL)
rc = spawnve (mode, cpargv0, (const char **) cpargv, (const char **) cpenvp);
else
rc = spawnv (mode, cpargv0, (const char **) cpargv);
g_free (cpargv0);
g_strfreev (cpargv);
g_strfreev (cpenvp);
}
g_free (wargv0);
g_strfreev ((gchar **) wargv);
g_strfreev ((gchar **) wenvp);
saved_errno = errno;
......@@ -630,6 +534,7 @@ do_spawn_with_pipes (gint *exit_status,
gint conv_error_index;
gchar *helper_process;
CONSOLE_CURSOR_INFO cursor_info;
wchar_t *whelper, **wargv, **wenvp;
SETUP_DEBUG();
......@@ -761,111 +666,58 @@ do_spawn_with_pipes (gint *exit_status,
g_print ("argv[%d]: %s\n", i, (new_argv[i] ? new_argv[i] : "NULL"));
}
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
wchar_t **wargv, **wenvp;
if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
{
if (conv_error_index == ARG_WORKING_DIRECTORY)
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_CHDIR,
_("Invalid working directory: %s"),
conv_error->message);
else
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in argument vector at %d: %s"),
conv_error_index - ARG_PROGRAM, conv_error->message);
g_error_free (conv_error);
g_strfreev (protected_argv);
g_free (new_argv[ARG_WORKING_DIRECTORY]);
g_free (new_argv);
g_free (whelper);
return FALSE;
}
if (!utf8_charv_to_wcharv (envp, &wenvp, NULL, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in environment: %s"),
conv_error->message);
g_error_free (conv_error);
g_strfreev (protected_argv);
g_free (new_argv[ARG_WORKING_DIRECTORY]);
g_free (new_argv);
g_free (whelper);
g_strfreev ((gchar **) wargv);
return FALSE;
}
if (child_setup)
(* child_setup) (user_data);
whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
if (wenvp != NULL)
/* Let's hope envp hasn't mucked with PATH so that
* gspawn-win32-helper.exe isn't found.
*/
rc = _wspawnvpe (P_NOWAIT, whelper, (const wchar_t **) wargv, (const wchar_t **) wenvp);
if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
{
if (conv_error_index == ARG_WORKING_DIRECTORY)
g_set_error (error, G_SPAWN_ERROR