Replace pairs of backslashes before '@' or '\@' with singles (allows escaping the escape character). Do not consume next '@' after '\@'.pull/2691/head
parent
325b2c25b6
commit
91a0126590
4 changed files with 63 additions and 13 deletions
@ -0,0 +1,19 @@ |
||||
/* No escape */ |
||||
#define MESSAGE1 "@var1@" |
||||
|
||||
/* Single escape means no replace */ |
||||
#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@" |
||||
|
||||
/* Check escape character outside variables */ |
||||
#define MESSAGE6 "\\ @ \@ \\\\@ \\\\\@" |
@ -0,0 +1,11 @@ |
||||
#include <string.h> |
||||
#include <config6.h> |
||||
|
||||
int main(int argc, char **argv) { |
||||
return strcmp(MESSAGE1, "foo") |
||||
|| strcmp(MESSAGE2, "@var1@") |
||||
|| strcmp(MESSAGE3, "\\foo") |
||||
|| strcmp(MESSAGE4, "\\@var1@") |
||||
|| strcmp(MESSAGE5, "@var1bar") |
||||
|| strcmp(MESSAGE6, "\\ @ @ \\@ \\@"); |
||||
} |
Loading…
Reference in new issue