-(defmacro with-buffered2-umls-file ((line filename) &body body)
-"Opens a UMLS and processes each parsed line with (body) argument"
- (let ((ustream (gensym))
- (buffer (gensym)))
- `(let ((,buffer (make-fields-buffer2)))
- (with-open-file
- (,ustream (umls-pathname ,filename)
- :direction :input :if-exists :overwrite)
- (do ((,line (read-buffered-fields2 ,buffer ,ustream) (read-buffered-fields2 ,buffer ,ustream)))
- ((eq ,line 'eof) t)
- ,@body)))))
+(defmacro with-reading-umls-file ((line path) &body body)
+ "Opens a UMLS and processes each parsed line with (body) argument"
+ (let ((ustream (gensym "STRM-"))
+ (eof (gensym "EOF-"))
+ (files (gensym "FILES-")))
+ `(let ((,eof (gensym "EOFSYM-"))
+ (,files (source-files ,path)))
+ (unless ,files
+ (error "Can't find file files for ~A~%" ,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)
+ ,@body)))))
+
+(defmacro with-umls-ufile ((line ufile) &body body)
+ "Opens a UMLS and processes each parsed line with (body) argument"
+ `(with-reading-umls-file (,line (ufile-pathname ,ufile))
+ ,@body))
+
+(defmacro with-umls-file ((line ufile) &body body)
+ "Opens a UMLS and processes each parsed line with (body) argument"
+ `(with-reading-umls-file (,line (umls-pathname ,ufile))
+ ,@body))
+
+(defmacro with-buffered-umls-file ((line filename) &body body)
+ "Opens a UMLS and processes each parsed line with (body) argument"
+ (let ((ustream (gensym "STRM-"))
+ (buffer (gensym "BUF-"))
+ (eof (gensym "EOF-")))
+ `(let ((,buffer (make-fields-buffer))
+ (,eof (gensym "EOFSYM-")))
+ (with-open-file
+ (,ustream (umls-pathname ,filename) :direction :input)
+ (do ((,line (read-buffered-fields ,buffer ,ustream #\| ,eof)
+ (read-buffered-fields ,buffer ,ustream #\| ,eof)))
+ ((eq ,line ,eof) t)
+ ,@body)))))
+