X-Git-Url: http://git.projectaon.org/?p=project-aon.git;a=blobdiff_plain;f=scripts%2Fcheckerrata.pl;fp=scripts%2Fcheckerrata.pl;h=0000000000000000000000000000000000000000;hp=258ce2d2d17007d47297c4ac2d0faabef7119545;hb=97545603aea8298f1eceb604ff65085cc7adfced;hpb=53d5f97cd1474231d3f343c70918a91ade6466e2 diff --git a/scripts/checkerrata.pl b/scripts/checkerrata.pl deleted file mode 100755 index 258ce2d..0000000 --- a/scripts/checkerrata.pl +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/perl -w -# This script parses the errata list of a book in XML form and tries to -# locate the added or replaced strings in the sections where they are now -# supposed to exist. Things that are not found by the simple errata list -# parsing code are just skipped. Nesting frontmatter sections are also -# skipped. - -# Old History: -# 2005-08-23 Tried to improve handling of tags -# 2005-03-12 Treat &thinspace; correctly. -# 2003-03-16 Fixed reporting of false positived due to tags -# 2003-03-15 First version. - -$xmlfile = shift @ARGV; -$xmlfile || die("usage: $0 \n"); -$invalid = shift @ARGV; -$invalid && die("usage: $0 \n"); - -open(ERRATA, $xmlfile) || die("Cannot read input file $xmlfile\n"); -open(SECTIONS, $xmlfile) || die("Cannot read input file $xmlfile\n"); - -while() { # find errata list - last if m//; -} -die("No errata section!? Aborting.\n") if eof(ERRATA); -while() { # find start of actual list - last if m//; -} -die("No data in the errata section!? Aborting.\n") if eof(ERRATA); - -print("No matches for these errata entries were found:\n"); - -# Now pick each paragraph (= errata) line -ERRATALOOP: while() { - next unless m/^\s*

/; # no paragraph = not an errata line - last if m||; # end of the errata list - ($sect) = m|\(.*\)|; - @reps = m|.*? with (.*?)|g; - @adds = m|[Aa]dded (.*?(?=))|g; - next unless @reps || @adds; - - # Now find section and append all contents into one string - while() { # locate section - last if m//; - } - die("Could not find section $sect!? (This might be because the errata\nentry for it is not placed in the correct section order.) Aborting.\n") if eof(SECTIONS); - while() { # locate data - last if m//; - } - die("Could not find any data in $sect!? Aborting.\n") if eof(SECTIONS); - $text = ""; - while() { # grab all section contents - last if m||; - if (m/

tags - # since they are commented out in the errata entries - s|<(/?)link-text>||g; - $text .= $_; - } - die("Could not find the end of $sect!? Aborting.\n") if eof(SECTIONS); - - # The replacement may contain &[lr][sd]quot; which in the sections are - # thingies. Translate these. Also ignore &thinspace; first and - # last in the replacements. - # Refactor the duplicated code below some day! - foreach $rep (@reps) { - $rep =~ s/\&l[sd]quot;//g; - $rep =~ s/\&r[sd]quot;/<\/quote>/g; - $rep =~ s/^\&thinspace;//g; - $rep =~ s/\&thinspace;$//g; - if ($text !~ m/\Q$rep\E/) { - print("Replacement \"$rep\" in $sect\n"); - } - } - foreach $add (@adds) { - $add =~ s/\&l[sd]quot;//g; - $add =~ s/\&r[sd]quot;/<\/quote>/g; - $add =~ s/^\&thinspace;//g; - $add =~ s/\&thinspace;$//g; - if ($text !~ m/\Q$add\E/) { - print("Addition \"$add\" in $sect\n"); - } - } -} -print("Checking finished!\n");