cmake: Remove strange bytes used for converting Makefiles #1275

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@ligfx
Contributor
ligfx commented Feb 21, 2017

An alternative solution that came out of discussion on #1271. The strange bytes are used to mark escaped newlines so that they can be converted back after processing. However, text editors and other programs tend to silently change these characters in CMakeLists.txt or complain. This is a cosmetic concern for generated files (which I assume no-one reads), so let's remove it entirely.

@ligfx, thanks for your PR! By analyzing the history of the files in this pull request, we identified @billhoffman, @Sukender and @jzakrzewski to be potential reviewers.

@bagder bagder added the cmake label Feb 22, 2017
@webmaster128

I tested this PR and support it (modulo the minor change request).

The resulting files are still safe for human consumption. The missing newlines only affect file lists and not the overall document or the license header. See both versions here: https://gist.github.com/webmaster128/6caba8a76052ea240a2e86077bf569bf

CMakeLists.txt
@@ -1043,9 +1043,8 @@ function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
- string(REGEX REPLACE "\\\\\n" "§!§" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ string(REGEX REPLACE "\\\\\n" "" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
webmaster128
webmaster128 Feb 24, 2017 Contributor

The replacement string should be " " instead of "" to be safe in cases where you have

XY_FILES = progress.h\
formdata.h

which would get converted to

XY_FILES = progress.hformdata.h

Even if this is not happening in current Makefile.inc files, an author of such a file expects that a whitespace is set when writing \↵.

webmaster128
webmaster128 Feb 24, 2017 Contributor

Sorry, I was wrong here. \↵ means breaking without adding whitespace. Confirm the Makefile

command2:
        ech\
o 123

where echo 123 is executed instead of ech o 123.

webmaster128
webmaster128 Feb 24, 2017 Contributor

Okay, now it is getting strange. The rule does not apply for variable definitions. The Makefile

AVAR = 12\
34

command2:
        echo "${AVAR}"
        echo -n "${AVAR}" | hexdump -C

gives me the newline converted to a space

$ make command2
echo "12 34"
12 34
echo -n "12 34" | hexdump -C
00000000  31 32 20 33 34                                    |12 34|
00000005
ligfx
ligfx Feb 24, 2017 Contributor

Good catch! Fixed.

@webmaster128

👍

@ligfx ligfx cmake: Remove strange bytes used for converting Makefiles
A solution that came out of discussion on #1271. The strange bytes are
used to mark escaped newlines so that they can be converted back after
processing. However, text editors and other programs tend to silently
change these characters in CMakeLists.txt or complain. This is a
cosmetic concern for generated files (which I assume no-one reads), so
let's remove it entirely.
17db8e9
@jay jay added a commit that closed this pull request Feb 25, 2017
@webmaster128 @jay webmaster128 + jay cmake: Replace invalid UTF-8 byte sequence
- Change the encoding of the regex temp placeholder token to UTF-8.

Prior to this change the file contained special chars in a different
encoding than ASCII or UTF-8 making text editors and Python complain
when reading the file.

Closes #1271
Closes #1275
bbc81c4
@jay jay closed this in bbc81c4 Feb 25, 2017
Owner
jay commented Feb 25, 2017

Thanks guys but I went with #1271 instead because the changes are minimal and it doesn't make the output difficult to read. Whether anyone is reading them I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment