Remove test for initial double backslash (UNC path), this will of course

2001-03-01  Tor Lillqvist  <tml@iki.fi>

	* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
	double backslash (UNC path), this will of course be matched by the
	test for an initial G_DIR_SEPARATOR right up front. Silly me.
	(g_find_program_in_path): Implement on Win32.
	(g_get_any_init): (Win32) Also look for the USERPROFILE env var
	indicating the home directory equivalent.

	* testglib.c (main): Test g_find_program_in_path() on Win32 by
	looking for more.com and regedit.exe.

	* glib.def: Add g_find_program_in_path.
This commit is contained in:
Tor Lillqvist 2001-03-01 09:34:45 +00:00 committed by Tor Lillqvist
parent 5215807c6c
commit b6ba941b50
17 changed files with 196 additions and 33 deletions

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -1,3 +1,17 @@
2001-03-01 Tor Lillqvist <tml@iki.fi>
* gutils.c (g_path_is_absolute): (Win32) Remove test for initial
double backslash (UNC path), this will of course be matched by the
test for an initial G_DIR_SEPARATOR right up front. Silly me.
(g_find_program_in_path): Implement on Win32.
(g_get_any_init): (Win32) Also look for the USERPROFILE env var
indicating the home directory equivalent.
* testglib.c (main): Test g_find_program_in_path() on Win32 by
looking for more.com and regedit.exe.
* glib.def: Add g_find_program_in_path.
2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 2001-02-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthreadpool.c (g_thread_pool_thread_proxy): Make * gthreadpool.c (g_thread_pool_thread_proxy): Make

View File

@ -24,9 +24,6 @@ the prebuilt DLLs (especially of GTK+), you *must* also use that flag.
(This flag means that the struct layout is identical to that used by (This flag means that the struct layout is identical to that used by
MSVC.) MSVC.)
To test the GLib functions, go to the tests subdirectory and enter
`nmake -f makefile.msc check` or `make -f makefile.mingw check`.
If you would want to use the cygwin tools to generate executables that If you would want to use the cygwin tools to generate executables that
*do* use the cygwin runtime, the normal Unix configuration method *do* use the cygwin runtime, the normal Unix configuration method
should work as if on Unix. But it won't produce DLLs. At least I should work as if on Unix. But it won't produce DLLs. At least I

View File

@ -129,6 +129,7 @@ EXPORTS
g_file_test g_file_test
g_filename_from_utf8 g_filename_from_utf8
g_filename_to_utf8 g_filename_to_utf8
g_find_program_in_path
g_free g_free
g_get_charset g_get_charset
g_get_codeset g_get_codeset

View File

@ -129,6 +129,7 @@ EXPORTS
g_file_test g_file_test
g_filename_from_utf8 g_filename_from_utf8
g_filename_to_utf8 g_filename_to_utf8
g_find_program_in_path
g_free g_free
g_get_charset g_get_charset
g_get_codeset g_get_codeset

View File

