Added test to check that backslashes are passed properly through the pipeline.

pull/351/head
Jussi Pakkanen 9 years ago
parent ea9b49438d
commit f1bf87ec8a
  1. 11
      ninjabackend.py
  2. 10
      test cases/common/104 backslash/comparer.c
  3. 3
      test cases/common/104 backslash/meson.build

@ -86,11 +86,10 @@ class NinjaBuildElement():
if len(self.orderdeps) > 0:
line += ' || ' + ' '.join([ninja_quote(x) for x in self.orderdeps])
line += '\n'
# This needs to be done to make these strings
# pass through arbitrary shells. Backslash is a
# quote character so it can break at any time.
# Because of this always use forward slashes,
# it is a path separator even on Windows.
# This is the only way I could find to make this work on all
# platforms including Windows command shell. Slash is a dir separator
# on Windows, too, so all characters are unambiguous and, more importantly,
# do not require quoting.
line = line.replace('\\', '/')
outfile.write(line)
@ -111,7 +110,7 @@ class NinjaBuildElement():
newelems.append(templ % ninja_quote(i))
line += ' '.join(newelems)
line += '\n'
line = line.replace('\\', '/')
line = line.replace('\\', '\\\\')
outfile.write(line)
outfile.write('\n')

@ -0,0 +1,10 @@
#include<string.h>
#include<stdio.h>
int main(int argc, char **argv) {
if(strcmp(DEF_WITH_BACKSLASH, "foo\\bar")) {
printf("Arg string is quoted incorrectly: %s\n", DEF_WITH_BACKSLASH);
return 1;
}
return 0;
}

@ -0,0 +1,3 @@
project('comparer', 'c')
test('backslash quoting', executable('comparer', 'comparer.c', c_args : '-DDEF_WITH_BACKSLASH="foo\\bar"'))
Loading…
Cancel
Save