1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 12:20:20 +02:00

Arrange so that 'file-encoding' does not truncate the encoding name.

Fixes <http://bugs.gnu.org/16463>.
Reported by Sree Harsha Totakura <sreeharsha@totakura.in>.

* libguile/read.c (ENCODING_NAME_MAX_SIZE): New macro.
  (SCM_ENCODING_SEARCH_SIZE): Change to 500 + ENCODING_NAME_MAX_SIZE.
  (scm_i_scan_for_encoding): Return NULL if there's less than
  ENCODING_NAME_MAX_SIZE bytes once "coding: *" has been read.
* test-suite/tests/coding.test ("line
  comment")["http://bugs.gnu.org/16463"]: New test.
This commit is contained in:
Ludovic Courtès 2014-01-17 18:18:41 +01:00
parent 802a25b1ed
commit 3ff8a9d6ff
2 changed files with 31 additions and 9 deletions

View file

@ -1,6 +1,6 @@
;;;; coding.test --- test suite for coding declarations. -*- mode: scheme -*-
;;;;
;;;; Copyright (C) 2011, 2013 Free Software Foundation, Inc.
;;;; Copyright (C) 2011, 2013, 2014 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
@ -101,4 +101,10 @@
(pass-if-equal "second line, whitespace, nl"
"ISO-8859-1"
(scan-coding "\n; coding: iso-8859-1 \n")))
(scan-coding "\n; coding: iso-8859-1 \n"))
(pass-if-equal "http://bugs.gnu.org/16463"
;; On Guile <= 2.0.9, this would return "ISO-8".
"ISO-8859-1"
(scan-coding (string-append (make-string 485 #\space)
"; coding: ISO-8859-1"))))