From 4ae2c5ebdd30b024c42bca54f1acacb6288377a7 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Fri, 9 Jun 2017 00:42:57 +1000 Subject: [PATCH] Write correct length to terminal for unflash sequences Introduce a wrapper for fwrite() of a full string to the current_ftarget. --- Changelog | 2 ++ source/output.c | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index 655cd8f..67264ce 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2.2] +* Write correct length to terminal for unflash sequences. (caf) + * Update source file dependencies in Makefile.in. (caf) * Remove unused opendir.c. (caf) diff --git a/source/output.c b/source/output.c index a414bec..2c5b69e 100644 --- a/source/output.c +++ b/source/output.c @@ -44,6 +44,12 @@ extern LastMsg last_servermsg[]; char three_stars[4] = "***"; +/* Write a string to the current target */ +static size_t writestr(const char *s) +{ + return fwrite(s, strlen(s), 1, current_ftarget); +} + /* unflash: sends a ^[c to the screen */ /* Must be defined to be useful, cause some vt100s really *do* reset when sent this command. >;-) */ @@ -51,19 +57,19 @@ char three_stars[4] = "***"; /* functions which switch the character set on the console */ /* ibmpc is not available on the xterm */ -void charset_ibmpc (void) +void charset_ibmpc(void) { - fwrite("\033(U", 3, 1, current_ftarget); /* switch to IBM code page 437 */ + writestr("\033(U"); /* switch to IBM code page 437 */ } -void charset_lat1 (void) +void charset_lat1(void) { - fwrite("\033(B", 3, 1, current_ftarget); /* switch to Latin-1 (ISO 8859-1) */ + writestr("\033(B"); /* switch to Latin-1 (ISO 8859-1) */ } void charset_cst(void) { - fwrite("\033(K", 3, 1, current_ftarget); /* switch too user-defined */ + writestr("\033(K"); /* switch to user-defined */ } /* currently not used. */ @@ -75,9 +81,9 @@ void unflash (void) #if !defined(WINNT) && !defined(__EMX__) #if defined(HARD_UNFLASH) && !defined(CHARSET_CUSTOM) - fwrite("\033c", 5, 1, current_ftarget); /* hard reset */ + writestr("\033c"); /* hard reset */ #else - fwrite("\033)0", 6, 1, current_ftarget); /* soft reset */ + writestr("\033)0"); /* soft reset */ #endif #if defined(LATIN1)