Changeset 1201
- Timestamp:
- 01/08/08 22:21:26 (7 months ago)
- Files:
-
- 1.8.3/branches/devel/utils/columnize.scm (modified) (6 diffs)
- 1.8.3/branches/devel/utils/typedefs.scm (modified) (5 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/utils/columnize.scm
r1198 r1201 1 #!/usr/local/bin/csi -script 1 #!/usr/local/bin/csi -script 2 #| !# ; |# 2 3 ;;; Formats words in columns for inclusion in help files. 4 5 ;; Works with chicken or guile 3 6 4 7 ;; Reads from standard input, prints to standard output. Intended to … … 11 14 ;; Something like :jfadskjfq423jram utils/columnize.scm 12 15 ;; 16 ;; (Or, using guile instead of chicken: guile -s utils/columize.scm) 17 ;; 13 18 ;; Compiled instead of interpeted: 14 19 ;; csc -o columize -O2 utils/columnize.scm 15 ;; 20 ;; (display "|") 16 21 ;; This is similar to column(1) but that doesn't always work the way 17 22 ;; we need. This does. … … 26 31 ((and chicken csi) 27 32 (use srfi-1 srfi-13 regex)) 28 (else #t)) 33 (guile 34 (use-modules (srfi srfi-1) (srfi srfi-13) (ice-9 regex) 35 (ice-9 rdelim)) 36 (define fx= =) 37 (define fx+ +) 38 (define fx< <) 39 (define fx> >) 40 (define fxmax max) 41 (define (read-lines) 42 (let loop ((line (read-line)) 43 (accum '())) 44 (if (eof-object? line) 45 (reverse accum) 46 (loop (read-line) (cons line accum))))) 47 (define-macro (define-constant sym val) 48 `(define ,sym ,val)) 49 (define (string-split-fields re str) 50 (map match:substring (list-matches re str))))) 29 51 30 52 (define-constant line-width 78) … … 39 61 (drop-while (lambda (w) (fx= (string-length w) 0)) 40 62 (sort 41 (string-split-fields " \\s+"42 (string-join (read-lines) " ") #:infix)63 (string-split-fields "[A-Za-z0-9_@()-]+" 64 (string-join (read-lines) " ")) 43 65 string-ci<?))) 44 66 (define max-word-length (fold (lambda (w len) … … 49 71 50 72 (define (print-word word column) 51 (cond 73 (cond 52 74 ((fx= column 1) 53 75 (display " ") … … 62 84 1))) 63 85 64 ( unless (fx=(fold print-word 1 words) 1) (newline))86 (if (fx> (fold print-word 1 words) 1) (newline)) 65 87 66 88 1.8.3/branches/devel/utils/typedefs.scm
- Property svn:executable set to *
r807 r1201 1 #!/usr/bin/env csi -script # -*-scheme-*- 1 #!/usr/local/bin/csi -script 2 #| !# ; |# 3 2 4 ; Print out a list of all typedefs in the src in a format suitable for 3 5 ; using in the indent rule for src/Makefile. Requires chicken scheme. 4 6 ; http://call-with-current-continuation.org or your package manager. 5 7 ; 8 ; Also works with guile 1.8 9 ; 6 10 ; Written by Raevnos <shawnw@speakeasy.org> for PennMUSH. 7 11 ; 8 ; Version 0.9. 1.12 ; Version 0.9.2 9 13 ; 10 14 ; Usage: … … 19 23 ; You can also use it as an interpreted script: 20 24 ; % csi -script utils/typedefs.scm < src/TAGS > indent.defs 25 ; or 26 ; % guile -s utils/typedefs.scm < src/TAGS > indent.defs 21 27 ; or 22 28 ; % chmod +x typedefs.scm … … 50 56 (require-extension srfi-1) 51 57 (require-extension srfi-13)) 52 (else #f)) 58 (guile 59 (use-modules (srfi srfi-1) (srfi srfi-13) (ice-9 rdelim) 60 (ice-9 format)) 61 (define fx>= >=) 62 (define fx+ +) 63 (define fx= =) 64 (define signal throw) 65 (define (for-each-line f in-port) 66 (let loop ((line (read-line in-port))) 67 (if (not (eof-object? line)) 68 (begin 69 (f line) 70 (loop (read-line in-port)))))) 71 (define-macro (handle-exceptions exn handler body) 72 `(catch #t 73 (lambda () ,body) 74 (lambda (,exn) ,handler))) 75 (define-macro (printf fmtstr . args) 76 `(format #t ,fmtstr ,@args)) 77 (define-macro (define-constant sym val) 78 `(define ,sym ,val)))) 53 79 54 80 … … 68 94 69 95 ; The special characters that mark the start and end of an identifier 70 (define-constant type-start #\x7F)71 (define-constant type-end #\x01)96 (define-constant type-start (integer->char 127)) 97 (define-constant type-end (integer->char 1))) 72 98 73 99 ; Either return a typedef name or a symbol : 'line-did-not-match or … … 142 168 ; Control pretty-printing of the typedefs. 143 169 (define-constant max-column-width 75) 144 (define-constant tab-stop 8) 170 (define-constant tab-stop 8)) 145 171 146 172 ; Print out one typedef to stdout, formated as indent args.
