]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
braille: Fix spurious spacing after last Form-Feed. 45/head
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 15 May 2018 11:57:47 +0000 (13:57 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Tue, 15 May 2018 11:59:33 +0000 (13:59 +0200)
NEWS
filter/braille/drivers/index/textbrftoindexv3.in
filter/braille/filters/brftopagedbrf.in
filter/braille/filters/cups-braille.sh.in

diff --git a/NEWS b/NEWS
index 19caf601299ac3a4833764554b303a6645a53da3..e6bfb7ef0e73f1e8cfe0ab58d81d825fb6bf0e30 100644 (file)
--- 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
 
index fa4be3b72d05af5253163ef7ed2095378dc8deeb..2e9e431cb861c1dbcc237ef9ff13ef8d34f3417b 100755 (executable)
@@ -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 ]
index 322b56dfef39c46106afc8a3716d5150c8f73968..d9873a182463e8fa76188745713120b0ccd0c3cf 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #
-# Copyright (c) 2015-2017 Samuel Thibault <samuel.thibault@ens-lyon.org>
+# Copyright (c) 2015-2018 Samuel Thibault <samuel.thibault@ens-lyon.org>
 # 
 # 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
 )
 
index 80c791a673c180c1748071fa04bbc40319bf71ec..47fda21a8995390101bf6b15336c0d1c03a59c32 100644 (file)
@@ -280,8 +280,10 @@ addmargins() {
   fi
 
   echo -n "$NEWPAGE"
-  exec sed -e "s/^\(\f\?\)/\1$LEFTSPACES/" \
-           -e "s/\f/\f$NEWPAGESED/"
+  sed -e '$s/\f$//' \
+      -e "s/^\(\f\?\)\([^\r]\)/\1$LEFTSPACES\2/" \
+      -e "s/\f/\f$NEWPAGESED/"
+  echo -n "\f"
 }
 
 #