From 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 29 Apr 2024 06:41:38 +0200 Subject: Adding upstream version 1.0.1. Signed-off-by: Daniel Baumann --- test cases/common/179 escape and unicode/file.c.in | 5 +++ test cases/common/179 escape and unicode/file.py | 10 ++++++ test cases/common/179 escape and unicode/find.py | 9 +++++ test cases/common/179 escape and unicode/fun.c | 3 ++ test cases/common/179 escape and unicode/main.c | 12 +++++++ .../common/179 escape and unicode/meson.build | 38 ++++++++++++++++++++++ 6 files changed, 77 insertions(+) create mode 100644 test cases/common/179 escape and unicode/file.c.in create mode 100644 test cases/common/179 escape and unicode/file.py create mode 100644 test cases/common/179 escape and unicode/find.py create mode 100644 test cases/common/179 escape and unicode/fun.c create mode 100644 test cases/common/179 escape and unicode/main.c create mode 100644 test cases/common/179 escape and unicode/meson.build (limited to 'test cases/common/179 escape and unicode') diff --git a/test cases/common/179 escape and unicode/file.c.in b/test cases/common/179 escape and unicode/file.c.in new file mode 100644 index 0000000..5dd6e50 --- /dev/null +++ b/test cases/common/179 escape and unicode/file.c.in @@ -0,0 +1,5 @@ +#include +const char* does_it_work(void) { + printf("{NAME}\n"); + return "yes it does"; +} diff --git a/test cases/common/179 escape and unicode/file.py b/test cases/common/179 escape and unicode/file.py new file mode 100644 index 0000000..40fa7ca --- /dev/null +++ b/test cases/common/179 escape and unicode/file.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +import sys +import os + +with open(sys.argv[1]) as fh: + content = fh.read().replace("{NAME}", sys.argv[2]) + +with open(os.path.join(sys.argv[3]), 'w', errors='replace') as fh: + fh.write(content) diff --git a/test cases/common/179 escape and unicode/find.py b/test cases/common/179 escape and unicode/find.py new file mode 100644 index 0000000..34a3eb8 --- /dev/null +++ b/test cases/common/179 escape and unicode/find.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +import os +import sys + +for fh in os.listdir('.'): + if os.path.isfile(fh): + if fh.endswith('.c'): + sys.stdout.write(fh + '\0') diff --git a/test cases/common/179 escape and unicode/fun.c b/test cases/common/179 escape and unicode/fun.c new file mode 100644 index 0000000..c5634d8 --- /dev/null +++ b/test cases/common/179 escape and unicode/fun.c @@ -0,0 +1,3 @@ +int a_fun(void) { + return 1; +} diff --git a/test cases/common/179 escape and unicode/main.c b/test cases/common/179 escape and unicode/main.c new file mode 100644 index 0000000..6137ad7 --- /dev/null +++ b/test cases/common/179 escape and unicode/main.c @@ -0,0 +1,12 @@ +#include + +const char* does_it_work(void); + +int a_fun(void); + +int main(void) { + if(strcmp(does_it_work(), "yes it does") != 0) { + return -a_fun(); + } + return 0; +} diff --git a/test cases/common/179 escape and unicode/meson.build b/test cases/common/179 escape and unicode/meson.build new file mode 100644 index 0000000..46c99d3 --- /dev/null +++ b/test cases/common/179 escape and unicode/meson.build @@ -0,0 +1,38 @@ +project('180 escape', 'c') + +gen = generator(find_program('file.py'), arguments:['@INPUT@', 'erd\u0151', '@OUTPUT@'], output: '@BASENAME@') + +gen_file = gen.process('file.c.in') + +find_file_list = run_command(find_program('find.py'), check: true) +assert(find_file_list.returncode() == 0, 'Didn\'t find any files.') + +# Strings should support both octal \ooo and hex \xhh encodings + +found_files_oct = [] +foreach l : find_file_list.stdout().strip('\0').split('\000') + found_files_oct += [files(l)] +endforeach + +test('first', executable('first', found_files_oct + [gen_file])) + +found_files_hex = [] +foreach l : find_file_list.stdout().strip('\x00').split('\x00') + found_files_hex += [files(l)] +endforeach + +test('second', executable('second', found_files_hex + [gen_file])) + +# Unrecognized and malformed escape sequences are literal + +malformed = [ + [ '\c', 'c' ], + [ '\Uabcdefghi', 'Uabcdefghi'], + [ '\u123 ', 'u123 '], + [ '\xqr', 'xqr'], +] + +foreach m : malformed + assert(m[0].endswith(m[1]), 'bad escape sequence had unexpected end') + assert(m[0].startswith('\\'), 'bad escape sequence had unexpected start') +endforeach -- cgit v1.2.3