forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure_file
: update \@ escape logic
Update meson logic to only handle matched pairs of \@ when escaping variables in 'meson' and 'cmake@' style configure_file invocations. The previous approach, using a regex to handle a single \@ to escape a variable has undesirable side effects, including mangling valid perl that needs to be configured. Closes: mesonbuild#7165
- Loading branch information
Showing
6 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
/* No escape */ | ||
#define MESSAGE1 "@var1@" | ||
|
||
/* Single escape means no replace */ | ||
#define MESSAGE2 "\@var1@" | ||
/* Escaped whole variable */ | ||
#define MESSAGE2 "\\@var1\\@" | ||
|
||
/* Replace pairs of escapes before '@' or '\@' with escape characters | ||
* (note we have to double number of pairs due to C string escaping) | ||
*/ | ||
#define MESSAGE3 "\\\\@var1@" | ||
|
||
/* Pairs of escapes and then single escape to avoid replace */ | ||
#define MESSAGE4 "\\\\\@var1@" | ||
|
||
/* Check escaped variable does not overlap following variable */ | ||
#define MESSAGE5 "\@var1@var2@" | ||
/* Pairs of escapes and then an escaped variable */ | ||
#define MESSAGE4 "\\\\\@var1\@" | ||
|
||
/* Check escape character outside variables */ | ||
#define MESSAGE6 "\\ @ \@ \\\\@ \\\\\@" | ||
#define MESSAGE5 "\\ @ \\\\@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
my @array = qw(1 2); | ||
use Data::Dumper; | ||
say Dumper(\@array); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
#include <string.h> | ||
#include <config6.h> | ||
#include <stdio.h> | ||
|
||
int main(void) { | ||
fprintf(stderr, "MESSAGE1 %s\n", MESSAGE1); | ||
fprintf(stderr, "MESSAGE2 %s\n", MESSAGE2); | ||
fprintf(stderr, "MESSAGE3 %s\n", MESSAGE3); | ||
fprintf(stderr, "MESSAGE4 %s\n", MESSAGE4); | ||
fprintf(stderr, "MESSAGE5 %s\n", MESSAGE5); | ||
|
||
return strcmp(MESSAGE1, "foo") | ||
|| strcmp(MESSAGE2, "@var1@") | ||
|| strcmp(MESSAGE3, "\\foo") | ||
|| strcmp(MESSAGE4, "\\@var1@") | ||
|| strcmp(MESSAGE5, "@var1bar") | ||
|| strcmp(MESSAGE6, "\\ @ @ \\@ \\@"); | ||
|| strcmp(MESSAGE5, "\\ @ \\@"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,4 @@ configure_file( | |
input: '../test.py.in', | ||
output: 'no_write_conflict.txt', | ||
configuration: conf | ||
) | ||
) |