From 41bf8dad3f3315e1c2d49338fe6dffa5dcfa5ddb Mon Sep 17 00:00:00 2001 From: shivers Date: Sat, 19 Apr 1997 19:12:37 +0000 Subject: [PATCH] Jim Blandy reported some small problems with the meta-arg Scheme parser. --- Error-log | 4 ++++ doc/scsh-manual/THANKS | 3 +++ doc/scsh-release-0.5 | 18 +++++++++--------- scsh/meta-arg.scm | 28 +++++++++++++++++----------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Error-log b/Error-log index 88ad7c1..859b999 100644 --- a/Error-log +++ b/Error-log @@ -142,3 +142,7 @@ Alan Bawden has reported a lot of bugs 4/97: crashing the system. 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. diff --git a/doc/scsh-manual/THANKS b/doc/scsh-manual/THANKS index b9606cf..83ec42b 100644 --- a/doc/scsh-manual/THANKS +++ b/doc/scsh-manual/THANKS @@ -26,3 +26,6 @@ euler@lavielle.COM (Lutz Euler) 2/24/97 Alan Bawden 4/97 Lots of good bug reports and fixes. + +Jim Blandy 4/97 + Fixes for meta.scm diff --git a/doc/scsh-release-0.5 b/doc/scsh-release-0.5 index 0415145..1d41b56 100644 --- a/doc/scsh-release-0.5 +++ b/doc/scsh-release-0.5 @@ -73,7 +73,7 @@ There is a new command-line switch, -sfd which causes scsh to read its script from file descriptor . -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. 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, slower than it should be. -We have introduced two new procedures for our Perl fans, for performing -regexp-directed string substitutions: +We have introduced two new procedures for performing regexp-directed +string substitutions: regexp-substitute regexp-substitute/global -The design is not what you might expect, but they are quite powerful -and efficient. +The design differs from what one finds in systems such as sed or perl, +and is quite powerful. Execing programs should be faster in this release, since we now use the 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 -users. In particular, we'd like to thank Alan Bawden, Michael Becker, Jin -Choi, Sean Doran, Lutz Euler, Kevin Esler, Rolf-Thomas Happe, David Hull, -Shriram Krishnamurthi, Tod Olson, Michel Schinz, Bill Sommerfeld, Mike -Sperber, and Victor Zandy for their contributions to this release. +users. In particular, we'd like to thank Alan Bawden, Michael Becker, Jim +Blandy, Jin Choi, Sean Doran, Lutz Euler, Kevin Esler, Rolf-Thomas Happe, +David Hull, Shriram Krishnamurthi, Tod Olson, Michel Schinz, Bill Sommerfeld, +Mike Sperber, and Victor Zandy for their contributions to this release. Thanks, guys; we really appreciate the feedback. diff --git a/scsh/meta-arg.scm b/scsh/meta-arg.scm index f20866e..216db6d 100644 --- a/scsh/meta-arg.scm +++ b/scsh/meta-arg.scm @@ -94,7 +94,13 @@ (define (read-backslash-sequence 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)) ;; This would be better handled by a char-map abstraction. @@ -102,26 +108,23 @@ ((char=? c1 #\r) carriage-return) ((char=? c1 #\t) tab) ((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. ((char-set-contains? char-set:simple-knockdown c1) c1) ((char-set-contains? char-set:octal-digits c1) - (let ((c2 (read-char port))) - (if (eof-object? c2) (eof-lose) - (let ((c3 (read-char port))) - (if (eof-object? c3) (eof-lose) - (ascii->char (+ (octet->int c3) - (* 8 (+ (octet->int c2) - (* 8 (octet->int c1))))))))))) + (let* ((o64 (octet->int c1)) + (o8 (octet->int (read-char port))) + (o1 (octet->int (read-char port)))) + (ascii->char (+ o1 (* 8 (+ o8 (* 8 o64))))))) (else (error "Illegal \\ escape sequence in meta-arg argument line." 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:simple-knockdown (string->char-set "\\ \n\t")) @@ -130,3 +133,6 @@ (define tab (ascii->char 9)) (define carriage-return (ascii->char 13)) (define backspace (ascii->char 8)) +(define alert (ascii->char 7)) +(define form-feed (ascii->char 12)) +(define vertical-tab (ascii->char 11))