@ -67,6 +67,7 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
# define STRICT /* Strict typing, please */ # define STRICT /* Strict typing, please */
# include <windows.h> # include <windows.h>
# undef STRICT
# include <ctype.h> # include <ctype.h>
# include <direct.h> # include <direct.h>
#endif /* G_OS_WIN32 */ #endif /* G_OS_WIN32 */
@ -173,12 +174,19 @@ g_find_program_in_path (const gchar *program)
{ {
const gchar *path, *p; const gchar *path, *p;
gchar *name, *freeme; gchar *name, *freeme;
#ifdef G_OS_WIN32
gchar *path_tmp;
#endif
size_t len; size_t len;
size_t pathlen; size_t pathlen;
/* On Win32, should we try appending .exe, .com, and the other
* components of %PATHEXT% ?
*/
g_return_val_if_fail (program != NULL, NULL); g_return_val_if_fail (program != NULL, NULL);
if (*program == '/') if (g_path_is_absolute (program))
{ {
if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE)) if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE))
return g_strdup (program); return g_strdup (program);
@ -187,6 +195,7 @@ g_find_program_in_path (const gchar *program)
} }
path = g_getenv ("PATH"); path = g_getenv ("PATH");
#ifdef G_OS_UNIX
if (path == NULL) if (path == NULL)
{ {
/* There is no `PATH' in the environment. The default /* There is no `PATH' in the environment. The default
@ -201,6 +210,23 @@ g_find_program_in_path (const gchar *program)
path = "/bin:/usr/bin:."; path = "/bin:/usr/bin:.";
} }
#else
{
gchar *tmp;
gchar moddir[PATH_MAX], sysdir[PATH_MAX], windir[PATH_MAX];
GetModuleFileName (NULL, moddir, sizeof (moddir));
tmp = g_path_get_dirname (moddir);
GetSystemDirectory (sysdir, sizeof (sysdir));
GetWindowsDirectory (windir, sizeof (windir));
path_tmp = g_strconcat (tmp, ";.;", sysdir, ";", windir,
(path != NULL ? ";" : NULL),
(path != NULL ? path : NULL),
NULL);
g_free (tmp);
path = path_tmp;
}
#endif
len = strlen (program) + 1; len = strlen (program) + 1;
pathlen = strlen (path); pathlen = strlen (path);
@ -210,7 +236,7 @@ g_find_program_in_path (const gchar *program)
memcpy (name + pathlen + 1, program, len); memcpy (name + pathlen + 1, program, len);
name = name + pathlen; name = name + pathlen;
/* And add the slash before the filename */ /* And add the slash before the filename */
*name = '/'; *name = G_DIR_SEPARATOR;
p = path; p = path;
do do
@ -218,7 +244,7 @@ g_find_program_in_path (const gchar *program)
char *startp; char *startp;
path = p; path = p;
p = my_strchrnul (path, ':'); p = my_strchrnul (path, G_SEARCHPATH_SEPARATOR);
if (p == path) if (p == path)
/* Two adjacent colons, or a colon at the beginning or the end /* Two adjacent colons, or a colon at the beginning or the end
@ -233,12 +259,18 @@ g_find_program_in_path (const gchar *program)
gchar *ret; gchar *ret;
ret = g_strdup (startp); ret = g_strdup (startp);
g_free (freeme); g_free (freeme);
#ifdef G_OS_WIN32
g_free (path_tmp);
#endif
return ret; return ret;
} }
} }
while (*p++ != '\0'); while (*p++ != '\0');
g_free (freeme); g_free (freeme);
#ifdef G_OS_WIN32
g_free (path_tmp);
#endif
return NULL; return NULL;
} }
@ -461,9 +493,6 @@ g_path_is_absolute (const gchar *file_name)
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR) if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
return TRUE; return TRUE;
if (file_name[0] == G_DIR_SEPARATOR && file_name[1] == G_DIR_SEPARATOR)
return TRUE;
#endif #endif
return FALSE; return FALSE;
@ -735,7 +764,7 @@ g_get_any_init (void)
{ {
/* USERPROFILE is probably the closest equivalent to $HOME? */ /* USERPROFILE is probably the closest equivalent to $HOME? */
if (getenv ("USERPROFILE") != NULL) if (getenv ("USERPROFILE") != NULL)
g_home_dir = g_getenv ("USERPROFILE"); g_home_dir = g_strdup (g_getenv ("USERPROFILE"));
} }
if (!g_home_dir) if (!g_home_dir)

View File

