diff options
| author | Nick Barnes | 2001-10-31 14:40:56 +0000 |
|---|---|---|
| committer | Nick Barnes | 2001-10-31 14:40:56 +0000 |
| commit | 7acfca905d76140f4cc0b09c9a12de237de364cd (patch) | |
| tree | 3ed8babfa3a73d30f29e08ca5d5adcda4ca4e826 /mps/code/idlench.awk | |
| parent | b7ce4893f9902d57cd67ac9a92fa6c3d5a8fc833 (diff) | |
| download | emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.tar.gz emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.zip | |
Branch imports for masters.
Copied from Perforce
Change: 23678
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/idlench.awk')
| -rw-r--r-- | mps/code/idlench.awk | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/mps/code/idlench.awk b/mps/code/idlench.awk new file mode 100644 index 00000000000..cafeaaedb8f --- /dev/null +++ b/mps/code/idlench.awk | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #!/bin/nawk -f | ||
| 2 | # impl.awk.idlench: IDENTIFIER LENGTH CHECK | ||
| 3 | # $HopeName$ | ||
| 4 | # Copyright (C) 1998. Harlequin Group plc. All rights reserved. | ||
| 5 | # | ||
| 6 | # READERSHIP | ||
| 7 | # | ||
| 8 | # .readership: Anyone prepared to read awk programs. | ||
| 9 | # | ||
| 10 | # SOURCE | ||
| 11 | # | ||
| 12 | # .language: This program is written in awk as specified in the Single | ||
| 13 | # UNIX Specification from the X/Open Group (aka XPG4 UNIX, aka UNIX98). | ||
| 14 | # See http://www.opengroup.org/onlinepubs/7908799/xcu/awk.html for | ||
| 15 | # their man page. | ||
| 16 | # | ||
| 17 | # DESIGN | ||
| 18 | # | ||
| 19 | # .design: See design.buildsys.idlench | ||
| 20 | # | ||
| 21 | # PURPOSE | ||
| 22 | # | ||
| 23 | # This program processes the output of cxref to find long | ||
| 24 | # identifiers. | ||
| 25 | # | ||
| 26 | # It outputs a list of functions that are used (ie those named appearing | ||
| 27 | # in the 3rd column: FUNCTION) whose names completely fill the column. | ||
| 28 | # | ||
| 29 | # A typical invocation might be: | ||
| 30 | # | ||
| 31 | # ./idlench.awk sos8cx/ci/*.o | ||
| 32 | # | ||
| 33 | # Not all awks are UNIX98 compliant; you need to find one that is. | ||
| 34 | # By default (if invoked as above) this script runs using /bin/nawk | ||
| 35 | # which on Solaris is a complant awk, but this isn't guaranteed for | ||
| 36 | # other systems. | ||
| 37 | # | ||
| 38 | # So the invocation might be something like: | ||
| 39 | # | ||
| 40 | # awk -f idlench.awk sos8cx/ci/*.o | ||
| 41 | # | ||
| 42 | # if there are problems with finding the right awk | ||
| 43 | |||
| 44 | # check for good awk | ||
| 45 | NR == 1 { | ||
| 46 | if(FNR!=1) { | ||
| 47 | print "error: bad version of awk, try nawk or /usr/xpg4/bin/awk ?" | ||
| 48 | exit 1 | ||
| 49 | } | ||
| 50 | } | ||
| 51 | # skip 1st line | ||
| 52 | FNR == 1 {next} | ||
| 53 | # 2nd line contains column titles from which we determine widths | ||
| 54 | FNR == 2 { | ||
| 55 | lastfunpos=index($0, "LINE")-2 | ||
| 56 | firstfunpos=index($0, "FUNCTION") | ||
| 57 | if(lastfunpos<=0 || firstfunpos > lastfunpos) { | ||
| 58 | print "error: malformed line 2 of file " FILENAME; exit 1} | ||
| 59 | funlength = lastfunpos - firstfunpos + 1 | ||
| 60 | next | ||
| 61 | } | ||
| 62 | # for the rest of file, simply check last char in FUNCTION field | ||
| 63 | substr($0, lastfunpos, 1) != " " { | ||
| 64 | fun = substr($0, firstfunpos, funlength) | ||
| 65 | if(!dup[fun]) { | ||
| 66 | print fun | ||
| 67 | dup[fun] = 1 | ||
| 68 | } | ||
| 69 | } | ||