diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2019-02-13 08:43:35 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-02-15 18:35:28 -0500 |
commit | 173d0cee84ef944059a473b1425e48062739988f (patch) | |
tree | 7e48418c8741ebbe57db2f4ac5c95a5ac94e8b3a /compiler/utils/StringBuffer.hs | |
parent | 887454d8889ca5dbba70425de41d97939cb9ac60 (diff) | |
download | haskell-173d0cee84ef944059a473b1425e48062739988f.tar.gz |
Properly escape character literals in Haddocks
Character literals in Haddock should not be written as plain `'\n'` since
single quotes are for linking identifiers. Besides, since we want the
character literal to be monospaced, we really should use `@\'\\n\'@`.
[skip ci]
Diffstat (limited to 'compiler/utils/StringBuffer.hs')
-rw-r--r-- | compiler/utils/StringBuffer.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/utils/StringBuffer.hs b/compiler/utils/StringBuffer.hs index a5fc4e7f12..64578bffde 100644 --- a/compiler/utils/StringBuffer.hs +++ b/compiler/utils/StringBuffer.hs @@ -81,7 +81,7 @@ data StringBuffer cur :: {-# UNPACK #-} !Int -- current pos } -- The buffer is assumed to be UTF-8 encoded, and furthermore - -- we add three '\0' bytes to the end as sentinels so that the + -- we add three @\'\\0\'@ bytes to the end as sentinels so that the -- decoder doesn't have to check for overflow at every single byte -- of a multibyte sequence. @@ -187,7 +187,7 @@ stringToStringBuffer str = -- the remaining portion (analogous to 'Data.List.uncons'). __Warning:__ The -- behavior is undefined if the 'StringBuffer' is empty. The result shares -- the same buffer as the original. Similar to 'utf8DecodeChar', if the --- character cannot be decoded as UTF-8, '\0' is returned. +-- character cannot be decoded as UTF-8, @\'\\0\'@ is returned. {-# INLINE nextChar #-} nextChar :: StringBuffer -> (Char,StringBuffer) nextChar (StringBuffer buf len (I# cur#)) = @@ -202,7 +202,7 @@ nextChar (StringBuffer buf len (I# cur#)) = -- | Return the first UTF-8 character of a nonempty 'StringBuffer' (analogous -- to 'Data.List.head'). __Warning:__ The behavior is undefined if the -- 'StringBuffer' is empty. Similar to 'utf8DecodeChar', if the character --- cannot be decoded as UTF-8, '\0' is returned. +-- cannot be decoded as UTF-8, @\'\\0\'@ is returned. currentChar :: StringBuffer -> Char currentChar = fst . nextChar @@ -285,7 +285,7 @@ skipToLine !line !len !op0 = go 1 op0 -- | Decode the first @n@ bytes of a 'StringBuffer' as UTF-8 into a 'String'. -- Similar to 'utf8DecodeChar', if the character cannot be decoded as UTF-8, --- they will be replaced with '\0'. +-- they will be replaced with @\'\\0\'@. lexemeToString :: StringBuffer -> Int -- ^ @n@, the number of bytes -> String |