rpms/cups/devel cups.spec,1.339,1.340 textonly.filter,1.1,1.2
Tim Waugh (twaugh)
fedora-extras-commits at redhat.com
Thu Jul 5 15:42:02 UTC 2007
Author: twaugh
Update of /cvs/pkgs/rpms/cups/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv913
Modified Files:
cups.spec textonly.filter
Log Message:
* Thu Jul 5 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.11-5
- Support for page-ranges and accounting in the textonly filter (bug #244979).
Index: cups.spec
===================================================================
RCS file: /cvs/pkgs/rpms/cups/devel/cups.spec,v
retrieving revision 1.339
retrieving revision 1.340
diff -u -r1.339 -r1.340
--- cups.spec 4 Jul 2007 12:21:44 -0000 1.339
+++ cups.spec 5 Jul 2007 15:41:27 -0000 1.340
@@ -6,7 +6,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.2.11
-Release: 4%{?dist}
+Release: 5%{?dist}
License: GPL
Group: System Environment/Daemons
Source: ftp://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -445,6 +445,9 @@
%{cups_serverbin}/daemon/cups-lpd
%changelog
+* Thu Jul 5 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.11-5
+- Support for page-ranges and accounting in the textonly filter (bug #244979).
+
* Wed Jul 4 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.11-4
- Better paper-out detection patch still (bug #246222).
Index: textonly.filter
===================================================================
RCS file: /cvs/pkgs/rpms/cups/devel/textonly.filter,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- textonly.filter 31 Oct 2006 13:37:46 -0000 1.1
+++ textonly.filter 5 Jul 2007 15:41:27 -0000 1.2
@@ -1,6 +1,9 @@
#!/bin/bash
## Copyright (C) 2003-2006 Red Hat, Inc.
## Copyright (C) 2003-2006 Tim Waugh <twaugh at redhat.com>
+## Changed on 2007/05/17, Opher Shachar, LADPC Ltd.
+## Added support for page-ranges option.
+## Added page accounting.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -37,9 +40,77 @@
TMPFILE="$6"
fi
+PR=${5#*page-ranges=}
+# Do options specify page-ranges?
+if [[ "$PR" != "$5" ]]; then
+ PR=${PR%% *}
+else
+ #unset PR
+ PR=1-999999
+fi
+
+if [[ "$PR" ]]; then
+ TMPFILE2=$(mktemp ${TMPDIR:-/tmp}/textonly2.XXXXXX)
+ pagenum=0
+ EOF=
+ {
+ while [[ "$PR" ]]; do
+ pl=${PR%%,*} ;# take first subrange
+ PR=${PR#$pl};PR=${PR#,} ;# remove from range list
+ pu=${pl#*-} ;# extract upper and lower
+ pl=${pl%-*} ;# pages of subrange
+ # Allows interpreting 0-5,3-10 as 1-5,6-10 rejects 5-1 or 1-
+ (( pagenum >= pl )) && pl=$(( pagenum + 1 ))
+ (( pl > pu )) && continue
+
+ # Loop reading pages until at or over lower page of subrange.
+ while read -d `echo -ne '\f'` -r; do
+ (( pagenum++ ))
+ (( pagenum == pl )) && break
+ done
+ # Did we reach lower page of subrange or EOF?
+ if (( pagenum < pl )); then
+ [[ ! "$REPLY" ]] && break ;# empty last page - we're done.
+ (( pagenum++ ))
+ EOF=y
+ fi
+ # Output page and report to page log
+ if (( pagenum == pl )); then
+ echo -n "${REPLY}" >>"$TMPFILE2"
+ # If EOF then page has no final FF
+ [[ ! "$EOF" ]] && echo -ne '\f' >>"$TMPFILE2"
+ echo "PAGE: $pagenum $COPIES" >&2
+ fi
+ [[ "$EOF" ]] && break
+ # Is the current subrange a single page?
+ (( pagenum == pu )) && continue
+ while read -d `echo -ne '\f'` -r; do
+ (( pagenum++ ))
+ echo -ne "${REPLY}\f" >>"$TMPFILE2"
+ echo "PAGE: $pagenum $COPIES" >&2
+ (( pagenum == pu )) && break
+ done
+ # Could be that we reached EOF before page boundry
+ if (( pagenum < pu )); then
+ if [[ "$REPLY" ]]; then
+ (( pagenum++ ))
+ echo -n "${REPLY}" >>"$TMPFILE2"
+ echo "PAGE: $pagenum $COPIES" >&2
+ fi
+ break
+ fi
+ done
+ } <"$TMPFILE"
+else
+ TMPFILE2="$TMPFILE"
+ pc=$(grep -co `echo -ne '\f'` "$TMPFILE2")
+ pc=$(( pc * $COPIES ))
+ echo "PAGE: $pc" >&2
+fi
+
while [ "$COPIES" -gt 0 ]; do
# Just translate LF->CRLF at the moment, until the PPD has options added.
- sed -e 's/$/'`echo -ne '\r'`'/g' "$TMPFILE"
+ sed -e 's/$/'`echo -ne '\r'`'/g' "$TMPFILE2"
if [ "$SENDFF" == "True" ]
then
@@ -48,3 +119,6 @@
COPIES=$(($COPIES - 1))
done
+# Cleanup
+[[ "$TMPFILE" != "$TMPFILE2" ]] && rm -f "$TMPFILE2"
+exit 0
More information about the scm-commits
mailing list