Megatest

Hex Artifact Content
Login

Artifact 9e9d6c85944303ad0929d6412cf3c6af7dd07281:


0000: 3b 3b 20 20 43 6f 70 79 72 69 67 68 74 20 32 30  ;;  Copyright 20
0010: 30 36 2d 32 30 31 37 2c 20 4d 61 74 74 68 65 77  06-2017, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b   Welland..;; .;;
0030: 20 54 68 69 73 20 66 69 6c 65 20 69 73 20 70 61   This file is pa
0040: 72 74 20 6f 66 20 4d 65 67 61 74 65 73 74 2e 0a  rt of Megatest..
0050: 3b 3b 20 0a 3b 3b 20 20 20 20 20 4d 65 67 61 74  ;; .;;     Megat
0060: 65 73 74 20 69 73 20 66 72 65 65 20 73 6f 66 74  est is free soft
0070: 77 61 72 65 3a 20 79 6f 75 20 63 61 6e 20 72 65  ware: you can re
0080: 64 69 73 74 72 69 62 75 74 65 20 69 74 20 61 6e  distribute it an
0090: 64 2f 6f 72 20 6d 6f 64 69 66 79 0a 3b 3b 20 20  d/or modify.;;  
00a0: 20 20 20 69 74 20 75 6e 64 65 72 20 74 68 65 20     it under the 
00b0: 74 65 72 6d 73 20 6f 66 20 74 68 65 20 47 4e 55  terms of the GNU
00c0: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20   General Public 
00d0: 4c 69 63 65 6e 73 65 20 61 73 20 70 75 62 6c 69  License as publi
00e0: 73 68 65 64 20 62 79 0a 3b 3b 20 20 20 20 20 74  shed by.;;     t
00f0: 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 72 65  he Free Software
0100: 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 65 69 74   Foundation, eit
0110: 68 65 72 20 76 65 72 73 69 6f 6e 20 33 20 6f 66  her version 3 of
0120: 20 74 68 65 20 4c 69 63 65 6e 73 65 2c 20 6f 72   the License, or
0130: 0a 3b 3b 20 20 20 20 20 28 61 74 20 79 6f 75 72  .;;     (at your
0140: 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74   option) any lat
0150: 65 72 20 76 65 72 73 69 6f 6e 2e 0a 3b 3b 20 0a  er version..;; .
0160: 3b 3b 20 20 20 20 20 4d 65 67 61 74 65 73 74 20  ;;     Megatest 
0170: 69 73 20 64 69 73 74 72 69 62 75 74 65 64 20 69  is distributed i
0180: 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61 74 20  n the hope that 
0190: 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 66 75  it will be usefu
01a0: 6c 2c 0a 3b 3b 20 20 20 20 20 62 75 74 20 57 49  l,.;;     but WI
01b0: 54 48 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e  THOUT ANY WARRAN
01c0: 54 59 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e  TY; without even
01d0: 20 74 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72   the implied war
01e0: 72 61 6e 74 79 20 6f 66 0a 3b 3b 20 20 20 20 20  ranty of.;;     
01f0: 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20  MERCHANTABILITY 
0200: 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41  or FITNESS FOR A
0210: 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50   PARTICULAR PURP
0220: 4f 53 45 2e 20 20 53 65 65 20 74 68 65 0a 3b 3b  OSE.  See the.;;
0230: 20 20 20 20 20 47 4e 55 20 47 65 6e 65 72 61 6c       GNU General
0240: 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20   Public License 
0250: 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73  for more details
0260: 2e 0a 3b 3b 20 0a 3b 3b 20 20 20 20 20 59 6f 75  ..;; .;;     You
0270: 20 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63   should have rec
0280: 65 69 76 65 64 20 61 20 63 6f 70 79 20 6f 66 20  eived a copy of 
0290: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20  the GNU General 
02a0: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 0a 3b  Public License.;
02b0: 3b 20 20 20 20 20 61 6c 6f 6e 67 20 77 69 74 68  ;     along with
02c0: 20 4d 65 67 61 74 65 73 74 2e 20 20 49 66 20 6e   Megatest.  If n
02d0: 6f 74 2c 20 73 65 65 20 3c 68 74 74 70 3a 2f 2f  ot, see <http://
02e0: 77 77 77 2e 67 6e 75 2e 6f 72 67 2f 6c 69 63 65  www.gnu.org/lice
02f0: 6e 73 65 73 2f 3e 2e 0a 3b 3b 0a 0a 3b 3b 20 67  nses/>..;;..;; g
0300: 6f 74 74 61 20 63 6f 6d 70 69 6c 65 20 77 69 74  otta compile wit
0310: 68 20 63 73 63 2c 20 64 6f 65 73 6e 27 74 20 77  h csc, doesn't w
0320: 6f 72 6b 20 77 69 74 68 20 63 73 69 20 2d 73 20  ork with csi -s 
0330: 66 6f 72 20 77 68 61 74 65 76 65 72 20 72 65 61  for whatever rea
0340: 73 6f 6e 0a 0a 28 75 73 65 20 73 72 66 69 2d 36  son..(use srfi-6
0350: 39 29 0a 28 75 73 65 20 6d 61 74 63 68 61 62 6c  9).(use matchabl
0360: 65 29 0a 28 75 73 65 20 75 74 69 6c 73 29 0a 28  e).(use utils).(
0370: 75 73 65 20 70 6f 72 74 73 29 0a 28 75 73 65 20  use ports).(use 
0380: 65 78 74 72 61 73 29 0a 28 75 73 65 20 73 72 66  extras).(use srf
0390: 69 2d 31 29 0a 28 75 73 65 20 70 6f 73 69 78 29  i-1).(use posix)
03a0: 0a 28 75 73 65 20 73 72 66 69 2d 31 32 29 0a 0a  .(use srfi-12)..
03b0: 3b 3b 20 74 75 72 6e 20 73 63 68 65 6d 65 20 66  ;; turn scheme f
03c0: 69 6c 65 20 74 6f 20 61 20 6c 69 73 74 20 6f 66  ile to a list of
03d0: 20 73 65 78 70 73 2c 20 73 65 78 70 73 20 6f 66   sexps, sexps of
03e0: 20 69 6e 74 65 72 65 73 74 20 77 69 6c 6c 20 62   interest will b
03f0: 65 20 69 6e 20 74 68 65 20 66 6f 72 6d 20 6f 66  e in the form of
0400: 20 28 64 65 66 69 6e 65 20 28 3c 70 72 6f 63 6e   (define (<procn
0410: 61 6d 65 3e 20 3c 61 72 67 73 3e 29 20 3c 62 6f  ame> <args>) <bo
0420: 64 79 3e 20 29 0a 0a 28 64 65 66 69 6e 65 20 28  dy> )..(define (
0430: 6c 6f 61 64 2d 73 63 6d 2d 66 69 6c 65 20 73 63  load-scm-file sc
0440: 6d 2d 66 69 6c 65 29 0a 20 20 3b 3b 28 70 72 69  m-file).  ;;(pri
0450: 6e 74 20 22 6c 6f 61 64 20 22 73 63 6d 2d 66 69  nt "load "scm-fi
0460: 6c 65 29 0a 20 20 28 68 61 6e 64 6c 65 2d 65 78  le).  (handle-ex
0470: 63 65 70 74 69 6f 6e 73 0a 20 20 20 65 78 6e 0a  ceptions.   exn.
0480: 20 20 20 27 28 29 0a 20 20 20 28 77 69 74 68 2d     '().   (with-
0490: 69 6e 70 75 74 2d 66 72 6f 6d 2d 73 74 72 69 6e  input-from-strin
04a0: 67 0a 20 20 20 20 20 20 20 28 63 6f 6e 63 20 22  g.       (conc "
04b0: 28 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  (".             
04c0: 28 77 69 74 68 2d 69 6e 70 75 74 2d 66 72 6f 6d  (with-input-from
04d0: 2d 66 69 6c 65 20 73 63 6d 2d 66 69 6c 65 20 72  -file scm-file r
04e0: 65 61 64 2d 61 6c 6c 29 0a 20 20 20 20 20 20 20  ead-all).       
04f0: 20 20 20 20 20 20 22 29 22 20 29 0a 20 20 20 20        ")" ).    
0500: 20 72 65 61 64 29 29 29 0a 0a 3b 3b 20 65 78 74   read)))..;; ext
0510: 72 61 63 74 20 61 20 6c 69 73 74 20 6f 66 20 70  ract a list of p
0520: 72 6f 63 6e 61 6d 65 2c 20 66 69 6c 65 6e 61 6d  rocname, filenam
0530: 65 2c 20 61 72 67 73 20 61 6e 64 20 62 6f 64 79  e, args and body
0540: 20 6f 66 20 70 72 6f 63 65 64 75 72 65 73 20 64   of procedures d
0550: 65 66 69 6e 65 64 20 69 6e 20 66 69 6c 65 6e 61  efined in filena
0560: 6d 65 2c 20 69 6e 70 75 74 20 66 72 6f 6d 20 6c  me, input from l
0570: 6f 61 64 2d 73 63 6d 2d 66 69 6c 65 0a 3b 3b 20  oad-scm-file.;; 
0580: 20 20 2d 2d 20 62 65 20 61 64 76 69 73 65 64 3a    -- be advised:
0590: 0a 3b 3b 20 20 20 20 20 20 2a 20 74 68 69 73 20  .;;      * this 
05a0: 6d 61 79 20 62 65 20 66 6f 6f 6c 65 64 20 62 79  may be fooled by
05b0: 20 6d 61 63 72 6f 73 2c 20 73 69 6e 63 65 20 74   macros, since t
05c0: 68 69 73 20 63 6f 64 65 20 64 6f 65 73 20 6e 6f  his code does no
05d0: 74 20 74 61 6b 65 20 74 68 65 6d 20 69 6e 74 6f  t take them into
05e0: 20 61 63 63 6f 75 6e 74 2e 0a 3b 3b 20 20 20 20   account..;;    
05f0: 20 20 2a 20 74 68 69 73 20 63 6f 64 65 20 64 6f    * this code do
0600: 65 73 20 6f 6e 6c 79 20 63 68 65 63 6b 73 20 66  es only checks f
0610: 6f 72 20 66 6f 72 6d 20 28 64 65 66 69 6e 65 20  or form (define 
0620: 28 3c 70 72 6f 63 6e 61 6d 65 3e 20 2e 2e 2e 20  (<procname> ... 
0630: 29 20 3c 62 6f 64 79 3e 29 0a 3b 3b 20 20 20 20  ) <body>).;;    
0640: 20 20 20 20 20 20 20 73 6f 20 69 74 20 65 78 63         so it exc
0650: 6c 75 64 65 73 20 66 72 6f 6d 20 72 65 63 6b 6f  ludes from recko
0660: 6e 69 6e 67 0a 3b 3b 20 20 20 20 20 20 20 20 20  ning.;;         
0670: 20 20 20 20 20 20 2d 20 67 65 6e 65 72 61 74 65        - generate
0680: 64 20 66 75 6e 63 74 69 6f 6e 73 2c 20 61 73 20  d functions, as 
0690: 69 6e 20 74 68 69 6e 67 73 20 6c 69 6b 65 20 66  in things like f
06a0: 6f 6f 2d 73 65 74 21 20 66 72 6f 6d 20 64 65 66  oo-set! from def
06b0: 73 74 72 75 63 74 73 2c 0a 3b 3b 20 20 20 20 20  structs,.;;     
06c0: 20 20 20 20 20 20 20 20 20 20 2d 20 64 65 66 69            - defi
06d0: 6e 65 2d 69 6e 6c 69 6e 65 2c 20 28 0a 3b 3b 20  ne-inline, (.;; 
06e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 20                - 
06f0: 64 65 66 69 6e 65 20 70 72 6f 63 6e 61 6d 65 20  define procname 
0700: 28 6c 61 6d 62 64 61 20 2e 2e 0a 3b 3b 20 20 20  (lambda ...;;   
0710: 20 20 20 20 20 20 20 20 20 20 20 20 2d 20 65 74              - et
0720: 63 2e 2e 2e 0a 28 64 65 66 69 6e 65 20 28 67 65  c....(define (ge
0730: 74 2d 74 6f 70 6c 65 76 65 6c 2d 70 72 6f 63 73  t-toplevel-procs
0740: 2b 66 69 6c 65 2b 61 72 67 73 2b 62 6f 64 79 20  +file+args+body 
0750: 66 69 6c 65 6e 61 6d 65 29 0a 20 20 28 6c 65 74  filename).  (let
0760: 2a 20 28 28 73 63 6d 2d 74 72 65 65 20 28 6c 6f  * ((scm-tree (lo
0770: 61 64 2d 73 63 6d 2d 66 69 6c 65 20 66 69 6c 65  ad-scm-file file
0780: 6e 61 6d 65 29 29 0a 20 20 20 20 20 20 20 20 20  name)).         
0790: 28 70 72 6f 63 73 0a 20 20 20 20 20 20 20 20 20  (procs.         
07a0: 20 28 66 69 6c 74 65 72 20 69 64 65 6e 74 69 74   (filter identit
07b0: 79 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  y.              
07c0: 20 20 20 20 28 6d 61 70 0a 20 20 20 20 20 20 20      (map.       
07d0: 20 20 20 20 20 20 20 20 20 20 20 20 28 6d 61 74              (mat
07e0: 63 68 2d 6c 61 6d 62 64 61 20 0a 20 20 20 20 20  ch-lambda .     
07f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5b                 [
0800: 28 27 64 65 66 69 6e 65 20 28 27 75 73 65 73 20  ('define ('uses 
0810: 61 72 67 73 20 2e 2e 2e 29 20 62 6f 64 79 20 2e  args ...) body .
0820: 2e 2e 29 20 23 66 5d 20 3b 3b 20 66 69 6c 74 65  ..) #f] ;; filte
0830: 72 20 6f 75 74 20 28 64 65 66 69 6e 65 20 28 75  r out (define (u
0840: 73 65 73 20 2e 2e 2e 0a 20 20 20 20 20 20 20 20  ses ....        
0850: 20 20 20 20 20 20 20 20 20 20 20 20 5b 28 27 64              [('d
0860: 65 66 69 6e 65 20 28 27 75 6e 69 74 20 61 72 67  efine ('unit arg
0870: 73 20 2e 2e 2e 29 20 62 6f 64 79 20 2e 2e 2e 29  s ...) body ...)
0880: 20 23 66 5d 20 3b 3b 20 66 69 6c 74 65 72 20 6f   #f] ;; filter o
0890: 75 74 20 28 64 65 66 69 6e 65 20 28 75 6e 69 74  ut (define (unit
08a0: 20 2e 2e 2e 0a 20 20 20 20 20 20 20 20 20 20 20   ....           
08b0: 20 20 20 20 20 20 20 20 20 5b 28 27 64 65 66 69           [('defi
08c0: 6e 65 20 28 27 70 72 65 66 69 78 20 61 72 67 73  ne ('prefix args
08d0: 20 2e 2e 2e 29 20 62 6f 64 79 20 2e 2e 2e 29 20   ...) body ...) 
08e0: 23 66 5d 20 3b 3b 20 66 69 6c 74 65 72 20 6f 75  #f] ;; filter ou
08f0: 74 20 28 64 65 66 69 6e 65 20 28 70 72 65 66 69  t (define (prefi
0900: 78 20 2e 2e 2e 0a 20 20 20 20 20 20 20 20 20 20  x ....          
0910: 20 20 20 20 20 20 20 20 20 20 5b 28 27 64 65 66            [('def
0920: 69 6e 65 20 28 64 65 66 6e 61 6d 65 20 61 72 67  ine (defname arg
0930: 73 20 2e 2e 2e 29 20 62 6f 64 79 20 2e 2e 2e 29  s ...) body ...)
0940: 20 3b 3b 20 6d 61 74 63 68 20 28 64 65 66 69 6e   ;; match (defin
0950: 65 20 28 70 72 6f 63 6e 61 6d 65 20 3c 61 72 67  e (procname <arg
0960: 73 3e 29 20 3c 62 6f 64 79 3e 29 0a 20 20 20 20  s>) <body>).    
0970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0980: 20 28 69 66 20 28 61 74 6f 6d 3f 20 64 65 66 6e   (if (atom? defn
0990: 61 6d 65 29 20 3b 3b 20 66 69 6c 74 65 72 20 6f  ame) ;; filter o
09a0: 75 74 20 74 68 69 6e 67 73 20 77 65 20 64 6f 6e  ut things we don
09b0: 74 20 75 6e 64 65 72 73 74 61 6e 64 20 28 70 72  t understand (pr
09c0: 6f 63 6e 61 6d 65 20 69 73 20 61 20 6c 69 73 74  ocname is a list
09d0: 2c 20 77 68 61 74 3f 3f 29 0a 20 20 20 20 20 20  , what??).      
09e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
09f0: 20 20 20 28 6c 69 73 74 20 64 65 66 6e 61 6d 65     (list defname
0a00: 20 66 69 6c 65 6e 61 6d 65 20 61 72 67 73 20 62   filename args b
0a10: 6f 64 79 29 0a 20 20 20 20 20 20 20 20 20 20 20  ody).           
0a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 66                #f
0a30: 29 5d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  )].             
0a40: 20 20 20 20 20 20 20 5b 65 6c 73 65 20 23 66 5d         [else #f]
0a50: 20 29 20 73 63 6d 2d 74 72 65 65 29 29 29 29 0a   ) scm-tree)))).
0a60: 20 20 20 20 70 72 6f 63 73 29 29 0a 0a 0a 3b 3b      procs))...;;
0a70: 20 67 69 76 65 6e 20 61 20 73 65 78 70 2c 20 72   given a sexp, r
0a80: 65 74 75 72 6e 20 61 20 66 6c 61 74 20 6c 69 73  eturn a flat lis
0a90: 74 20 6f 66 20 61 74 6f 6d 73 20 69 6e 20 74 68  t of atoms in th
0aa0: 61 74 20 73 65 78 70 0a 28 64 65 66 69 6e 65 20  at sexp.(define 
0ab0: 28 67 65 74 2d 61 74 6f 6d 73 2d 69 6e 2d 62 6f  (get-atoms-in-bo
0ac0: 64 79 20 62 6f 64 79 29 0a 20 20 28 63 6f 6e 64  dy body).  (cond
0ad0: 0a 20 20 20 28 28 6e 75 6c 6c 3f 20 62 6f 64 79  .   ((null? body
0ae0: 29 20 27 28 29 29 0a 20 20 20 28 28 61 74 6f 6d  ) '()).   ((atom
0af0: 3f 20 62 6f 64 79 29 20 28 6c 69 73 74 20 62 6f  ? body) (list bo
0b00: 64 79 29 29 0a 20 20 20 28 65 6c 73 65 0a 20 20  dy)).   (else.  
0b10: 20 20 28 61 70 70 6c 79 20 61 70 70 65 6e 64 20    (apply append 
0b20: 28 6d 61 70 20 67 65 74 2d 61 74 6f 6d 73 2d 69  (map get-atoms-i
0b30: 6e 2d 62 6f 64 79 20 62 6f 64 79 29 29 29 29 29  n-body body)))))
0b40: 0a 0a 3b 3b 20 20 67 69 76 65 6e 20 61 20 66 69  ..;;  given a fi
0b50: 6c 65 2c 20 72 65 74 75 72 6e 20 61 20 6c 69 73  le, return a lis
0b60: 74 20 6f 66 20 70 72 6f 63 6e 61 6d 65 2c 20 66  t of procname, f
0b70: 69 6c 65 2c 20 6c 69 73 74 20 6f 66 20 61 74 6f  ile, list of ato
0b80: 6d 73 20 69 6e 20 73 61 69 64 20 70 72 6f 63 6e  ms in said procn
0b90: 61 6d 65 0a 28 64 65 66 69 6e 65 20 28 67 65 74  ame.(define (get
0ba0: 2d 70 72 6f 63 73 2b 66 69 6c 65 2b 61 74 6f 6d  -procs+file+atom
0bb0: 73 20 66 69 6c 65 29 0a 20 20 28 6c 65 74 2a 20  s file).  (let* 
0bc0: 28 28 74 6f 70 6c 65 76 65 6c 2d 70 72 6f 63 2d  ((toplevel-proc-
0bd0: 69 74 65 6d 73 20 28 67 65 74 2d 74 6f 70 6c 65  items (get-tople
0be0: 76 65 6c 2d 70 72 6f 63 73 2b 66 69 6c 65 2b 61  vel-procs+file+a
0bf0: 72 67 73 2b 62 6f 64 79 20 66 69 6c 65 29 29 0a  rgs+body file)).
0c00: 20 20 20 20 20 20 20 20 20 28 72 65 73 0a 20 20           (res.  
0c10: 20 20 20 20 20 20 20 20 28 6d 61 70 0a 20 20 20          (map.   
0c20: 20 20 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20          (lambda 
0c30: 28 69 74 65 6d 29 0a 20 20 20 20 20 20 20 20 20  (item).         
0c40: 20 20 20 20 28 6c 65 74 2a 20 28 28 70 72 6f 63      (let* ((proc
0c50: 20 28 63 61 72 20 69 74 65 6d 29 29 0a 20 20 20   (car item)).   
0c60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0c70: 20 28 66 69 6c 65 20 28 63 61 64 72 20 69 74 65   (file (cadr ite
0c80: 6d 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20  m)).            
0c90: 20 20 20 20 20 20 20 20 28 61 72 67 73 20 28 63          (args (c
0ca0: 61 64 64 72 20 69 74 65 6d 29 29 0a 20 20 20 20  addr item)).    
0cb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0cc0: 28 62 6f 64 79 20 28 63 61 64 64 64 72 20 69 74  (body (cadddr it
0cd0: 65 6d 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  em)).           
0ce0: 20 20 20 20 20 20 20 20 20 28 61 74 6f 6d 73 20           (atoms 
0cf0: 28 61 70 70 65 6e 64 20 28 67 65 74 2d 61 74 6f  (append (get-ato
0d00: 6d 73 2d 69 6e 2d 62 6f 64 79 20 61 72 67 73 29  ms-in-body args)
0d10: 20 28 67 65 74 2d 61 74 6f 6d 73 2d 69 6e 2d 62   (get-atoms-in-b
0d20: 6f 64 79 20 62 6f 64 79 29 29 29 29 0a 20 20 20  ody body)))).   
0d30: 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73              (lis
0d40: 74 20 70 72 6f 63 20 66 69 6c 65 20 61 74 6f 6d  t proc file atom
0d50: 73 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  s))).           
0d60: 74 6f 70 6c 65 76 65 6c 2d 70 72 6f 63 2d 69 74  toplevel-proc-it
0d70: 65 6d 73 29 29 29 0a 20 20 20 20 72 65 73 29 29  ems))).    res))
0d80: 0a 0a 3b 3b 20 75 6e 69 71 75 69 66 79 20 61 20  ..;; uniquify a 
0d90: 6c 69 73 74 20 6f 66 20 61 74 6f 6d 73 20 0a 28  list of atoms .(
0da0: 64 65 66 69 6e 65 20 28 75 6e 69 71 75 65 2d 61  define (unique-a
0db0: 74 6f 6d 73 20 6c 73 74 29 0a 20 20 28 6c 65 74  toms lst).  (let
0dc0: 20 6c 6f 6f 70 20 28 28 6c 73 74 20 28 66 6c 61   loop ((lst (fla
0dd0: 74 74 65 6e 20 6c 73 74 29 29 20 28 72 65 73 20  tten lst)) (res 
0de0: 27 28 29 29 29 0a 20 20 20 20 28 69 66 20 28 6e  '())).    (if (n
0df0: 75 6c 6c 3f 20 6c 73 74 29 0a 20 20 20 20 20 20  ull? lst).      
0e00: 20 20 28 72 65 76 65 72 73 65 20 72 65 73 29 0a    (reverse res).
0e10: 20 20 20 20 20 20 20 20 28 6c 65 74 20 28 28 63          (let ((c
0e20: 20 28 63 61 72 20 6c 73 74 29 29 29 0a 20 20 20   (car lst))).   
0e30: 20 20 20 20 20 20 20 28 6c 6f 6f 70 20 28 63 64         (loop (cd
0e40: 72 20 6c 73 74 29 20 28 69 66 20 28 6d 65 6d 62  r lst) (if (memb
0e50: 65 72 20 63 20 72 65 73 29 20 72 65 73 20 28 63  er c res) res (c
0e60: 6f 6e 73 20 63 20 72 65 73 29 29 29 29 29 29 29  ons c res)))))))
0e70: 0a 0a 3b 3b 20 67 69 76 65 6e 20 61 20 6c 69 73  ..;; given a lis
0e80: 74 20 6f 66 20 70 72 6f 63 6e 61 6d 65 2c 20 66  t of procname, f
0e90: 69 6c 65 6e 61 6d 65 2c 20 6c 69 73 74 20 6f 66  ilename, list of
0ea0: 20 70 72 6f 63 73 20 63 61 6c 6c 65 64 20 66 72   procs called fr
0eb0: 6f 6d 20 70 72 6f 63 6e 61 6d 65 2c 20 63 72 6f  om procname, cro
0ec0: 73 73 20 72 65 66 65 72 65 6e 63 65 20 61 6e 64  ss reference and
0ed0: 20 72 65 76 65 72 73 65 0a 3b 3b 20 72 65 74 75   reverse.;; retu
0ee0: 72 6e 69 6e 67 20 61 6c 69 73 74 20 6d 61 70 70  rning alist mapp
0ef0: 69 6e 67 20 70 72 6f 63 6e 61 6d 65 20 74 6f 20  ing procname to 
0f00: 70 72 6f 63 6e 61 6d 65 20 74 68 61 74 20 63 61  procname that ca
0f10: 6c 6c 73 20 73 61 69 64 20 70 72 6f 63 6e 61 6d  lls said procnam
0f20: 65 0a 28 64 65 66 69 6e 65 20 28 67 65 74 2d 63  e.(define (get-c
0f30: 61 6c 6c 65 72 73 2d 61 6c 69 73 74 20 61 6c 6c  allers-alist all
0f40: 2d 70 72 6f 63 73 2b 66 69 6c 65 2b 63 61 6c 6c  -procs+file+call
0f50: 73 29 0a 20 20 28 6c 65 74 2a 20 28 28 61 6c 6c  s).  (let* ((all
0f60: 2d 70 72 6f 63 73 20 28 6d 61 70 20 63 61 72 20  -procs (map car 
0f70: 61 6c 6c 2d 70 72 6f 63 73 2b 66 69 6c 65 2b 63  all-procs+file+c
0f80: 61 6c 6c 73 29 29 0a 20 20 20 20 20 20 20 20 20  alls)).         
0f90: 28 63 61 6c 6c 65 72 2d 68 74 20 28 6d 61 6b 65  (caller-ht (make
0fa0: 2d 68 61 73 68 2d 74 61 62 6c 65 29 29 29 20 0a  -hash-table))) .
0fb0: 20 20 20 20 3b 3b 20 6c 65 74 27 73 20 63 72 6f      ;; let's cro
0fc0: 73 73 20 72 65 66 65 72 65 6e 63 65 20 77 69 74  ss reference wit
0fd0: 68 20 61 20 68 61 73 68 20 74 61 62 6c 65 0a 20  h a hash table. 
0fe0: 20 20 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61     (for-each (la
0ff0: 6d 62 64 61 20 28 70 72 6f 63 29 20 28 68 61 73  mbda (proc) (has
1000: 68 2d 74 61 62 6c 65 2d 73 65 74 21 20 63 61 6c  h-table-set! cal
1010: 6c 65 72 2d 68 74 20 70 72 6f 63 20 27 28 29 29  ler-ht proc '())
1020: 29 20 61 6c 6c 2d 70 72 6f 63 73 29 0a 20 20 20  ) all-procs).   
1030: 20 28 66 6f 72 2d 65 61 63 68 20 28 6c 61 6d 62   (for-each (lamb
1040: 64 61 20 28 69 74 65 6d 29 0a 20 20 20 20 20 20  da (item).      
1050: 20 20 20 20 20 20 20 20 20 28 6c 65 74 2a 20 28           (let* (
1060: 28 70 72 6f 63 20 28 63 61 72 20 69 74 65 6d 29  (proc (car item)
1070: 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ).              
1080: 20 20 20 20 20 20 20 20 28 66 69 6c 65 20 28 63          (file (c
1090: 61 64 72 20 69 74 65 6d 29 29 0a 20 20 20 20 20  adr item)).     
10a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10b0: 20 28 63 61 6c 6c 73 20 28 63 61 64 64 72 20 69   (calls (caddr i
10c0: 74 65 6d 29 29 29 0a 20 20 20 20 20 20 20 20 20  tem))).         
10d0: 20 20 20 20 20 20 20 20 28 66 6f 72 2d 65 61 63          (for-eac
10e0: 68 20 28 6c 61 6d 62 64 61 20 28 63 61 6c 6c 65  h (lambda (calle
10f0: 65 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  e).             
1100: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1110: 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74 21  (hash-table-set!
1120: 20 63 61 6c 6c 65 72 2d 68 74 20 63 61 6c 6c 65   caller-ht calle
1130: 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  e.              
1140: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1150: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1160: 28 63 6f 6e 73 20 70 72 6f 63 0a 20 20 20 20 20  (cons proc.     
1170: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1180: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1190: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
11a0: 68 61 73 68 2d 74 61 62 6c 65 2d 72 65 66 20 63  hash-table-ref c
11b0: 61 6c 6c 65 72 2d 68 74 20 63 61 6c 6c 65 65 29  aller-ht callee)
11c0: 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20  ))).            
11d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63                 c
11e0: 61 6c 6c 73 29 29 29 0a 20 20 20 20 20 20 20 20  alls))).        
11f0: 20 20 20 20 20 20 61 6c 6c 2d 70 72 6f 63 73 2b        all-procs+
1200: 66 69 6c 65 2b 63 61 6c 6c 73 29 0a 20 20 20 20  file+calls).    
1210: 28 6d 61 70 20 28 6c 61 6d 62 64 61 20 28 78 29  (map (lambda (x)
1220: 0a 20 20 20 20 20 20 20 20 20 20 20 28 6c 65 74  .           (let
1230: 20 28 28 6b 20 28 63 61 72 20 78 29 29 0a 20 20   ((k (car x)).  
1240: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
1250: 72 20 28 75 6e 69 71 75 65 2d 61 74 6f 6d 73 20  r (unique-atoms 
1260: 28 63 64 72 20 78 29 29 29 29 0a 20 20 20 20 20  (cdr x)))).     
1270: 20 20 20 20 20 20 20 20 28 63 6f 6e 73 20 6b 20          (cons k 
1280: 72 29 29 29 20 20 20 20 20 20 20 20 20 20 20 20  r)))            
1290: 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 20 20          .       
12a0: 20 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 3e 61    (hash-table->a
12b0: 6c 69 73 74 20 63 61 6c 6c 65 72 2d 68 74 29 29  list caller-ht))
12c0: 29 29 0a 0a 3b 3b 20 63 72 65 61 74 65 20 61 20  ))..;; create a 
12d0: 68 61 6e 64 79 20 63 72 6f 73 73 2d 72 65 66 65  handy cross-refe
12e0: 72 65 6e 63 65 20 6f 66 20 63 61 6c 6c 65 65 73  rence of callees
12f0: 20 74 6f 20 63 61 6c 6c 65 72 73 20 69 6e 20 74   to callers in t
1300: 68 65 20 66 6f 72 6d 20 6f 66 20 61 6e 20 61 6c  he form of an al
1310: 69 73 74 2e 0a 28 64 65 66 69 6e 65 20 28 67 65  ist..(define (ge
1320: 74 2d 78 72 65 66 20 61 6c 6c 2d 73 63 6d 2d 66  t-xref all-scm-f
1330: 69 6c 65 73 29 0a 20 20 28 6c 65 74 2a 20 28 28  iles).  (let* ((
1340: 61 6c 6c 2d 70 72 6f 63 73 2b 66 69 6c 65 2b 61  all-procs+file+a
1350: 74 6f 6d 73 0a 20 20 20 20 20 20 20 20 20 20 28  toms.          (
1360: 61 70 70 6c 79 20 61 70 70 65 6e 64 20 28 6d 61  apply append (ma
1370: 70 20 67 65 74 2d 70 72 6f 63 73 2b 66 69 6c 65  p get-procs+file
1380: 2b 61 74 6f 6d 73 20 61 6c 6c 2d 73 63 6d 2d 66  +atoms all-scm-f
1390: 69 6c 65 73 29 29 29 0a 20 20 20 20 20 20 20 20  iles))).        
13a0: 20 28 61 6c 6c 2d 70 72 6f 63 73 20 28 6d 61 70   (all-procs (map
13b0: 20 63 61 72 20 61 6c 6c 2d 70 72 6f 63 73 2b 66   car all-procs+f
13c0: 69 6c 65 2b 61 74 6f 6d 73 29 29 0a 20 20 20 20  ile+atoms)).    
13d0: 20 20 20 20 20 28 61 6c 6c 2d 70 72 6f 63 73 2b       (all-procs+
13e0: 66 69 6c 65 2b 63 61 6c 6c 73 20 20 3b 20 70 72  file+calls  ; pr
13f0: 6f 63 20 63 61 6c 6c 73 20 74 68 69 6e 67 73 20  oc calls things 
1400: 69 6e 20 63 61 6c 6c 73 20 6c 69 73 74 0a 20 20  in calls list.  
1410: 20 20 20 20 20 20 20 20 28 6d 61 70 20 28 6c 61          (map (la
1420: 6d 62 64 61 20 28 69 74 65 6d 29 0a 20 20 20 20  mbda (item).    
1430: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 65               (le
1440: 74 2a 20 28 28 70 72 6f 63 20 28 63 61 72 20 69  t* ((proc (car i
1450: 74 65 6d 29 29 0a 20 20 20 20 20 20 20 20 20 20  tem)).          
1460: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 66                (f
1470: 69 6c 65 20 28 63 61 64 72 20 69 74 65 6d 29 29  ile (cadr item))
1480: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
1490: 20 20 20 20 20 20 20 20 20 28 61 74 6f 6d 73 20           (atoms 
14a0: 28 63 61 64 64 72 20 69 74 65 6d 29 29 0a 20 20  (caddr item)).  
14b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
14c0: 20 20 20 20 20 20 28 63 61 6c 6c 73 0a 20 20 20        (calls.   
14d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
14e0: 20 20 20 20 20 20 28 66 69 6c 74 65 72 20 69 64        (filter id
14f0: 65 6e 74 69 74 79 0a 20 20 20 20 20 20 20 20 20  entity.         
1500: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1510: 20 20 20 20 20 20 20 20 28 6d 61 70 0a 20 20 20          (map.   
1520: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1530: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
1540: 6c 61 6d 62 64 61 20 28 78 29 0a 20 20 20 20 20  lambda (x).     
1550: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1560: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28                 (
1570: 69 66 20 28 61 6e 64 20 3b 3b 20 28 6e 6f 74 20  if (and ;; (not 
1580: 28 65 71 75 61 6c 3f 20 78 20 70 72 6f 63 29 29  (equal? x proc))
1590: 20 20 3b 3b 20 75 6e 63 6f 6d 6d 65 6e 74 20 74    ;; uncomment t
15a0: 6f 20 70 72 65 76 65 6e 74 20 6c 69 73 74 69 6e  o prevent listin
15b0: 67 20 73 65 6c 66 0a 20 20 20 20 20 20 20 20 20  g self.         
15c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15e0: 28 6d 65 6d 62 65 72 20 78 20 61 6c 6c 2d 70 72  (member x all-pr
15f0: 6f 63 73 29 29 0a 20 20 20 20 20 20 20 20 20 20  ocs)).          
1600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1610: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 78 0a                x.
1620: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1630: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1640: 20 20 20 20 20 20 20 20 23 66 29 29 0a 20 20 20          #f)).   
1650: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1660: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 61                 a
1670: 74 6f 6d 73 29 29 29 29 0a 20 20 20 20 20 20 20  toms)))).       
1680: 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 69 73              (lis
1690: 74 20 70 72 6f 63 20 66 69 6c 65 20 63 61 6c 6c  t proc file call
16a0: 73 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  s))).           
16b0: 20 20 20 20 61 6c 6c 2d 70 72 6f 63 73 2b 66 69      all-procs+fi
16c0: 6c 65 2b 61 74 6f 6d 73 29 29 0a 20 20 20 20 20  le+atoms)).     
16d0: 20 20 20 20 28 63 61 6c 6c 65 72 73 20 28 67 65      (callers (ge
16e0: 74 2d 63 61 6c 6c 65 72 73 2d 61 6c 69 73 74 20  t-callers-alist 
16f0: 61 6c 6c 2d 70 72 6f 63 73 2b 66 69 6c 65 2b 63  all-procs+file+c
1700: 61 6c 6c 73 29 29 29 20 0a 20 20 20 20 63 61 6c  alls))) .    cal
1710: 6c 65 72 73 29 29 0a 0a 28 64 65 66 69 6e 65 20  lers))..(define 
1720: 28 67 65 74 2d 64 61 6e 67 6c 65 72 73 29 0a 20  (get-danglers). 
1730: 20 28 6c 65 74 2a 20 28 28 61 6c 6c 2d 73 63 6d   (let* ((all-scm
1740: 2d 66 69 6c 65 73 20 28 67 6c 6f 62 20 22 2a 2e  -files (glob "*.
1750: 73 63 6d 22 29 29 0a 20 20 20 20 20 20 20 20 20  scm")).         
1760: 28 78 72 65 66 20 28 67 65 74 2d 78 72 65 66 20  (xref (get-xref 
1770: 61 6c 6c 2d 73 63 6d 2d 66 69 6c 65 73 29 29 0a  all-scm-files)).
1780: 20 20 20 20 20 20 20 20 20 28 64 61 6e 67 6c 69           (dangli
1790: 6e 67 2d 70 72 6f 63 73 0a 20 20 20 20 20 20 20  ng-procs.       
17a0: 20 20 20 28 6d 61 70 20 63 61 72 20 28 66 69 6c     (map car (fil
17b0: 74 65 72 20 28 6c 61 6d 62 64 61 20 28 78 29 20  ter (lambda (x) 
17c0: 28 65 71 75 61 6c 3f 20 31 20 28 6c 65 6e 67 74  (equal? 1 (lengt
17d0: 68 20 78 29 29 29 20 78 72 65 66 29 29 29 29 0a  h x))) xref)))).
17e0: 20 20 20 20 64 61 6e 67 6c 69 6e 67 2d 70 72 6f      dangling-pro
17f0: 63 73 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72  cs))..(define (r
1800: 65 61 64 2d 69 67 6e 6f 72 65 2d 66 69 6c 65 20  ead-ignore-file 
1810: 66 6e 61 6d 65 29 0a 20 20 28 6c 65 74 20 28 28  fname).  (let ((
1820: 68 74 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61  ht (make-hash-ta
1830: 62 6c 65 29 29 29 0a 20 20 20 20 28 69 66 20 28  ble))).    (if (
1840: 66 69 6c 65 2d 65 78 69 73 74 73 3f 20 66 6e 61  file-exists? fna
1850: 6d 65 29 0a 09 28 66 6f 72 2d 65 61 63 68 0a 09  me)..(for-each..
1860: 20 28 6c 61 6d 62 64 61 20 28 78 29 0a 09 20 20   (lambda (x)..  
1870: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 73 65 74   (hash-table-set
1880: 21 20 68 74 20 78 20 23 74 29 29 0a 09 20 28 77  ! ht x #t)).. (w
1890: 69 74 68 2d 69 6e 70 75 74 2d 66 72 6f 6d 2d 66  ith-input-from-f
18a0: 69 6c 65 20 66 6e 61 6d 65 0a 09 20 20 20 72 65  ile fname..   re
18b0: 61 64 2d 6c 69 6e 65 73 29 29 29 0a 20 20 20 20  ad-lines))).    
18c0: 68 74 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 73  ht))..(define (s
18d0: 68 6f 77 2d 64 61 6e 67 6c 65 72 73 29 0a 20 20  how-danglers).  
18e0: 28 6c 65 74 20 28 28 69 67 6e 6f 72 65 73 20 20  (let ((ignores  
18f0: 20 20 20 28 72 65 61 64 2d 69 67 6e 6f 72 65 2d     (read-ignore-
1900: 66 69 6c 65 20 22 64 61 6e 67 6c 65 72 73 2d 74  file "danglers-t
1910: 6f 2d 69 67 6e 6f 72 65 2e 74 78 74 22 29 29 0a  o-ignore.txt")).
1920: 09 28 64 61 6e 67 6c 65 72 73 20 20 20 20 28 6d  .(danglers    (m
1930: 61 70 20 67 65 74 2d 73 74 61 74 73 20 28 67 65  ap get-stats (ge
1940: 74 2d 64 61 6e 67 6c 65 72 73 29 29 29 29 0a 20  t-danglers)))). 
1950: 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 69 67     ;; (print "ig
1960: 6e 6f 72 65 73 3a 20 22 20 28 68 61 73 68 2d 74  nores: " (hash-t
1970: 61 62 6c 65 2d 3e 61 6c 69 73 74 20 69 67 6e 6f  able->alist igno
1980: 72 65 73 29 29 0a 20 20 20 20 28 66 6f 72 2d 65  res)).    (for-e
1990: 61 63 68 20 28 6c 61 6d 62 64 61 20 28 64 61 6e  ach (lambda (dan
19a0: 67 6c 65 72 29 0a 09 09 28 6c 65 74 2a 20 28 28  gler)...(let* ((
19b0: 66 6e 6e 61 6d 65 20 28 63 6f 6e 63 20 28 63 61  fnname (conc (ca
19c0: 64 72 20 64 61 6e 67 6c 65 72 29 29 29 29 0a 09  dr dangler))))..
19d0: 09 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 66 6e  .  ;; (print "fn
19e0: 6e 61 6d 65 3d 22 66 6e 6e 61 6d 65 22 20 6d 65  name="fnname" me
19f0: 6d 62 65 72 3a 20 22 28 6d 65 6d 62 65 72 20 66  mber: "(member f
1a00: 6e 6e 61 6d 65 20 69 67 6e 6f 72 65 2d 6c 69 73  nname ignore-lis
1a10: 74 29 29 0a 09 09 20 20 28 69 66 20 28 6e 6f 74  t))...  (if (not
1a20: 20 28 68 61 73 68 2d 74 61 62 6c 65 2d 65 78 69   (hash-table-exi
1a30: 73 74 73 3f 20 69 67 6e 6f 72 65 73 20 66 6e 6e  sts? ignores fnn
1a40: 61 6d 65 29 29 0a 09 09 20 20 20 20 20 20 28 61  ame))...      (a
1a50: 70 70 6c 79 20 70 72 69 6e 74 20 28 69 6e 74 65  pply print (inte
1a60: 72 73 70 65 72 73 65 20 20 64 61 6e 67 6c 65 72  rsperse  dangler
1a70: 20 22 5c 74 22 29 29 0a 09 09 20 20 20 20 20 20   "\t"))...      
1a80: 23 3b 28 70 72 69 6e 74 20 22 73 6b 69 70 70 69  #;(print "skippi
1a90: 6e 67 20 22 66 6e 6e 61 6d 65 29 29 29 29 0a 09  ng "fnname))))..
1aa0: 20 20 20 20 20 20 28 73 6f 72 74 20 64 61 6e 67        (sort dang
1ab0: 6c 65 72 73 20 28 6c 61 6d 62 64 61 20 28 61 20  lers (lambda (a 
1ac0: 62 29 28 3c 20 28 63 61 72 20 61 29 28 63 61 72  b)(< (car a)(car
1ad0: 20 62 29 29 29 29 29 29 29 0a 0a 20 20 20 20 3b   b)))))))..    ;
1ae0: 3b 20 28 66 6f 72 2d 65 61 63 68 20 70 72 69 6e  ; (for-each prin
1af0: 74 20 64 61 6e 67 6c 69 6e 67 2d 70 72 6f 63 73  t dangling-procs
1b00: 29 20 3b 3b 20 6f 75 72 20 70 72 6f 64 75 63 74  ) ;; our product
1b10: 2e 0a 0a 28 64 65 66 69 6e 65 20 28 67 65 74 2d  ...(define (get-
1b20: 73 74 61 74 73 20 66 6e 29 0a 20 20 28 6c 65 74  stats fn).  (let
1b30: 2a 20 28 28 64 61 74 61 20 20 28 77 69 74 68 2d  * ((data  (with-
1b40: 69 6e 70 75 74 2d 66 72 6f 6d 2d 70 69 70 65 20  input-from-pipe 
1b50: 28 63 6f 6e 63 20 22 67 72 65 70 20 27 22 66 6e  (conc "grep '"fn
1b60: 22 27 20 2a 2e 73 63 6d 22 29 20 72 65 61 64 2d  "' *.scm") read-
1b70: 6c 69 6e 65 73 29 29 0a 09 20 28 66 69 6c 65 73  lines)).. (files
1b80: 20 28 64 65 6c 65 74 65 2d 64 75 70 6c 69 63 61   (delete-duplica
1b90: 74 65 73 0a 09 09 20 28 6d 61 70 20 28 6c 61 6d  tes... (map (lam
1ba0: 62 64 61 20 28 65 6e 74 72 79 29 0a 09 09 09 28  bda (entry)....(
1bb0: 63 61 72 20 28 73 74 72 69 6e 67 2d 73 70 6c 69  car (string-spli
1bc0: 74 20 65 6e 74 72 79 20 22 3a 22 29 29 29 0a 09  t entry ":")))..
1bd0: 09 20 20 20 20 20 20 64 61 74 61 29 29 29 29 0a  .      data)))).
1be0: 20 20 20 20 28 6c 69 73 74 20 28 6c 65 6e 67 74      (list (lengt
1bf0: 68 20 64 61 74 61 29 20 66 6e 20 66 69 6c 65 73  h data) fn files
1c00: 29 29 29 0a 0a 28 73 68 6f 77 2d 64 61 6e 67 6c  )))..(show-dangl
1c10: 65 72 73 29 0a 0a 20 20 20 20 0a                 ers)..    .