summaryrefslogtreecommitdiff
path: root/libc/debian/fix.x.pl
blob: fccfc6e3e81ad58145cafcc089ed5866f6224152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl


# *Rewrites* files:
#
# % some string \
# % other string
#
# ===>>
# % some string other string

use warnings;
use strict;

my $file = $ARGV[0];

open(FH, '<', $file) || die "open $file: $!";
my @lines = <FH>;
close(FH);

open(FH, '>', $file) || die "open $file: $!";
my $concat = 0;
foreach (@lines) {

    if ($concat) {
        s/^\s*%/ /;
    }

    if (s/\\+$//) {
        chomp;
        $concat = 1;
    } else {
        $concat = 0;
    }

    print FH;
}
close(FH);