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,95 +309,59 @@ 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();
if (fp)
{
print_utf8_buffer (fp, p, n);
return;
}
#ifdef USE_W32_CONSOLE #ifdef USE_W32_CONSOLE
/* not so effective, change it if you want */ /* Not so effective, change it if you want */
if (fp) for (; n; n--, p++)
{ {
for( ; n; n--, p++ ) if (iscntrl (*p))
{ {
if( iscntrl( *p ) ) if( *p == '\n' )
{ tty_printf ("\\n");
if( *p == '\n' ) else if( !*p )
tty_fprintf (fp, "\\n"); tty_printf ("\\0");
else if( !*p ) else
tty_fprintf (fp, "\\0"); tty_printf ("\\x%02x", *p);
else }
tty_fprintf (fp, "\\x%02x", *p); else
} tty_printf ("%c", *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);
}
}
#else #else
if (fp) for (; n; n--, p++)
{ {
for( ; n; n--, p++ ) if (iscntrl (*p))
{ {
if (iscntrl (*p)) putc ('\\', ttyfp);
{ if ( *p == '\n' )
es_putc ('\\', fp); putc ('n', ttyfp);
if ( *p == '\n' ) else if ( !*p )
es_putc ('n', fp); putc ('0', ttyfp);
else if ( !*p ) else
es_putc ('0', fp); fprintf (ttyfp, "x%02x", *p );
else }
es_fprintf (fp, "x%02x", *p); else
} putc (*p, ttyfp);
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);
}
}
#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);