File: messages.pl

package info (click to toggle)
pdftk-java 3.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,992 kB
  • sloc: java: 48,283; xml: 202; sh: 55; perl: 19; makefile: 10
file content (21 lines) | stat: -rwxr-xr-x 588 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl
use strict;
use warnings;

open(MANPAGE, "-|", "groff -mman -Tascii -rHY=14 pdftk.1");
open(DEVNULL, ">", "/dev/null");
open(SYNOPSIS, ">", "java/com/gitlab/pdftk_java/resources/synopsis.txt");
open(DESCRIPTION, ">", "java/com/gitlab/pdftk_java/resources/description.txt");
my $fh = *DEVNULL;
my $newlines = 0;
while(<MANPAGE>) {
  s/(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]//g;
  if (m/SYNOPSIS/) { $fh = *SYNOPSIS; }
  if (m/DESCRIPTION/) { $fh = *DESCRIPTION; }
  if (m/^$/) {
    if ((++$newlines) > 1) { $fh = *DEVNULL; }
  } else {
    $newlines=0;
  }
  print $fh $_;
}