summaryrefslogtreecommitdiff
path: root/regress/usr.bin/m4/reconstitute
blob: 98554bc38868a4218bb48687a9f41d139af7d377 (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
#! /usr/bin/perl
# $OpenBSD: reconstitute,v 1.1 2005/09/06 15:33:21 espie Exp $

# Written by Marc Espie, 2005
# Public domain

# This simple perl script puts back line numbers everywhere.
# This is suitable for testing synchronization, as we don't really
# care how many synchronization marks we emit, as long as the line
# numbers match

use File::Basename;

my ($lineno, $file) = (-1, "<unknown>");

while (<>) {
	if (m/^#line\s+(\d+)\s+\"(.*)\"/) {
		($lineno, $file) = ($1, $2);
		$file=basename($file);
	} else {
		print "$file:$lineno:$_";
		$lineno++;
	}
}