remove holds based on fulfillment library
[migration-tools.git] / marc_cleanup
1 #!/usr/bin/perl
2
3 # Copyright 2009-2012, Equinox Software, Inc.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
19 require 5.10.0;
20
21 use strict;
22 use warnings;
23
24 use Getopt::Long;
25 use Term::ReadLine;
26 use Equinox::Migration::SimpleTagList;
27
28 my $term = new Term::ReadLine 'yaz-cleanup';
29 my $OUT = $term->OUT || \*STDOUT;
30 binmode STDOUT, ":utf8";
31 binmode $OUT, ":utf8";
32
33 $| = 1;
34
35 # initialization and setup
36 my $c = {};
37 initialize($c);
38
39 # set up files, since everything appears to be in order
40 open MARC, '<:utf8', $c->{marcfile}
41   or die "Can't open input file $!\n";
42 open my $NUMARC, '>:utf8', $c->{output}
43   or die "Can't open output file $!\n";
44 open my $OLD2NEW, '>', 'old2new.map'
45   if ($c->{'renumber-from'} and $c->{'original-tag'});
46 my $EXMARC = 'EX';
47 print $NUMARC "<collection xmlns=\"http://www.loc.gov/MARC21/slim\">\n";
48
49 $c->{totalrecs} = `grep -c '<record' $c->{marcfile}`;
50 chomp $c->{totalrecs};
51 $c->{percent}   = 0;
52
53 my @record;  # current record storage
54 my %recmeta; # metadata about current record
55 my $ptr = 0; # record index pointer
56
57 # this is the dispatch table which drives command selection in
58 # edit(), below
59 my %commands = ( c => \&print_fullcontext,
60                  n => \&next_line,
61                  p => \&prev_line,
62                  '<' => \&widen_window,
63                  '>' => \&narrow_window,
64                  d => \&display_lines,
65                  o => \&insert_original,
66                  k => \&kill_line,
67                  y => \&yank_line,
68                  f => \&flip_line,
69                  m => \&merge_lines,
70                  s => \&substitute,
71                  t => \&commit_edit,
72                  x => \&dump_record,
73                  q => \&quit,
74                  '?' => \&help,
75                  h   => \&help,
76                  help => \&help,
77                );
78
79 my @spinner = qw(- \\ | /);
80 my $sidx = 0;
81
82 while ( buildrecord() ) {
83     unless ($c->{ricount} % 50) {
84         $c->{percent} = int(($c->{ricount} / $c->{totalrecs}) * 100);
85         print "\rWorking (",$c->{percent},"%) ", $spinner[$sidx];
86         $sidx = ($sidx == $#spinner) ? 0 : $sidx + 1;
87     }
88
89     my $rc = do_automated_cleanups();
90     next if $rc;
91
92     $ptr = 0;
93     until ($ptr == $#record) {
94         # get datafield/tag data if we have it
95         $rc = stow_record_data() if ($c->{'renumber-from'} and $c->{'original-tag'});
96         next if $rc;
97
98         # naked ampersands
99         if ($record[$ptr] =~ /&/ && $record[$ptr] !~ /&\w+?;/)
100           { edit("Naked ampersand"); $ptr= 0; next }
101
102         if ($record[$ptr] =~ /<datafield tag="(.+?)"/) {
103             my $match = $1;
104             # tags must be numeric
105             if ($match =~ /\D/) {
106                 edit("Non-numerics in tag") unless $c->{autoscrub};
107                 next;
108             }
109         }
110
111         # subfields can't be non-alphanumeric
112         if ($record[$ptr] =~ /<subfield code="(.*?)"/) {
113             if ($1 =~ /\P{IsAlnum}/ or $1 eq '') {
114                 edit("Junk in subfield code/Null subfield code");
115                 next;
116             }
117         }
118         # subfields can't be larger than 1 char (technically you could make the MARC format accomodate that:)
119         if ($record[$ptr] =~ /<subfield code="(\w{2,})"/) {
120             edit("Subfield code larger than 1 char");
121             next;
122         }
123
124         $ptr++;
125     }
126     write_record($NUMARC);
127 }
128 print $NUMARC "</collection>\n";
129 print $OUT "\nDone. ",$c->{ricount}," in; ",$c->{rocount}," dumped          \n";
130
131
132 #-----------------------------------------------------------------------------------
133 # cleanup routines
134 #-----------------------------------------------------------------------------------
135
136 sub do_automated_cleanups {
137     $ptr = 0;
138     until ($ptr == $#record) {
139
140         # catch empty datafield elements
141         if ($record[$ptr] =~ m/<datafield tag="..."/) {
142             if ($record[$ptr + 1] =~ m|</datafield>|) {
143                 my @a = @record[0 .. $ptr - 1];
144                 my @b = @record[$ptr + 2 .. $#record];
145                 @record = (@a, @b);
146                 @a = undef; @b = undef;
147                 message("Empty datafield scrubbed");
148                 $ptr = 0;
149                 next;
150             }
151         }
152         # and quasi-empty subfields
153         if ($record[$ptr] =~ m|<subfield code="(.*?)">(.*?)</sub|) {
154             my $code = $1; my $content = $2;
155             if ($code =~ /\W/ and ($content =~ /\s+/ or $content eq '')) {
156                 my @a = @record[0 .. $ptr - 1];
157                 my @b = @record[$ptr + 1 .. $#record];
158                 @record = (@a, @b);
159                 @a = undef; @b = undef;
160                 message("Empty subfield scrubbed");
161                 $ptr = 0;
162                 next;
163             }
164         }
165         $ptr++;
166     }
167
168     # single-line fixes
169     for $ptr (0 .. $#record) {
170         # pad short leaders
171         if ($record[$ptr] =~ m|<leader>(.+?)</leader>|) {
172             my $leader = $1;
173             if (length $leader < 24) {
174                 $leader .= ' ' x (20 - length($leader));
175                 $leader .= "4500";
176                 $record[$ptr] = "<leader>$leader</leader>\n";
177                 message("Short leader padded");
178             }
179         }
180         if ($record[$ptr] =~ m|<controlfield tag="008">(.+?)</control|) {
181             #pad short 008
182             my $content = $1;
183             if (length $content < 40) {
184                 $content .= ' ' x (40 - length($content));
185                 $record[$ptr] = "<controlfield tag=\"008\">$content</controlfield>\n";
186                 message("Short 008 padded");
187             }
188         }
189
190         # clean misplaced dollarsigns
191         if ($record[$ptr] =~ m|<subfield code="\$">c?\d+\.\d{2}|) {
192             $record[$ptr] =~ s|"\$">c?(\d+\.\d{2})|"c">\$$1|;
193             message("Dollar sign corrected");
194         }
195
196         # excessive trailing whitespace in subfield contents
197         if ($record[$ptr] =~ m|\s{10,}</subfield>|) {
198             $record[$ptr] =~ s|\s{10,}</subfield>|</subfield>|;
199             message("Trailing whitespace trimmed from subfield contents");
200         }
201
202         # automatable subfield maladies
203         $record[$ptr] =~ s/code=" ">c/code="c">/;
204         $record[$ptr] =~ s/code=" ">\$/code="c">\$/;
205
206         if ($c->{'fix-subfield'}) {
207             $record[$ptr] =~ s/code="&amp;">/code="$c->{'fix-subfield'}">/;
208             $record[$ptr] =~ s/code="\P{IsAlnum}">/code="$c->{'fix-subfield'}">/;
209             $record[$ptr] =~ s/code="">/code="$c->{'fix-subfield'}">/;
210         }
211     }
212     return 0;
213 }
214
215 sub stow_record_data {
216     # get tag data if we're looking at it
217     my $tag = 0;
218     if ($record[$ptr] =~ m/<(?:control|data)field tag="(.{3})"/) {
219         $recmeta{tag} = $1;
220         $tag = $recmeta{tag};
221         $record[$ptr] =~ m/ind1="(.)"/;
222         $recmeta{ind1} = $1 || '';
223         $record[$ptr] =~ m/ind2="(.)"/;
224         $recmeta{ind2} = $1 || '';
225
226         unless ($tag) {
227             message("Autokill record: no detectable tag");
228             dump_record("No detectable tag") ;
229             return 1;
230         }
231
232         # and since we are looking at a tag, see if it's the original id
233         if ($tag == $c->{'original-tag'}) {
234             my $oid = 0;
235             if ($tag < 10) {
236                 # controlfield
237                 if ($record[$ptr] =~ m|<controlfield tag="$tag">(.+?)</controlfield>|)
238                       { $oid = $1; print $OLD2NEW "$oid\t", $recmeta{nid}, "\n" }
239             } elsif ($tag >= 10 and $c->{'original-subfield'}) {
240                 # datafield
241                 my $line = $record[$ptr]; my $lptr = $ptr;
242                 my $osub = $c->{'original-subfield'};
243                 # skim to end of this tag
244                 until ($line =~ m|</datafield>|) {
245                     if ($line =~ /<subfield code="$osub">(.+?)</)
246                       { $oid = $1; print $OLD2NEW "$oid\t", $recmeta{nid}, "\n" }
247                     $lptr++;
248                     $line = $record[$lptr];
249                 }
250             } else {
251                 return 0;
252             }
253
254             # didn't find the old id!
255             unless ($oid) {
256                 message("Autokill record: no oldid when old2new mapping requested");
257                 dump_record("No old id found");
258                 return 1;
259             }
260
261             # got it; write to old->new map file
262             if ($c->{'renumber-from'} and $c->{'original-subfield'}) {
263             }
264
265         }
266     }
267     return 0;
268 }
269
270 #-----------------------------------------------------------------------------------
271 # driver routines
272 #-----------------------------------------------------------------------------------
273
274 =head2 edit
275
276 Handles the Term::ReadLine loop
277
278 =cut
279
280 sub edit {
281     my ($msg) = @_;
282
283     return if $c->{trash}->has( $recmeta{tag} );
284     if ( $c->{fullauto} )
285     { dump_record($msg); return }
286
287     $c->{editmsg} = $msg;
288     print_fullcontext();
289
290     # stow original problem line
291     $recmeta{origline} = $record[$ptr];
292
293     while (1) {
294         my $line = $term->readline('marc-cleanup>');
295         my @chunks = split /\s+/, $line;
296
297         # lines with single-character first chunks are commands.
298         # make sure they exist.
299         if (length $chunks[0] == 1) {
300             unless (defined $commands{$chunks[0]}) {
301                 print $OUT "No such command '", $chunks[0], "'\n";
302                 next;
303             }
304         }
305
306         if (defined $commands{$chunks[0]}) {
307             my $term = $commands{$chunks[0]}->(@chunks[1..$#chunks]);
308             last if $term;
309         } else {
310             $recmeta{prevline} = $record[$ptr];
311             $record[$ptr] = "$line\n";
312             print_context();
313         }
314     }
315     # set pointer to top on the way out
316     $ptr = 0;
317 }
318
319 =head2 buildrecord
320
321 Constructs record arrays from the incoming MARC file and returns them
322 to the driver loop.
323
324 =cut
325
326 sub buildrecord {
327     my $l = '';
328     my $istrash = 0;
329     my $trash = $c->{trash};
330
331     $l = <MARC> while (defined $l and $l !~ /<record/);
332     return $l unless defined $l;
333     $c->{ricount}++;
334
335     for (keys %recmeta) { $recmeta{$_} = undef }
336     for (0 .. @record)  { delete $record[$_] }
337
338     my $i = 0;
339     until ($l =~ m|</record>|) {
340         # clean up tags with spaces in them
341         $l =~ s/tag="  /tag="00/g;
342         $l =~ s/tag=" /tag="0/g;
343         $l =~ s/tag="-/tag="0/g;
344         $l =~ s/tag="(\d\d) /tag="0$1/g;
345
346         # excise unwanted tags
347         if ($istrash) {
348             $istrash = 0 if ($l =~ m|</datafield|);
349             $l = <MARC>;
350             next;
351         }
352         if ($l =~ m/<datafield tag="(.{3})"/) {
353             if ($trash->has($1) or ($c->{autoscrub} and $1 =~ /\D/))
354               { $istrash = 1; next }
355         }
356
357         push @record, $l;
358         $l = <MARC>;
359         $i++;
360     }
361
362     # add 903(?) with new record id
363     if ($c->{'renumber-from'}) {
364         $recmeta{nid} = $c->{'renumber-from'};
365         push @record, join('', ' <datafield tag="', $c->{'renumber-tag'},
366                            '" ind1=" " ind2=" "> <subfield code="',
367                            $c->{'renumber-subfield'},
368                            '">',
369                            $recmeta{nid},
370                            "</subfield></datafield>\n");
371         $c->{'renumber-from'}++;
372     }
373     $i++;
374
375     push @record, $l;
376     return 1;
377 }
378
379 sub write_record {
380     my ($FH) = @_;
381
382     if ($FH eq 'EX') {
383         $EXMARC = undef;
384         open $EXMARC, '>:utf8', $c->{exception}
385           or die "Can't open exception file $!\n";
386         $FH = $EXMARC;
387     }
388
389     print $FH '<!-- ', $recmeta{explanation}, " -->\n"
390       if(defined $recmeta{explanation});
391
392     # scrub newlines (unless told not to or writing exception record)
393     unless ($c->{nocollapse} or $FH eq $EXMARC)
394       { s/\n// for (@record) }
395
396     # actually write the record
397     print $FH @record,"\n";
398
399     # increment output record count (if not exception)
400     $c->{rocount}++ if ($FH eq $EXMARC);
401
402     # if we were dumping to exception file, nuke the record and set ptr
403     # to terminate processing loop
404     @record = ('a');
405     $ptr = 0;
406 }
407
408 sub print_fullcontext {
409     print $OUT "\r", ' ' x 72, "\n";
410     print $OUT $c->{editmsg},"\n";
411     print $OUT "\r    Tag:",$recmeta{tag}, " Ind1:'",
412       $recmeta{ind1},"' Ind2:'", $recmeta{ind2}, "'";
413     print $OUT " @ ", $c->{ricount}, "/", $c->{totalrecs};
414     print_context();
415     return 0;
416 }
417
418 sub print_context {
419     my $upper = int($c->{window} / 2) + 1;
420     my $lower = int($c->{window} / 2) - 1;
421     my $start = ($ptr - $upper < 0) ? 0 : $ptr - $upper;
422     my $stop  = ($ptr + $lower > $#record) ? $#record : $ptr + $lower;
423     print $OUT "\n";
424     print $OUT '    |', $record[$_] for ($start .. $ptr - 1);
425     print $OUT '==> |', $record[$ptr];
426     print $OUT '    |', $record[$_] for ($ptr + 1 .. $stop);
427     print $OUT "\n";
428     return 0;
429 }
430
431 sub message {
432     my ($msg) = @_;
433     print $OUT "\r$msg at ",$c->{ricount},"/",$c->{totalrecs}, "\n";
434 }
435
436 #-----------------------------------------------------------------------------------
437 # command routines
438 #-----------------------------------------------------------------------------------
439
440 sub substitute {
441     my (@chunks) = @_;
442
443     my $ofrom = shift @chunks;
444     if ($ofrom =~ /^'/) {
445         until ($ofrom =~ /'$/ or !@chunks)
446           { $ofrom .= join(' ','',shift @chunks) }
447         $ofrom =~ s/^'//; $ofrom =~ s/'$//;
448     }
449     my $to = shift @chunks;
450     if ($to =~ /^'/) {
451         until ($to =~ /'$/ or !@chunks)
452           { $to .= join(' ','',shift @chunks) }
453         $to =~ s/^'//; $to =~ s/'$//;
454     }
455
456     my $from = '';
457     for my $char (split(//,$ofrom)) {
458         $char = "\\" . $char if ($char =~ /\W/);
459         $from = join('', $from, $char);
460     }
461
462     $recmeta{prevline} = $record[$ptr];
463     $record[$ptr] =~ s/$from/$to/;
464     $ofrom = undef; $to = undef; $from = undef;
465     print_context();
466     return 0;
467 }
468
469 sub merge_lines {
470     $recmeta{prevline} = $record[$ptr];
471     # remove <subfield stuff; extract (probably wrong) subfield code
472     $record[$ptr] =~ s/^\s*<subfield code="(.*?)">//;
473     # and move to front of line
474     $record[$ptr] = join(' ', $1 , $record[$ptr]);
475     # tear off trailing subfield tag from preceeding line
476     $record[$ptr - 1] =~ s|</subfield>\n||;
477     # join current line onto preceeding line
478     $record[$ptr - 1] = join('', $record[$ptr - 1], $record[$ptr]);
479     # erase current line
480     my @a = @record[0 .. $ptr - 1];
481     my @b = @record[$ptr + 1 .. $#record];
482     @record = (@a, @b);
483     # move record pointer to previous line
484     prev_line();
485     print_context();
486     return 0;
487 }
488
489 sub flip_line {
490     unless ($recmeta{prevline})
491       { print $OUT "No previously edited line to flip\n"; return }
492     my $temp = $record[$ptr];
493     $record[$ptr] = $recmeta{prevline};
494     $recmeta{prevline} = $temp;
495     $temp = undef;
496     print_context();
497     return 0;
498 }
499
500 sub kill_line {
501     $recmeta{killline} = $record[$ptr];
502     my @a = @record[0 .. $ptr - 1];
503     my @b = @record[$ptr + 1 .. $#record];
504     @record = (@a, @b);
505     @a = undef; @b = undef;
506     print_context();
507     return 0;
508 }
509
510 sub yank_line {
511     unless ($recmeta{killline})
512       { print $OUT "No killed line to yank\n"; return }
513     my @a = @record[0 .. $ptr - 1];
514     my @b = @record[$ptr .. $#record];
515     @record = (@a, $c->{killline}, @b);
516     @a = undef; @b = undef;
517     print_context();
518     return 0;
519 }
520
521 sub insert_original {
522     $record[$ptr] = $recmeta{origline};
523     print_context();
524     return 0;
525 }
526
527 sub display_lines {
528     print $OUT "\nOrig. edit line  :", $recmeta{origline};
529     print $OUT "Current flip line:", $recmeta{prevline} if $recmeta{prevline};
530     print $OUT "Last killed line :", $recmeta{killline} if $recmeta{killline};
531     print $OUT "\n";
532     return 0;
533 }
534
535 sub dump_record {
536     my (@explanation) = @_;
537     $recmeta{explanation} = join(' ', 'DUMPING RECORD: Tag', $recmeta{tag}, @explanation);
538     message( $recmeta{explanation} );
539     write_record($EXMARC);
540     return 1;
541 }
542
543 sub next_line {
544     $ptr++ unless ($ptr == $#record);;
545     print_context();
546     return 0;
547 }
548
549 sub prev_line {
550     $ptr-- unless ($ptr == 0);
551     print_context();
552     return 0;
553 }
554
555 sub commit_edit { return 1 }
556
557 sub widen_window {
558     if ($c->{window} == 15)
559       { print $OUT "Window can't be bigger than 15 lines\n"; return }
560     $c->{window} += 2;
561     print_context;
562 }
563
564 sub narrow_window {
565     if ($c->{window} == 5)
566       { print $OUT "Window can't be smaller than 5 lines\n"; return }
567     $c->{window} -= 2;
568     print_context;
569 }
570
571 sub help {
572 print $OUT <<HELP;
573 Type a replacement for the indicated line, or enter a command.
574
575 DISPLAY COMMANDS             | LINE AUTO-EDIT COMMANDS
576 <  Expand context window     | k  Kill current line
577 >  Contract context window   | y  Yank last killed line
578 p  Move pointer to prev line | m  Merge current line into preceding line
579 n  Move pointer to next line | o  Insert original line
580 c  Print line context        | f  Flip current line and last edited line
581 d  Print current saved lines |
582 -----------------------------+-------------------------------------------
583 s  Subtitute; replace ARG1 in current line with ARG2. If either ARG
584    contains spaces, it must be single-quoted
585 t  Commit changes and resume automated operations
586 x  Dump record to exception file
587 q  Quit
588
589 HELP
590 return 0;
591 }
592
593 sub quit { exit }
594
595 #-----------------------------------------------------------------------
596
597 =head2 initialize
598
599 Performs boring script initialization. Handles argument parsing,
600 mostly.
601
602 =cut
603
604 sub initialize {
605     my ($c) = @_;
606     my @missing = ();
607
608     # set mode on existing filehandles
609     binmode(STDIN, ':utf8');
610
611     my $rc = GetOptions( $c,
612                          'autoscrub|a',
613                          'fullauto',
614                          'exception|x=s',
615                          'output|o=s',
616                          'marcfile|m=s',
617                          'prefix|p=s',
618                          'nocollapse|n',
619                          'renumber-from|rf=i',
620                          'renumber-tag|rt=i',
621                          'renumber-subfield|rs=s',
622                          'original-tag|ot=i',
623                          'original-subfield|os=s',
624                          'fix-subfield|fs=s',
625                          'script',
626                          'no-strip9',
627                          'trashfile|t=s',
628                          'trashhelp',
629                          'help|h',
630                        );
631     show_help() unless $rc;
632     show_help() if ($c->{help});
633     show_trashhelp() if ($c->{trashhelp});
634
635     # defaults
636     my $pfx = defined($c->{prefix}) ? $c->{prefix} : "bibs";
637     $c->{ricount} = 0;
638     $c->{rocount} = 0;
639     $c->{'renumber-tag'} = 903 unless defined $c->{'renumber-tag'};
640     $c->{'renumber-subfield'} = 'a' unless defined $c->{'renumber-subfield'};
641     $c->{window} = 9;
642     if ($c->{prefix}) {
643         $c->{output} = join('.',$c->{prefix},'clean','marc','xml')
644           unless $c->{output};
645         $c->{exception} = join('.',$c->{prefix},'exception','marc','xml')
646           unless $c->{exception};
647         $c->{marcfile} = $c->{prefix} . '.marc.xml'
648           unless $c->{marcfile};
649     }
650     show_help() unless ($c->{marcfile} and $c->{output});
651
652     if ($c->{trashfile}) {
653         $c->{trash} = Equinox::Migration::SimpleTagList->new(file => $c->{trashfile})
654     } else {
655         $c->{trash} = Equinox::Migration::SimpleTagList->new;
656     }
657     # autotrash 901, 903 unless no strip-nines
658     unless ($c->{'no-strip9'}) {
659         $c->{trash}->add_tag(901);
660         $c->{trash}->add_tag(903);
661     }
662     # remove original id sequence tag from trash hash if we know it
663     $c->{trash}->remove_tag($c->{'original-tag'})
664       if ( $c->{'original-tag'} and $c->{trash}->has($c->{'original-tag'}) );
665 }
666
667 sub show_help {
668     print <<HELP;
669 Usage is: marc_cleanup [OPTIONS] <filelist>
670 Options
671   --output     -o  Cleaned MARCXML output filename
672   --exception  -x  Exception (dumped records) MARCXML filename
673        or
674   --prefix=<PREFIX>    -p  Shared prefix for output/exception files. Will produce
675                            PREFIX.clean.marc.xml and PREFIX.exception.marc.xml
676
677   --marcfile  -m  Input filename. Defaults to PREFIX.marc.xml
678
679   --renumber-from     -rf  Begin renumbering id sequence with this number
680   --renumber-tag      -rt  Tag to use in renumbering (default: 903)
681   --renumber-subfield -rs  Subfield code to use in renumbering (default: a)
682   --original-tag      -ot  Original id tag; will be kept in output even if
683                            it appears in the trash file
684   --original-subfield -os  Original id subfield code. If this is specified
685                            and renumbering is in effect, an old-to-new mapping
686                            file (old2new.map) will be generated.
687
688   --autoscrub         -a   Automatically remove non-numeric tags in data
689   --fix-subfield      -fs  Subfield code to use in place of non-alphanumeric
690                            or empty subfield codes
691   --nocollapse        -n   Don't compress records to one line on output
692   --no-strip9              Don't autoremove 901/903 tags in data
693   --trashfile         -t   File containing trash tag data (see --trashhelp)
694
695   --fullauto               No manual edits. All problematic records dumped to
696                            exception file.
697
698 HELP
699 exit;
700 }
701
702 sub show_trashhelp {
703     print <<HELP;
704 See
705
706 http://intra.lan.hq.esilibrary.com/dokuwiki/doku.php?id=migration:tag_files
707
708 for tag file syntax information.
709 HELP
710 exit;
711 }