summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2001-03-01 09:34:45 +0000
committerTor Lillqvist <tml@src.gnome.org>2001-03-01 09:34:45 +0000
commitb6ba941b505beb30da5c3004a3d8985ae5837335 (patch)
treea4d243a041b06552462019eb2a8aa2e17c9801cc
parent5215807c6c2072a4937a6e30a2f5e7b63e0742cc (diff)
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.
-rw-r--r--ChangeLog14
-rw-r--r--ChangeLog.pre-2-014
-rw-r--r--ChangeLog.pre-2-1014
-rw-r--r--ChangeLog.pre-2-1214
-rw-r--r--ChangeLog.pre-2-214
-rw-r--r--ChangeLog.pre-2-414
-rw-r--r--ChangeLog.pre-2-614
-rw-r--r--ChangeLog.pre-2-814
-rw-r--r--README.win323
-rw-r--r--glib.def1
-rw-r--r--glib/glib.def1
-rw-r--r--glib/gutils.c43
-rw-r--r--glib/makefile.msc.in9
-rw-r--r--gutils.c43
-rw-r--r--makefile.msc.in9
-rw-r--r--testglib.c4
-rw-r--r--tests/testglib.c4
17 files changed, 196 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 76eadce08..b3dc4cbdd 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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>
* gthreadpool.c (g_thread_pool_thread_proxy): Make
diff --git a/README.win32 b/README.win32
index cf17390d1..06105e3fa 100644
--- a/README.win32
+++ b/README.win32
@@ -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
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
*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
diff --git a/glib.def b/glib.def
index 748602bcb..c43203786 100644
--- a/glib.def
+++ b/glib.def
@@ -129,6 +129,7 @@ EXPORTS
g_file_test
g_filename_from_utf8
g_filename_to_utf8
+ g_find_program_in_path
g_free
g_get_charset
g_get_codeset
diff --git a/glib/glib.def b/glib/glib.def
index 748602bcb..c43203786 100644
--- a/glib/glib.def
+++ b/glib/glib.def
@@ -129,6 +129,7 @@ EXPORTS
g_file_test
g_filename_from_utf8
g_filename_to_utf8
+ g_find_program_in_path
g_free
g_get_charset
g_get_codeset
diff --git a/glib/gutils.c b/glib/gutils.c
index f474517ed..1c8987786 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -67,6 +67,7 @@
#ifdef G_OS_WIN32
# define STRICT /* Strict typing, please */
# include <windows.h>
+# undef STRICT
# include <ctype.h>
# include <direct.h>
#endif /* G_OS_WIN32 */
@@ -173,12 +174,19 @@ g_find_program_in_path (const gchar *program)
{
const gchar *path, *p;
gchar *name, *freeme;
+#ifdef G_OS_WIN32
+ gchar *path_tmp;
+#endif
size_t len;
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);
- if (*program == '/')
+ if (g_path_is_absolute (program))
{
if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE))
return g_strdup (program);
@@ -187,6 +195,7 @@ g_find_program_in_path (const gchar *program)
}
path = g_getenv ("PATH");
+#ifdef G_OS_UNIX
if (path == NULL)
{
/* 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:.";
}
+#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;
pathlen = strlen (path);
@@ -210,7 +236,7 @@ g_find_program_in_path (const gchar *program)
memcpy (name + pathlen + 1, program, len);
name = name + pathlen;
/* And add the slash before the filename */
- *name = '/';
+ *name = G_DIR_SEPARATOR;
p = path;
do
@@ -218,7 +244,7 @@ g_find_program_in_path (const gchar *program)
char *startp;
path = p;
- p = my_strchrnul (path, ':');
+ p = my_strchrnul (path, G_SEARCHPATH_SEPARATOR);
if (p == path)
/* 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;
ret = g_strdup (startp);
g_free (freeme);
+#ifdef G_OS_WIN32
+ g_free (path_tmp);
+#endif
return ret;
}
}
while (*p++ != '\0');
g_free (freeme);
+#ifdef G_OS_WIN32
+ g_free (path_tmp);
+#endif
return NULL;
}
@@ -461,9 +493,6 @@ g_path_is_absolute (const gchar *file_name)
#ifdef G_OS_WIN32
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
return TRUE;
-
- if (file_name[0] == G_DIR_SEPARATOR && file_name[1] == G_DIR_SEPARATOR)
- return TRUE;
#endif
return FALSE;
@@ -735,7 +764,7 @@ g_get_any_init (void)
{
/* USERPROFILE is probably the closest equivalent to $HOME? */
if (getenv ("USERPROFILE") != NULL)
- g_home_dir = g_getenv ("USERPROFILE");
+ g_home_dir = g_strdup (g_getenv ("USERPROFILE"));
}
if (!g_home_dir)
diff --git a/glib/makefile.msc.in b/glib/makefile.msc.in
index 3e0677602..73ddfd97c 100644
--- a/glib/makefile.msc.in
+++ b/glib/makefile.msc.in
@@ -1,10 +1,6 @@
## Makefile for building the GLib dlls with Microsoft C
## 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 = ..
!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)
DLLS_TO_BUILD = \
- glib-$(GLIB_VER).dll \
+ glib-$(GLIB_VER).dll \
sub-gmodule \
sub-gthread \
sub-gobject
@@ -35,9 +31,6 @@ all : \
testgdate.exe \
testgdateparser.exe
-install : all
- copy glib-$(GLIB_VER).dll $(BIN)
-
glib_OBJECTS = \
garray.obj \
gasyncqueue.obj \
diff --git a/gutils.c b/gutils.c
index f474517ed..1c8987786 100644
--- a/gutils.c
+++ b/gutils.c
@@ -67,6 +67,7 @@
#ifdef G_OS_WIN32
# define STRICT /* Strict typing, please */
# include <windows.h>
+# undef STRICT
# include <ctype.h>
# include <direct.h>
#endif /* G_OS_WIN32 */
@@ -173,12 +174,19 @@ g_find_program_in_path (const gchar *program)
{
const gchar *path, *p;
gchar *name, *freeme;
+#ifdef G_OS_WIN32
+ gchar *path_tmp;
+#endif
size_t len;
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);
- if (*program == '/')
+ if (g_path_is_absolute (program))
{
if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE))
return g_strdup (program);
@@ -187,6 +195,7 @@ g_find_program_in_path (const gchar *program)
}
path = g_getenv ("PATH");
+#ifdef G_OS_UNIX
if (path == NULL)
{
/* 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:.";
}
+#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;
pathlen = strlen (path);
@@ -210,7 +236,7 @@ g_find_program_in_path (const gchar *program)
memcpy (name + pathlen + 1, program, len);
name = name + pathlen;
/* And add the slash before the filename */
- *name = '/';
+ *name = G_DIR_SEPARATOR;
p = path;
do
@@ -218,7 +244,7 @@ g_find_program_in_path (const gchar *program)
char *startp;
path = p;
- p = my_strchrnul (path, ':');
+ p = my_strchrnul (path, G_SEARCHPATH_SEPARATOR);
if (p == path)
/* 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;
ret = g_strdup (startp);
g_free (freeme);
+#ifdef G_OS_WIN32
+ g_free (path_tmp);
+#endif
return ret;
}
}
while (*p++ != '\0');
g_free (freeme);
+#ifdef G_OS_WIN32
+ g_free (path_tmp);
+#endif
return NULL;
}
@@ -461,9 +493,6 @@ g_path_is_absolute (const gchar *file_name)
#ifdef G_OS_WIN32
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
return TRUE;
-
- if (file_name[0] == G_DIR_SEPARATOR && file_name[1] == G_DIR_SEPARATOR)
- return TRUE;
#endif
return FALSE;
@@ -735,7 +764,7 @@ g_get_any_init (void)
{
/* USERPROFILE is probably the closest equivalent to $HOME? */
if (getenv ("USERPROFILE") != NULL)
- g_home_dir = g_getenv ("USERPROFILE");
+ g_home_dir = g_strdup (g_getenv ("USERPROFILE"));
}
if (!g_home_dir)
diff --git a/makefile.msc.in b/makefile.msc.in
index 3e0677602..73ddfd97c 100644
--- a/makefile.msc.in
+++ b/makefile.msc.in
@@ -1,10 +1,6 @@
## Makefile for building the GLib dlls with Microsoft C
## 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 = ..
!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)
DLLS_TO_BUILD = \
- glib-$(GLIB_VER).dll \
+ glib-$(GLIB_VER).dll \
sub-gmodule \
sub-gthread \
sub-gobject
@@ -35,9 +31,6 @@ all : \
testgdate.exe \
testgdateparser.exe
-install : all
- copy glib-$(GLIB_VER).dll $(BIN)
-
glib_OBJECTS = \
garray.obj \
gasyncqueue.obj \
diff --git a/testglib.c b/testglib.c
index 32ede0242..bdb7b09c4 100644
--- a/testglib.c
+++ b/testglib.c
@@ -1165,6 +1165,10 @@ main (int argc,
g_win32_get_package_installation_subdirectory (NULL, glib_dll, "locale"));
g_print ("GTK+ 2.0 installation directory, if available: %s\n",
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
g_print ("checking file functions...\n");
diff --git a/tests/testglib.c b/tests/testglib.c
index 32ede0242..bdb7b09c4 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -1165,6 +1165,10 @@ main (int argc,
g_win32_get_package_installation_subdirectory (NULL, glib_dll, "locale"));
g_print ("GTK+ 2.0 installation directory, if available: %s\n",
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
g_print ("checking file functions...\n");