1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Description: Fixing garbled output for no trailing newline in input
Printing newline in case of eof to emulate a trailing newline.
.
Due to how fgetws works (reading until meeting a newline,
returning NULL, if end of stream is reached),
if there would be a trailing newline, we never would see the eof,
so we wouldn't print double newlines.
.
This patch only fixes the case of a non-interactive input,
because in the interactive case, the input itself shifts the output,
if there is no new line -
example:
test⠤⡧⠄⡠⠤⡀⡠⠤⠄⠤⡧⠄
⠀⠣⠄⠫⠭⠁⠬⠭⠂⠀⠣⠄
Forwarded: yes (via IRC on Fri Jul 23 22:00:36 2021)
Last-Update: 2021-07-23
--- braillefont-1.0.orig/braillefont.c
+++ braillefont-1.0/braillefont.c
@@ -62,6 +62,9 @@ int main()
else
phalf(map_character(*b), 0);
}
+ if(feof(stdin)) {
+ printf("\n");
+ }
for (b=buf; *b; b++)
{
if (*b < 32)
@@ -69,6 +72,9 @@ int main()
else
phalf(map_character(*b), 4*L);
}
+ if(feof(stdin)) {
+ printf("\n");
+ }
}
return 0;
|