sliceprint.in - enscript - GNU Enscript
(HTM) git clone git://thinkerwim.org/enscript.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
sliceprint.in (2036B)
---
1 #!@PERLPROG@
2 # -*- perl -*-
3 #
4 # Print documents with long lines.
5 # Copyright (c) 1996-1999 Markku Rossi
6 #
7 # Author: Markku Rossi <mtr@iki.fi>
8 #
9
10 #
11 # This file is part of GNU Enscript.
12 #
13 # Enscript is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # Enscript is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with Enscript. If not, see <http://www.gnu.org/licenses/>.
25 #
26
27 $enscript = "enscript";
28 $ENV{LC_ALL} = "C"; # we parse enscript's output
29
30 $program = $0;
31 $program =~ s/.*\///g;
32
33 sub usage {
34 warn "Usage: $program [-oFILE] [ENSCRIPT_OPTION]... [FILE]...\n";
35 }
36
37 # Handle arguments.
38 $args = "--extended-return-values";
39 $files = "";
40 while ($arg = shift(@ARGV)) {
41 if ($arg eq "--help") {
42 &usage;
43 exit 0;
44 } elsif ($arg eq "--version") {
45 warn "sliceprint 1.0\n";
46 exit 0;
47 } elsif ($arg =~ /^-p(.+)$/
48 || $arg =~ /^-o(.+)$/
49 || $arg =~ /^--output=(.+)$/) {
50 $output_file = $1;
51 } elsif ($arg eq "-p" || $arg eq "-o") {
52 $output_file = shift(@ARGV);
53 } elsif ($arg =~ /^-/) {
54 $args .= " $arg";
55 } else {
56 $files .= " $arg";
57 }
58 }
59
60 # Check if output file is "-".
61 if (defined($output_file) && $output_file eq "-") {
62 die "$program: output file can't be stdout\n";
63 }
64
65 $slice = 0;
66 while (1) {
67 $slice++;
68 if (defined($output_file)) {
69 $cmd = "$enscript " . $args . " --slice=$slice -p"
70 . $output_file . "." . $slice . " " . $files;
71 } else {
72 $cmd = "$enscript " . $args . " --slice=$slice" . $files;
73 }
74 print "printing slice $slice...\n";
75 $result = `$cmd 2>&1`;
76 print $result;
77 if ($result !~ ".*line.* were wrapped.*") {
78 last;
79 }
80 }