Skip to content

data-to-c.py: autodetect line endings

Aleksandr Mezin requested to merge amezin/glib:fix-data-to-c-line-endings into master

When GLib code is checked out with Windows line endings (happens on Windows), data-to-c.py embedded that line endings into generated string literal. And then they translated to double newlines in glib-compile-resources output.

clang-cl failed to compile such files because of empty lines in the middle of multiline macros:

#define G_MSVC_CTOR(_func,_sym_prefix) \

  static void _func(void); \

To fix the issue, enable 'universal newlines' mode when reading the input in data-to-c.py - translate both '\n' and '\r\n' to '\n'.

Fixes #2340 (closed)

Edited by Aleksandr Mezin

Merge request reports