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,43 +309,28 @@ tty_fprintf (estream_t fp, const char *fmt, ... )
} }
/**************** /* Print a string, but filter all control characters out. If FP is
* Print a string, but filter all control characters out. If FP is * not NULL print to that stream instead to the tty. */
* not NULL print to that stream instead to the tty. static void
*/ do_print_string (estream_t fp, const byte *p, size_t n )
void
tty_print_string (estream_t fp, const byte *p, size_t n )
{ {
if (no_terminal && !fp) if (no_terminal && !fp)
return; return;
if( !initialized & !fp) if (!initialized && !fp)
init_ttyfp(); init_ttyfp();
#ifdef USE_W32_CONSOLE
/* not so effective, change it if you want */
if (fp) if (fp)
{ {
for( ; n; n--, p++ ) print_utf8_buffer (fp, p, n);
{ return;
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); #ifdef USE_W32_CONSOLE
} /* Not so effective, change it if you want */
} for (; n; n--, p++)
else
{ {
for( ; n; n--, p++ ) if (iscntrl (*p))
{
if( iscntrl( *p ) )
{ {
if( *p == '\n' ) if( *p == '\n' )
tty_printf ("\\n"); tty_printf ("\\n");
@ -357,28 +342,7 @@ tty_print_string (estream_t fp, const byte *p, size_t n )
else else
tty_printf ("%c", *p); tty_printf ("%c", *p);
} }
}
#else #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++) for (; n; n--, p++)
{ {
if (iscntrl (*p)) if (iscntrl (*p))
@ -394,10 +358,10 @@ tty_print_string (estream_t fp, const byte *p, size_t n )
else else
putc (*p, ttyfp); putc (*p, ttyfp);
} }
}
#endif #endif
} }
void void
tty_print_utf8_string2 (estream_t fp, const byte *p, size_t n, size_t max_n) 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) ) { if( max_n && (n > 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, ... ); void tty_fprintf (estream_t fp, const char *fmt, ... );
char *tty_getf (const char *promptfmt, ... ); char *tty_getf (const char *promptfmt, ... );
#endif #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_string (const unsigned char *p, size_t n);
void tty_print_utf8_string2 (estream_t fp, void tty_print_utf8_string2 (estream_t fp,
const unsigned char *p, size_t n, size_t max_n); const unsigned char *p, size_t n, size_t max_n);