aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2019-01-23 21:43:14 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-01-24 21:02:34 +0200
commit8df5afc98aae6863d1fc24d902dc4e31141a1711 (patch)
treeb0eeae0a152e4cd97143fd5f7f270c773743b62a /mesonbuild/mesonlib.py
parentb45c367d922a0a6baa134f59a7b900390cb3fe7b (diff)
downloadmeson-8df5afc98aae6863d1fc24d902dc4e31141a1711.zip
meson-8df5afc98aae6863d1fc24d902dc4e31141a1711.tar.gz
meson-8df5afc98aae6863d1fc24d902dc4e31141a1711.tar.bz2
configure_file: preserve newlines of the input file. Fixes #4817
In some cases (see #4817) it's helpful if the output file uses the same newlines as the input file without translating them to the platform defaults. open() by default recognizes all newline styles and translates them to "\n" and then to the platform default when writing. Passing "" to "newline" disables the translation and lets us pass through the original newline characters.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 98c2366..2170fec 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -729,7 +729,7 @@ def do_mesondefine(line, confdata):
def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
try:
- with open(src, encoding=encoding) as f:
+ with open(src, encoding=encoding, newline='') as f:
data = f.readlines()
except Exception as e:
raise MesonException('Could not read input file %s: %s' % (src, str(e)))
@@ -763,7 +763,7 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
result.append(line)
dst_tmp = dst + '~'
try:
- with open(dst_tmp, 'w', encoding=encoding) as f:
+ with open(dst_tmp, 'w', encoding=encoding, newline='') as f:
f.writelines(result)
except Exception as e:
raise MesonException('Could not write output file %s: %s' % (dst, str(e)))