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

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