home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / CREF.ZIP / CREF.DOC < prev    next >
Encoding:
Text File  |  1988-11-26  |  3.9 KB  |  108 lines

  1. Cross Reference Generator in C; A Program Conversion Aid.
  2. 25 November 88
  3. Ken Gant
  4. Albuquerque, NM
  5. (505) 299-9303
  6.  
  7. CREDITS
  8. -------
  9. First off, credit where credit is due.  About 90% of this is taken
  10. verbatim (with only stylistic editing) from the listing in Dr. Dobb's
  11. TOOLBOOK OF C, starting on page 479. According to the book, "This
  12. chapter originally appeared in DDJ #68 (June 1982)."  So, if the code
  13. looks familiar, you know why. It was originally written by Jeff
  14. Taylor.  My major effort was porting it to MS-DOS in MicroSoft C 5.1
  15. The details can be found in the title block in the code.
  16.  
  17. USAGE
  18. -----
  19.  
  20. cref [filename [filename ...]]
  21.  
  22. If no files are listed on the command line, standard input is used as
  23. the source.
  24. The output is to standard output, so to get the results in a file,
  25. output redirection must be used.
  26.  
  27. NEAT STUFF
  28. ----------
  29. The neat things about this cross-referencer are:
  30.  
  31. 1.  It takes multiple files as input.  Not so extraordinary, but not
  32. all of them out there do.
  33.  
  34. 2.  It prints entries in the following format:
  35. node
  36.     cref.c           51   55   57   62   63   74   75   96   100   102   111
  37.                      123   175   419   459
  38.  
  39. "node" is the symbol name.  "cref.c" is the file for the following
  40. line numbers.  As for the numbers, figure it out, Sherlock.  If the
  41. symbol is defined in multiple files, all the file entries are listed
  42. alphabetically under the symbol entry.  So, priority is given to the
  43. symbol, not the file.
  44.  
  45. 3.  It doesn't print the file.  I view this as a big plus; I didn't
  46. want a pretty printer, or even program lister.  I just wanted a
  47. reasonable cross-referencer.
  48.  
  49. 4.  With minor modifications (i.e. to the reserved words table and the
  50. preprocessor directive handling section of xref()), this program can
  51. be used for any other language.  I suppose any x-reffer with source is
  52. like that, but I still think it's neat.
  53.  
  54. 5.  Code for both recursive and non-recursive operation is included
  55. here (it was in the original).
  56.  
  57. The changes I've made are in the output formatting, and one bug that I
  58. fixed in the function xref().  It seems that if you put a comment
  59. starting on a line with a #define and ending on another line (see
  60. example), the contents of the second line were interpereted as valid
  61. identifiers, because after the program had parsed off the first token
  62. following the #define (i.e. MAGIC here), it went and got a new line
  63. from the input, without checking to see if a comment might just have
  64. started later on the line.  I fixed that.  See the code; lines 378-382.
  65.  
  66. example:
  67. #define MAGIC   18      /*  numbers are bad, but 18 = 4 + 14; 4 for left
  68.                             margin, 14 for max UNIX filename length. KRG */
  69.  
  70.  
  71. PUTTING IT TOGETHER
  72. -------------------
  73. 1.      If you have MicroSoft C, use the makefile.  Otherwise, go on
  74.         to #2.
  75. 2.      The files needed are:
  76.         cref.c
  77.         esccref.c
  78.         strcref.c
  79.         style.h
  80.  
  81.         Compile 'em and link 'em with whatever you have.  If your
  82.         compiler is ANSI-compatible, the only change you might have to
  83.         make is in the call to the function itoa() from the function
  84.         list_file() (line 443 of cref.c).  According to the back of my
  85.         manual, itoa() isn't ANSI.  Mr. Taylor had written a version,
  86.         but I commented it out and used the MS function instead.  All
  87.         the old code is still there, so mere shifting of comment
  88.         delimiters is required to reactivate it.  Everything else, I
  89.         believe, is in the ANSI standard library, so should be no
  90.         problema.
  91.  
  92. File set:
  93.         cref.c
  94.         esccref.c
  95.         strcref.c
  96.         style.h
  97.         cref.doc
  98.         cref.mak
  99.  
  100. NEXT
  101. ----
  102. What'll happen next is that I'll introduce classes of identifiers to
  103. the program, so that functions are listed as such, as opposed to other
  104. identifiers.  However, I'm not in a terrible hurry.  Maybe a couple of
  105. months down the road.
  106.  
  107. KRG
  108.