diff -uNr gettext-runtime/configure.ac.org gettext-runtime/configure.ac --- gettext-runtime/configure.ac.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/configure.ac 2011-03-26 22:06:26.000000000 +0900 @@ -101,7 +101,7 @@ #endif /* Extra OS/2 (emx+gcc) defines. */ -#ifdef __EMX__ +#if defined __EMX__ && !defined __INNOTEK_LIBC__ # include "intl/os2compat.h" #endif ]) diff -uNr gettext-runtime/gnulib-lib/localcharset.c.org gettext-runtime/gnulib-lib/localcharset.c --- gettext-runtime/gnulib-lib/localcharset.c.org 2010-05-09 10:36:14.000000000 +0900 +++ gettext-runtime/gnulib-lib/localcharset.c 2011-03-27 18:14:48.000000000 +0900 @@ -475,6 +475,7 @@ ULONG cp[3]; ULONG cplen; + codeset = NULL; /* Allow user to override the codeset, as set in the operating system, with standard language environment variables. */ locale = getenv ("LC_ALL"); @@ -504,12 +505,13 @@ buf [modifier - dot] = '\0'; return buf; } - } - /* Resolve through the charset.alias file. */ - codeset = locale; + /* Resolve through the charset.alias file. */ + codeset = locale; + } } - else + + if (codeset == NULL) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) diff -uNr gettext-runtime/gnulib-lib/progreloc.c.org gettext-runtime/gnulib-lib/progreloc.c --- gettext-runtime/gnulib-lib/progreloc.c.org 2010-02-17 06:31:28.000000000 +0900 +++ gettext-runtime/gnulib-lib/progreloc.c 2011-03-27 12:05:00.000000000 +0900 @@ -43,6 +43,12 @@ # include #endif +#ifdef __EMX__ +# define INCL_DOS +# include +#endif + + #include "relocatable.h" #ifdef NO_XMALLOC @@ -172,7 +178,19 @@ return xstrdup (location); #endif } -#else /* Unix && !Cygwin */ +#elif defined __EMX__ + PPIB ppib; + char location[CCHMAXPATH]; + + DosGetInfoBlocks (NULL, &ppib); + + if (DosQueryModuleName (ppib->pib_hmte, sizeof (location), location)) + return NULL; + + _fnslashify (location); + + return xstrdup (location); +#else /* Unix && !Cygwin && !EMX */ #ifdef __linux__ /* The executable is accessible as /proc//exe. In newer Linux versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink diff -uNr gettext-runtime/gnulib-lib/relocatable.c.org gettext-runtime/gnulib-lib/relocatable.c --- gettext-runtime/gnulib-lib/relocatable.c.org 2010-02-17 06:31:28.000000000 +0900 +++ gettext-runtime/gnulib-lib/relocatable.c 2011-03-27 12:03:28.000000000 +0900 @@ -48,6 +48,14 @@ # include #endif +#ifdef __EMX__ +# define INCL_DOS +# include + +#define strcmp stricmp +#define strncmp strnicmp +#endif + #if DEPENDS_ON_LIBCHARSET # include #endif @@ -336,7 +344,44 @@ return TRUE; } -#else /* Unix except Cygwin */ +#elif defined __EMX__ + +extern int _CRT_init (void); +extern void _CRT_term (void); +extern void __ctordtorInit (void); +extern void __ctordtorTerm (void); + +unsigned long _System +_DLL_InitTerm (unsigned long hModule, unsigned long ulFlag) +{ + static char location[CCHMAXPATH]; + + switch (ulFlag) + { + case 0: + if (_CRT_init () == -1) + return 0; + + __ctordtorInit(); + + if (DosQueryModuleName (hModule, sizeof (location), location)) + return 0; + + _fnslashify (location); + shared_library_fullname = strdup (location); + break; + + case 1: + __ctordtorTerm(); + + _CRT_term (); + break; + } + + return 1; +} + +#else /* Unix except Cygwin and EMX */ static void find_shared_library_fullname () @@ -387,15 +432,15 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin and EMX) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux, Cygwin and Woe32. */ + Guaranteed to work only on Linux, Cygwin, Woe32 and EMX. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { @@ -486,8 +531,30 @@ } } } + +#ifdef __EMX__ + if (pathname && ISSLASH (pathname[0])) + { + const char *unixroot = getenv ("UNIXROOT"); + + if (unixroot && HAS_DEVICE (unixroot) && !unixroot[2]) + { + char *result = (char *) xmalloc (2 + strlen (pathname) + 1); +#ifdef NO_XMALLOC + if (result != NULL) +#endif + { + strcpy (result, unixroot); + strcpy (result + 2, pathname); + return result; + } + } + } +#endif + /* Nothing to relocate. */ return pathname; } #endif + diff -uNr gettext-runtime/gnulib-lib/stdint.in.h.org gettext-runtime/gnulib-lib/stdint.in.h --- gettext-runtime/gnulib-lib/stdint.in.h.org 2010-04-25 18:20:42.000000000 +0900 +++ gettext-runtime/gnulib-lib/stdint.in.h 2011-03-26 21:35:30.000000000 +0900 @@ -243,8 +243,15 @@ #undef intptr_t #undef uintptr_t +#ifndef __INNOTEK_LIBC__ typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; +#else +/* intptr_t and uintptr_t are defined as int and unsigned int on OS/2 kLIBC, + respectively */ +typedef int gl_intptr_t; +typedef unsigned int gl_uintptr_t; +#endif #define intptr_t gl_intptr_t #define uintptr_t gl_uintptr_t diff -uNr gettext-runtime/gnulib-lib/wcwidth.c.org gettext-runtime/gnulib-lib/wcwidth.c --- gettext-runtime/gnulib-lib/wcwidth.c.org 2010-04-25 18:20:42.000000000 +0900 +++ gettext-runtime/gnulib-lib/wcwidth.c 2011-03-26 21:41:18.000000000 +0900 @@ -26,6 +26,15 @@ #include "streq.h" #include "uniwidth.h" +#ifdef __INNOTEK_LIBC__ +/* To avoid 'conflicting types' error for `__wcwidth' on OS/2 kLIBC. + wchar_t(unsigned short) is defined differently from wint_t(int) on + OS/2 kLIBC. */ +#undef wcwidth +/* Ignore wcwidth() of OS/2 kLIBC */ +#undef HAVE_WCWIDTH +#endif + int wcwidth (wchar_t wc) #undef wcwidth diff -uNr gettext-runtime/intl/bindtextdom.c.org gettext-runtime/intl/bindtextdom.c --- gettext-runtime/intl/bindtextdom.c.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/bindtextdom.c 2011-03-27 12:03:28.000000000 +0900 @@ -320,6 +320,27 @@ char * BINDTEXTDOMAIN (const char *domainname, const char *dirname) { +#ifdef __EMX__ + char dirname_with_drive[_MAX_PATH]; + + if (dirname && (dirname[0] == '/' || dirname[0] == '\\' )) + { + const char *unixroot = getenv ("UNIXROOT"); + size_t len = strlen (dirname) + 1; + + if (unixroot + && unixroot[0] != '\0' + && unixroot[1] == ':' + && unixroot[2] == '\0' + && 2 + len <= _MAX_PATH) + { + memcpy (dirname_with_drive, unixroot, 2); + memcpy (dirname_with_drive + 2, dirname, len); + + dirname = dirname_with_drive; + } + } +#endif set_binding_values (domainname, &dirname, NULL); return (char *) dirname; } diff -uNr gettext-runtime/intl/dcigettext.c.org gettext-runtime/intl/dcigettext.c --- gettext-runtime/intl/dcigettext.c.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/dcigettext.c 2011-03-27 18:10:28.000000000 +0900 @@ -325,7 +325,7 @@ #endif /* Contains the default location of the message catalogs. */ -#if defined __EMX__ +#if defined __EMX__ && !defined __INNOTEK_LIBC__ extern const char _nl_default_dirname[]; #else # ifdef _LIBC diff -uNr gettext-runtime/intl/gettextP.h.org gettext-runtime/intl/gettextP.h --- gettext-runtime/intl/gettextP.h.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/gettextP.h 2011-03-26 18:56:58.000000000 +0900 @@ -220,6 +220,9 @@ /* A counter which is incremented each time some previous translations become invalid. This variable is part of the external ABI of the GNU libintl. */ +#if defined __INNOTEK_LIBC__ && !defined _LIBC +# define _nl_msg_cat_cntr libintl_nl_msg_cat_cntr +#endif #ifdef IN_LIBGLOCALE # include extern LIBGLOCALE_DLL_EXPORTED int _nl_msg_cat_cntr; diff -uNr gettext-runtime/intl/localcharset.c.org gettext-runtime/intl/localcharset.c --- gettext-runtime/intl/localcharset.c.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/localcharset.c 2011-03-27 18:08:46.000000000 +0900 @@ -476,6 +476,7 @@ ULONG cp[3]; ULONG cplen; + codeset = NULL; /* Allow user to override the codeset, as set in the operating system, with standard language environment variables. */ locale = getenv ("LC_ALL"); @@ -505,12 +506,13 @@ buf [modifier - dot] = '\0'; return buf; } - } - /* Resolve through the charset.alias file. */ - codeset = locale; + /* Resolve through the charset.alias file. */ + codeset = locale; + } } - else + + if (codeset == NULL) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) diff -uNr gettext-runtime/intl/Makefile.in.org gettext-runtime/intl/Makefile.in --- gettext-runtime/intl/Makefile.in.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/Makefile.in 2011-03-26 17:40:42.000000000 +0900 @@ -224,7 +224,8 @@ $(address@hidden@) \ -version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \ -rpath $(libdir) \ - -no-undefined + -no-undefined \ + -shortname $(subst lib, k, $(basename $@)) # Libtool's library version information for libintl. # Before making a gettext release, the gettext maintainer must change this diff -uNr gettext-runtime/intl/osdep.c.org gettext-runtime/intl/osdep.c --- gettext-runtime/intl/osdep.c.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/osdep.c 2011-03-26 22:01:36.000000000 +0900 @@ -18,7 +18,7 @@ #if defined __CYGWIN__ # include "intl-exports.c" -#elif defined __EMX__ +#elif defined __EMX__ && !defined __INNOTEK_LIBC__ # include "os2compat.c" #else /* Avoid AIX compiler warning. */ diff -uNr gettext-runtime/intl/relocatable.c.org gettext-runtime/intl/relocatable.c --- gettext-runtime/intl/relocatable.c.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/intl/relocatable.c 2011-03-27 12:03:28.000000000 +0900 @@ -48,6 +48,14 @@ # include #endif +#ifdef __EMX__ +# define INCL_DOS +# include + +#define strcmp stricmp +#define strncmp strnicmp +#endif + #if DEPENDS_ON_LIBCHARSET # include #endif @@ -336,7 +344,44 @@ return TRUE; } -#else /* Unix except Cygwin */ +#elif defined __EMX__ + +extern int _CRT_init (void); +extern void _CRT_term (void); +extern void __ctordtorInit (void); +extern void __ctordtorTerm (void); + +unsigned long _System +_DLL_InitTerm (unsigned long hModule, unsigned long ulFlag) +{ + static char location[CCHMAXPATH]; + + switch (ulFlag) + { + case 0: + if (_CRT_init () == -1) + return 0; + + __ctordtorInit(); + + if (DosQueryModuleName (hModule, sizeof (location), location)) + return 0; + + _fnslashify (location); + shared_library_fullname = strdup (location); + break; + + case 1: + __ctordtorTerm(); + + _CRT_term (); + break; + } + + return 1; +} + +#else /* Unix except Cygwin and EMX */ static void find_shared_library_fullname () @@ -387,15 +432,15 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin and EMX) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux, Cygwin and Woe32. */ + Guaranteed to work only on Linux, Cygwin, Woe32 and EMX. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { @@ -486,6 +531,27 @@ } } } + +#ifdef __EMX__ + if (pathname && ISSLASH (pathname[0])) + { + const char *unixroot = getenv ("UNIXROOT"); + + if (unixroot && HAS_DEVICE (unixroot) && !unixroot[2]) + { + char *result = (char *) xmalloc (2 + strlen (pathname) + 1); +#ifdef NO_XMALLOC + if (result != NULL) +#endif + { + strcpy (result, unixroot); + strcpy (result + 2, pathname); + return result; + } + } + } +#endif + /* Nothing to relocate. */ return pathname; } diff -uNr gettext-runtime/tests/test-lock.c.org gettext-runtime/tests/test-lock.c --- gettext-runtime/tests/test-lock.c.org 2010-06-06 21:49:56.000000000 +0900 +++ gettext-runtime/tests/test-lock.c 2011-03-26 21:43:36.000000000 +0900 @@ -85,7 +85,11 @@ #if TEST_POSIX_THREADS # include -# include +# ifndef __OS2__ +# include +# else +# define sched_yield() pthread_yield() +# endif typedef pthread_t gl_thread_t; static inline gl_thread_t gl_thread_create (void * (*func) (void *), void *arg) { diff -uNr gettext-tools/configure.ac.org gettext-tools/configure.ac --- gettext-tools/configure.ac.org 2010-06-07 05:04:04.000000000 +0900 +++ gettext-tools/configure.ac 2011-03-26 23:30:58.000000000 +0900 @@ -100,7 +100,7 @@ case "$host_os" in # On Cygwin, without -no-undefined, a warning is emitted and only a static # library is built. - beos* | mingw* | cygwin*) LTNOUNDEF='-no-undefined' ;; + beos* | mingw* | cygwin* | os2*) LTNOUNDEF='-no-undefined' ;; *) LTNOUNDEF='' ;; esac AC_SUBST([LTNOUNDEF]) @@ -135,7 +135,7 @@ [x = ceil(x); x = sqrt(x);], [MSGMERGE_LIBM=]) if test "$MSGMERGE_LIBM" = "?"; then - save_LIBS="$LIBS" + save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ #ifndef __NO_MATH_INLINES @@ -268,7 +268,7 @@ #endif /* Extra OS/2 (emx+gcc) defines. */ -#ifdef __EMX__ +#if defined __EMX__ && !defined __INNOTEK_LIBC__ # include "intl/os2compat.h" #endif ]) diff -uNr gettext-tools/gnulib-lib/binary-io.h.org gettext-tools/gnulib-lib/binary-io.h --- gettext-tools/gnulib-lib/binary-io.h.org 2010-05-24 18:42:36.000000000 +0900 +++ gettext-tools/gnulib-lib/binary-io.h 2011-03-27 12:09:36.000000000 +0900 @@ -47,7 +47,7 @@ # undef fileno # define fileno _fileno # endif -# ifdef __DJGPP__ +# if defined __EMX__ || defined __DJGPP__ # include /* declares isatty() */ /* Avoid putting stdin/stdout in binary mode if it is connected to the console, because that would make it impossible for the user diff -uNr gettext-tools/gnulib-lib/localcharset.c.org gettext-tools/gnulib-lib/localcharset.c --- gettext-tools/gnulib-lib/localcharset.c.org 2010-05-24 19:59:08.000000000 +0900 +++ gettext-tools/gnulib-lib/localcharset.c 2011-03-27 18:15:10.000000000 +0900 @@ -475,6 +475,7 @@ ULONG cp[3]; ULONG cplen; + codeset = NULL; /* Allow user to override the codeset, as set in the operating system, with standard language environment variables. */ locale = getenv ("LC_ALL"); @@ -504,12 +505,13 @@ buf [modifier - dot] = '\0'; return buf; } - } - /* Resolve through the charset.alias file. */ - codeset = locale; + /* Resolve through the charset.alias file. */ + codeset = locale; + } } - else + + if (codeset == NULL) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) diff -uNr gettext-tools/gnulib-lib/progreloc.c.org gettext-tools/gnulib-lib/progreloc.c --- gettext-tools/gnulib-lib/progreloc.c.org 2010-05-24 18:42:46.000000000 +0900 +++ gettext-tools/gnulib-lib/progreloc.c 2011-03-27 12:10:26.000000000 +0900 @@ -43,6 +43,11 @@ # include #endif +#ifdef __EMX__ +# define INCL_DOS +# include +#endif + #include "relocatable.h" #ifdef NO_XMALLOC @@ -172,7 +177,19 @@ return xstrdup (location); #endif } -#else /* Unix && !Cygwin */ +#elif defined __EMX__ + PPIB ppib; + char location[CCHMAXPATH]; + + DosGetInfoBlocks (NULL, &ppib); + + if (DosQueryModuleName (ppib->pib_hmte, sizeof (location), location)) + return NULL; + + _fnslashify (location); + + return xstrdup (location); +#else /* Unix && !Cygwin && !EMX */ #ifdef __linux__ /* The executable is accessible as /proc//exe. In newer Linux versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink diff -uNr gettext-tools/gnulib-lib/relocatable.c.org gettext-tools/gnulib-lib/relocatable.c --- gettext-tools/gnulib-lib/relocatable.c.org 2010-05-24 18:42:46.000000000 +0900 +++ gettext-tools/gnulib-lib/relocatable.c 2011-03-27 12:03:28.000000000 +0900 @@ -48,6 +48,14 @@ # include #endif +#ifdef __EMX__ +# define INCL_DOS +# include + +#define strcmp stricmp +#define strncmp strnicmp +#endif + #if DEPENDS_ON_LIBCHARSET # include #endif @@ -336,7 +344,44 @@ return TRUE; } -#else /* Unix except Cygwin */ +#elif defined __EMX__ + +extern int _CRT_init (void); +extern void _CRT_term (void); +extern void __ctordtorInit (void); +extern void __ctordtorTerm (void); + +unsigned long _System +_DLL_InitTerm (unsigned long hModule, unsigned long ulFlag) +{ + static char location[CCHMAXPATH]; + + switch (ulFlag) + { + case 0: + if (_CRT_init () == -1) + return 0; + + __ctordtorInit(); + + if (DosQueryModuleName (hModule, sizeof (location), location)) + return 0; + + _fnslashify (location); + shared_library_fullname = strdup (location); + break; + + case 1: + __ctordtorTerm(); + + _CRT_term (); + break; + } + + return 1; +} + +#else /* Unix except Cygwin and EMX */ static void find_shared_library_fullname () @@ -387,15 +432,15 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin and EMX) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux, Cygwin and Woe32. */ + Guaranteed to work only on Linux, Cygwin, Woe32 and EMX. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { @@ -486,6 +531,27 @@ } } } + +#ifdef __EMX__ + if (pathname && ISSLASH (pathname[0])) + { + const char *unixroot = getenv ("UNIXROOT"); + + if (unixroot && HAS_DEVICE (unixroot) && !unixroot[2]) + { + char *result = (char *) xmalloc (2 + strlen (pathname) + 1); +#ifdef NO_XMALLOC + if (result != NULL) +#endif + { + strcpy (result, unixroot); + strcpy (result + 2, pathname); + return result; + } + } + } +#endif + /* Nothing to relocate. */ return pathname; } diff -uNr gettext-tools/gnulib-lib/spawn.in.h.org gettext-tools/gnulib-lib/spawn.in.h --- gettext-tools/gnulib-lib/spawn.in.h.org 2010-05-24 18:42:46.000000000 +0900 +++ gettext-tools/gnulib-lib/spawn.in.h 2011-03-26 22:58:44.000000000 +0900 @@ -32,7 +32,10 @@ /* Get definitions of 'struct sched_param' and 'sigset_t'. But avoid namespace pollution on glibc systems. */ #ifndef __GLIBC__ -# include +/* OS/2 kLIBC defines 'struct sched_param' in spawn.h */ +# ifndef __INNOTEK_LIBC__ +# include +# endif # include #endif diff -uNr gettext-tools/gnulib-lib/stdint.in.h.org gettext-tools/gnulib-lib/stdint.in.h --- gettext-tools/gnulib-lib/stdint.in.h.org 2010-05-24 18:42:46.000000000 +0900 +++ gettext-tools/gnulib-lib/stdint.in.h 2011-03-26 22:48:44.000000000 +0900 @@ -243,8 +243,15 @@ #undef intptr_t #undef uintptr_t +#ifndef __INNOTEK_LIBC__ typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; +#else +/* intptr_t and uintptr_t are defined as int and unsigned int on OS/2 kLIBC, + respectively */ +typedef int gl_intptr_t; +typedef unsigned int gl_uintptr_t; +#endif #define intptr_t gl_intptr_t #define uintptr_t gl_uintptr_t diff -uNr gettext-tools/gnulib-lib/wcwidth.c.org gettext-tools/gnulib-lib/wcwidth.c --- gettext-tools/gnulib-lib/wcwidth.c.org 2010-05-24 18:42:48.000000000 +0900 +++ gettext-tools/gnulib-lib/wcwidth.c 2011-03-26 23:05:14.000000000 +0900 @@ -26,6 +26,15 @@ #include "streq.h" #include "uniwidth.h" +#ifdef __INNOTEK_LIBC__ +/* To avoid 'conflicting types' error for `__wcwidth' on OS/2 kLIBC. + wchar_t(unsigned short) is defined differently from wint_t(int) on + OS/2 kLIBC. */ +#undef wcwidth +/* Ignore wcwidth() of OS/2 kLIBC */ +#undef HAVE_WCWIDTH +#endif + int wcwidth (wchar_t wc) #undef wcwidth diff -uNr gettext-tools/libgettextpo/localcharset.c.org gettext-tools/libgettextpo/localcharset.c --- gettext-tools/libgettextpo/localcharset.c.org 2010-05-09 10:38:02.000000000 +0900 +++ gettext-tools/libgettextpo/localcharset.c 2011-03-27 18:15:28.000000000 +0900 @@ -475,6 +475,7 @@ ULONG cp[3]; ULONG cplen; + codeset = NULL; /* Allow user to override the codeset, as set in the operating system, with standard language environment variables. */ locale = getenv ("LC_ALL"); @@ -504,12 +505,13 @@ buf [modifier - dot] = '\0'; return buf; } - } - /* Resolve through the charset.alias file. */ - codeset = locale; + /* Resolve through the charset.alias file. */ + codeset = locale; + } } - else + + if (codeset == NULL) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) diff -uNr gettext-tools/libgettextpo/relocatable.c.org gettext-tools/libgettextpo/relocatable.c --- gettext-tools/libgettextpo/relocatable.c.org 2010-02-17 06:33:14.000000000 +0900 +++ gettext-tools/libgettextpo/relocatable.c 2011-03-27 12:03:28.000000000 +0900 @@ -48,6 +48,14 @@ # include #endif +#ifdef __EMX__ +# define INCL_DOS +# include + +#define strcmp stricmp +#define strncmp strnicmp +#endif + #if DEPENDS_ON_LIBCHARSET # include #endif @@ -336,7 +344,44 @@ return TRUE; } -#else /* Unix except Cygwin */ +#elif defined __EMX__ + +extern int _CRT_init (void); +extern void _CRT_term (void); +extern void __ctordtorInit (void); +extern void __ctordtorTerm (void); + +unsigned long _System +_DLL_InitTerm (unsigned long hModule, unsigned long ulFlag) +{ + static char location[CCHMAXPATH]; + + switch (ulFlag) + { + case 0: + if (_CRT_init () == -1) + return 0; + + __ctordtorInit(); + + if (DosQueryModuleName (hModule, sizeof (location), location)) + return 0; + + _fnslashify (location); + shared_library_fullname = strdup (location); + break; + + case 1: + __ctordtorTerm(); + + _CRT_term (); + break; + } + + return 1; +} + +#else /* Unix except Cygwin and EMX */ static void find_shared_library_fullname () @@ -387,15 +432,15 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin and EMX) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux, Cygwin and Woe32. */ + Guaranteed to work only on Linux, Cygwin, Woe32 and EMX. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { @@ -486,6 +531,27 @@ } } } + +#ifdef __EMX__ + if (pathname && ISSLASH (pathname[0])) + { + const char *unixroot = getenv ("UNIXROOT"); + + if (unixroot && HAS_DEVICE (unixroot) && !unixroot[2]) + { + char *result = (char *) xmalloc (2 + strlen (pathname) + 1); +#ifdef NO_XMALLOC + if (result != NULL) +#endif + { + strcpy (result, unixroot); + strcpy (result + 2, pathname); + return result; + } + } + } +#endif + /* Nothing to relocate. */ return pathname; } diff -uNr gettext-tools/libgettextpo/stdint.in.h.org gettext-tools/libgettextpo/stdint.in.h --- gettext-tools/libgettextpo/stdint.in.h.org 2010-04-25 18:22:40.000000000 +0900 +++ gettext-tools/libgettextpo/stdint.in.h 2011-03-27 11:27:14.000000000 +0900 @@ -243,8 +243,15 @@ #undef intptr_t #undef uintptr_t +#ifndef __INNOTEK_LIBC__ typedef long int gl_intptr_t; typedef unsigned long int gl_uintptr_t; +#else +/* intptr_t and uintptr_t are defined as int and unsigned int on OS/2 kLIBC, + respectively */ +typedef int gl_intptr_t; +typedef unsigned int gl_uintptr_t; +#endif #define intptr_t gl_intptr_t #define uintptr_t gl_uintptr_t diff -uNr gettext-tools/libgettextpo/wcwidth.c.org gettext-tools/libgettextpo/wcwidth.c --- gettext-tools/libgettextpo/wcwidth.c.org 2010-04-25 18:22:40.000000000 +0900 +++ gettext-tools/libgettextpo/wcwidth.c 2011-03-27 11:30:12.000000000 +0900 @@ -26,6 +26,15 @@ #include "streq.h" #include "uniwidth.h" +#ifdef __INNOTEK_LIBC__ +/* To avoid 'conflicting types' error for `__wcwidth' on OS/2 kLIBC. + wchar_t(unsigned short) is defined differently from wint_t(int) on + OS/2 kLIBC. */ +#undef wcwidth +/* Ignore wcwidth() of OS/2 kLIBC */ +#undef HAVE_WCWIDTH +#endif + int wcwidth (wchar_t wc) #undef wcwidth