1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-01-17 10:19:06 +01:00
parent adbfbf608e
commit bae42e5437
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 46 additions and 83 deletions

View File

@ -309,40 +309,25 @@ 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( !initialized & !fp)
if (!initialized && !fp)
init_ttyfp();
#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);
print_utf8_buffer (fp, p, n);
return;
}
else
tty_fprintf (fp, "%c", *p);
}
}
else
{
#ifdef USE_W32_CONSOLE
/* Not so effective, change it if you want */
for (; n; n--, p++)
{
if (iscntrl (*p))
@ -357,28 +342,7 @@ tty_print_string (estream_t fp, const byte *p, size_t n )
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))
@ -394,10 +358,10 @@ tty_print_string (estream_t fp, const byte *p, size_t n )
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 );
}
}

View File

@ -47,7 +47,6 @@ void tty_printf (const char *fmt, ... );
void tty_fprintf (estream_t fp, const char *fmt, ... );
char *tty_getf (const char *promptfmt, ... );
#endif
void tty_print_string (estream_t fp, const unsigned char *p, size_t n);
void tty_print_utf8_string (const unsigned char *p, size_t n);
void tty_print_utf8_string2 (estream_t fp,
const unsigned char *p, size_t n, size_t max_n);