File: lineno.perl

package info (click to toggle)
cmix 2.0.12-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 6,924 kB
  • ctags: 6,063
  • sloc: cpp: 27,155; ansic: 11,923; sh: 3,000; exp: 2,270; yacc: 1,724; makefile: 1,251; lex: 488; perl: 278
file content (35 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download | duplicates (4)
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
# This is a -*- perl -*- script
#
# Authors:  Henning Makholm (makholm@diku.dk)
# Content:  C-Mix system: postprocessor for preprocessed output
#
# Copyright  1999. The TOPPS group at DIKU, U of Copenhagen.
# Redistribution and modification are allowed under certain
# terms; see the file COPYING.cmix for details.
#
#
# This script may be useful for post-processing the output
# of `cmix -E'. It prefixed every line in the input with a
# filename:line: specification identical to the one C-Mix
# uses in error messages. This makes it easy to search for
# the origin of an error message in the preprocessed code.

$filename = "stdin" ;
$line = 1 ;
while( <> ) {
  if ( m!^/\* C-MIX/II PREPROCESSED: (.*) \*/$! ) {
    print "========== $1 ==========\n" ;
    $filename = $1 ;
    $line = 1 ;
  } elsif ( /^\s*#\s*(line)?\s*([0-9]+)\s*"([^"]+)"/ ) {
    $filename = $3 ;
    $line = $2 ;
  } elsif ( /^\s*#\s*(line)?\s*([0-9]+)/ ) {
    $line = $2 ;
  } elsif ( /^\s*$/ ) {
    $line++ ;
  } else {
    print "$filename:$line: $_" ;
    $line++ ;
  }
}