File: cg-untrace

package info (click to toggle)
cg3 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,684 kB
  • sloc: cpp: 26,476; xml: 6,139; perl: 1,398; lisp: 1,091; ansic: 178; sh: 47; python: 26; makefile: 14
file content (46 lines) | stat: -rwxr-xr-x 912 bytes parent folder | download
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
40
41
42
43
44
45
46
#!/usr/bin/perl
# -*- mode: cperl; indent-tabs-mode: nil; tab-width: 3; cperl-indent-level: 3; -*-
use warnings;
use strict;
use utf8;
BEGIN {
   $| = 1;
   binmode(STDIN, ':encoding(UTF-8)');
   binmode(STDOUT, ':encoding(UTF-8)');
}
use open qw( :encoding(UTF-8) :std );

use Getopt::Long;
Getopt::Long::Configure('no_ignore_case');
my %opts = ();
GetOptions(\%opts, ('help|?'));

sub print_help {
   print <<'XOUT';
Usage: cg-untrace

Pipe a CG stream through this to remove all deleted readings and tracing tags.

XOUT
}

if (defined $opts{'help'}) {
   print_help();
   exit(0);
}

while (<STDIN>) {
   # Discard deleted readings
   if (/^;/) {
      next;
   }
   # On readings only...
   if (/^\s+"/) {
      s/ (ID|R):/ x$1:/g;
      # ...strip trace tags
      while (s/ [-A-Z]+:[^"\s\n]+//g) {}
      while (s/ (ADD|REM|SET)RELATIONS?\(\S+\):[^"\s\n]+//g) {}
      s/ x(ID|R):/ $1:/g;
   }
   print;
}