@ -1,10 +1,6 @@
## Makefile for building the GLib dlls with Microsoft C ## Makefile for building the GLib dlls with Microsoft C
## Use: nmake -f makefile.msc ## Use: nmake -f makefile.msc
# Change this to wherever you want to install the DLLs. This directory
# should be in your PATH.
BIN = C:\bin
TOP = .. TOP = ..
!INCLUDE build\win32\make.msc !INCLUDE build\win32\make.msc
@ -21,7 +17,7 @@ DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -D
DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS) DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS)
DLLS_TO_BUILD = \ DLLS_TO_BUILD = \
glib-$(GLIB_VER).dll \ glib-$(GLIB_VER).dll \
sub-gmodule \ sub-gmodule \
sub-gthread \ sub-gthread \
sub-gobject sub-gobject
@ -35,9 +31,6 @@ all : \
testgdate.exe \ testgdate.exe \
testgdateparser.exe testgdateparser.exe
install : all
copy glib-$(GLIB_VER).dll $(BIN)
glib_OBJECTS = \ glib_OBJECTS = \
garray.obj \ garray.obj \
gasyncqueue.obj \ gasyncqueue.obj \

View File

@ -67,6 +67,7 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
# define STRICT /* Strict typing, please */ # define STRICT /* Strict typing, please */
# include <windows.h> # include <windows.h>
# undef STRICT
# include <ctype.h> # include <ctype.h>
# include <direct.h> # include <direct.h>
#endif /* G_OS_WIN32 */ #endif /* G_OS_WIN32 */
@ -173,12 +174,19 @@ g_find_program_in_path (const gchar *program)
{ {
const gchar *path, *p; const gchar *path, *p;
gchar *name, *freeme; gchar *name, *freeme;
#ifdef G_OS_WIN32
gchar *path_tmp;
#endif
size_t len; size_t len;
size_t pathlen; size_t pathlen;
/* On Win32, should we try appending .exe, .com, and the other
* components of %PATHEXT% ?
*/
g_return_val_if_fail (program != NULL, NULL); g_return_val_if_fail (program != NULL, NULL);
if (*program == '/') if (g_path_is_absolute (program))
{ {
if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE)) if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE))
return g_strdup (program); return g_strdup (program);
@ -187,6 +195,7 @@ g_find_program_in_path (const gchar *program)
} }
path = g_getenv ("PATH"); path = g_getenv ("PATH");
#ifdef G_OS_UNIX
if (path == NULL) if (path == NULL)
{ {
/* There is no `PATH' in the environment. The default /* There is no `PATH' in the environment. The default
@ -201,6 +210,23 @@ g_find_program_in_path (const gchar *program)
path = "/bin:/usr/bin:."; path = "/bin:/usr/bin:.";
} }
#else
{
gchar *tmp;
gchar moddir[PATH_MAX], sysdir[PATH_MAX], windir[PATH_MAX];
GetModuleFileName (NULL, moddir, sizeof (moddir));
tmp = g_path_get_dirname (moddir);
GetSystemDirectory (sysdir, sizeof (sysdir));
GetWindowsDirectory (windir, sizeof (windir));
path_tmp = g_strconcat (tmp, ";.;", sysdir, ";", windir,
(path != NULL ? ";" : NULL),
(path != NULL ? path : NULL),
NULL);
g_free (tmp);
path = path_tmp;
}
#endif
len = strlen (program) + 1; len = strlen (program) + 1;
pathlen = strlen (path); pathlen = strlen (path);
@ -210,7 +236,7 @@ g_find_program_in_path (const gchar *program)
memcpy (name + pathlen + 1, program, len); memcpy (name + pathlen + 1, program, len);
name = name + pathlen; name = name + pathlen;
/* And add the slash before the filename */ /* And add the slash before the filename */
*name = '/'; *name = G_DIR_SEPARATOR;
p = path; p = path;
do do
@ -218,7 +244,7 @@ g_find_program_in_path (const gchar *program)
char *startp; char *startp;
path = p; path = p;
p = my_strchrnul (path, ':'); p = my_strchrnul (path, G_SEARCHPATH_SEPARATOR);
if (p == path) if (p == path)
/* Two adjacent colons, or a colon at the beginning or the end /* Two adjacent colons, or a colon at the beginning or the end
@ -233,12 +259,18 @@ g_find_program_in_path (const gchar *program)
gchar *ret; gchar *ret;
ret = g_strdup (startp); ret = g_strdup (startp);
g_free (freeme); g_free (freeme);
#ifdef G_OS_WIN32
g_free (path_tmp);
#endif
return ret; return ret;
} }
} }
while (*p++ != '\0'); while (*p++ != '\0');
g_free (freeme); g_free (freeme);
#ifdef G_OS_WIN32
g_free (path_tmp);
#endif
return NULL; return NULL;
} }
@ -461,9 +493,6 @@ g_path_is_absolute (const gchar *file_name)
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR) if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
return TRUE; return TRUE;
if (file_name[0] == G_DIR_SEPARATOR && file_name[1] == G_DIR_SEPARATOR)
return TRUE;
#endif #endif
return FALSE; return FALSE;
@ -735,7 +764,7 @@ g_get_any_init (void)
{ {
/* USERPROFILE is probably the closest equivalent to $HOME? */ /* USERPROFILE is probably the closest equivalent to $HOME? */
if (getenv ("USERPROFILE") != NULL) if (getenv ("USERPROFILE") != NULL)
g_home_dir = g_getenv ("USERPROFILE"); g_home_dir = g_strdup (g_getenv ("USERPROFILE"));
} }
if (!g_home_dir) if (!g_home_dir)

