[commit: ghc] ghc-7.10: When iconv is unavailable, use an ASCII encoding to encode ASCII (2c67c68)

git at git.haskell.org git at git.haskell.org
Tue Jul 21 23:48:10 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/2c67c68eb93e7ca44a9eb66e287cfdec4d1bd24c/ghc

>---------------------------------------------------------------

commit 2c67c68eb93e7ca44a9eb66e287cfdec4d1bd24c
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Tue Jul 21 21:46:38 2015 +0200

    When iconv is unavailable, use an ASCII encoding to encode ASCII
    
    D898 and D1059 implemented a fallback behavior to handle the case
    that the end user's iconv installation is broken (typically due to
    running inside a chroot in which the necessary locale files and/or
    gconv modules have not been installed). In this case, if the
    program requests an ASCII locale, GHC's char8 encoding is used
    rather than the program failing.
    
    However, silently mangling data like char8 does when the programmer
    did not ask for it is poor behavior, for reasons described in D1059.
    
    This commit implements an ASCII encoding and uses it in the fallback
    case when iconv is unavailable and the user has requested ASCII.
    
    Test Plan:
    Added tests for the encodings defined in Latin1.
    Also, manually ran a statically-linked executable of that test
    in a chroot and the tests passed (up to the ones that call
    mkTextEncoding "LATIN1", since there is no fallback from iconv
    for that case yet).
    
    Reviewers: austin, hvr, hsyl20, bgamari
    
    Reviewed By: hsyl20, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1085
    
    GHC Trac Issues: #7695, #10623


>---------------------------------------------------------------

2c67c68eb93e7ca44a9eb66e287cfdec4d1bd24c
 libraries/base/GHC/IO/Encoding.hs          |  14 ++--
 libraries/base/GHC/IO/Encoding/Iconv.hs    |  25 +++++--
 libraries/base/GHC/IO/Encoding/Latin1.hs   |  83 ++++++++++++++++++++-
 libraries/base/GHC/TopHandler.hs           |   3 +-
 libraries/base/tests/.gitignore            |   1 +
 libraries/base/tests/IO/all.T              |   1 +
 libraries/base/tests/IO/encoding005.hs     | 115 +++++++++++++++++++++++++++++
 libraries/base/tests/IO/encoding005.stdout |   5 ++
 8 files changed, 227 insertions(+), 20 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 2c67c68eb93e7ca44a9eb66e287cfdec4d1bd24c


More information about the ghc-commits mailing list