fix reversion
In 793ddecd4b
, writeSshConfig was made to
writeFile a ByteString, which lost the newline conversion on Windows.
Added linesFile to fix it. This will also be useful for other writeFile
conversions.
This commit is contained in:
parent
7a94ba1bf2
commit
de1af273e0
2 changed files with 20 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
{- misc utility functions
|
||||
-
|
||||
- Copyright 2010-2011 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2025 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- License: BSD-2-clause
|
||||
-}
|
||||
|
@ -18,6 +18,8 @@ module Utility.Misc (
|
|||
firstLine',
|
||||
fileLines,
|
||||
fileLines',
|
||||
linesFile,
|
||||
linesFile',
|
||||
segment,
|
||||
segmentDelim,
|
||||
massReplace,
|
||||
|
@ -113,6 +115,22 @@ fileLines' = map stripCR . S8.lines
|
|||
fileLines' = S8.lines
|
||||
#endif
|
||||
|
||||
-- One windows, writeFile does NewlineMode translation,
|
||||
-- adding CR before LF. When converting to ByteString, use this to emulate that.
|
||||
linesFile :: L.ByteString -> L.ByteString
|
||||
#ifndef mingw32_HOST_OS
|
||||
linesFile = id
|
||||
#else
|
||||
linesFile = L8.concat . concatMap (\x -> [x, L8.pack "\r\n"]) . fileLines
|
||||
#endif
|
||||
|
||||
linesFile' :: S.ByteString -> S.ByteString
|
||||
#ifndef mingw32_HOST_OS
|
||||
linesFile' = id
|
||||
#else
|
||||
linesFile' = S8.concat . concatMap (\x -> [x, S8.pack "\r\n"]) . fileLines'
|
||||
#endif
|
||||
|
||||
{- Splits a list into segments that are delimited by items matching
|
||||
- a predicate. (The delimiters are not included in the segments.)
|
||||
- Segments may be empty. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue