1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-21 03:00:19 +02:00

Use encoding-error' instead of misc-error' for string encoding errors.

* libguile/strings.c (scm_encoding_error): New function.
  (scm_from_stringn, scm_to_stringn): Use it instead of `scm_misc_error ()'.

* test-suite/lib.scm (exception:encoding-error): Adjust accordingly.

* test-suite/tests/encoding-escapes.test (exception:conversion):
  Remove.  Use `exception:encoding-error' instead.

* test-suite/tests/encoding-iso88591.test: Likewise.

* test-suite/tests/encoding-iso88597.test: Likewise.

* test-suite/tests/encoding-utf8.test: Likewise.
This commit is contained in:
Ludovic Courtès 2010-01-07 00:37:10 +01:00
parent 7b0419128b
commit a3d7d5d508
6 changed files with 32 additions and 34 deletions

View file

@ -269,7 +269,7 @@ with-locale with-locale*
(define exception:system-error
(cons 'system-error ".*"))
(define exception:encoding-error
(cons 'misc-error "(cannot convert to output locale|input locale conversion error)"))
(cons 'encoding-error "(cannot convert to output locale|input locale conversion error)"))
(define exception:miscellaneous-error
(cons 'misc-error "^.*"))
(define exception:read-error

View file

@ -1,6 +1,6 @@
;;;; encoding-escapes.test --- test suite for Guile's string encodings -*- mode: scheme; coding: utf-8 -*-
;;;;
;;;; Copyright (C) 2009 Free Software Foundation, Inc.
;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -20,9 +20,6 @@
#:use-module (test-suite lib)
#:use-module (srfi srfi-1))
(define exception:conversion
(cons 'misc-error "^cannot convert to output locale"))
;; Create a string from integer char values, eg. (string-ints 65) => "A"
(define (string-ints . args)
(apply string (map integer->char args)))
@ -71,14 +68,14 @@
(with-test-prefix "display output errors"
(pass-if-exception "ultima"
exception:conversion
exception:encoding-error
(let ((pt (open-output-string)))
(set-port-encoding! pt "ASCII")
(set-port-conversion-strategy! pt 'error)
(display s1 pt)))
(pass-if-exception "Rashomon"
exception:conversion
exception:encoding-error
(let ((pt (open-output-string)))
(set-port-encoding! pt "ASCII")
(set-port-conversion-strategy! pt 'error)

View file

@ -1,6 +1,6 @@
;;;; encoding-iso88591.test --- test suite for Guile's string encodings -*- mode: scheme; coding: iso-8859-1 -*-
;;;;
;;;; Copyright (C) 2009 Free Software Foundation, Inc.
;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -20,9 +20,6 @@
#:use-module (test-suite lib)
#:use-module (srfi srfi-1))
(define exception:conversion
(cons 'misc-error "^cannot convert to output locale"))
;; Create a string from integer char values, eg. (string-ints 65) => "A"
(define (string-ints . args)
(apply string (map integer->char args)))
@ -167,7 +164,7 @@
(with-test-prefix "output errors"
(pass-if-exception "char 256" exception:conversion
(pass-if-exception "char 256" exception:encoding-error
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(set-port-conversion-strategy! pt 'error)

View file

@ -1,6 +1,6 @@
;;;; encoding-iso88697.test --- test suite for Guile's string encodings -*- mode: scheme; coding: iso-8859-7 -*-
;;;;
;;;; Copyright (C) 2009 Free Software Foundation, Inc.
;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -20,9 +20,6 @@
#:use-module (test-suite lib)
#:use-module (srfi srfi-1))
(define exception:conversion
(cons 'misc-error "^cannot convert to output locale"))
;; Create a string from integer char values, eg. (string-ints 65) => "A"
(define (string-ints . args)
(apply string (map integer->char args)))
@ -165,7 +162,7 @@
(with-test-prefix "output errors"
(pass-if-exception "char #x0400"
exception:conversion
exception:encoding-error
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(set-port-conversion-strategy! pt 'error)

View file

@ -1,6 +1,6 @@
;;;; encoding-utf8.test --- test suite for Guile's string encodings -*- mode: scheme; coding: utf-8 -*-
;;;;
;;;; Copyright (C) 2009 Free Software Foundation, Inc.
;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -20,9 +20,6 @@
#:use-module (test-suite lib)
#:use-module (srfi srfi-1))
(define exception:conversion
(cons 'misc-error "^cannot convert to output locale"))
;; Create a string from integer char values, eg. (string-ints 65) => "A"
(define (string-ints . args)
(apply string (map integer->char args)))