Add tradcpp to the repository, and use it as GENCPP (generic preprocessor)
With lots of experimenting, tradcpp (0.4) seems to work way better than gcc, and it's output is actually valid. We'll go with that for now.
This commit is contained in:
1
cde/util/tradcpp/tests/subdir/test.h
Normal file
1
cde/util/tradcpp/tests/subdir/test.h
Normal file
@@ -0,0 +1 @@
|
||||
hello
|
||||
1
cde/util/tradcpp/tests/t01.c
Normal file
1
cde/util/tradcpp/tests/t01.c
Normal file
@@ -0,0 +1 @@
|
||||
glop.
|
||||
1
cde/util/tradcpp/tests/t01.good
Normal file
1
cde/util/tradcpp/tests/t01.good
Normal file
@@ -0,0 +1 @@
|
||||
glop.
|
||||
2
cde/util/tradcpp/tests/t02.c
Normal file
2
cde/util/tradcpp/tests/t02.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define glop flop
|
||||
glop
|
||||
1
cde/util/tradcpp/tests/t02.good
Normal file
1
cde/util/tradcpp/tests/t02.good
Normal file
@@ -0,0 +1 @@
|
||||
flop
|
||||
2
cde/util/tradcpp/tests/t03.c
Normal file
2
cde/util/tradcpp/tests/t03.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define glop(x) flop x
|
||||
glop(boo)
|
||||
1
cde/util/tradcpp/tests/t03.good
Normal file
1
cde/util/tradcpp/tests/t03.good
Normal file
@@ -0,0 +1 @@
|
||||
flop boo
|
||||
2
cde/util/tradcpp/tests/t04.c
Normal file
2
cde/util/tradcpp/tests/t04.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define string(x) "x"
|
||||
string(abc)
|
||||
1
cde/util/tradcpp/tests/t04.good
Normal file
1
cde/util/tradcpp/tests/t04.good
Normal file
@@ -0,0 +1 @@
|
||||
"abc"
|
||||
2
cde/util/tradcpp/tests/t05.c
Normal file
2
cde/util/tradcpp/tests/t05.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define concat(a, b) a/**/b
|
||||
concat(abc,def)
|
||||
1
cde/util/tradcpp/tests/t05.good
Normal file
1
cde/util/tradcpp/tests/t05.good
Normal file
@@ -0,0 +1 @@
|
||||
abcdef
|
||||
2
cde/util/tradcpp/tests/t06.c
Normal file
2
cde/util/tradcpp/tests/t06.c
Normal file
@@ -0,0 +1,2 @@
|
||||
/*glop*/
|
||||
|
||||
1
cde/util/tradcpp/tests/t06.good
Normal file
1
cde/util/tradcpp/tests/t06.good
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
3
cde/util/tradcpp/tests/t07.c
Normal file
3
cde/util/tradcpp/tests/t07.c
Normal file
@@ -0,0 +1,3 @@
|
||||
/*
|
||||
* gloop
|
||||
*/
|
||||
1
cde/util/tradcpp/tests/t07.good
Normal file
1
cde/util/tradcpp/tests/t07.good
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
41
cde/util/tradcpp/tests/t08.c
Normal file
41
cde/util/tradcpp/tests/t08.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*#include <stdio.h>*/
|
||||
|
||||
int d =
|
||||
#if 2 > 1 ? 0 : 0 ? 1 : 1
|
||||
1
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
;
|
||||
|
||||
int e =
|
||||
#if (2 > 1 ? 0 : 0) ? 1 : 1
|
||||
1
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
;
|
||||
|
||||
int f =
|
||||
#if 2 > 1 ? 0 : (0 ? 1 : 1)
|
||||
1
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int a, b, c;
|
||||
|
||||
a = 2 > 1 ? 0 : 0 ? 1 : 1;
|
||||
b = (2 > 1 ? 0 : 0) ? 1 : 1;
|
||||
c = 2 > 1 ? 0 : (0 ? 1 : 1);
|
||||
|
||||
printf("%d %d %d\n", a, b, c);
|
||||
printf("%d %d %d\n", d, e, f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
cde/util/tradcpp/tests/t08.good
Normal file
21
cde/util/tradcpp/tests/t08.good
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
int d =
|
||||
0
|
||||
;
|
||||
int e =
|
||||
1
|
||||
;
|
||||
int f =
|
||||
0
|
||||
;
|
||||
int
|
||||
main()
|
||||
{
|
||||
int a, b, c;
|
||||
a = 2 > 1 ? 0 : 0 ? 1 : 1;
|
||||
b = (2 > 1 ? 0 : 0) ? 1 : 1;
|
||||
c = 2 > 1 ? 0 : (0 ? 1 : 1);
|
||||
printf("%d %d %d\n", a, b, c);
|
||||
printf("%d %d %d\n", d, e, f);
|
||||
return 0;
|
||||
}
|
||||
6
cde/util/tradcpp/tests/t09.c
Normal file
6
cde/util/tradcpp/tests/t09.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#define STOP */
|
||||
#define START /*
|
||||
|
||||
/*
|
||||
* blah blah blah STOP fnord START goop moop
|
||||
*/
|
||||
0
cde/util/tradcpp/tests/t09.good
Normal file
0
cde/util/tradcpp/tests/t09.good
Normal file
3
cde/util/tradcpp/tests/t10.c
Normal file
3
cde/util/tradcpp/tests/t10.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define mac(r)o
|
||||
mac(3)
|
||||
mac()
|
||||
2
cde/util/tradcpp/tests/t10.good
Normal file
2
cde/util/tradcpp/tests/t10.good
Normal file
@@ -0,0 +1,2 @@
|
||||
o
|
||||
o
|
||||
2
cde/util/tradcpp/tests/t11.c
Normal file
2
cde/util/tradcpp/tests/t11.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define BOO BOO
|
||||
BOO
|
||||
1
cde/util/tradcpp/tests/t11.good
Normal file
1
cde/util/tradcpp/tests/t11.good
Normal file
@@ -0,0 +1 @@
|
||||
BOO
|
||||
2
cde/util/tradcpp/tests/t12.c
Normal file
2
cde/util/tradcpp/tests/t12.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define BOO(yah) BOO(yah)
|
||||
BOO(yah)
|
||||
1
cde/util/tradcpp/tests/t12.good
Normal file
1
cde/util/tradcpp/tests/t12.good
Normal file
@@ -0,0 +1 @@
|
||||
BOO(yah)
|
||||
4
cde/util/tradcpp/tests/t13.c
Normal file
4
cde/util/tradcpp/tests/t13.c
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
#define FOO BAR
|
||||
*/
|
||||
FOO
|
||||
2
cde/util/tradcpp/tests/t13.good
Normal file
2
cde/util/tradcpp/tests/t13.good
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
FOO
|
||||
4
cde/util/tradcpp/tests/t14.c
Normal file
4
cde/util/tradcpp/tests/t14.c
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
#define FOO BAR */
|
||||
FOO
|
||||
FOO
|
||||
3
cde/util/tradcpp/tests/t14.good
Normal file
3
cde/util/tradcpp/tests/t14.good
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
FOO
|
||||
FOO
|
||||
3
cde/util/tradcpp/tests/t15.c
Normal file
3
cde/util/tradcpp/tests/t15.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define FOO /* BAR */ BAZ
|
||||
FOO
|
||||
FOO
|
||||
2
cde/util/tradcpp/tests/t15.good
Normal file
2
cde/util/tradcpp/tests/t15.good
Normal file
@@ -0,0 +1,2 @@
|
||||
BAZ
|
||||
BAZ
|
||||
11
cde/util/tradcpp/tests/t16.c
Normal file
11
cde/util/tradcpp/tests/t16.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#define a() x
|
||||
a()
|
||||
a ()
|
||||
#define b(p) p
|
||||
x/**/b(1)/**/x
|
||||
x/**/b (1)/**/x
|
||||
x/**/b()/**/x
|
||||
#define c(p,q) p/**/q
|
||||
x/**/c(1,2)/**/x
|
||||
x/**/c(1)/**/x
|
||||
x/**/c()/**/x
|
||||
11
cde/util/tradcpp/tests/t16.good
Normal file
11
cde/util/tradcpp/tests/t16.good
Normal file
@@ -0,0 +1,11 @@
|
||||
x
|
||||
x
|
||||
x1x
|
||||
x1x
|
||||
xx
|
||||
x12x
|
||||
t16.c:10:1: Wrong number of arguments for macro c; found 1, expected 2
|
||||
x1x
|
||||
t16.c:11:1: Wrong number of arguments for macro c; found 0, expected 2
|
||||
xx
|
||||
FAILED
|
||||
2
cde/util/tradcpp/tests/t17.c
Normal file
2
cde/util/tradcpp/tests/t17.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define file "subdir/test.h"
|
||||
#include file
|
||||
1
cde/util/tradcpp/tests/t17.good
Normal file
1
cde/util/tradcpp/tests/t17.good
Normal file
@@ -0,0 +1 @@
|
||||
hello
|
||||
2
cde/util/tradcpp/tests/t18.c
Normal file
2
cde/util/tradcpp/tests/t18.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#if FOO /* ignore me */
|
||||
#endif
|
||||
0
cde/util/tradcpp/tests/t18.good
Normal file
0
cde/util/tradcpp/tests/t18.good
Normal file
3
cde/util/tradcpp/tests/t19.c
Normal file
3
cde/util/tradcpp/tests/t19.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#define foo /* comment continues
|
||||
into the next line */ baz
|
||||
baz
|
||||
1
cde/util/tradcpp/tests/t19.good
Normal file
1
cde/util/tradcpp/tests/t19.good
Normal file
@@ -0,0 +1 @@
|
||||
baz
|
||||
1
cde/util/tradcpp/tests/t20.c
Normal file
1
cde/util/tradcpp/tests/t20.c
Normal file
@@ -0,0 +1 @@
|
||||
#undef foo /* blah */
|
||||
0
cde/util/tradcpp/tests/t20.good
Normal file
0
cde/util/tradcpp/tests/t20.good
Normal file
3
cde/util/tradcpp/tests/t21.c
Normal file
3
cde/util/tradcpp/tests/t21.c
Normal file
@@ -0,0 +1,3 @@
|
||||
# define FOO BAR
|
||||
#undef FOO /* would be wrong */
|
||||
FOO
|
||||
2
cde/util/tradcpp/tests/t21.good
Normal file
2
cde/util/tradcpp/tests/t21.good
Normal file
@@ -0,0 +1,2 @@
|
||||
#undef BAR
|
||||
BAR
|
||||
2
cde/util/tradcpp/tests/t22.c
Normal file
2
cde/util/tradcpp/tests/t22.c
Normal file
@@ -0,0 +1,2 @@
|
||||
pa/*
|
||||
*/ste
|
||||
1
cde/util/tradcpp/tests/t22.good
Normal file
1
cde/util/tradcpp/tests/t22.good
Normal file
@@ -0,0 +1 @@
|
||||
paste
|
||||
8
cde/util/tradcpp/tests/t23.c
Normal file
8
cde/util/tradcpp/tests/t23.c
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
fnord1
|
||||
/*
|
||||
fnord2
|
||||
*/
|
||||
foo
|
||||
*/
|
||||
bar
|
||||
4
cde/util/tradcpp/tests/t23.good
Normal file
4
cde/util/tradcpp/tests/t23.good
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
foo
|
||||
*/
|
||||
bar
|
||||
67
cde/util/tradcpp/tests/t24.c
Normal file
67
cde/util/tradcpp/tests/t24.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#if 0
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
right
|
||||
#endif
|
||||
|
||||
#if -1
|
||||
right
|
||||
#endif
|
||||
|
||||
#if 0 + 0
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 1 + 1
|
||||
right
|
||||
#endif
|
||||
|
||||
#if 1 - 1
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if -1 + 1
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 3 - 2 - 1
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 3 * 2 - 6
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 6 - 2 * 3
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 3 - 3 && 1
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 3 - 3 || 0
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 1 && 0
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 0 && 1
|
||||
wrong
|
||||
#endif
|
||||
|
||||
#if 1 || 0
|
||||
right
|
||||
#endif
|
||||
|
||||
#if 0 || 1
|
||||
right
|
||||
#endif
|
||||
|
||||
#if (0 || 1) && (0 || 0)
|
||||
wrong
|
||||
#endif
|
||||
5
cde/util/tradcpp/tests/t24.good
Normal file
5
cde/util/tradcpp/tests/t24.good
Normal file
@@ -0,0 +1,5 @@
|
||||
right
|
||||
right
|
||||
right
|
||||
right
|
||||
right
|
||||
4
cde/util/tradcpp/tests/t25.c
Normal file
4
cde/util/tradcpp/tests/t25.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#define FOO foo /*
|
||||
#undef FOO
|
||||
#define FOO bar */
|
||||
FOO
|
||||
1
cde/util/tradcpp/tests/t25.good
Normal file
1
cde/util/tradcpp/tests/t25.good
Normal file
@@ -0,0 +1 @@
|
||||
foo
|
||||
4
cde/util/tradcpp/tests/t26.c
Normal file
4
cde/util/tradcpp/tests/t26.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#define FOO foo
|
||||
FOO
|
||||
"FOO"
|
||||
'FOO'
|
||||
3
cde/util/tradcpp/tests/t26.good
Normal file
3
cde/util/tradcpp/tests/t26.good
Normal file
@@ -0,0 +1,3 @@
|
||||
foo
|
||||
"FOO"
|
||||
'FOO'
|
||||
29
cde/util/tradcpp/tests/t27.c
Normal file
29
cde/util/tradcpp/tests/t27.c
Normal file
@@ -0,0 +1,29 @@
|
||||
1.
|
||||
#define A(a) a
|
||||
A();
|
||||
|
||||
2.
|
||||
#define B(a, b) (a,b)
|
||||
B(a, );
|
||||
B(, b);
|
||||
B( , );
|
||||
B(a,);
|
||||
B(,b);
|
||||
B(,);
|
||||
|
||||
3.
|
||||
#define C(a, b, c) (a,b,c)
|
||||
C(a, b, );
|
||||
C(a, , c);
|
||||
C(, , c);
|
||||
C(a, , );
|
||||
C(, b, );
|
||||
C(, , c);
|
||||
C(, , )
|
||||
C(a,b,);
|
||||
C(a,,c);
|
||||
C(,,c);
|
||||
C(a,,);
|
||||
C(,b,);
|
||||
C(,,c);
|
||||
C(,,)
|
||||
24
cde/util/tradcpp/tests/t27.good
Normal file
24
cde/util/tradcpp/tests/t27.good
Normal file
@@ -0,0 +1,24 @@
|
||||
1.
|
||||
;
|
||||
2.
|
||||
(a, );
|
||||
(, b);
|
||||
( , );
|
||||
(a,);
|
||||
(,b);
|
||||
(,);
|
||||
3.
|
||||
(a, b, );
|
||||
(a, , c);
|
||||
(, , c);
|
||||
(a, , );
|
||||
(, b, );
|
||||
(, , c);
|
||||
(, , )
|
||||
(a,b,);
|
||||
(a,,c);
|
||||
(,,c);
|
||||
(a,,);
|
||||
(,b,);
|
||||
(,,c);
|
||||
(,,)
|
||||
53
cde/util/tradcpp/tests/t28.c
Normal file
53
cde/util/tradcpp/tests/t28.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#if 1
|
||||
. right
|
||||
|
||||
# if 1
|
||||
.. right
|
||||
# elif 1
|
||||
.. wrong
|
||||
# elif 0
|
||||
.. wrong
|
||||
# else
|
||||
.. wrong
|
||||
# endif
|
||||
|
||||
#elif 1
|
||||
. wrong
|
||||
|
||||
# if 1
|
||||
.. wrong
|
||||
# elif 1
|
||||
.. wrong
|
||||
# elif 0
|
||||
.. wrong
|
||||
# else
|
||||
.. wrong
|
||||
# endif
|
||||
|
||||
#elif 0
|
||||
. wrong
|
||||
|
||||
# if 1
|
||||
.. wrong
|
||||
# elif 1
|
||||
.. wrong
|
||||
# elif 0
|
||||
.. wrong
|
||||
# else
|
||||
.. wrong
|
||||
# endif
|
||||
|
||||
#else
|
||||
. wrong
|
||||
|
||||
# if 1
|
||||
.. wrong
|
||||
# elif 1
|
||||
.. wrong
|
||||
# elif 0
|
||||
.. wrong
|
||||
# else
|
||||
.. wrong
|
||||
# endif
|
||||
|
||||
#endif
|
||||
2
cde/util/tradcpp/tests/t28.good
Normal file
2
cde/util/tradcpp/tests/t28.good
Normal file
@@ -0,0 +1,2 @@
|
||||
. right
|
||||
.. right
|
||||
4
cde/util/tradcpp/tests/t29.c
Normal file
4
cde/util/tradcpp/tests/t29.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#if 0
|
||||
# if this is a syntax error
|
||||
# endif
|
||||
#endif
|
||||
0
cde/util/tradcpp/tests/t29.good
Normal file
0
cde/util/tradcpp/tests/t29.good
Normal file
2
cde/util/tradcpp/tests/t30.c
Normal file
2
cde/util/tradcpp/tests/t30.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define x(a,b,c) a;b;c;
|
||||
x((,),x,",")
|
||||
1
cde/util/tradcpp/tests/t30.good
Normal file
1
cde/util/tradcpp/tests/t30.good
Normal file
@@ -0,0 +1 @@
|
||||
(,);x;",";
|
||||
6
cde/util/tradcpp/tests/t31.c
Normal file
6
cde/util/tradcpp/tests/t31.c
Normal file
@@ -0,0 +1,6 @@
|
||||
this line 'has /* no' comment */ in it
|
||||
|
||||
#define BELCH(x) 'x'
|
||||
"BELCH(123)": BELCH(123)
|
||||
'BELCH(123)': BELCH(123)
|
||||
|
||||
3
cde/util/tradcpp/tests/t31.good
Normal file
3
cde/util/tradcpp/tests/t31.good
Normal file
@@ -0,0 +1,3 @@
|
||||
this line 'has /* no' comment */ in it
|
||||
"BELCH(123)": '123'
|
||||
'BELCH(123)': '123'
|
||||
21
cde/util/tradcpp/tests/t32.c
Normal file
21
cde/util/tradcpp/tests/t32.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#define foo(x) "x"
|
||||
#define bar(x) 'x'
|
||||
#define baz frob
|
||||
foo(3)
|
||||
bar(3)
|
||||
foo(baz)
|
||||
bar(baz)
|
||||
"baz"
|
||||
'baz'
|
||||
"foo(baz)"
|
||||
"bar(baz)"
|
||||
|
||||
#define foo2(x) foo(x)
|
||||
#define bar2(x) bar(x)
|
||||
foo2(baz)
|
||||
bar2(baz)
|
||||
|
||||
#define foo3(x) foo2(x)
|
||||
#define bar3(x) bar2(x)
|
||||
foo3(baz)
|
||||
bar3(baz)
|
||||
12
cde/util/tradcpp/tests/t32.good
Normal file
12
cde/util/tradcpp/tests/t32.good
Normal file
@@ -0,0 +1,12 @@
|
||||
"3"
|
||||
'3'
|
||||
"baz"
|
||||
'baz'
|
||||
"baz"
|
||||
'baz'
|
||||
"foo(baz)"
|
||||
"bar(baz)"
|
||||
"baz"
|
||||
'baz'
|
||||
"baz"
|
||||
'baz'
|
||||
6
cde/util/tradcpp/tests/t33.c
Normal file
6
cde/util/tradcpp/tests/t33.c
Normal file
@@ -0,0 +1,6 @@
|
||||
/* make sure that R gets defined and doesn't end up part of a string */
|
||||
#define Q "
|
||||
#define R r
|
||||
#define S "
|
||||
R
|
||||
Q
|
||||
3
cde/util/tradcpp/tests/t33.good
Normal file
3
cde/util/tradcpp/tests/t33.good
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
r
|
||||
"
|
||||
5
cde/util/tradcpp/tests/t34.c
Normal file
5
cde/util/tradcpp/tests/t34.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#define Q "
|
||||
#define FOO foo
|
||||
Q FOO Q
|
||||
|
||||
|
||||
1
cde/util/tradcpp/tests/t34.good
Normal file
1
cde/util/tradcpp/tests/t34.good
Normal file
@@ -0,0 +1 @@
|
||||
" foo "
|
||||
6
cde/util/tradcpp/tests/t35.c
Normal file
6
cde/util/tradcpp/tests/t35.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#define Q "
|
||||
#define FOO foo
|
||||
|
||||
Q FOO Q 'I like "FOO" and "BAR"'
|
||||
|
||||
|
||||
1
cde/util/tradcpp/tests/t35.good
Normal file
1
cde/util/tradcpp/tests/t35.good
Normal file
@@ -0,0 +1 @@
|
||||
" foo " 'I like "FOO" and "BAR"'
|
||||
7
cde/util/tradcpp/tests/t36.c
Normal file
7
cde/util/tradcpp/tests/t36.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#define C(x) //**/* x */**//
|
||||
C(3)
|
||||
C(abc /* def */ ghi)
|
||||
|
||||
#define D(x) ///**/**/**///**/* x */**///**/**/**///
|
||||
D(3)
|
||||
D(abc /* def */ ghi)
|
||||
4
cde/util/tradcpp/tests/t36.good
Normal file
4
cde/util/tradcpp/tests/t36.good
Normal file
@@ -0,0 +1,4 @@
|
||||
/* 3 */
|
||||
/* abc ghi */
|
||||
//**/* 3 */**//
|
||||
//**/* abc ghi */**//
|
||||
19
cde/util/tradcpp/tests/t37.c
Normal file
19
cde/util/tradcpp/tests/t37.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#define BC //**/*
|
||||
#define EC */**//
|
||||
|
||||
BC
|
||||
comment?
|
||||
EC
|
||||
|
||||
BC comment? EC
|
||||
|
||||
#define FOO(x) x
|
||||
FOO(abc BC def EC ghi)
|
||||
|
||||
#define BAR(x, y) x y
|
||||
BAR(abc BC def, ghi EC jkl)
|
||||
|
||||
BC
|
||||
#define BAZ baz
|
||||
EC
|
||||
BAZ
|
||||
9
cde/util/tradcpp/tests/t37.good
Normal file
9
cde/util/tradcpp/tests/t37.good
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
comment?
|
||||
*/
|
||||
/* comment? */
|
||||
abc /* def */ ghi
|
||||
abc /* def ghi */ jkl
|
||||
/*
|
||||
*/
|
||||
baz
|
||||
36
cde/util/tradcpp/tests/tradcpp.sh
Normal file
36
cde/util/tradcpp/tests/tradcpp.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
test_case() {
|
||||
local name="$1"
|
||||
local source="$2"
|
||||
local tradcpp="$3"
|
||||
local descr="Test tradcpp behavior"
|
||||
atf_test_case ${name}
|
||||
if [ -e "$(atf_get_srcdir)/${name}.txt" ]; then
|
||||
descr=$(cat "$(atf_get_srcdir)/${name}.txt")
|
||||
fi
|
||||
eval "${name}_head() { \
|
||||
atf_set descr \"${descr}\"; \
|
||||
atf_set require.progs \"/usr/bin/tradcpp\"; \
|
||||
}"
|
||||
local stdout="file:$(atf_get_srcdir)/${name}.good"
|
||||
local options=""
|
||||
local options_file="$(atf_get_srcdir)/${name}.cmdline"
|
||||
if [ -e ${options_file} ]; then
|
||||
options=$(cat ${options_file})
|
||||
fi
|
||||
eval "${name}_body() { \
|
||||
atf_check -s eq:0 -o ${stdout} -x '${tradcpp} ${options} ${source} 2>&1 || echo FAILED'; \
|
||||
}"
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
local tradcpp=$(make -V .OBJDIR -C $(atf_get_srcdir)/..)/tradcpp
|
||||
if [ ! -x ${tradcpp} ]; then
|
||||
tradcpp=/usr/bin/tradcpp
|
||||
fi
|
||||
cd $(atf_get_srcdir)
|
||||
for testfile in t*.c; do
|
||||
local name=${testfile%%.c}
|
||||
test_case ${name} ${testfile} ${tradcpp}
|
||||
atf_add_test_case ${name}
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user