View File

@ -1,10 +1,6 @@
## Makefile for building the GLib dlls with Microsoft C ## Makefile for building the GLib dlls with Microsoft C
## Use: nmake -f makefile.msc ## Use: nmake -f makefile.msc
# Change this to wherever you want to install the DLLs. This directory
# should be in your PATH.
BIN = C:\bin
TOP = .. TOP = ..
!INCLUDE build\win32\make.msc !INCLUDE build\win32\make.msc
@ -21,7 +17,7 @@ DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -D
DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS) DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS)
DLLS_TO_BUILD = \ DLLS_TO_BUILD = \
glib-$(GLIB_VER).dll \ glib-$(GLIB_VER).dll \
sub-gmodule \ sub-gmodule \
sub-gthread \ sub-gthread \
sub-gobject sub-gobject
@ -35,9 +31,6 @@ all : \
testgdate.exe \ testgdate.exe \
testgdateparser.exe testgdateparser.exe
install : all
copy glib-$(GLIB_VER).dll $(BIN)
glib_OBJECTS = \ glib_OBJECTS = \
garray.obj \ garray.obj \
gasyncqueue.obj \ gasyncqueue.obj \

View File

@ -1165,6 +1165,10 @@ main (int argc,
g_win32_get_package_installation_subdirectory (NULL, glib_dll, "locale")); g_win32_get_package_installation_subdirectory (NULL, glib_dll, "locale"));
g_print ("GTK+ 2.0 installation directory, if available: %s\n", g_print ("GTK+ 2.0 installation directory, if available: %s\n",
g_win32_get_package_installation_directory ("gtk20", NULL)); g_win32_get_package_installation_directory ("gtk20", NULL));
g_print ("found more.com as %s\n", g_find_program_in_path ("more.com"));
g_print ("found regedit.exe as %s\n", g_find_program_in_path ("regedit.exe"));
#endif #endif
g_print ("checking file functions...\n"); g_print ("checking file functions...\n");

View File

@ -1165,6 +1165,10 @@ main (int argc,
g_win32_get_package_installation_subdirectory (NULL, glib_dll, "locale")); g_win32_get_package_installation_subdirectory (NULL, glib_dll, "locale"));
g_print ("GTK+ 2.0 installation directory, if available: %s\n", g_print ("GTK+ 2.0 installation directory, if available: %s\n",
g_win32_get_package_installation_directory ("gtk20", NULL)); g_win32_get_package_installation_directory ("gtk20", NULL));
g_print ("found more.com as %s\n", g_find_program_in_path ("more.com"));
g_print ("found regedit.exe as %s\n", g_find_program_in_path ("regedit.exe"));
#endif #endif
g_print ("checking file functions...\n"); g_print ("checking file functions...\n");