r11479: declare type
[umlisp.git] / parse-macros.lisp
index 6e006d816ef9a9fd4cd989b4c6cc7b949b8b8d92..1b00ae50fbd5639e17f31096e5b25ae14a7858f1 100644 (file)
@@ -26,7 +26,7 @@
        (delimited-string-to-list line #\| t))))
 
 (defun source-files (path)
-  (if (probe-file path) 
+  (if (probe-file path)
       (list path)
     (sort
      (directory (make-pathname :defaults path
@@ -47,7 +47,9 @@
     `(let ((,eof (gensym "EOFSYM-"))
           (,buffer (make-fields-buffer))
           (,files (source-files ,path)))
-       (with-open-file (,ustream (first ,files) :direction :input)
+       (with-open-file (,ustream (first ,files) :direction :input
+                        #+(and clisp unicode) :external-format
+                        #+(and clisp unicode) charset:utf-8)
         (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof)
                     (read-buffered-fields ,buffer ,ustream #\| ,eof)))
             ((eq ,line ,eof) t)
        (files (gensym "FILES-")))
     `(let ((,eof (gensym "EOFSYM-"))
           (,files (source-files ,path)))
-       (with-open-file (,ustream (first ,files) :direction :input)
-        (do ((,line (read-umls-line ,ustream ,eof)
-                    (read-umls-line ,ustream ,eof)))
-            ((eq ,line ,eof) t)
-          ,@body)))))
+      (unless ,files
+        (error "Can't find files for ~A~%" (namestring ,path)))
+      (with-open-file (,ustream (first ,files) :direction :input
+                       #+(and clisp unicode) :external-format
+                       #+(and clisp unicode) charset:utf-8)
+        (do ((,line (read-umls-line ,ustream ,eof)
+                    (read-umls-line ,ustream ,eof)))
+            ((eq ,line ,eof) t)
+          (locally (declare (type list ,line))
+                   ,@body))))))
 
 (defmacro with-umls-ufile ((line ufile) &body body)
   "Opens a UMLS and processes each parsed line with (body) argument"