Blame SOURCES/cups-filters-brftopagedbrf-install.patch

706f84
diff -up cups-filters-1.20.0/configure.ac.brftopagedbrf-install cups-filters-1.20.0/configure.ac
706f84
--- cups-filters-1.20.0/configure.ac.brftopagedbrf-install	2018-01-29 19:14:59.000000000 +0100
706f84
+++ cups-filters-1.20.0/configure.ac	2018-04-27 11:19:33.987213243 +0200
706f84
@@ -856,6 +856,7 @@ AC_CONFIG_FILES([
706f84
 	filter/braille/filters/cups-braille.sh
706f84
 	filter/braille/filters/imagetobrf
706f84
 	filter/braille/filters/texttobrf
706f84
+	filter/braille/filters/brftopagedbrf
706f84
 	filter/braille/filters/vectortopdf
706f84
 	filter/braille/filters/vectortobrf
706f84
 	filter/braille/filters/musicxmltobrf
706f84
diff -up cups-filters-1.20.0/filter/braille/filters/brftopagedbrf.in.brftopagedbrf-install cups-filters-1.20.0/filter/braille/filters/brftopagedbrf.in
706f84
--- cups-filters-1.20.0/filter/braille/filters/brftopagedbrf.in.brftopagedbrf-install	2018-04-27 11:19:41.038152279 +0200
706f84
+++ cups-filters-1.20.0/filter/braille/filters/brftopagedbrf.in	2018-04-27 11:21:47.344068714 +0200
706f84
@@ -0,0 +1,146 @@
706f84
+#!/bin/bash
706f84
+
706f84
+#
706f84
+# Copyright (c) 2015-2017 Samuel Thibault <samuel.thibault@ens-lyon.org>
706f84
+# 
706f84
+# Permission is hereby granted, free of charge, to any person obtaining a copy
706f84
+# of this software and associated documentation files (the "Software"), to deal
706f84
+# in the Software without restriction, including without limitation the rights
706f84
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
706f84
+# copies of the Software, and to permit persons to whom the Software is
706f84
+# furnished to do so, subject to the following conditions:
706f84
+# 
706f84
+# 
706f84
+# The above copyright notice and this permission notice shall be included in
706f84
+# all copies or substantial portions of the Software.
706f84
+# 
706f84
+# 
706f84
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
706f84
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
706f84
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
706f84
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
706f84
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
706f84
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
706f84
+# THE SOFTWARE.
706f84
+# 
706f84
+
706f84
+# Make sure we have enough options
706f84
+if [ $# != 5 -a $# != 6 ]; then
706f84
+  echo "ERROR: $0 jobid user name nb options [filename]" >&2
706f84
+  exit 1
706f84
+fi
706f84
+
706f84
+NB=$4
706f84
+OPTIONS=$5
706f84
+FILE=$6
706f84
+
706f84
+. @CUPS_DATADIR@/braille/cups-braille.sh
706f84
+
706f84
+shopt -s extglob
706f84
+
706f84
+# Construct list of pages from PAGERANGES
706f84
+
706f84
+PAGES=" "   # Explicit list of pages
706f84
+AFTER=      # All pages including and after this
706f84
+BEFORE=     # All pages before and including this
706f84
+
706f84
+[ -n "$PAGERANGES" ] || PAGERANGES="1-"
706f84
+
706f84
+while [ -n "${PAGERANGES}" ]
706f84
+do
706f84
+  PAGERANGE=${PAGERANGES/,*}
706f84
+  PAGERANGE=${PAGERANGE%%*( )}
706f84
+  PAGERANGE=${PAGERANGE##*( )}
706f84
+  if [ -n "${PAGERANGES/*,*}" ]
706f84
+  then
706f84
+    # last range
706f84
+    PAGERANGES=""
706f84
+  else
706f84
+    # Remove leading range
706f84
+    PAGERANGES="${PAGERANGES#*,}"
706f84
+  fi
706f84
+
706f84
+  if [ -n "${PAGERANGE/*-*}" ]
706f84
+  then
706f84
+    # single-page
706f84
+    PAGES="$PAGES$PAGERANGE "
706f84
+
706f84
+  elif [ -z "${PAGERANGE%%*-}" ]
706f84
+  then
706f84
+    # To the end
706f84
+    FIRST=${PAGERANGE%%-*}
706f84
+    if [ -z "$AFTER" ] || [ "$FIRST" -lt "$AFTER" ]
706f84
+    then
706f84
+      AFTER="$FIRST"
706f84
+    fi
706f84
+
706f84
+  elif [ -z "${PAGERANGE##-*}" ]
706f84
+  then
706f84
+    # From the beginning
706f84
+    LAST=${PAGERANGE##*-}
706f84
+    if [ -z "$BEFORE" ] || [ "$LAST" -gt "$BEFORE" ]
706f84
+    then
706f84
+      BEFORE="$LAST"
706f84
+    fi
706f84
+
706f84
+  else
706f84
+    # page range
706f84
+    FIRST=${PAGERANGE/-*}
706f84
+    LAST=${PAGERANGE/*-}
706f84
+    PAGES="$PAGES$(seq "$FIRST" "$LAST" | tr $'\012' ' ')"
706f84
+
706f84
+  fi
706f84
+done
706f84
+
706f84
+# Determine whether to print this page
706f84
+doprint() {
706f84
+  PAGE="$1"
706f84
+  if [ -n "$BEFORE" ] && [ "$PAGE" -le "$BEFORE" ]
706f84
+  then
706f84
+    echo 1
706f84
+    return
706f84
+  elif [ -n "$AFTER" ] && [ "$PAGE" -ge "$AFTER" ]
706f84
+  then
706f84
+    echo 1
706f84
+    return
706f84
+  fi
706f84
+  case "$PAGES" in
706f84
+    *\ $PAGE\ *)
706f84
+      echo 1
706f84
+      return
706f84
+      ;;
706f84
+  esac
706f84
+  echo 0
706f84
+}
706f84
+
706f84
+if [ -z "$FILE" ]
706f84
+then
706f84
+  cat
706f84
+else
706f84
+  cat "$FILE"
706f84
+fi | (
706f84
+  P=1
706f84
+  DOPRINT=$(doprint $P)
706f84
+  while IFS=$'\n' read -r LINE
706f84
+  do
706f84
+    while [ -z "${LINE/*$'\014'*}" ]
706f84
+    do
706f84
+      # Possibly print before FF
706f84
+      HEAD=${LINE%%$'\014'*}
706f84
+      [ $DOPRINT == 0 ] || printf %s "$HEAD"$'\014'
706f84
+
706f84
+      # Next page 
706f84
+      P=$(($P + 1))
706f84
+      DOPRINT=$(doprint $P)
706f84
+
706f84
+      # Drop head of line
706f84
+      LINE=${LINE#*$'\014'}
706f84
+    done
706f84
+
706f84
+    # Remainder of line
706f84
+    [ $DOPRINT == 0 ] || printf "%s\n" "$LINE"
706f84
+  done
706f84
+)
706f84
+
706f84
+echo "INFO: Ready" >&2
706f84
+exit 0
706f84
diff -up cups-filters-1.20.0/Makefile.am.brftopagedbrf-install cups-filters-1.20.0/Makefile.am
706f84
--- cups-filters-1.20.0/Makefile.am.brftopagedbrf-install	2017-12-15 02:15:32.000000000 +0100
706f84
+++ cups-filters-1.20.0/Makefile.am	2018-04-27 11:19:33.987213243 +0200
706f84
@@ -591,6 +591,7 @@ nodist_pkgfilter_SCRIPTS = \
706f84
 	filter/braille/filters/vectortopdf \
706f84
 	filter/braille/filters/vectortobrf \
706f84
 	filter/braille/filters/texttobrf \
706f84
+	filter/braille/filters/brftopagedbrf \
706f84
 	filter/braille/filters/musicxmltobrf
706f84
 endif
706f84