#!/usr/local/bin/perl # # David MacKay August 94 # # delatex1a.p - reads in stuff in one array to do ignores right. # assumes that all { } are matched within the ignore. # $* = 1 ; @a = <> ; # read in everything. @b = split ( /\\ign/ , join ( '' , @a ) ) ; print STDERR ">>> processing $#b ignores <<<\n" ; foreach $e (@b) { if ( !($e =~ s/^ore\{/BEGINORE/ ) ) { next ; } # this preserves the initial block which # does not start with an ignore{ $c = 1 ; $rights = 0 ; @A = $e =~ m/(\{|\})/g ; # print STDERR "found $#A parentheses @A\n" ; for ( $i = 0 ; $i <= $#A && $c > 0 ; $i ++ ) { # while ( ($c > 0) && ($e =~ m/(\{|\})/g) ) { # figure out which has happened $theb = $A[$i] ; # print STDERR $c,$theb,";"; if ( $theb eq "\}" ) { $c -- ; $rights ++ ; } elsif ( $theb eq "\{" ) { $c ++ ; } else { print STDERR "ERROR " , $theb, "\n" ; } } # print STDERR "hoping to kill $rights in: $e\n" ; while ( $rights > 0 ) { $e =~ s/BEGINORE[^\}]*\}/BEGINORE/; $rights -- ; } $e =~ s/BEGINORE// ; } print join ( '' , @b ) ;