[comp.os.minix] Bug Fixes to mref.c

busch@arisia.Xerox.COM (Richard Busch) (11/13/90)

The following patch corrects 6 bugs that I recently discovered in the Minix
v1.5 mref utility. The bugs cause inaccuracies in the cross reference list
which is presented at the end of the new Minix v1.5 reference manual.

These patches have been examined and approved for posting by Dr. Tanenbaum.
Just so everyone's in sync, here are the crcs before and after the patch.

43034  25486 mref-old.c
27852   3515 mref.c.cdiff
10718  25726 mref.c

For those people who care, here is a list of the problems that the patches
correct. Page and line numbers refer to the reference manual accompanying
the new Minix v1.5 release from PH. The problems are:

1) The symbol that gets stored in location 0 of mref's symbol table is not 
   listed in the cross reference list. (This is why the global symbol "T"
   which is defined on source line 1109 (p.315) does not appear in the
   cross reference listing.)

2) When the -m flag is specified, and when the first reference to a global
   symbol is on the same line of input as the last reference to the alpha-
   betically previous global symbol, then the line number of the new first
   reference will not be listed in the cross reference list. (This bug does
   not affect the cross reference listing in the v1.5 manual, since the -m
   flag was not used in its creation, but it's still a bug.)

3) A character constant that happens to match a global symbol will erroneously
   be included in the cross reference list. (This is why, for example, line
   number 6762 appears in the cross reference list for the global symbol "D"
   on p.642.)

4) A local symbol will occasionally be listed in the cross reference list
   (only global symbols are supposed to be shown). This happens because, under
   certain circumstances, the symbol table lookup routine incorrectly
   indicates a "hit" when, in fact, the symbol is not present in the symbol
   table. (This may or may not be reflected in the v1.5 cross reference listing
   (I didn't have time to track down a specific occurrence) but the problem
   can be demonstrated with a contrived input file.)

5) When the symbol table fills up due to processing a large quantity of input
   (like trying to mref all of the include files, kernel, fs, and mm source,
   in one invocation - a reasonable thing to want to do) the next attempt to
   store a symbol into the table sends mref into an infinite loop. 

6) An incorrect parameter declaration causes the trashing of a word of
   memory. (Discovered while tracking down the above problems.)

-richard

-----cut here-----cut here-----cut here-----cut here-----cut here---- 
table
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
begin 644 mref.c.cdiff
M*BHJ(&UR968M;VQD+F,)5&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97<@;VYE+B J+PH@( HM+2T@.38R+#DW,2 M+2TM"B @"B @"B @h
M:6YT(&YE=U]N86UE*&-U<BP@=7-E9"P@<&YA;64L('9A;'5E<RD*(2!C:&%Rg
M("IC=7(["0D)+RH@<W1O<F%G92!F;W(@8W5R<F5N="!N86UE("HO"B$@:6YTf
M('5S960["0D)+RH@,"!O;FQY(&]N(&9I<G-T(&-A;&PN("HO"B$@8VAA<B Je
M<&YA;64["0D)+RH@<&]I;G1E<B!T;R!T:&4@;F5W(&YA;64@*B\*(2!I;G0@d
M=F%L=65S6UT["0D)+RH@86QL('1H92!D969I;FET:6]N<R!O9B!T:&4@;F5Wc
M(&YA;64@*B\*("!["B @+RH@02!N97<@;F%M92!H87,@8F5E;B!R96%D+B @b
M1FEN:7-H(&]F9B!T:&4@;VQD(&]N92!A;F0@<')E<&%R92!N97<@;VYE+B Ja
%+PH@( IHz
 y
end
-----end-----end-----end-----end-----end-----end-----end-----end-----

============================================================================
Richard Busch         San Diego State University         busch@math.sdsu.edu
                           Xerox Corporation              busch.sd@xerox.com
============================================================================