From 2aa72b64a6963a81532926a8b5ad0033d22d05a8 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 30 Sep 2008 17:12:19 -0700 Subject: [PATCH] rdsrc.pl: handle tabs in the input It is just to painful to keep the source files tab-free. Handle tabs in the input as required. Signed-off-by: H. Peter Anvin --- doc/rdsrc.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl index c4069b1e..ab85af87 100644 --- a/doc/rdsrc.pl +++ b/doc/rdsrc.pl @@ -104,6 +104,7 @@ $pname = "para000000"; @pnames = @pflags = (); $para = undef; while (defined($_ = )) { + $_ = &untabify($_); &check_include($_); } &got_para($para); @@ -151,6 +152,26 @@ if ($out_format eq 'txt') { die "$0: unknown output format: $out_format\n"; } +sub untabify($) { + my($s) = @_; + my $o = ''; + my($c, $i, $p); + + $p = 0; + for ($i = 0; $i < length($s); $i++) { + $c = substr($s, $i, 1); + if ($c eq "\t") { + do { + $o .= ' '; + $p++; + } while ($p & 7); + } else { + $o .= $c; + $p++; + } + } + return $o; +} sub check_include { local $_ = shift; if (/\\& (\S+)/) { -- 2.11.4.GIT