Do the "isprint()" hack for GTK+ 2.x or 1.3[.x], whether on UNIX or

Windows - the problem is that GTK+ 1.3[.x] and later assume strings
handed to them are UTF-8 strings, not, for example, ISO 8859/x strings.

In packet-radius.c, re-define "isprint()" rather than #ifdeffing its use
(the old code was also incorrectly treating 0x7f as a printable).

svn path=/trunk/; revision=9435
This commit is contained in:
Guy Harris 2003-12-24 01:12:17 +00:00
parent 839ce07c9a
commit e6f433d884
2 changed files with 21 additions and 32 deletions

View File

@ -1,7 +1,7 @@
/* strutil.c
* String utility routines
*
* $Id: strutil.c,v 1.12 2003/08/27 15:23:02 gram Exp $
* $Id: strutil.c,v 1.13 2003/12/24 01:12:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -133,14 +133,14 @@ get_token_len(const guchar *linep, const guchar *lineend,
#define INITIAL_FMTBUF_SIZE 128
#ifdef _WIN32
#if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
/*
* XXX - "isprint()" can return "true" for non-ASCII characters, but
* those don't work with GTK+ on Windows, as GTK+ on Windows assumes
* UTF-8 strings. Until we fix up Ethereal to properly handle
* non-ASCII characters in all output (both GUI displays and text
* printouts) on all platforms including Windows, we work around
* the problem by escaping all characters that aren't printable ASCII.
* those don't work with GTK+ 1.3 or later, as they take UTF-8 strings
* as input. Until we fix up Ethereal to properly handle non-ASCII
* characters in all output (both GUI displays and text printouts)
* in those versions of GTK+, we work around the problem by escaping
* all characters that aren't printable ASCII.
*/
#undef isprint
#define isprint(c) (c >= 0x20 && c < 0x7f)

View File

@ -6,7 +6,7 @@
*
* RFC 2865, RFC 2866, RFC 2867, RFC 2868, RFC 2869
*
* $Id: packet-radius.c,v 1.87 2003/12/17 07:05:22 guy Exp $
* $Id: packet-radius.c,v 1.88 2003/12/24 01:12:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -2255,6 +2255,19 @@ rdconvertbufftostr(gchar *dest, tvbuff_t *tvb, int offset, int length)
dest[totlen+1]=0;
}
#if GTK_MAJOR_VERSION >= 2 || GTK_MINOR_VERSION >= 3
/*
* XXX - "isprint()" can return "true" for non-ASCII characters, but
* those don't work with GTK+ 1.3 or later, as they take UTF-8 strings
* as input. Until we fix up Ethereal to properly handle non-ASCII
* characters in all output (both GUI displays and text printouts)
* in those versions of GTK+, we work around the problem by escaping
* all characters that aren't printable ASCII.
*/
#undef isprint
#define isprint(c) (c >= 0x20 && c < 0x7f)
#endif
static void
rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length)
{
@ -2282,19 +2295,7 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length)
pd = tvb_get_ptr(tvb,offset,length);
for( i = 0 ; i < 16 && i < (guint32)length ; i++ ) {
c = pd[i] ^ digest[i];
#ifdef _WIN32
/*
* XXX - "isprint()" can return "true" for non-ASCII characters, but
* those don't work with GTK+ on Windows, as GTK+ on Windows assumes
* UTF-8 strings. Until we fix up Ethereal to properly handle
* non-ASCII characters in all output (both GUI displays and text
* printouts) on all platforms including Windows, we work around
* the problem by escaping all characters that aren't printable ASCII.
*/
if ( c >= 0x20 && c <= 0x7f) {
#else
if ( isprint(c)) {
#endif
dest[totlen] = c;
totlen++;
} else {
@ -2303,19 +2304,7 @@ rddecryptpass(gchar *dest,tvbuff_t *tvb,int offset,int length)
}
}
while(i<(guint32)length) {
#ifdef _WIN32
/*
* XXX - "isprint()" can return "true" for non-ASCII characters, but
* those don't work with GTK+ on Windows, as GTK+ on Windows assumes
* UTF-8 strings. Until we fix up Ethereal to properly handle
* non-ASCII characters in all output (both GUI displays and text
* printouts) on all platforms including Windows, we work around
* the problem by escaping all characters that aren't printable ASCII.
*/
if ( pd[i] >= 0x20 && pd[i] <= 0x7f) {
#else
if ( isprint(pd[i]) ) {
#endif
dest[totlen] = (gchar)pd[i];
totlen++;
} else {