| 1 |
#!/bin/sh |
| 2 |
exec guile -q -s "$0" "$@" |
| 3 |
!# |
| 4 |
|
| 5 |
;; The use of certain identifiers as variable or parameter names has |
| 6 |
;; been found to cause build problems on particular platforms. The |
| 7 |
;; aim of this test is to cause "make check" to fail (on GNU/Linux, |
| 8 |
;; which most Guile developers use) if we accidentally add new code |
| 9 |
;; that uses those identifiers. |
| 10 |
|
| 11 |
(define bad-identifiers |
| 12 |
'( |
| 13 |
;; On AIX 5.2 and 5.3, /usr/include/sys/timer.h includes: |
| 14 |
;; #ifndef _LINUX_SOURCE_COMPAT |
| 15 |
;; #define func_data t_union.data |
| 16 |
;; #endif |
| 17 |
;; So we want to avoid using func_data in Guile source code. |
| 18 |
"func_data" |
| 19 |
|
| 20 |
;; More troublesome identifiers can be added into the list here. |
| 21 |
)) |
| 22 |
|
| 23 |
(use-modules (ice-9 regex) (ice-9 rdelim)) |
| 24 |
|
| 25 |
(define bad-id-regexp |
| 26 |
(make-regexp (string-append "\\<(" |
| 27 |
(string-join (map regexp-quote bad-identifiers) "|") |
| 28 |
")\\>"))) |
| 29 |
|
| 30 |
(define exit-status 0) |
| 31 |
|
| 32 |
;; Non-exported code from (ice-9 ftw). |
| 33 |
(define (directory-files dir) |
| 34 |
(let ((dir-stream (opendir dir))) |
| 35 |
(let loop ((new (readdir dir-stream)) |
| 36 |
(acc '())) |
| 37 |
(if (eof-object? new) |
| 38 |
(begin |
| 39 |
(closedir dir-stream) |
| 40 |
acc) |
| 41 |
(loop (readdir dir-stream) |
| 42 |
(if (or (string=? "." new) ;;; ignore |
| 43 |
(string=? ".." new)) ;;; ignore |
| 44 |
acc |
| 45 |
(cons (in-vicinity dir new) acc))))))) |
| 46 |
|
| 47 |
(let loop ((file-names (filter (lambda (fn) |
| 48 |
(and (or (string-suffix? ".h" fn) |
| 49 |
(string-suffix? ".c" fn)) |
| 50 |
(not (string-prefix? "." (basename fn))))) |
| 51 |
(directory-files "../../libguile")))) |
| 52 |
(or (null? file-names) |
| 53 |
(begin |
| 54 |
(with-input-from-file (car file-names) |
| 55 |
(lambda () |
| 56 |
(let loop ((linenum 1) (line (read-line))) |
| 57 |
(or (eof-object? line) |
| 58 |
(begin |
| 59 |
(if (regexp-exec bad-id-regexp line) |
| 60 |
(begin |
| 61 |
(set! exit-status 1) |
| 62 |
(format (current-error-port) |
| 63 |
"~a:~a: ~a\n" |
| 64 |
(car file-names) |
| 65 |
linenum |
| 66 |
line))) |
| 67 |
(loop (+ linenum 1) (read-line))))))) |
| 68 |
(loop (cdr file-names))))) |
| 69 |
|
| 70 |
(exit exit-status) |
| 71 |
|
| 72 |
;; Local Variables: |
| 73 |
;; mode: scheme |
| 74 |
;; End: |