Jim Blandy reported some small problems with the meta-arg Scheme parser.

This commit is contained in:
shivers 1997-04-19 19:12:37 +00:00
parent 5c5ae4dc99
commit 41bf8dad3f
4 changed files with 33 additions and 20 deletions

View File

@ -142,3 +142,7 @@ Alan Bawden has reported a lot of bugs 4/97:
crashing the system. crashing the system.
set-file-group had bugs (uid/gid args were transposed in the syscall) set-file-group had bugs (uid/gid args were transposed in the syscall)
meta.scm was blowing up on illegal numeric escapes like \3Q in meta-arg lines.
Was also not recognizing the whole set of C escapes (e.g. \n, \a, \f).
Jim Blandy reported the bug, with fixes for the second problem, 4/97.

View File

@ -26,3 +26,6 @@ euler@lavielle.COM (Lutz Euler) 2/24/97
Alan Bawden 4/97 Alan Bawden 4/97
Lots of good bug reports and fixes. Lots of good bug reports and fixes.
Jim Blandy 4/97
Fixes for meta.scm

View File

@ -73,7 +73,7 @@ There is a new command-line switch,
-sfd <num> -sfd <num>
which causes scsh to read its script from file descriptor <num>. which causes scsh to read its script from file descriptor <num>.
Scheme 48's floating point support was inadvertently omitted from the last Scheme 48's floating-point support was inadvertently omitted from the last
release. It has been reinstated. release. It has been reinstated.
The regular expression system has been sped up. Regular-expression The regular expression system has been sped up. Regular-expression
@ -81,12 +81,12 @@ compilation is now provided, and the AWK macro has been rewritten to
pre-compile regexps used in rules outside the loop. It is still, however, pre-compile regexps used in rules outside the loop. It is still, however,
slower than it should be. slower than it should be.
We have introduced two new procedures for our Perl fans, for performing We have introduced two new procedures for performing regexp-directed
regexp-directed string substitutions: string substitutions:
regexp-substitute regexp-substitute
regexp-substitute/global regexp-substitute/global
The design is not what you might expect, but they are quite powerful The design differs from what one finds in systems such as sed or perl,
and efficient. and is quite powerful.
Execing programs should be faster in this release, since we now use the Execing programs should be faster in this release, since we now use the
CLOEXEC status bit to get automatic closing of unrevealed port file CLOEXEC status bit to get automatic closing of unrevealed port file
@ -96,10 +96,10 @@ descriptors.
-------- --------
We received many bug reports, improvements, fixes and suggestions from scsh We received many bug reports, improvements, fixes and suggestions from scsh
users. In particular, we'd like to thank Alan Bawden, Michael Becker, Jin users. In particular, we'd like to thank Alan Bawden, Michael Becker, Jim
Choi, Sean Doran, Lutz Euler, Kevin Esler, Rolf-Thomas Happe, David Hull, Blandy, Jin Choi, Sean Doran, Lutz Euler, Kevin Esler, Rolf-Thomas Happe,
Shriram Krishnamurthi, Tod Olson, Michel Schinz, Bill Sommerfeld, Mike David Hull, Shriram Krishnamurthi, Tod Olson, Michel Schinz, Bill Sommerfeld,
Sperber, and Victor Zandy for their contributions to this release. Mike Sperber, and Victor Zandy for their contributions to this release.
Thanks, guys; we really appreciate the feedback. Thanks, guys; we really appreciate the feedback.

View File

@ -94,7 +94,13 @@
(define (read-backslash-sequence port) (define (read-backslash-sequence port)
(let ((c1 (read-char port)) (let ((c1 (read-char port))
(eof-lose (lambda () (error "Premature EOF within backslash-sequence in meta-arg argument line")))) (eof-lose (lambda () (error "Premature EOF within backslash-sequence in meta-arg argument line")))
(octet->int (lambda (c)
(cond ((eof-object? c) (eof-lose))
((char-set-contains? char-set:octal-digits c)
(- (char->ascii c) (char->ascii #\0)))
(else (error "Non-octal-digit in \\nnn escape sequence in meta-arg argument line." c))))))
(cond ((eof-object? c1) (eof-lose)) (cond ((eof-object? c1) (eof-lose))
;; This would be better handled by a char-map abstraction. ;; This would be better handled by a char-map abstraction.
@ -102,26 +108,23 @@
((char=? c1 #\r) carriage-return) ((char=? c1 #\r) carriage-return)
((char=? c1 #\t) tab) ((char=? c1 #\t) tab)
((char=? c1 #\b) backspace) ((char=? c1 #\b) backspace)
;; ...whatever. Look up complete table. ((char=? c1 #\a) alert)
((char=? c1 #\f) form-feed)
((char=? c1 #\v) vertical-tab)
;; \, space, tab, newline. ;; \, space, tab, newline.
((char-set-contains? char-set:simple-knockdown c1) c1) ((char-set-contains? char-set:simple-knockdown c1) c1)
((char-set-contains? char-set:octal-digits c1) ((char-set-contains? char-set:octal-digits c1)
(let ((c2 (read-char port))) (let* ((o64 (octet->int c1))
(if (eof-object? c2) (eof-lose) (o8 (octet->int (read-char port)))
(let ((c3 (read-char port))) (o1 (octet->int (read-char port))))
(if (eof-object? c3) (eof-lose) (ascii->char (+ o1 (* 8 (+ o8 (* 8 o64)))))))
(ascii->char (+ (octet->int c3)
(* 8 (+ (octet->int c2)
(* 8 (octet->int c1)))))))))))
(else (error "Illegal \\ escape sequence in meta-arg argument line." (else (error "Illegal \\ escape sequence in meta-arg argument line."
c1))))) c1)))))
(define (octet->int c) (- (char->ascii c) (char->ascii #\0)))
(define char-set:octal-digits (char-set #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7)) (define char-set:octal-digits (char-set #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7))
(define char-set:simple-knockdown (string->char-set "\\ \n\t")) (define char-set:simple-knockdown (string->char-set "\\ \n\t"))
@ -130,3 +133,6 @@
(define tab (ascii->char 9)) (define tab (ascii->char 9))
(define carriage-return (ascii->char 13)) (define carriage-return (ascii->char 13))
(define backspace (ascii->char 8)) (define backspace (ascii->char 8))
(define alert (ascii->char 7))
(define form-feed (ascii->char 12))
(define vertical-tab (ascii->char 11))