From 75519e8656a715fee8770647fc3e19a1acf88355 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 15 May 2018 13:57:47 +0200 Subject: [PATCH] braille: Fix spurious spacing after last Form-Feed. --- NEWS | 2 ++ .../braille/drivers/index/textbrftoindexv3.in | 11 +++++++++-- filter/braille/filters/brftopagedbrf.in | 19 +++++++++++++++---- filter/braille/filters/cups-braille.sh.in | 6 ++++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 19caf6012..e6bfb7ef0 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,8 @@ CHANGES IN V1.20.4 - braille: Warn when no text translation was selected in case the user didn't notice. Thanks to Samuel Thibault for this patch (Pull request #37). + - braille: Fix spurious spacing after last Form-Feed (Pull + request #45). CHANGES IN V1.20.3 diff --git a/filter/braille/drivers/index/textbrftoindexv3.in b/filter/braille/drivers/index/textbrftoindexv3.in index fa4be3b72..2e9e431cb 100755 --- a/filter/braille/drivers/index/textbrftoindexv3.in +++ b/filter/braille/drivers/index/textbrftoindexv3.in @@ -57,7 +57,9 @@ then else cat "$FILE" fi | ( - while IFS=$'\n' read -r LINE + IFS=$'\n' read -r LINE + EOF=$? + while [ "$EOF" = 0 -o -n "$LINE" ] do # Strip CRs LINE=${LINE//$'\015'} @@ -113,7 +115,12 @@ then tr "\000-\037\177\200-\377" " " | \ tr " \!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[\\\\\\]^_" "\\0V tSQW"$'\004'"gvAT@DP"$'\024'"d"$'\002\006'"\"bB&fF\$a\`Cw4q"$'\020\001\003\021'"1!"$'\023'"3#"$'\022'"2"$'\005\007\025'"5%"$'\027'"7'"$'\026'"6EGrUueRcs0p" fi - printf "\\r\\n" + if [ "$EOF" = 0 ] + then + printf "\\r\\n" + fi + IFS=$'\n' read -r LINE + EOF=$? done ) if [ $? != 0 ] diff --git a/filter/braille/filters/brftopagedbrf.in b/filter/braille/filters/brftopagedbrf.in index 322b56dfe..d9873a182 100755 --- a/filter/braille/filters/brftopagedbrf.in +++ b/filter/braille/filters/brftopagedbrf.in @@ -1,7 +1,7 @@ #!/bin/bash # -# Copyright (c) 2015-2017 Samuel Thibault +# Copyright (c) 2015-2018 Samuel Thibault # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -121,9 +121,11 @@ else fi | ( P=1 DOPRINT=$(doprint $P) - while IFS=$'\n' read -r LINE + IFS=$'\n' read -r LINE + EOF=$? + while [ "$EOF" = 0 -o -n "$LINE" ] do - while [ -z "${LINE/*$'\014'*}" ] + while [ -n "$LINE" -a -z "${LINE/*$'\014'*}" ] do # Possibly print before FF HEAD=${LINE%%$'\014'*} @@ -138,7 +140,16 @@ fi | ( done # Remainder of line - [ $DOPRINT == 0 ] || printf "%s\n" "$LINE" + if [ "$EOF" = 0 ] + then + NL="\n" + else + NL="" + fi + [ $DOPRINT == 0 ] || printf "%s$NL" "$LINE" + + IFS=$'\n' read -r LINE + EOF=$? done ) diff --git a/filter/braille/filters/cups-braille.sh.in b/filter/braille/filters/cups-braille.sh.in index 80c791a67..47fda21a8 100644 --- a/filter/braille/filters/cups-braille.sh.in +++ b/filter/braille/filters/cups-braille.sh.in @@ -280,8 +280,10 @@ addmargins() { fi echo -n "$NEWPAGE" - exec sed -e "s/^\( \?\)/\1$LEFTSPACES/" \ - -e "s/ / $NEWPAGESED/" + sed -e '$s/ $//' \ + -e "s/^\( \?\)\([^ ]\)/\1$LEFTSPACES\2/" \ + -e "s/ / $NEWPAGESED/" + echo -n " " } # -- 2.47.2