mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>.
2001-02-21 Tor Lillqvist <tml@iki.fi> Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>. Hopefully I got it all in while simultaneously adding support for auto*/libtool for mingw. * Makefile.am: Changes for auto* support on Cygwin and Win32. Do still distribute the hand-written makefiles and *.win32.in files, though. Use GIO, GSPAWN and PLATFORMDEP macros set by configure. Use -no-undefined. Pass -export-symbols glib.def to libtool. * configure.in: Define G_PLATFORM_WIN32 on both pure Win32 (mingw) and Cygwin. Add AC_CYGWIN, AC_EXEEXT and AC_LIBTOOL_WIN32_DLL calls for Cygwin and mingw support. Check for %I64u guint64 format (in MS C library). Set G_MODULE_IMPL on mingw and Cygwin. Use ac_object and ac_exeext. Set GIO, GSPAWN, PLATFORMDEP and G_LIBS_EXTRA. Compile timeloop only on Unix. Define OS_WIN32 automake conditional on Win32. * glib.h: Include gwin32.h also on Cygwin. * gfileutils.c (get_contents_posix): Use O_BINARY (defined as 0 on Unix) for Cygwin's sake. * gtimer.c (GETTIME): Reduce #ifdefs, use a macro GETTIME(). * gconvert.c * gthread.c * gutf8.c * gutils.c: For code needed both on Cygwin and native Win32, test for G_PLATFORM_WIN32. * gmarkup.h: Use G_BEGIN_DECLS and G_END_DECLS. * gtypes.h: Refine GLIB_VAR definition. Also check for DLL_EXPORT in case compiling a static library on Win32 or Cygwin. * gwin32.c: No <direct.h> on Cygwin. No need for ftruncate() or dirent emulation on Cygwin. (get_package_directory_from_module) Convert return value from GetModuleFileName() to POSIX path on Cygwin. * tests/Makefile.am (progs_LDADD): Link with libglib, libgthread and libgmodule as appropriate. Use -no-undefined. * gbacktrace.c: Move #ifdefs around a bit on Win32. * gshell.c (unquote_string_inplace): Make static. * testglib.c: Make some vars static. Add Cygwin path tests.
This commit is contained in:
parent
31c5b1899d
commit
754d8ddad8
@ -59,6 +59,14 @@ struct _GRealTimer
|
||||
guint active : 1;
|
||||
};
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
# define GETTIME(v) \
|
||||
v = GetTickCount ()
|
||||
#else /* !G_OS_WIN32 */
|
||||
# define GETTIME(v) \
|
||||
gettimeofday (&v, NULL)
|
||||
#endif /* !G_OS_WIN32 */
|
||||
|
||||
GTimer*
|
||||
g_timer_new (void)
|
||||
{
|
||||
@ -67,11 +75,7 @@ g_timer_new (void)
|
||||
timer = g_new (GRealTimer, 1);
|
||||
timer->active = TRUE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
timer->start = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&timer->start, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME (timer->start);
|
||||
|
||||
return ((GTimer*) timer);
|
||||
}
|
||||
@ -94,11 +98,7 @@ g_timer_start (GTimer *timer)
|
||||
rtimer = (GRealTimer*) timer;
|
||||
rtimer->active = TRUE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
rtimer->start = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&rtimer->start, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME (rtimer->start);
|
||||
}
|
||||
|
||||
void
|
||||
@ -111,11 +111,7 @@ g_timer_stop (GTimer *timer)
|
||||
rtimer = (GRealTimer*) timer;
|
||||
rtimer->active = FALSE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
rtimer->end = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&rtimer->end, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME(rtimer->end);
|
||||
}
|
||||
|
||||
void
|
||||
@ -127,11 +123,7 @@ g_timer_reset (GTimer *timer)
|
||||
|
||||
rtimer = (GRealTimer*) timer;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
rtimer->start = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&rtimer->start, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME (rtimer->start);
|
||||
}
|
||||
|
||||
gdouble
|
||||
@ -152,10 +144,7 @@ g_timer_elapsed (GTimer *timer,
|
||||
if (rtimer->active)
|
||||
rtimer->end = GetTickCount ();
|
||||
|
||||
/* Check for wraparound, which happens every 49.7 days.
|
||||
* No, Win95 machines probably are never running for that long,
|
||||
* but NT machines are.
|
||||
*/
|
||||
/* Check for wraparound, which happens every 49.7 days. */
|
||||
if (rtimer->end < rtimer->start)
|
||||
total = (UINT_MAX - (rtimer->start - rtimer->end)) / 1000.0;
|
||||
else
|
||||
|
@ -327,15 +327,25 @@ G_END_DECLS
|
||||
/* We prefix variable declarations so they can
|
||||
* properly get exported in windows dlls.
|
||||
*/
|
||||
#ifdef G_OS_WIN32
|
||||
#ifndef GLIB_VAR
|
||||
# ifdef G_PLATFORM_WIN32
|
||||
# ifdef GLIB_STATIC_COMPILATION
|
||||
# define GLIB_VAR extern
|
||||
# else /* !GLIB_STATIC_COMPILATION */
|
||||
# ifdef GLIB_COMPILATION
|
||||
# ifdef DLL_EXPORT
|
||||
# define GLIB_VAR __declspec(dllexport)
|
||||
# else /* !DLL_EXPORT */
|
||||
# define GLIB_VAR extern
|
||||
# endif /* !DLL_EXPORT */
|
||||
# else /* !GLIB_COMPILATION */
|
||||
# define GLIB_VAR extern __declspec(dllimport)
|
||||
# endif /* !GLIB_COMPILATION */
|
||||
#else /* !G_OS_WIN32 */
|
||||
# endif /* !GLIB_STATIC_COMPILATION */
|
||||
# else /* !G_PLATFORM_WIN32 */
|
||||
# define GLIB_VAR extern
|
||||
#endif /* !G_OS_WIN32 */
|
||||
# endif /* !G_PLATFORM_WIN32 */
|
||||
#endif /* GLIB_VAR */
|
||||
|
||||
#endif /* __G_TYPES_H__ */
|
||||
|
||||
|
@ -161,7 +161,7 @@ gunichar *g_unicode_canonical_decomposition (gunichar ch,
|
||||
|
||||
/* Array of skip-bytes-per-initial character.
|
||||
* We prefix variable declarations so they can
|
||||
* properly get exported in windows dlls.
|
||||
* properly get exported in Windows DLLs.
|
||||
*/
|
||||
GLIB_VAR char g_utf8_skip[256];
|
||||
|
||||
|
@ -29,10 +29,11 @@
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
#include <stdio.h>
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#undef STRICT
|
||||
#endif
|
||||
|
||||
#include "glibintl.h"
|
||||
@ -341,7 +342,7 @@ g_utf8_get_charset_internal (char **a)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
if (a && ! *a)
|
||||
{
|
||||
static char codepage[10];
|
||||
|
@ -64,13 +64,16 @@
|
||||
#define G_PATH_LENGTH 2048
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
# define STRICT /* Strict typing, please */
|
||||
# include <windows.h>
|
||||
# undef STRICT
|
||||
# include <ctype.h>
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
# include <direct.h>
|
||||
#endif /* G_OS_WIN32 */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CODESET
|
||||
#include <langinfo.h>
|
||||
@ -548,9 +551,10 @@ g_path_is_absolute (const gchar *file_name)
|
||||
return TRUE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Recognize drive letter on native Windows */
|
||||
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
|
||||
return TRUE;
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -560,13 +564,13 @@ g_path_skip_root (const gchar *file_name)
|
||||
{
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Skip \\server\share */
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
/* Skip \\server\share (Win32) or //server/share (Cygwin) */
|
||||
if (file_name[0] == G_DIR_SEPARATOR &&
|
||||
file_name[1] == G_DIR_SEPARATOR &&
|
||||
file_name[2])
|
||||
{
|
||||
gchar *p, *q;
|
||||
gchar *p;
|
||||
|
||||
if ((p = strchr (file_name + 2, G_DIR_SEPARATOR)) > file_name + 2 &&
|
||||
p[1])
|
||||
@ -1087,12 +1091,12 @@ g_get_codeset (void)
|
||||
char *result = nl_langinfo (CODESET);
|
||||
return g_strdup (result);
|
||||
#else
|
||||
#ifndef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
return g_strdup_printf ("CP%d", GetACP ());
|
||||
#else
|
||||
/* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
|
||||
*/
|
||||
return g_strdup ("ISO-8859-1");
|
||||
#else
|
||||
return g_strdup_printf ("CP%d", GetACP ());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -1102,7 +1106,8 @@ g_get_codeset (void)
|
||||
#include <libintl.h>
|
||||
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifndef GLIB_LOCALE_DIR
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
|
||||
#define GLIB_LOCALE_DIR \
|
||||
g_win32_get_package_installation_subdirectory \
|
||||
@ -1111,7 +1116,8 @@ g_get_codeset (void)
|
||||
GLIB_MINOR_VERSION), \
|
||||
"locale")
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
#endif /* !GLIB_LOCALE_DIR */
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
_glib_gettext (const gchar *str)
|
||||
|
@ -42,7 +42,10 @@
|
||||
|
||||
#define STRICT /* Strict typing, please */
|
||||
#include <windows.h>
|
||||
#undef STRICT
|
||||
#ifndef G_WITH_CYGWIN
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#ifdef _MSC_VER
|
||||
@ -51,7 +54,13 @@
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
int
|
||||
#ifdef G_WITH_CYGWIN
|
||||
#include <sys/cygwin.h>
|
||||
#endif
|
||||
|
||||
#ifndef G_WITH_CYGWIN
|
||||
|
||||
gint
|
||||
g_win32_ftruncate (gint fd,
|
||||
guint size)
|
||||
{
|
||||
@ -214,8 +223,9 @@ g_win32_closedir (DIR *dir)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Mingw32 headers don't have latest language and sublanguage codes */
|
||||
/* Mingw headers don't have latest language and sublanguage codes */
|
||||
#ifndef LANG_AFRIKAANS
|
||||
#define LANG_AFRIKAANS 0x36
|
||||
#endif
|
||||
@ -873,12 +883,23 @@ get_package_directory_from_module (gchar *module_name)
|
||||
if (!GetModuleFileName (hmodule, fn, MAX_PATH))
|
||||
return NULL;
|
||||
|
||||
if ((p = strrchr (fn, '\\')) != NULL)
|
||||
#ifdef G_WITH_CYGWIN
|
||||
/* In Cygwin we need to have POSIX paths */
|
||||
{
|
||||
gchar tmp[MAX_PATH];
|
||||
|
||||
cygwin_conv_to_posix_path(fn, tmp);
|
||||
g_free(fn);
|
||||
fn = g_strdup(tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
if (module_name)
|
||||
{
|
||||
p = strrchr (fn, '\\');
|
||||
p = strrchr (fn, G_DIR_SEPARATOR);
|
||||
if (p && (g_strcasecmp (p + 1, "bin") == 0 ||
|
||||
g_strcasecmp (p + 1, "lib") == 0))
|
||||
*p = '\0';
|
||||
@ -927,7 +948,6 @@ g_win32_get_package_installation_directory (gchar *package,
|
||||
static GHashTable *package_dirs = NULL;
|
||||
gchar *result = NULL;
|
||||
gchar *key;
|
||||
char win_dir[MAX_PATH];
|
||||
HKEY reg_key = NULL;
|
||||
DWORD type;
|
||||
DWORD nbytes;
|
||||
@ -1001,7 +1021,8 @@ g_win32_get_package_installation_subdirectory (gchar *package,
|
||||
|
||||
prefix = g_win32_get_package_installation_directory (package, dll_name);
|
||||
|
||||
sep = (prefix[strlen (prefix) - 1] == '\\' ? "" : "\\");
|
||||
sep = (prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
|
||||
"" : G_DIR_SEPARATOR_S);
|
||||
|
||||
return g_strconcat (prefix, sep, subdir, NULL);
|
||||
}
|
||||
|
@ -29,19 +29,23 @@
|
||||
|
||||
#include <gtypes.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
|
||||
/* Windows emulation stubs for common Unix functions
|
||||
*/
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
/*
|
||||
* To get prototypes for the following POSIXish functions, you have to
|
||||
* include the indicated non-POSIX headers. The functions are defined
|
||||
@ -89,13 +93,15 @@ struct DIR
|
||||
typedef struct DIR DIR;
|
||||
|
||||
/* emulation functions */
|
||||
extern int g_win32_ftruncate (gint f,
|
||||
gint g_win32_ftruncate (gint f,
|
||||
guint size);
|
||||
DIR* g_win32_opendir (const gchar *dirname);
|
||||
struct dirent* g_win32_readdir (DIR *dir);
|
||||
void g_win32_rewinddir (DIR *dir);
|
||||
gint g_win32_closedir (DIR *dir);
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
/* The MS setlocale uses locale names of the form "English_United
|
||||
* States.1252" etc. We want the Unixish standard form "en", "zh_TW"
|
||||
* etc. This function gets the current thread locale from Windows and
|
||||
@ -119,6 +125,6 @@ gchar* g_win32_get_package_installation_subdirectory (gchar *package,
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
|
||||
#endif /* __G_WIN32_H__ */
|
||||
|
@ -15,7 +15,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
|
||||
# Nothing much configurable below
|
||||
|
||||
INCLUDES = -I .
|
||||
DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG
|
||||
DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DDLL_EXPORT
|
||||
DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS)
|
||||
|
||||
DLLS_TO_BUILD = \
|
||||
|
37
gtimer.c
37
gtimer.c
@ -59,6 +59,14 @@ struct _GRealTimer
|
||||
guint active : 1;
|
||||
};
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
# define GETTIME(v) \
|
||||
v = GetTickCount ()
|
||||
#else /* !G_OS_WIN32 */
|
||||
# define GETTIME(v) \
|
||||
gettimeofday (&v, NULL)
|
||||
#endif /* !G_OS_WIN32 */
|
||||
|
||||
GTimer*
|
||||
g_timer_new (void)
|
||||
{
|
||||
@ -67,11 +75,7 @@ g_timer_new (void)
|
||||
timer = g_new (GRealTimer, 1);
|
||||
timer->active = TRUE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
timer->start = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&timer->start, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME (timer->start);
|
||||
|
||||
return ((GTimer*) timer);
|
||||
}
|
||||
@ -94,11 +98,7 @@ g_timer_start (GTimer *timer)
|
||||
rtimer = (GRealTimer*) timer;
|
||||
rtimer->active = TRUE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
rtimer->start = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&rtimer->start, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME (rtimer->start);
|
||||
}
|
||||
|
||||
void
|
||||
@ -111,11 +111,7 @@ g_timer_stop (GTimer *timer)
|
||||
rtimer = (GRealTimer*) timer;
|
||||
rtimer->active = FALSE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
rtimer->end = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&rtimer->end, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME(rtimer->end);
|
||||
}
|
||||
|
||||
void
|
||||
@ -127,11 +123,7 @@ g_timer_reset (GTimer *timer)
|
||||
|
||||
rtimer = (GRealTimer*) timer;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
rtimer->start = GetTickCount ();
|
||||
#else /* !G_OS_WIN32 */
|
||||
gettimeofday (&rtimer->start, NULL);
|
||||
#endif /* !G_OS_WIN32 */
|
||||
GETTIME (rtimer->start);
|
||||
}
|
||||
|
||||
gdouble
|
||||
@ -152,10 +144,7 @@ g_timer_elapsed (GTimer *timer,
|
||||
if (rtimer->active)
|
||||
rtimer->end = GetTickCount ();
|
||||
|
||||
/* Check for wraparound, which happens every 49.7 days.
|
||||
* No, Win95 machines probably are never running for that long,
|
||||
* but NT machines are.
|
||||
*/
|
||||
/* Check for wraparound, which happens every 49.7 days. */
|
||||
if (rtimer->end < rtimer->start)
|
||||
total = (UINT_MAX - (rtimer->start - rtimer->end)) / 1000.0;
|
||||
else
|
||||
|
16
gtypes.h
16
gtypes.h
@ -327,15 +327,25 @@ G_END_DECLS
|
||||
/* We prefix variable declarations so they can
|
||||
* properly get exported in windows dlls.
|
||||
*/
|
||||
#ifdef G_OS_WIN32
|
||||
#ifndef GLIB_VAR
|
||||
# ifdef G_PLATFORM_WIN32
|
||||
# ifdef GLIB_STATIC_COMPILATION
|
||||
# define GLIB_VAR extern
|
||||
# else /* !GLIB_STATIC_COMPILATION */
|
||||
# ifdef GLIB_COMPILATION
|
||||
# ifdef DLL_EXPORT
|
||||
# define GLIB_VAR __declspec(dllexport)
|
||||
# else /* !DLL_EXPORT */
|
||||
# define GLIB_VAR extern
|
||||
# endif /* !DLL_EXPORT */
|
||||
# else /* !GLIB_COMPILATION */
|
||||
# define GLIB_VAR extern __declspec(dllimport)
|
||||
# endif /* !GLIB_COMPILATION */
|
||||
#else /* !G_OS_WIN32 */
|
||||
# endif /* !GLIB_STATIC_COMPILATION */
|
||||
# else /* !G_PLATFORM_WIN32 */
|
||||
# define GLIB_VAR extern
|
||||
#endif /* !G_OS_WIN32 */
|
||||
# endif /* !G_PLATFORM_WIN32 */
|
||||
#endif /* GLIB_VAR */
|
||||
|
||||
#endif /* __G_TYPES_H__ */
|
||||
|
||||
|
@ -161,7 +161,7 @@ gunichar *g_unicode_canonical_decomposition (gunichar ch,
|
||||
|
||||
/* Array of skip-bytes-per-initial character.
|
||||
* We prefix variable declarations so they can
|
||||
* properly get exported in windows dlls.
|
||||
* properly get exported in Windows DLLs.
|
||||
*/
|
||||
GLIB_VAR char g_utf8_skip[256];
|
||||
|
||||
|
5
gutf8.c
5
gutf8.c
@ -29,10 +29,11 @@
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
#include <stdio.h>
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#undef STRICT
|
||||
#endif
|
||||
|
||||
#include "glibintl.h"
|
||||
@ -341,7 +342,7 @@ g_utf8_get_charset_internal (char **a)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
if (a && ! *a)
|
||||
{
|
||||
static char codepage[10];
|
||||
|
28
gutils.c
28
gutils.c
@ -64,13 +64,16 @@
|
||||
#define G_PATH_LENGTH 2048
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
# define STRICT /* Strict typing, please */
|
||||
# include <windows.h>
|
||||
# undef STRICT
|
||||
# include <ctype.h>
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
# include <direct.h>
|
||||
#endif /* G_OS_WIN32 */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CODESET
|
||||
#include <langinfo.h>
|
||||
@ -548,9 +551,10 @@ g_path_is_absolute (const gchar *file_name)
|
||||
return TRUE;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Recognize drive letter on native Windows */
|
||||
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
|
||||
return TRUE;
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -560,13 +564,13 @@ g_path_skip_root (const gchar *file_name)
|
||||
{
|
||||
g_return_val_if_fail (file_name != NULL, NULL);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Skip \\server\share */
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
/* Skip \\server\share (Win32) or //server/share (Cygwin) */
|
||||
if (file_name[0] == G_DIR_SEPARATOR &&
|
||||
file_name[1] == G_DIR_SEPARATOR &&
|
||||
file_name[2])
|
||||
{
|
||||
gchar *p, *q;
|
||||
gchar *p;
|
||||
|
||||
if ((p = strchr (file_name + 2, G_DIR_SEPARATOR)) > file_name + 2 &&
|
||||
p[1])
|
||||
@ -1087,12 +1091,12 @@ g_get_codeset (void)
|
||||
char *result = nl_langinfo (CODESET);
|
||||
return g_strdup (result);
|
||||
#else
|
||||
#ifndef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
return g_strdup_printf ("CP%d", GetACP ());
|
||||
#else
|
||||
/* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
|
||||
*/
|
||||
return g_strdup ("ISO-8859-1");
|
||||
#else
|
||||
return g_strdup_printf ("CP%d", GetACP ());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -1102,7 +1106,8 @@ g_get_codeset (void)
|
||||
#include <libintl.h>
|
||||
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifndef GLIB_LOCALE_DIR
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
|
||||
#define GLIB_LOCALE_DIR \
|
||||
g_win32_get_package_installation_subdirectory \
|
||||
@ -1111,7 +1116,8 @@ g_get_codeset (void)
|
||||
GLIB_MINOR_VERSION), \
|
||||
"locale")
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
#endif /* !GLIB_LOCALE_DIR */
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
_glib_gettext (const gchar *str)
|
||||
|
33
gwin32.c
33
gwin32.c
@ -42,7 +42,10 @@
|
||||
|
||||
#define STRICT /* Strict typing, please */
|
||||
#include <windows.h>
|
||||
#undef STRICT
|
||||
#ifndef G_WITH_CYGWIN
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#ifdef _MSC_VER
|
||||
@ -51,7 +54,13 @@
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
int
|
||||
#ifdef G_WITH_CYGWIN
|
||||
#include <sys/cygwin.h>
|
||||
#endif
|
||||
|
||||
#ifndef G_WITH_CYGWIN
|
||||
|
||||
gint
|
||||
g_win32_ftruncate (gint fd,
|
||||
guint size)
|
||||
{
|
||||
@ -214,8 +223,9 @@ g_win32_closedir (DIR *dir)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Mingw32 headers don't have latest language and sublanguage codes */
|
||||
/* Mingw headers don't have latest language and sublanguage codes */
|
||||
#ifndef LANG_AFRIKAANS
|
||||
#define LANG_AFRIKAANS 0x36
|
||||
#endif
|
||||
@ -873,12 +883,23 @@ get_package_directory_from_module (gchar *module_name)
|
||||
if (!GetModuleFileName (hmodule, fn, MAX_PATH))
|
||||
return NULL;
|
||||
|
||||
if ((p = strrchr (fn, '\\')) != NULL)
|
||||
#ifdef G_WITH_CYGWIN
|
||||
/* In Cygwin we need to have POSIX paths */
|
||||
{
|
||||
gchar tmp[MAX_PATH];
|
||||
|
||||
cygwin_conv_to_posix_path(fn, tmp);
|
||||
g_free(fn);
|
||||
fn = g_strdup(tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
if (module_name)
|
||||
{
|
||||
p = strrchr (fn, '\\');
|
||||
p = strrchr (fn, G_DIR_SEPARATOR);
|
||||
if (p && (g_strcasecmp (p + 1, "bin") == 0 ||
|
||||
g_strcasecmp (p + 1, "lib") == 0))
|
||||
*p = '\0';
|
||||
@ -927,7 +948,6 @@ g_win32_get_package_installation_directory (gchar *package,
|
||||
static GHashTable *package_dirs = NULL;
|
||||
gchar *result = NULL;
|
||||
gchar *key;
|
||||
char win_dir[MAX_PATH];
|
||||
HKEY reg_key = NULL;
|
||||
DWORD type;
|
||||
DWORD nbytes;
|
||||
@ -1001,7 +1021,8 @@ g_win32_get_package_installation_subdirectory (gchar *package,
|
||||
|
||||
prefix = g_win32_get_package_installation_directory (package, dll_name);
|
||||
|
||||
sep = (prefix[strlen (prefix) - 1] == '\\' ? "" : "\\");
|
||||
sep = (prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
|
||||
"" : G_DIR_SEPARATOR_S);
|
||||
|
||||
return g_strconcat (prefix, sep, subdir, NULL);
|
||||
}
|
||||
|
12
gwin32.h
12
gwin32.h
@ -29,19 +29,23 @@
|
||||
|
||||
#include <gtypes.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
|
||||
/* Windows emulation stubs for common Unix functions
|
||||
*/
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
/*
|
||||
* To get prototypes for the following POSIXish functions, you have to
|
||||
* include the indicated non-POSIX headers. The functions are defined
|
||||
@ -89,13 +93,15 @@ struct DIR
|
||||
typedef struct DIR DIR;
|
||||
|
||||
/* emulation functions */
|
||||
extern int g_win32_ftruncate (gint f,
|
||||
gint g_win32_ftruncate (gint f,
|
||||
guint size);
|
||||
DIR* g_win32_opendir (const gchar *dirname);
|
||||
struct dirent* g_win32_readdir (DIR *dir);
|
||||
void g_win32_rewinddir (DIR *dir);
|
||||
gint g_win32_closedir (DIR *dir);
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
/* The MS setlocale uses locale names of the form "English_United
|
||||
* States.1252" etc. We want the Unixish standard form "en", "zh_TW"
|
||||
* etc. This function gets the current thread locale from Windows and
|
||||
@ -119,6 +125,6 @@ gchar* g_win32_get_package_installation_subdirectory (gchar *package,
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
#endif /* G_PLATFORM_WIN32 */
|
||||
|
||||
#endif /* __G_WIN32_H__ */
|
||||
|
@ -15,7 +15,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@
|
||||
# Nothing much configurable below
|
||||
|
||||
INCLUDES = -I .
|
||||
DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG
|
||||
DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DDLL_EXPORT
|
||||
DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS)
|
||||
|
||||
DLLS_TO_BUILD = \
|
||||
|
17
testglib.c
17
testglib.c
@ -46,8 +46,8 @@
|
||||
#include <io.h> /* For read(), write() etc */
|
||||
#endif
|
||||
|
||||
int array[10000];
|
||||
gboolean failed = FALSE;
|
||||
static int array[10000];
|
||||
static gboolean failed = FALSE;
|
||||
|
||||
#define TEST(m,cond) G_STMT_START { failed = !(cond); \
|
||||
if (failed) \
|
||||
@ -350,6 +350,9 @@ main (int argc,
|
||||
{ "a\\b", "a" },
|
||||
{ "a\\b\\", "a\\b" },
|
||||
{ "c\\\\\\", "c" },
|
||||
#endif
|
||||
#ifdef G_WITH_CYGWIN
|
||||
{ "//server/share///x", "//server/share" },
|
||||
#endif
|
||||
{ ".", "." },
|
||||
{ "..", "." },
|
||||
@ -373,6 +376,9 @@ main (int argc,
|
||||
{ "\\\\server\\foo", "" },
|
||||
{ "\\\\server\\foo\\bar", "bar" },
|
||||
{ "a\\b", NULL },
|
||||
#endif
|
||||
#ifdef G_WITH_CYGWIN
|
||||
{ "//server/share///x", "//x" },
|
||||
#endif
|
||||
{ ".", NULL },
|
||||
{ "", NULL },
|
||||
@ -397,6 +403,11 @@ main (int argc,
|
||||
GLIB_MAJOR_VERSION,
|
||||
GLIB_MINOR_VERSION);
|
||||
#endif
|
||||
#ifdef G_WITH_CYGWIN
|
||||
gchar *glib_dll = g_strdup_printf ("cygglib-%d.%d.dll",
|
||||
GLIB_MAJOR_VERSION,
|
||||
GLIB_MINOR_VERSION);
|
||||
#endif
|
||||
|
||||
g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n",
|
||||
glib_major_version,
|
||||
@ -1151,7 +1162,7 @@ main (int argc,
|
||||
|
||||
g_print ("ok\n");
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
g_print ("current locale: %s\n", g_win32_getlocale ());
|
||||
|
||||
g_print ("GLib installation directory, from Registry entry for %s if available: %s\n",
|
||||
|
@ -46,8 +46,8 @@
|
||||
#include <io.h> /* For read(), write() etc */
|
||||
#endif
|
||||
|
||||
int array[10000];
|
||||
gboolean failed = FALSE;
|
||||
static int array[10000];
|
||||
static gboolean failed = FALSE;
|
||||
|
||||
#define TEST(m,cond) G_STMT_START { failed = !(cond); \
|
||||
if (failed) \
|
||||
@ -350,6 +350,9 @@ main (int argc,
|
||||
{ "a\\b", "a" },
|
||||
{ "a\\b\\", "a\\b" },
|
||||
{ "c\\\\\\", "c" },
|
||||
#endif
|
||||
#ifdef G_WITH_CYGWIN
|
||||
{ "//server/share///x", "//server/share" },
|
||||
#endif
|
||||
{ ".", "." },
|
||||
{ "..", "." },
|
||||
@ -373,6 +376,9 @@ main (int argc,
|
||||
{ "\\\\server\\foo", "" },
|
||||
{ "\\\\server\\foo\\bar", "bar" },
|
||||
{ "a\\b", NULL },
|
||||
#endif
|
||||
#ifdef G_WITH_CYGWIN
|
||||
{ "//server/share///x", "//x" },
|
||||
#endif
|
||||
{ ".", NULL },
|
||||
{ "", NULL },
|
||||
@ -397,6 +403,11 @@ main (int argc,
|
||||
GLIB_MAJOR_VERSION,
|
||||
GLIB_MINOR_VERSION);
|
||||
#endif
|
||||
#ifdef G_WITH_CYGWIN
|
||||
gchar *glib_dll = g_strdup_printf ("cygglib-%d.%d.dll",
|
||||
GLIB_MAJOR_VERSION,
|
||||
GLIB_MINOR_VERSION);
|
||||
#endif
|
||||
|
||||
g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n",
|
||||
glib_major_version,
|
||||
@ -1151,7 +1162,7 @@ main (int argc,
|
||||
|
||||
g_print ("ok\n");
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
g_print ("current locale: %s\n", g_win32_getlocale ());
|
||||
|
||||
g_print ("GLib installation directory, from Registry entry for %s if available: %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user