Check for broken glibc 2.0 mb functions, and avoid them.
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0 mb functions, and avoid them.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
Wed Dec 16 22:50:52 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk.c gdk/gdkim.c: Check for broken glibc 2.0
|
||||||
|
mb functions, and avoid them.
|
||||||
|
|
||||||
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
Wed Dec 16 16:57:55 1998 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkevents.c (gdk_events_queue): Don't
|
* gdk/gdkevents.c (gdk_events_queue): Don't
|
||||||
|
34
gdk/gdk.c
34
gdk/gdk.c
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <X11/Xlocale.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -448,39 +447,6 @@ gdk_exit (int errorcode)
|
|||||||
exit (errorcode);
|
exit (errorcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*--------------------------------------------------------------
|
|
||||||
* gdk_set_locale
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
*
|
|
||||||
* Results:
|
|
||||||
*
|
|
||||||
* Side effects:
|
|
||||||
*
|
|
||||||
*--------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
gchar*
|
|
||||||
gdk_set_locale (void)
|
|
||||||
{
|
|
||||||
if (!setlocale (LC_ALL,""))
|
|
||||||
g_message ("locale not supported by C library");
|
|
||||||
|
|
||||||
if (!XSupportsLocale ())
|
|
||||||
{
|
|
||||||
g_message ("locale not supported by Xlib, locale set to C");
|
|
||||||
setlocale (LC_ALL, "C");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!XSetLocaleModifiers (""))
|
|
||||||
{
|
|
||||||
g_message ("can not set locale modifiers");
|
|
||||||
}
|
|
||||||
|
|
||||||
return setlocale (LC_ALL,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_set_use_xshm (gint use_xshm)
|
gdk_set_use_xshm (gint use_xshm)
|
||||||
{
|
{
|
||||||
|
101
gdk/gdkim.c
101
gdk/gdkim.c
@ -17,6 +17,7 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <X11/Xlocale.h>
|
||||||
#include "gdk.h"
|
#include "gdk.h"
|
||||||
#include "gdkprivate.h"
|
#include "gdkprivate.h"
|
||||||
#include "gdki18n.h"
|
#include "gdki18n.h"
|
||||||
@ -39,6 +40,12 @@ typedef struct {
|
|||||||
gpointer value;
|
gpointer value;
|
||||||
} GdkImArg;
|
} GdkImArg;
|
||||||
|
|
||||||
|
/* If this variable is FALSE, it indicates that we should
|
||||||
|
* avoid trying to use multibyte conversion functions and
|
||||||
|
* assume everything is 1-byte per character
|
||||||
|
*/
|
||||||
|
gboolean gdk_use_mb;
|
||||||
|
|
||||||
#ifdef USE_XIM
|
#ifdef USE_XIM
|
||||||
|
|
||||||
static void gdk_im_instantiate_cb (Display *display,
|
static void gdk_im_instantiate_cb (Display *display,
|
||||||
@ -61,6 +68,69 @@ static GList* xim_ic_list;
|
|||||||
|
|
||||||
#endif /* USE_XIM */
|
#endif /* USE_XIM */
|
||||||
|
|
||||||
|
/*
|
||||||
|
*--------------------------------------------------------------
|
||||||
|
* gdk_set_locale
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
*
|
||||||
|
* Results:
|
||||||
|
*
|
||||||
|
* Side effects:
|
||||||
|
*
|
||||||
|
*--------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
gdk_set_locale (void)
|
||||||
|
{
|
||||||
|
wchar_t result;
|
||||||
|
gchar *current_locale;
|
||||||
|
|
||||||
|
gdk_use_mb = FALSE;
|
||||||
|
|
||||||
|
if (!setlocale (LC_ALL,""))
|
||||||
|
g_message ("locale not supported by C library");
|
||||||
|
|
||||||
|
if (!XSupportsLocale ())
|
||||||
|
{
|
||||||
|
g_message ("locale not supported by Xlib, locale set to C");
|
||||||
|
setlocale (LC_ALL, "C");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!XSetLocaleModifiers (""))
|
||||||
|
g_message ("can not set locale modifiers");
|
||||||
|
|
||||||
|
current_locale = setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
|
||||||
|
{
|
||||||
|
gdk_use_mb = TRUE;
|
||||||
|
|
||||||
|
#ifndef X_LOCALE
|
||||||
|
/* Detect GNU libc, where mb == UTF8. Not useful unless it's
|
||||||
|
* really a UTF8 locale. The below still probably will
|
||||||
|
* screw up on Greek, Cyrillic, etc, encoded as UTF8.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((MB_CUR_MAX == 2) &&
|
||||||
|
(mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
|
||||||
|
result == 0x765)
|
||||||
|
{
|
||||||
|
if ((strlen (current_locale) < 4) ||
|
||||||
|
g_strcasecmp (current_locale + strlen(current_locale) - 4, "utf8"))
|
||||||
|
gdk_use_mb = FALSE;
|
||||||
|
}
|
||||||
|
#endif /* X_LOCALE */
|
||||||
|
}
|
||||||
|
|
||||||
|
GDK_NOTE (XIM,
|
||||||
|
g_message ("%s multi-byte string functions.",
|
||||||
|
gdk_use_mb ? "Using" : "Not using"));
|
||||||
|
|
||||||
|
return setlocale (LC_ALL,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
* gdk_im_begin
|
* gdk_im_begin
|
||||||
@ -1374,7 +1444,11 @@ gchar *
|
|||||||
gdk_wcstombs (const GdkWChar *src)
|
gdk_wcstombs (const GdkWChar *src)
|
||||||
{
|
{
|
||||||
gchar *mbstr;
|
gchar *mbstr;
|
||||||
|
|
||||||
|
if (gdk_use_mb)
|
||||||
|
{
|
||||||
XTextProperty tpr;
|
XTextProperty tpr;
|
||||||
|
|
||||||
if (sizeof(wchar_t) != sizeof(GdkWChar))
|
if (sizeof(wchar_t) != sizeof(GdkWChar))
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
@ -1405,6 +1479,21 @@ gdk_wcstombs (const GdkWChar *src)
|
|||||||
*/
|
*/
|
||||||
mbstr = g_strdup(tpr.value);
|
mbstr = g_strdup(tpr.value);
|
||||||
XFree (tpr.value);
|
XFree (tpr.value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gint length = 0;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
while (src[length++] != 0)
|
||||||
|
;
|
||||||
|
|
||||||
|
mbstr = g_new (gchar, length + 1);
|
||||||
|
|
||||||
|
for (i=0; i<length+1; i++)
|
||||||
|
mbstr[i] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
return mbstr;
|
return mbstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1418,6 +1507,8 @@ gdk_wcstombs (const GdkWChar *src)
|
|||||||
gint
|
gint
|
||||||
gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
|
gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
|
||||||
{
|
{
|
||||||
|
if (gdk_use_mb)
|
||||||
|
{
|
||||||
XTextProperty tpr;
|
XTextProperty tpr;
|
||||||
wchar_t **wstrs, *wstr_src;
|
wchar_t **wstrs, *wstr_src;
|
||||||
gint num_wstrs;
|
gint num_wstrs;
|
||||||
@ -1442,4 +1533,14 @@ gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
|
|||||||
dest[len_cpy] = wstr_src[len_cpy];
|
dest[len_cpy] = wstr_src[len_cpy];
|
||||||
XwcFreeStringList (wstrs);
|
XwcFreeStringList (wstrs);
|
||||||
return len_cpy;
|
return len_cpy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i=0; i<dest_max && src[i]; i++)
|
||||||
|
dest[i] = src[i];
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <X11/Xlocale.h>
|
||||||
#include "gdk.h"
|
#include "gdk.h"
|
||||||
#include "gdkprivate.h"
|
#include "gdkprivate.h"
|
||||||
#include "gdki18n.h"
|
#include "gdki18n.h"
|
||||||
@ -39,6 +40,12 @@ typedef struct {
|
|||||||
gpointer value;
|
gpointer value;
|
||||||
} GdkImArg;
|
} GdkImArg;
|
||||||
|
|
||||||
|
/* If this variable is FALSE, it indicates that we should
|
||||||
|
* avoid trying to use multibyte conversion functions and
|
||||||
|
* assume everything is 1-byte per character
|
||||||
|
*/
|
||||||
|
gboolean gdk_use_mb;
|
||||||
|
|
||||||
#ifdef USE_XIM
|
#ifdef USE_XIM
|
||||||
|
|
||||||
static void gdk_im_instantiate_cb (Display *display,
|
static void gdk_im_instantiate_cb (Display *display,
|
||||||
@ -61,6 +68,69 @@ static GList* xim_ic_list;
|
|||||||
|
|
||||||
#endif /* USE_XIM */
|
#endif /* USE_XIM */
|
||||||
|
|
||||||
|
/*
|
||||||
|
*--------------------------------------------------------------
|
||||||
|
* gdk_set_locale
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
*
|
||||||
|
* Results:
|
||||||
|
*
|
||||||
|
* Side effects:
|
||||||
|
*
|
||||||
|
*--------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
gchar*
|
||||||
|
gdk_set_locale (void)
|
||||||
|
{
|
||||||
|
wchar_t result;
|
||||||
|
gchar *current_locale;
|
||||||
|
|
||||||
|
gdk_use_mb = FALSE;
|
||||||
|
|
||||||
|
if (!setlocale (LC_ALL,""))
|
||||||
|
g_message ("locale not supported by C library");
|
||||||
|
|
||||||
|
if (!XSupportsLocale ())
|
||||||
|
{
|
||||||
|
g_message ("locale not supported by Xlib, locale set to C");
|
||||||
|
setlocale (LC_ALL, "C");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!XSetLocaleModifiers (""))
|
||||||
|
g_message ("can not set locale modifiers");
|
||||||
|
|
||||||
|
current_locale = setlocale (LC_ALL, "");
|
||||||
|
|
||||||
|
if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
|
||||||
|
{
|
||||||
|
gdk_use_mb = TRUE;
|
||||||
|
|
||||||
|
#ifndef X_LOCALE
|
||||||
|
/* Detect GNU libc, where mb == UTF8. Not useful unless it's
|
||||||
|
* really a UTF8 locale. The below still probably will
|
||||||
|
* screw up on Greek, Cyrillic, etc, encoded as UTF8.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((MB_CUR_MAX == 2) &&
|
||||||
|
(mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
|
||||||
|
result == 0x765)
|
||||||
|
{
|
||||||
|
if ((strlen (current_locale) < 4) ||
|
||||||
|
g_strcasecmp (current_locale + strlen(current_locale) - 4, "utf8"))
|
||||||
|
gdk_use_mb = FALSE;
|
||||||
|
}
|
||||||
|
#endif /* X_LOCALE */
|
||||||
|
}
|
||||||
|
|
||||||
|
GDK_NOTE (XIM,
|
||||||
|
g_message ("%s multi-byte string functions.",
|
||||||
|
gdk_use_mb ? "Using" : "Not using"));
|
||||||
|
|
||||||
|
return setlocale (LC_ALL,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
* gdk_im_begin
|
* gdk_im_begin
|
||||||
@ -1374,7 +1444,11 @@ gchar *
|
|||||||
gdk_wcstombs (const GdkWChar *src)
|
gdk_wcstombs (const GdkWChar *src)
|
||||||
{
|
{
|
||||||
gchar *mbstr;
|
gchar *mbstr;
|
||||||
|
|
||||||
|
if (gdk_use_mb)
|
||||||
|
{
|
||||||
XTextProperty tpr;
|
XTextProperty tpr;
|
||||||
|
|
||||||
if (sizeof(wchar_t) != sizeof(GdkWChar))
|
if (sizeof(wchar_t) != sizeof(GdkWChar))
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
@ -1405,6 +1479,21 @@ gdk_wcstombs (const GdkWChar *src)
|
|||||||
*/
|
*/
|
||||||
mbstr = g_strdup(tpr.value);
|
mbstr = g_strdup(tpr.value);
|
||||||
XFree (tpr.value);
|
XFree (tpr.value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gint length = 0;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
while (src[length++] != 0)
|
||||||
|
;
|
||||||
|
|
||||||
|
mbstr = g_new (gchar, length + 1);
|
||||||
|
|
||||||
|
for (i=0; i<length+1; i++)
|
||||||
|
mbstr[i] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
return mbstr;
|
return mbstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1418,6 +1507,8 @@ gdk_wcstombs (const GdkWChar *src)
|
|||||||
gint
|
gint
|
||||||
gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
|
gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
|
||||||
{
|
{
|
||||||
|
if (gdk_use_mb)
|
||||||
|
{
|
||||||
XTextProperty tpr;
|
XTextProperty tpr;
|
||||||
wchar_t **wstrs, *wstr_src;
|
wchar_t **wstrs, *wstr_src;
|
||||||
gint num_wstrs;
|
gint num_wstrs;
|
||||||
@ -1442,4 +1533,14 @@ gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
|
|||||||
dest[len_cpy] = wstr_src[len_cpy];
|
dest[len_cpy] = wstr_src[len_cpy];
|
||||||
XwcFreeStringList (wstrs);
|
XwcFreeStringList (wstrs);
|
||||||
return len_cpy;
|
return len_cpy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i=0; i<dest_max && src[i]; i++)
|
||||||
|
dest[i] = src[i];
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <X11/Xlocale.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -448,39 +447,6 @@ gdk_exit (int errorcode)
|
|||||||
exit (errorcode);
|
exit (errorcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*--------------------------------------------------------------
|
|
||||||
* gdk_set_locale
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
*
|
|
||||||
* Results:
|
|
||||||
*
|
|
||||||
* Side effects:
|
|
||||||
*
|
|
||||||
*--------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
gchar*
|
|
||||||
gdk_set_locale (void)
|
|
||||||
{
|
|
||||||
if (!setlocale (LC_ALL,""))
|
|
||||||
g_message ("locale not supported by C library");
|
|
||||||
|
|
||||||
if (!XSupportsLocale ())
|
|
||||||
{
|
|
||||||
g_message ("locale not supported by Xlib, locale set to C");
|
|
||||||
setlocale (LC_ALL, "C");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!XSetLocaleModifiers (""))
|
|
||||||
{
|
|
||||||
g_message ("can not set locale modifiers");
|
|
||||||
}
|
|
||||||
|
|
||||||
return setlocale (LC_ALL,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_set_use_xshm (gint use_xshm)
|
gdk_set_use_xshm (gint use_xshm)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user