4cb48f996450fb69ac2f12e5201f4ffa1afbd0f3
[openssl.git] / util / mkerr.pl
1 #!/usr/local/bin/perl -w
2
3 my $config = "crypto/err/openssl.ec";
4 my $debug = 0;
5 my $rebuild = 0;
6 my $static = 1;
7 my $recurse = 0;
8 my $reindex = 0;
9 my $dowrite = 0;
10 my $staticloader = "";
11
12 my $pack_errcode;
13 my $load_errcode;
14
15 while (@ARGV) {
16         my $arg = $ARGV[0];
17         if($arg eq "-conf") {
18                 shift @ARGV;
19                 $config = shift @ARGV;
20         } elsif($arg eq "-debug") {
21                 $debug = 1;
22                 shift @ARGV;
23         } elsif($arg eq "-rebuild") {
24                 $rebuild = 1;
25                 shift @ARGV;
26         } elsif($arg eq "-recurse") {
27                 $recurse = 1;
28                 shift @ARGV;
29         } elsif($arg eq "-reindex") {
30                 $reindex = 1;
31                 shift @ARGV;
32         } elsif($arg eq "-nostatic") {
33                 $static = 0;
34                 shift @ARGV;
35         } elsif($arg eq "-staticloader") {
36                 $staticloader = "static ";
37                 shift @ARGV;
38         } elsif($arg eq "-write") {
39                 $dowrite = 1;
40                 shift @ARGV;
41         } else {
42                 last;
43         }
44 }
45
46 if($recurse) {
47         @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>);
48 } else {
49         @source = @ARGV;
50 }
51
52 # Read in the config file
53
54 open(IN, "<$config") || die "Can't open config file $config";
55
56 # Parse config file
57
58 while(<IN>)
59 {
60         if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) {
61                 $hinc{$1} = $2;
62                 $libinc{$2} = $1;
63                 $cskip{$3} = $1;
64                 if($3 ne "NONE") {
65                         $csrc{$1} = $3;
66                         $fmax{$1} = 99;
67                         $rmax{$1} = 99;
68                         $fnew{$1} = 0;
69                         $rnew{$1} = 0;
70                 }
71         } elsif (/^F\s+(\S+)/) {
72         # Add extra function with $1
73         } elsif (/^R\s+(\S+)\s+(\S+)/) {
74                 $rextra{$1} = $2;
75                 $rcodes{$1} = $2;
76         }
77 }
78
79 close IN;
80
81 # Scan each header file in turn and make a list of error codes
82 # and function names
83
84 while (($hdr, $lib) = each %libinc)
85 {
86         next if($hdr eq "NONE");
87         print STDERR "Scanning header file $hdr\n" if $debug; 
88         my $line = "", $def= "", $linenr = 0, $gotfile = 0;
89         if (open(IN, "<$hdr")) {
90             $gotfile = 1;
91             while(<IN>) {
92                 $linenr++;
93                 print STDERR "line: $linenr\r" if $debug;
94
95                 last if(/BEGIN\s+ERROR\s+CODES/);
96                 if ($line ne '') {
97                     $_ = $line . $_;
98                     $line = '';
99                 }
100
101                 if (/\\$/) {
102                     $line = $_;
103                     next;
104                 }
105
106                 if(/\/\*/) {
107                     if (not /\*\//) {           # multiline comment...
108                         $line = $_;             # ... just accumulate
109                         next; 
110                     } else {
111                         s/\/\*.*?\*\///gs;      # wipe it
112                     }
113                 }
114
115                 if ($cpp) {
116                     $cpp++ if /^#\s*if/;
117                     $cpp-- if /^#\s*endif/;
118                     next;
119                 }
120                 $cpp = 1 if /^#.*ifdef.*cplusplus/;  # skip "C" declaration
121
122                 next if (/^\#/);                      # skip preprocessor directives
123
124                 s/{[^{}]*}//gs;                      # ignore {} blocks
125
126                 if (/\{|\/\*/) { # Add a } so editor works...
127                     $line = $_;
128                 } else {
129                     $def .= $_;
130                 }
131             }
132         }
133
134         print STDERR "                                  \r" if $debug;
135         $defnr = 0;
136         foreach (split /;/, $def) {
137             $defnr++;
138             print STDERR "def: $defnr\r" if $debug;
139
140             # The goal is to collect function names from function declarations.
141
142             s/^[\n\s]*//g;
143             s/[\n\s]*$//g;
144
145             # Skip over recognized non-function declarations
146             next if(/typedef\W/ or /DECLARE_STACK_OF/ or /TYPEDEF_.*_OF/);
147
148             # Reduce argument lists to empty ()
149             # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
150             while(/\(.*\)/s) {
151                 s/\([^\(\)]+\)/\{\}/gs;
152                 s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs;    #(*f{}) -> f
153             }
154             # pretend as we didn't use curly braces: {} -> ()
155             s/\{\}/\(\)/gs;
156
157             if (/(\w+)\s*\(\).*/s) {    # first token prior [first] () is
158                 my $name = $1;          # a function name!
159                 $name =~ tr/[a-z]/[A-Z]/;
160                 $ftrans{$name} = $1;
161             } elsif (/[\(\)]/ and not (/=/)) {
162                 print STDERR "Header $hdr: cannot parse: $_;\n";
163             }
164         }
165
166         print STDERR "                                  \r" if $debug;
167
168         next if $reindex;
169
170         # Scan function and reason codes and store them: keep a note of the
171         # maximum code used.
172
173         if ($gotfile) {
174             while(<IN>) {
175                 if(/^\#define\s+(\S+)\s+(\S+)/) {
176                         $name = $1;
177                         $code = $2;
178                         next if $name =~ /^${lib}err/;
179                         unless($name =~ /^${lib}_([RF])_(\w+)$/) {
180                                 print STDERR "Invalid error code $name\n";
181                                 next;
182                         }
183                         if($1 eq "R") {
184                                 $rcodes{$name} = $code;
185                                 if(!(exists $rextra{$name}) &&
186                                          ($code > $rmax{$lib}) ) {
187                                         $rmax{$lib} = $code;
188                                 }
189                         } else {
190                                 if($code > $fmax{$lib}) {
191                                         $fmax{$lib} = $code;
192                                 }
193                                 $fcodes{$name} = $code;
194                         }
195                 }
196             }
197         }
198
199         if ($debug) {
200                 if (defined($rmax{$lib})) {
201                         print STDERR "Max reason code rmax" . "{" . "$lib" . "} = $rmax{$lib}\n";
202                 }
203                 if (defined($fmax{$lib})) {
204                         print STDERR "Max function code fmax" . "{" . "$lib" . "} = $fmax{$lib}\n";
205                 }
206         }
207
208         close IN;
209 }
210
211 # Scan each C source file and look for function and reason codes
212 # This is done by looking for strings that "look like" function or
213 # reason codes: basically anything consisting of all upper case and
214 # numerics which has _F_ or _R_ in it and which has the name of an
215 # error library at the start. This seems to work fine except for the
216 # oddly named structure BIO_F_CTX which needs to be ignored.
217 # If a code doesn't exist in list compiled from headers then mark it
218 # with the value "X" as a place holder to give it a value later.
219 # Store all function and reason codes found in %ufcodes and %urcodes
220 # so all those unreferenced can be printed out.
221
222
223 foreach $file (@source) {
224         # Don't parse the error source file.
225         next if exists $cskip{$file};
226         print STDERR "File loaded: ".$file."\r" if $debug;
227         open(IN, "<$file") || die "Can't open source file $file\n";
228         while(<IN>) {
229                 if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) {
230                         next unless exists $csrc{$2};
231                         next if($1 eq "BIO_F_BUFFER_CTX");
232                         $ufcodes{$1} = 1;
233                         if(!exists $fcodes{$1}) {
234                                 $fcodes{$1} = "X";
235                                 $fnew{$2}++;
236                         }
237                         $notrans{$1} = 1 unless exists $ftrans{$3};
238                 }
239                 if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) {
240                         next unless exists $csrc{$2};
241                         $urcodes{$1} = 1;
242                         if(!exists $rcodes{$1}) {
243                                 $rcodes{$1} = "X";
244                                 $rnew{$2}++;
245                         }
246                 } 
247         }
248         close IN;
249 }
250 print STDERR "                                  \n" if $debug;
251
252 # Now process each library in turn.
253
254 foreach $lib (keys %csrc)
255 {
256         my $hfile = $hinc{$lib};
257         my $cfile = $csrc{$lib};
258         if(!$fnew{$lib} && !$rnew{$lib}) {
259                 print STDERR "$lib:\t\tNo new error codes\n";
260                 next unless $rebuild;
261         } else {
262                 print STDERR "$lib:\t\t$fnew{$lib} New Functions,";
263                 print STDERR " $rnew{$lib} New Reasons.\n";
264                 next unless $dowrite;
265         }
266
267         # If we get here then we have some new error codes so we
268         # need to rebuild the header file and C file.
269
270         # Make a sorted list of error and reason codes for later use.
271
272         my @function = sort grep(/^${lib}_/,keys %fcodes);
273         my @reasons = sort grep(/^${lib}_/,keys %rcodes);
274
275         # Rewrite the header file
276
277         if (open(IN, "<$hfile")) {
278             # Copy across the old file
279             while(<IN>) {
280                 push @out, $_;
281                 last if (/BEGIN ERROR CODES/);
282             }
283             close IN;
284         } else {
285             push @out,
286 "/* ====================================================================\n",
287 " * Copyright (c) 2001-2005 The OpenSSL Project.  All rights reserved.\n",
288 " *\n",
289 " * Redistribution and use in source and binary forms, with or without\n",
290 " * modification, are permitted provided that the following conditions\n",
291 " * are met:\n",
292 " *\n",
293 " * 1. Redistributions of source code must retain the above copyright\n",
294 " *    notice, this list of conditions and the following disclaimer. \n",
295 " *\n",
296 " * 2. Redistributions in binary form must reproduce the above copyright\n",
297 " *    notice, this list of conditions and the following disclaimer in\n",
298 " *    the documentation and/or other materials provided with the\n",
299 " *    distribution.\n",
300 " *\n",
301 " * 3. All advertising materials mentioning features or use of this\n",
302 " *    software must display the following acknowledgment:\n",
303 " *    \"This product includes software developed by the OpenSSL Project\n",
304 " *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n",
305 " *\n",
306 " * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n",
307 " *    endorse or promote products derived from this software without\n",
308 " *    prior written permission. For written permission, please contact\n",
309 " *    openssl-core\@openssl.org.\n",
310 " *\n",
311 " * 5. Products derived from this software may not be called \"OpenSSL\"\n",
312 " *    nor may \"OpenSSL\" appear in their names without prior written\n",
313 " *    permission of the OpenSSL Project.\n",
314 " *\n",
315 " * 6. Redistributions of any form whatsoever must retain the following\n",
316 " *    acknowledgment:\n",
317 " *    \"This product includes software developed by the OpenSSL Project\n",
318 " *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n",
319 " *\n",
320 " * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n",
321 " * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n",
322 " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n",
323 " * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n",
324 " * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n",
325 " * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n",
326 " * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n",
327 " * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n",
328 " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n",
329 " * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n",
330 " * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n",
331 " * OF THE POSSIBILITY OF SUCH DAMAGE.\n",
332 " * ====================================================================\n",
333 " *\n",
334 " * This product includes cryptographic software written by Eric Young\n",
335 " * (eay\@cryptsoft.com).  This product includes software written by Tim\n",
336 " * Hudson (tjh\@cryptsoft.com).\n",
337 " *\n",
338 " */\n",
339 "\n",
340 "#ifndef HEADER_${lib}_ERR_H\n",
341 "#define HEADER_${lib}_ERR_H\n",
342 "\n",
343 "/* BEGIN ERROR CODES */\n";
344         }
345         open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n";
346
347         print OUT @out;
348         undef @out;
349         print OUT <<"EOF";
350 /* The following lines are auto generated by the script mkerr.pl. Any changes
351  * made after this point may be overwritten when the script is next run.
352  */
353 EOF
354         if($static) {
355                 print OUT <<"EOF";
356 ${staticloader}void ERR_load_${lib}_strings(void);
357
358 EOF
359         } else {
360                 print OUT <<"EOF";
361 ${staticloader}void ERR_load_${lib}_strings(void);
362 ${staticloader}void ERR_unload_${lib}_strings(void);
363 ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
364 #define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
365
366 EOF
367         }
368         print OUT <<"EOF";
369 /* Error codes for the $lib functions. */
370
371 /* Function codes. */
372 EOF
373
374         foreach $i (@function) {
375                 $z=6-int(length($i)/8);
376                 if($fcodes{$i} eq "X") {
377                         $fcodes{$i} = ++$fmax{$lib};
378                         print STDERR "New Function code $i\n" if $debug;
379                 }
380                 printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z;
381         }
382
383         print OUT "\n/* Reason codes. */\n";
384
385         foreach $i (@reasons) {
386                 $z=6-int(length($i)/8);
387                 if($rcodes{$i} eq "X") {
388                         $rcodes{$i} = ++$rmax{$lib};
389                         print STDERR "New Reason code   $i\n" if $debug;
390                 }
391                 printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z;
392         }
393         print OUT <<"EOF";
394
395 #ifdef  __cplusplus
396 }
397 #endif
398 #endif
399 EOF
400         close OUT;
401
402         # Rewrite the C source file containing the error details.
403
404         # First, read any existing reason string definitions:
405         my %err_reason_strings;
406         if (open(IN,"<$cfile")) {
407                 while (<IN>) {
408                         if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) {
409                                 $err_reason_strings{$1} = $2;
410                         }
411                 }
412                 close(IN);
413         }
414
415         my $hincf;
416         if($static) {
417                 $hfile =~ /([^\/]+)$/;
418                 $hincf = "<openssl/$1>";
419         } else {
420                 $hincf = "\"$hfile\"";
421         }
422
423         # If static we know the error code at compile time so use it
424         # in error definitions.
425
426         if ($static)
427                 {
428                 $pack_errcode = "ERR_LIB_${lib}";
429                 $load_errcode = "0";
430                 }
431         else
432                 {
433                 $pack_errcode = "0";
434                 $load_errcode = "ERR_LIB_${lib}";
435                 }
436
437
438         open (OUT,">$cfile") || die "Can't open $cfile for writing";
439
440         print OUT <<"EOF";
441 /* $cfile */
442 /* ====================================================================
443  * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.
444  *
445  * Redistribution and use in source and binary forms, with or without
446  * modification, are permitted provided that the following conditions
447  * are met:
448  *
449  * 1. Redistributions of source code must retain the above copyright
450  *    notice, this list of conditions and the following disclaimer. 
451  *
452  * 2. Redistributions in binary form must reproduce the above copyright
453  *    notice, this list of conditions and the following disclaimer in
454  *    the documentation and/or other materials provided with the
455  *    distribution.
456  *
457  * 3. All advertising materials mentioning features or use of this
458  *    software must display the following acknowledgment:
459  *    "This product includes software developed by the OpenSSL Project
460  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
461  *
462  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
463  *    endorse or promote products derived from this software without
464  *    prior written permission. For written permission, please contact
465  *    openssl-core\@OpenSSL.org.
466  *
467  * 5. Products derived from this software may not be called "OpenSSL"
468  *    nor may "OpenSSL" appear in their names without prior written
469  *    permission of the OpenSSL Project.
470  *
471  * 6. Redistributions of any form whatsoever must retain the following
472  *    acknowledgment:
473  *    "This product includes software developed by the OpenSSL Project
474  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
475  *
476  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
477  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
478  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
479  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
480  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
481  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
482  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
483  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
484  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
485  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
486  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
487  * OF THE POSSIBILITY OF SUCH DAMAGE.
488  * ====================================================================
489  *
490  * This product includes cryptographic software written by Eric Young
491  * (eay\@cryptsoft.com).  This product includes software written by Tim
492  * Hudson (tjh\@cryptsoft.com).
493  *
494  */
495
496 /* NOTE: this file was auto generated by the mkerr.pl script: any changes
497  * made to it will be overwritten when the script next updates this file,
498  * only reason strings will be preserved.
499  */
500
501 #include <stdio.h>
502 #include <openssl/err.h>
503 #include $hincf
504
505 /* BEGIN ERROR CODES */
506 #ifndef OPENSSL_NO_ERR
507
508 #define ERR_FUNC(func) ERR_PACK($pack_errcode,func,0)
509 #define ERR_REASON(reason) ERR_PACK($pack_errcode,0,reason)
510
511 static ERR_STRING_DATA ${lib}_str_functs[]=
512         {
513 EOF
514         # Add each function code: if a function name is found then use it.
515         foreach $i (@function) {
516                 my $fn;
517                 $i =~ /^${lib}_F_(\S+)$/;
518                 $fn = $1;
519                 if(exists $ftrans{$fn}) {
520                         $fn = $ftrans{$fn};
521                 }
522 #               print OUT "{ERR_PACK($pack_errcode,$i,0),\t\"$fn\"},\n";
523                 print OUT "{ERR_FUNC($i),\t\"$fn\"},\n";
524         }
525         print OUT <<"EOF";
526 {0,NULL}
527         };
528
529 static ERR_STRING_DATA ${lib}_str_reasons[]=
530         {
531 EOF
532         # Add each reason code.
533         foreach $i (@reasons) {
534                 my $rn;
535                 my $rstr = "ERR_REASON($i)";
536                 my $nspc = 0;
537                 if (exists $err_reason_strings{$i}) {
538                         $rn = $err_reason_strings{$i};
539                 } else {
540                         $i =~ /^${lib}_R_(\S+)$/;
541                         $rn = $1;
542                         $rn =~ tr/_[A-Z]/ [a-z]/;
543                 }
544                 $nspc = 40 - length($rstr) unless length($rstr) > 40;
545                 $nspc = " " x $nspc;
546                 print OUT "{${rstr}${nspc},\"$rn\"},\n";
547         }
548 if($static) {
549         print OUT <<"EOF";
550 {0,NULL}
551         };
552
553 #endif
554
555 ${staticloader}void ERR_load_${lib}_strings(void)
556         {
557         static int init=1;
558
559         if (init)
560                 {
561                 init=0;
562 #ifndef OPENSSL_NO_ERR
563                 ERR_load_strings($load_errcode,${lib}_str_functs);
564                 ERR_load_strings($load_errcode,${lib}_str_reasons);
565 #endif
566
567                 }
568         }
569 EOF
570 } else {
571         print OUT <<"EOF";
572 {0,NULL}
573         };
574
575 #endif
576
577 #ifdef ${lib}_LIB_NAME
578 static ERR_STRING_DATA ${lib}_lib_name[]=
579         {
580 {0      ,${lib}_LIB_NAME},
581 {0,NULL}
582         };
583 #endif
584
585
586 static int ${lib}_lib_error_code=0;
587 static int ${lib}_error_init=1;
588
589 ${staticloader}void ERR_load_${lib}_strings(void)
590         {
591         if (${lib}_lib_error_code == 0)
592                 ${lib}_lib_error_code=ERR_get_next_error_library();
593
594         if (${lib}_error_init)
595                 {
596                 ${lib}_error_init=0;
597 #ifndef OPENSSL_NO_ERR
598                 ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs);
599                 ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons);
600 #endif
601
602 #ifdef ${lib}_LIB_NAME
603                 ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0);
604                 ERR_load_strings(0,${lib}_lib_name);
605 #endif
606                 }
607         }
608
609 ${staticloader}void ERR_unload_${lib}_strings(void)
610         {
611         if (${lib}_error_init == 0)
612                 {
613 #ifndef OPENSSL_NO_ERR
614                 ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs);
615                 ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons);
616 #endif
617
618 #ifdef ${lib}_LIB_NAME
619                 ERR_unload_strings(0,${lib}_lib_name);
620 #endif
621                 ${lib}_error_init=1;
622                 }
623         }
624
625 ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line)
626         {
627         if (${lib}_lib_error_code == 0)
628                 ${lib}_lib_error_code=ERR_get_next_error_library();
629         ERR_PUT_error(${lib}_lib_error_code,function,reason,file,line);
630         }
631 EOF
632
633 }
634
635         close OUT;
636         undef %err_reason_strings;
637 }
638
639 if($debug && defined(%notrans)) {
640         print STDERR "The following function codes were not translated:\n";
641         foreach(sort keys %notrans)
642         {
643                 print STDERR "$_\n";
644         }
645 }
646
647 # Make a list of unreferenced function and reason codes
648
649 foreach (keys %fcodes) {
650         push (@funref, $_) unless exists $ufcodes{$_};
651 }
652
653 foreach (keys %rcodes) {
654         push (@runref, $_) unless exists $urcodes{$_};
655 }
656
657 if($debug && defined(@funref) ) {
658         print STDERR "The following function codes were not referenced:\n";
659         foreach(sort @funref)
660         {
661                 print STDERR "$_\n";
662         }
663 }
664
665 if($debug && defined(@runref) ) {
666         print STDERR "The following reason codes were not referenced:\n";
667         foreach(sort @runref)
668         {
669                 print STDERR "$_\n";
670         }
671 }