#!/usr/bin/scsh -s 
!#

; -*-scheme-*-

(define add-up
  (lambda (dir-name depth)

    (let* ((depth-str (number->string depth))
	   (str
	    (car (run/strings (| (find ,dir-name "-maxdepth" ,depth-str 
				       "(" -name "*.c" 
				       -o -name "*.cc"
				       -o -name "*.h"
				       -o -name "*.hh"
				       -o -name "*.cpp"
				       -o -name "configure.in"
				       -o -name "Makefile.am"
				       -o -name "*.m4"
				       -o -name "ChangeLog"
				       -o -name "*.tex"
				       ")")
				 (xargs wc -l)
				 (tail -1))))))
      
      (format #t "~s: ~s~%" dir-name str)

	; the number is the first part of the string, but after
        ; some spaces (which get transformed into "")
					; 
      (string->number (car (cdr ((infix-splitter) str)))))))


	 

; (let ((intl-dir-count (add-up "intl" 1))
;       ( all-dir-count (add-up "." 2)))

;   (format #t "Lines of code: ~s~%"
; 	  (- all-dir-count intl-dir-count)))


(format #t "Lines of code: ~s~%" (add-up "." 2))


	
