From 2bffa31fcc136244665f3230ddad6827eba35ad3 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Wed, 19 Feb 2003 19:23:55 +0000 Subject: [PATCH] * ttyio.c (tty_print_utf8_string, tty_print_utf8_string2): Use 0 to indicate a string with no maximum size. This prevents early truncation of strings that contain control chars which are expanded into \xXX form. --- util/ChangeLog | 7 +++++++ util/ttyio.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/util/ChangeLog b/util/ChangeLog index 792236acd..39140d846 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,10 @@ +2003-02-19 David Shaw + + * ttyio.c (tty_print_utf8_string, tty_print_utf8_string2): Use 0 + to indicate a string with no maximum size. This prevents early + truncation of strings that contain control chars which are + expanded into \xXX form. + 2002-12-26 David Shaw * iobuf.c (iobuf_flush): Only print debug info if debugging is on. diff --git a/util/ttyio.c b/util/ttyio.c index 2869187e8..86062ae2a 100644 --- a/util/ttyio.c +++ b/util/ttyio.c @@ -276,7 +276,7 @@ tty_print_utf8_string2( byte *p, size_t n, size_t max_n ) } if( i < n ) { buf = utf8_to_native( p, n, 0 ); - if( strlen( buf ) > max_n ) { + if( max_n && (strlen( buf ) > max_n )) { buf[max_n] = 0; } /*(utf8 conversion already does the control character quoting)*/ @@ -284,7 +284,7 @@ tty_print_utf8_string2( byte *p, size_t n, size_t max_n ) m_free( buf ); } else { - if( n > max_n ) { + if( max_n && (n > max_n) ) { n = max_n; } tty_print_string( p, n ); @@ -294,7 +294,7 @@ tty_print_utf8_string2( byte *p, size_t n, size_t max_n ) void tty_print_utf8_string( byte *p, size_t n ) { - tty_print_utf8_string2( p, n, n ); + tty_print_utf8_string2( p, n, 0 ); }