Drop isprint.h use g_ascii_isprint() when this include hack was enabled.

svn path=/trunk/; revision=54327
This commit is contained in:
Jakub Zawadzki 2013-12-21 15:01:45 +00:00
parent be733f3041
commit 746ee39329
14 changed files with 23 additions and 82 deletions

View File

@ -65,7 +65,6 @@ SHARK_COMMON_INCLUDES = \
file.h \ file.h \
fileset.h \ fileset.h \
frame_tvbuff.h \ frame_tvbuff.h \
isprint.h \
register.h \ register.h \
version_info.h \ version_info.h \
ws_symbol_export.h ws_symbol_export.h

View File

@ -32,8 +32,6 @@
#include <glib.h> #include <glib.h>
#include "isprint.h"
#include <epan/packet.h> #include <epan/packet.h>
#include <epan/strutil.h> #include <epan/strutil.h>
@ -576,9 +574,9 @@ aim_get_message( guchar *msg, tvbuff_t *tvb, int msg_offset, int msg_length)
#ifdef STRIP_TAGS #ifdef STRIP_TAGS
if( j == '<' ) bracket = TRUE; if( j == '<' ) bracket = TRUE;
if( j == '>' ) bracket = FALSE; if( j == '>' ) bracket = FALSE;
if( (isprint(j) ) && (bracket == FALSE) && (j != '>')) if( (g_ascii_isprint(j) ) && (bracket == FALSE) && (j != '>'))
#else #else
if( isprint(j) ) if( g_ascii_isprint(j) )
#endif #endif
{ {
msg[i] = j; msg[i] = j;

View File

@ -94,7 +94,6 @@
#include <epan/expert.h> #include <epan/expert.h>
#include <epan/prefs.h> #include <epan/prefs.h>
#include <ctype.h> #include <ctype.h>
#include <isprint.h>
#include "packet-dcerpc.h" #include "packet-dcerpc.h"
#include "packet-dcom.h" #include "packet-dcom.h"
@ -1602,7 +1601,7 @@ dcom_tvb_get_nwstringz0(tvbuff_t *tvb, gint offset, guint32 inLength, gchar *psz
/* is this character printable? */ /* is this character printable? */
/* XXX - there are probably more printable chars than isprint() */ /* XXX - there are probably more printable chars than isprint() */
if(!isprint(u8Tmp1) || u8Tmp2 != 0) { if(!g_ascii_isprint(u8Tmp1) || u8Tmp2 != 0) {
*isPrintable = FALSE; *isPrintable = FALSE;
} }
} }

View File

@ -287,8 +287,6 @@
#include <glib.h> #include <glib.h>
#include <math.h> #include <math.h>
#include "isprint.h"
#include <epan/packet.h> #include <epan/packet.h>
#include <epan/exceptions.h> #include <epan/exceptions.h>
#include <epan/conversation.h> #include <epan/conversation.h>
@ -2082,7 +2080,7 @@ gchar *make_printable_string (const gchar *in, guint32 len) {
memcpy(print_string, in, len); /* and make a copy of input data */ memcpy(print_string, in, len); /* and make a copy of input data */
for (i=0; i < len; i++) { for (i=0; i < len; i++) {
if ( !isprint( (unsigned char)print_string[i] ) ) if ( !g_ascii_isprint( (unsigned char)print_string[i] ) )
print_string[i] = '.'; print_string[i] = '.';
} }

View File

@ -31,7 +31,6 @@
#include <epan/strutil.h> #include <epan/strutil.h>
#include "packet-ncp-int.h" #include "packet-ncp-int.h"
#include "packet-ncp-sss.h" #include "packet-ncp-sss.h"
#include "isprint.h"
void proto_register_sss(void); void proto_register_sss(void);
@ -456,7 +455,7 @@ sss_string(tvbuff_t* tvb, int hfinfo, proto_tree *sss_tree, int offset, gboolean
} }
for ( i = 0; i < str_length; i++ ) { for ( i = 0; i < str_length; i++ ) {
c_char = tvb_get_guint8(tvb, foffset); c_char = tvb_get_guint8(tvb, foffset);
if (isprint(c_char)) { if (g_ascii_isprint(c_char)) {
buffer[i] = c_char; buffer[i] = c_char;
} else { } else {
if (c_char) { if (c_char) {

View File

@ -149,8 +149,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "isprint.h"
#include <glib.h> #include <glib.h>
#include <epan/packet.h> #include <epan/packet.h>
@ -1250,7 +1248,7 @@ static char *data_to_string(void *data, guint col_type, guint col_size)
case SYBVARCHAR: case SYBVARCHAR:
/* strncpy(result, (char *)data, col_size); */ /* strncpy(result, (char *)data, col_size); */
for (i=0;i<col_size && i<(256-1);i++) for (i=0;i<col_size && i<(256-1);i++)
if (!isprint(((char *)data)[i])) result[i]='.'; if (!g_ascii_isprint(((char *)data)[i])) result[i]='.';
else result[i]=((char *)data)[i]; else result[i]=((char *)data)[i];
result[i] = '\0'; result[i] = '\0';
break; break;

View File

@ -27,7 +27,6 @@
#include "config.h" #include "config.h"
#include <ctype.h> #include <ctype.h>
#include "isprint.h"
#include <glib.h> #include <glib.h>
#include <epan/packet.h> #include <epan/packet.h>
@ -2563,7 +2562,7 @@ dissect_linux_usb_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
type = tvb_get_guint8(tvb, 8); type = tvb_get_guint8(tvb, 8);
proto_tree_add_uint_format_value(tree, hf_usb_urb_type, tvb, 8, 1, proto_tree_add_uint_format_value(tree, hf_usb_urb_type, tvb, 8, 1,
type, "%s ('%c')", val_to_str(type, usb_urb_type_vals, "Unknown %d"), type, "%s ('%c')", val_to_str(type, usb_urb_type_vals, "Unknown %d"),
isprint(type) ? type : '.'); g_ascii_isprint(type) ? type : '.');
proto_tree_add_item(tree, hf_usb_transfer_type, tvb, 9, 1, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_usb_transfer_type, tvb, 9, 1, ENC_BIG_ENDIAN);
transfer_type = tvb_get_guint8(tvb, 9); transfer_type = tvb_get_guint8(tvb, 9);
@ -2590,7 +2589,7 @@ dissect_linux_usb_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
proto_tree_add_string(tree, hf_usb_setup_flag, tvb, 14, 1, "relevant (0)"); proto_tree_add_string(tree, hf_usb_setup_flag, tvb, 14, 1, "relevant (0)");
} else { } else {
proto_tree_add_string_format_value(tree, hf_usb_setup_flag, tvb, proto_tree_add_string_format_value(tree, hf_usb_setup_flag, tvb,
14, 1, flag, "not relevant ('%c')", isprint(flag[0]) ? flag[0]: '.'); 14, 1, flag, "not relevant ('%c')", g_ascii_isprint(flag[0]) ? flag[0]: '.');
} }
flag[0] = tvb_get_guint8(tvb, 15); flag[0] = tvb_get_guint8(tvb, 15);
@ -2599,7 +2598,7 @@ dissect_linux_usb_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
proto_tree_add_string(tree, hf_usb_data_flag, tvb, 15, 1, "present (0)"); proto_tree_add_string(tree, hf_usb_data_flag, tvb, 15, 1, "present (0)");
} else { } else {
proto_tree_add_string_format_value(tree, hf_usb_data_flag, tvb, proto_tree_add_string_format_value(tree, hf_usb_data_flag, tvb,
15, 1, flag, "not present ('%c')", isprint(flag[0]) ? flag[0] : '.'); 15, 1, flag, "not present ('%c')", g_ascii_isprint(flag[0]) ? flag[0] : '.');
} }
tvb_memcpy(tvb, (guint8 *)&val64, 16, 8); tvb_memcpy(tvb, (guint8 *)&val64, 16, 8);

View File

@ -43,7 +43,6 @@
#include <epan/packet-range.h> #include <epan/packet-range.h>
#include "print.h" #include "print.h"
#include "isprint.h"
#include "ps.h" #include "ps.h"
#include "version_info.h" #include "version_info.h"
#include <wsutil/file_util.h> #include <wsutil/file_util.h>
@ -767,7 +766,7 @@ proto_tree_write_carrays(guint32 num, FILE *fh, epan_dissect_t *edt)
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
fprintf(fh, "0x%02x", *(cp + i)); fprintf(fh, "0x%02x", *(cp + i));
ascii[i % 8] = isprint(*(cp + i)) ? *(cp + i) : '.'; ascii[i % 8] = g_ascii_isprint(*(cp + i)) ? *(cp + i) : '.';
if (i == (length - 1)) { if (i == (length - 1)) {
guint rem; guint rem;

View File

@ -30,7 +30,6 @@
#include <glib.h> #include <glib.h>
#include "strutil.h" #include "strutil.h"
#include "emem.h" #include "emem.h"
#include <../isprint.h>
#ifdef _WIN32 #ifdef _WIN32
@ -185,7 +184,7 @@ format_text(const guchar *string, size_t len)
} }
c = *string++; c = *string++;
if (isprint(c)) { if (g_ascii_isprint(c)) {
fmtbuf[idx][column] = c; fmtbuf[idx][column] = c;
column++; column++;
} else { } else {
@ -291,7 +290,7 @@ format_text_wsp(const guchar *string, size_t len)
} }
c = *string++; c = *string++;
if (isprint(c)) { if (g_ascii_isprint(c)) {
fmtbuf[idx][column] = c; fmtbuf[idx][column] = c;
column++; column++;
} else if (isspace(c)) { } else if (isspace(c)) {
@ -400,7 +399,7 @@ format_text_chr(const guchar *string, const size_t len, const guchar chr)
} }
c = *string++; c = *string++;
if (isprint(c)) if (g_ascii_isprint(c))
{ {
fmtbuf[idx][column] = c; fmtbuf[idx][column] = c;
column++; column++;
@ -566,7 +565,7 @@ uri_str_to_bytes(const char *uri_str, GByteArray *bytes) {
p = (const guchar *)uri_str; p = (const guchar *)uri_str;
while (*p) { while (*p) {
if (! isascii(*p) || ! isprint(*p)) if (! isascii(*p) || ! g_ascii_isprint(*p))
return FALSE; return FALSE;
if (*p == '%') { if (*p == '%') {
p++; p++;
@ -637,7 +636,7 @@ format_uri(const GByteArray *bytes, const gchar *reserved_chars)
} }
c = bytes->data[column]; c = bytes->data[column];
if (!isascii(c) || !isprint(c) || c == '%') { if (!isascii(c) || !g_ascii_isprint(c) || c == '%') {
is_reserved = TRUE; is_reserved = TRUE;
} }
@ -976,7 +975,7 @@ escape_string_len(const char *string)
} }
/* Values that can't nicely be represented /* Values that can't nicely be represented
* in ASCII need to be escaped. */ * in ASCII need to be escaped. */
else if (!isprint((unsigned char)c)) { else if (!g_ascii_isprint(c)) {
/* c --> \xNN */ /* c --> \xNN */
repr_len += 4; repr_len += 4;
} }
@ -1007,7 +1006,7 @@ escape_string(char *buf, const char *string)
} }
/* Values that can't nicely be represented /* Values that can't nicely be represented
* in ASCII need to be escaped. */ * in ASCII need to be escaped. */
else if (!isprint((unsigned char)c)) { else if (!g_ascii_isprint(c)) {
/* c --> \xNN */ /* c --> \xNN */
g_snprintf(hexbuf,sizeof(hexbuf), "%02x", (unsigned char) c); g_snprintf(hexbuf,sizeof(hexbuf), "%02x", (unsigned char) c);
*bufp++ = '\\'; *bufp++ = '\\';

View File

@ -1,40 +0,0 @@
/* isprint.h
* Temporary redefinition of "isprint()" to cope with GTK+ 1.3 and
* later using UTF-8 strings
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __ISPRINT_H__
#define __ISPRINT_H__
/*
* 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 Wireshark 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

View File

@ -36,8 +36,6 @@
#include <string.h> #include <string.h>
#include "../isprint.h"
#include <epan/charsets.h> #include <epan/charsets.h>
#include <epan/packet.h> #include <epan/packet.h>
#include <epan/prefs.h> #include <epan/prefs.h>
@ -753,7 +751,7 @@ _bytes_view_line_common(BytesView *bv, void *data, const int org_off, int xx, in
EBCDIC_to_ASCII1(pd[off]) : EBCDIC_to_ASCII1(pd[off]) :
pd[off]; pd[off];
str[cur++] = isprint(c) ? c : '.'; str[cur++] = g_ascii_isprint(c) ? c : '.';
} else } else
str[cur++] = ' '; str[cur++] = ' ';

View File

@ -51,8 +51,6 @@
#include <epan/charsets.h> #include <epan/charsets.h>
#include <epan/prefs.h> #include <epan/prefs.h>
#include "../isprint.h"
#include "ui/alert_box.h" #include "ui/alert_box.h"
#include "ui/last_open_dir.h" #include "ui/last_open_dir.h"
#include "ui/progress_dlg.h" #include "ui/progress_dlg.h"

View File

@ -39,7 +39,6 @@
#include <epan/prefs.h> #include <epan/prefs.h>
#include <epan/charsets.h> #include <epan/charsets.h>
#include <../isprint.h>
#include <epan/print.h> #include <epan/print.h>
#include <ui/alert_box.h> #include <ui/alert_box.h>
@ -109,8 +108,8 @@ follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_from_server,
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
GtkTextIter iter; GtkTextIter iter;
/* While our isprint() hack is in place, we /*
* have to convert some chars to '.' in order * have to convert non printable ASCII chars to '.' in order
* to be able to see the data we *should* see * to be able to see the data we *should* see
* in the GtkText widget. * in the GtkText widget.
*/ */
@ -119,7 +118,7 @@ follow_add_to_gtk_text(char *buffer, size_t nchars, gboolean is_from_server,
for (i = 0; i < nchars; i++) { for (i = 0; i < nchars; i++) {
if (buffer[i] == '\n' || buffer[i] == '\r') if (buffer[i] == '\n' || buffer[i] == '\r')
continue; continue;
if (! isprint((guchar)buffer[i])) { if (! g_ascii_isprint(buffer[i])) {
buffer[i] = '.'; buffer[i] = '.';
} }
} }

View File

@ -52,8 +52,6 @@
#include <epan/prefs.h> #include <epan/prefs.h>
#include <wsutil/filesystem.h> #include <wsutil/filesystem.h>
#include "../isprint.h"
#include "ui/alert_box.h" #include "ui/alert_box.h"
#include "ui/last_open_dir.h" #include "ui/last_open_dir.h"
#include "ui/progress_dlg.h" #include "ui/progress_dlg.h"
@ -582,7 +580,7 @@ copy_hex_all_info(GString* copy_buffer, const guint8* data_p, int data_len, gboo
g_string_append_printf(hex_str," %02x",*data_p); g_string_append_printf(hex_str," %02x",*data_p);
if(append_text) { if(append_text) {
g_string_append_printf(char_str,"%c",isprint(*data_p) ? *data_p : '.'); g_string_append_printf(char_str,"%c",g_ascii_isprint(*data_p) ? *data_p : '.');
} }
++data_p; ++data_p;
@ -628,7 +626,7 @@ copy_hex_bytes_text_only(GString* copy_buffer, const guint8* data_p, int data_le
gchar to_append; gchar to_append;
/* Copy printable characters, newlines, and (horizontal) tabs. */ /* Copy printable characters, newlines, and (horizontal) tabs. */
if(isprint(*data_p)) { if(g_ascii_isprint(*data_p)) {
to_append = *data_p; to_append = *data_p;
} else if(*data_p==0x0a) { } else if(*data_p==0x0a) {
to_append = '\n'; to_append = '\n';