diff options
author | Werner Koch <[email protected]> | 2017-01-17 09:19:06 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-01-17 09:19:06 +0000 |
commit | bae42e543799a428e59bad870aed9719dd6e6e45 (patch) | |
tree | 7c1ad041bb689139b5e7626d346de8b3cedbb910 /common/ttyio.c | |
parent | gpg: Prepare some key cleaning function for use with secret key packets. (diff) | |
download | gnupg-bae42e543799a428e59bad870aed9719dd6e6e45.tar.gz gnupg-bae42e543799a428e59bad870aed9719dd6e6e45.zip |
common: Remove unused function tty_print_string.
* common/ttyio.c (tty_print_string): Rename to ...
(do_print_string): this. Make local. Simplify FP case by using
print_utf8_buffer. Change caller.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/ttyio.c')
-rw-r--r-- | common/ttyio.c | 128 |
1 files changed, 46 insertions, 82 deletions
diff --git a/common/ttyio.c b/common/ttyio.c index 5fb620dfa..29af1b3ff 100644 --- a/common/ttyio.c +++ b/common/ttyio.c @@ -309,95 +309,59 @@ tty_fprintf (estream_t fp, const char *fmt, ... ) } -/**************** - * Print a string, but filter all control characters out. If FP is - * not NULL print to that stream instead to the tty. - */ -void -tty_print_string (estream_t fp, const byte *p, size_t n ) +/* Print a string, but filter all control characters out. If FP is + * not NULL print to that stream instead to the tty. */ +static void +do_print_string (estream_t fp, const byte *p, size_t n ) { - if (no_terminal && !fp) - return; + if (no_terminal && !fp) + return; - if( !initialized & !fp) - init_ttyfp(); + if (!initialized && !fp) + init_ttyfp(); + + if (fp) + { + print_utf8_buffer (fp, p, n); + return; + } #ifdef USE_W32_CONSOLE - /* not so effective, change it if you want */ - if (fp) - { - for( ; n; n--, p++ ) - { - if( iscntrl( *p ) ) - { - if( *p == '\n' ) - tty_fprintf (fp, "\\n"); - else if( !*p ) - tty_fprintf (fp, "\\0"); - else - tty_fprintf (fp, "\\x%02x", *p); - } - else - tty_fprintf (fp, "%c", *p); - } - } - else - { - for( ; n; n--, p++ ) - { - if( iscntrl( *p ) ) - { - if( *p == '\n' ) - tty_printf ("\\n"); - else if( !*p ) - tty_printf ("\\0"); - else - tty_printf ("\\x%02x", *p); - } - else - tty_printf ("%c", *p); - } - } + /* Not so effective, change it if you want */ + for (; n; n--, p++) + { + if (iscntrl (*p)) + { + if( *p == '\n' ) + tty_printf ("\\n"); + else if( !*p ) + tty_printf ("\\0"); + else + tty_printf ("\\x%02x", *p); + } + else + tty_printf ("%c", *p); + } #else - if (fp) - { - for( ; n; n--, p++ ) - { - if (iscntrl (*p)) - { - es_putc ('\\', fp); - if ( *p == '\n' ) - es_putc ('n', fp); - else if ( !*p ) - es_putc ('0', fp); - else - es_fprintf (fp, "x%02x", *p); - } - else - es_putc (*p, fp); - } - } - else - { - for (; n; n--, p++) - { - if (iscntrl (*p)) - { - putc ('\\', ttyfp); - if ( *p == '\n' ) - putc ('n', ttyfp); - else if ( !*p ) - putc ('0', ttyfp); - else - fprintf (ttyfp, "x%02x", *p ); - } - else - putc (*p, ttyfp); - } - } + for (; n; n--, p++) + { + if (iscntrl (*p)) + { + putc ('\\', ttyfp); + if ( *p == '\n' ) + putc ('n', ttyfp); + else if ( !*p ) + putc ('0', ttyfp); + else + fprintf (ttyfp, "x%02x", *p ); + } + else + putc (*p, ttyfp); + } #endif } + void tty_print_utf8_string2 (estream_t fp, const byte *p, size_t n, size_t max_n) { @@ -425,7 +389,7 @@ tty_print_utf8_string2 (estream_t fp, const byte *p, size_t n, size_t max_n) if( max_n && (n > max_n) ) { n = max_n; } - tty_print_string (fp, p, n ); + do_print_string (fp, p, n ); } } |