[Pkg-gnupg-commit] [gnupg2] 79/116: common: Remove unused function tty_print_string.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Jan 24 04:40:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit bae42e543799a428e59bad870aed9719dd6e6e45
Author: Werner Koch <wk at gnupg.org>
Date: Tue Jan 17 10:19:06 2017 +0100
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 at gnupg.org>
---
common/ttyio.c | 128 +++++++++++++++++++++------------------------------------
common/ttyio.h | 1 -
2 files changed, 46 insertions(+), 83 deletions(-)
diff --git a/common/ttyio.c b/common/ttyio.c
index 5fb620d..29af1b3 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 );
}
}
diff --git a/common/ttyio.h b/common/ttyio.h
index 004aa85..5bff82f 100644
--- a/common/ttyio.h
+++ b/common/ttyio.h
@@ -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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list