home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1834 < prev    next >
Internet Message Format  |  1990-12-28  |  1KB

  1. From: lee@sq.sq.com (Liam R. E. Quin)
  2. Newsgroups: comp.unix.shell,alt.sources
  3. Subject: Re: Extract function names
  4. Message-ID: <1990Sep17.165902.13109@sq.sq.com>
  5. Date: 17 Sep 90 16:59:02 GMT
  6.  
  7. chen@digital.sps.mot.com (Jinfu Chen) writes:
  8. >I'm looking for a tool to extract names of function call in C files. A
  9. >typical use of it is to build a cross-reference list for function calls. For
  10. >example, given source files of RN, I would like to find out which file the
  11. >ngdata_init() call is defined (and optionally) used.
  12. >
  13.  
  14. Here is cfind, which prints out the entire function.  It assumes a lot
  15. about indenting styes, though.
  16. It's easy to hack it to print just the name...
  17.  
  18. You could also look at "calls", a sort of cross-reference generating
  19. program, and at "cpr", which emboldens function names.
  20.  
  21. Lee
  22.  
  23.  
  24. #! /bin/sh
  25. if [ "x$1" = "x" -o "x$2" = "x" ]
  26. then
  27.     echo "Usage: $0 function file [file...]" 1>&2
  28.     exit 1
  29. fi
  30.  
  31. pat="$1"
  32. echo "Looking for $pat" 1>&2
  33. shift
  34. for i
  35. do
  36.     echo "$i:" 1>&2 ; cat "$i" |
  37.     sed -n -e '/^[     ]*[a-zA-Z0-9]*[     ]*[*]*[     ]*'"$pat"'/,/^}/p'
  38. done
  39.  
  40. #end
  41.  
  42. disclaimer:  I've not looked at cfind for several years!
  43.  
  44. Lee
  45. -- 
  46. Liam R. E. Quin,  lee@sq.com, SoftQuad Inc., Toronto, +1 (416) 963-8337
  47. [Granny weatherwax] was opposed to books on strict moral grounds, since she
  48. had heard that many of them were written by dead people  and therefore it
  49. stod to reason reading them would be as bad as necromancy.  [Equal Rites 118]
  50.