diff options
author | Jim Blandy <jimb@red-bean.com> | 1999-06-09 12:54:59 +0000 |
---|---|---|
committer | Jim Blandy <jimb@red-bean.com> | 1999-06-09 12:54:59 +0000 |
commit | 2645b7b835293e8b16aaeda2bd18058430dc15e7 (patch) | |
tree | c2643382087fd99504bd2b6fa8e611620284e7c3 | |
parent | 51786bda60dcb2313b5da72265340c8f9167e009 (diff) | |
download | guile-2645b7b835293e8b16aaeda2bd18058430dc15e7.tar.gz |
* expect.scm (expect-regexec): define 'eof-next?'. I don't
know why it was missing. also don't peek for end of lines
unless expect-strings-exec-flags contains regexp/noteol.
(expect-strings-exec-flags): initialise to regexp/noteol.
-rw-r--r-- | ice-9/expect.scm | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/ice-9/expect.scm b/ice-9/expect.scm index 9c2ebd2bd..26ad197db 100644 --- a/ice-9/expect.scm +++ b/ice-9/expect.scm @@ -1,6 +1,4 @@ -;;; installed-scm-file - -;;;; Copyright (C) 1996, 1998 Free Software Foundation, Inc. +;;;; Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc. ;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -98,7 +96,7 @@ (define-public expect-strings-compile-flags regexp/newline) -(define-public expect-strings-exec-flags 0) +(define-public expect-strings-exec-flags regexp/noteol) ;;; the regexec front-end to expect: ;;; each test must evaluate to a regular expression. @@ -135,14 +133,20 @@ (pair? (car (select (list port) '() '() relative)))))) -;;; convert a match object to a list of strings, for the => syntax. +;;; return a regexp match as a list of strings, for the => syntax. (define-public (expect-regexec rx s port) - (let* ((flags (if eof-next? - expect-strings-exec-flags - (logior expect-strings-exec-flags regexp/noteol))) + ;; if expect-strings-exec-flags contains regexp/noteol, + ;; check whether at EOF. if so, remove regexp/noteol + (let* ((eof-next? + (and (logand expect-strings-exec-flags regexp/noteol) + (eof-object? (peek-char port)))) + (flags (if eof-next? + (logxor expect-strings-exec-flags regexp/noteol) + expect-strings-exec-flags)) (match (regexp-exec rx s 0 flags))) (if match (do ((i (- (match:count match) 1) (- i 1)) (result '() (cons (match:substring match i) result))) ((< i 0) result)) #f))) + |