1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

read: Use "invalid" rather than "illegal".

* libguile/read.c (scm_read_string_like_syntax): All characters are
permitted by law; some aren't valid in certain contexts.
* test-suite/tests/reader.test: Replace occurrences of "illegal" by
"invalid".
* test-suite/tests/strings.test: Likewise.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-06-04 21:26:23 +02:00 committed by Ludovic Courtès
parent a15acbb828
commit 52809cc630
3 changed files with 20 additions and 20 deletions

View file

@ -704,7 +704,7 @@ scm_read_string_like_syntax (int chr, SCM port, scm_t_read_opts *opts)
break;
bad_escaped:
scm_i_input_error (FUNC_NAME, port,
"illegal character in escape sequence: ~S",
"invalid character in escape sequence: ~S",
scm_list_1 (SCM_MAKE_CHAR (c)));
}
}

View file

@ -1,6 +1,6 @@
;;;; reader.test --- Reader test. -*- coding: iso-8859-1; mode: scheme -*-
;;;;
;;;; Copyright (C) 1999, 2001-2003, 2007-2011, 2013-2015
;;;; Copyright (C) 1999, 2001-2003, 2007-2011, 2013-2015, 2020
;;;; Free Software Foundation, Inc.
;;;;
;;;; Jim Blandy <jimb@red-bean.com>
@ -40,8 +40,8 @@
(cons 'read-error "end of file in string constant$"))
(define exception:eof-in-symbol
(cons 'read-error "end of file while reading symbol$"))
(define exception:illegal-escape
(cons 'read-error "illegal character in escape sequence: .*$"))
(define exception:invalid-escape
(cons 'read-error "invalid character in escape sequence: .*$"))
(define exception:missing-expression
(cons 'read-error "no expression after #;"))
(define exception:mismatched-paren
@ -234,8 +234,8 @@
(pass-if-exception "eof in string"
exception:eof-in-string
(read-string "\"the string that never ends"))
(pass-if-exception "illegal escape in string"
exception:illegal-escape
(pass-if-exception "invalid escape in string"
exception:invalid-escape
(read-string "\"some string \\???\"")))
@ -304,31 +304,31 @@
(with-test-prefix "r6rs-hex-escapes"
(pass-if-exception "non-hex char in two-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-read-options '(r6rs-hex-escapes)
(lambda ()
(with-input-from-string "\"\\x0g;\"" read))))
(pass-if-exception "non-hex char in four-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-read-options '(r6rs-hex-escapes)
(lambda ()
(with-input-from-string "\"\\x000g;\"" read))))
(pass-if-exception "non-hex char in six-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-read-options '(r6rs-hex-escapes)
(lambda ()
(with-input-from-string "\"\\x00000g;\"" read))))
(pass-if-exception "no semicolon at termination of one-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-read-options '(r6rs-hex-escapes)
(lambda ()
(with-input-from-string "\"\\x0\"" read))))
(pass-if-exception "no semicolon at termination of three-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-read-options '(r6rs-hex-escapes)
(lambda ()
(with-input-from-string "\"\\x000\"" read))))

View file

@ -1,7 +1,7 @@
;;;; strings.test --- test suite for Guile's string functions -*- scheme -*-
;;;; Jim Blandy <jimb@red-bean.com> --- August 1999
;;;;
;;;; Copyright (C) 1999,2001,2004-2006,2008-2011,2013,2015,2018
;;;; Copyright (C) 1999,2001,2004-2006,2008-2011,2013,2015,2018,2020
;;;; Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
@ -25,8 +25,8 @@
(define exception:read-only-string
(cons 'misc-error "^string is read-only"))
(define exception:illegal-escape
(cons 'read-error "illegal character in escape sequence"))
(define exception:invalid-escape
(cons 'read-error "invalid character in escape sequence"))
;; Create a string from integer char values, eg. (string-ints 65) => "A"
(define (string-ints . args)
@ -197,27 +197,27 @@
(with-test-prefix "escapes"
(pass-if-exception "non-hex char in two-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-input-from-string "\"\\x0g\"" read))
(pass-if-exception "non-hex char in four-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-input-from-string "\"\\u000g\"" read))
(pass-if-exception "non-hex char in six-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-input-from-string "\"\\U00000g\"" read))
(pass-if-exception "premature termination of two-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-input-from-string "\"\\x0\"" read))
(pass-if-exception "premature termination of four-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-input-from-string "\"\\u000\"" read))
(pass-if-exception "premature termination of six-digit hex-escape"
exception:illegal-escape
exception:invalid-escape
(with-input-from-string "\"\\U00000\"" read))
(pass-if "extra hex digits ignored for two-digit hex escape"