blob: 26386ba43f6f209fbe719b6fde73cdf6370afc06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/sh
set -eu
src="${TMPDIR-/tmp}/mcpu-cpp-comments-$$.c"
out="${TMPDIR-/tmp}/mcpu-cpp-comments-$$.out"
trap 'rm -f "$src" "$out"' EXIT HUP INT TERM
cat > "$src" <<'EOT'
/*
#lang "diff"
*/
int c_side;
/* comment before directive */ #lang "diff"
y' = 1;
#endlang
// one-line comment
/*
multi-line comment
*/
LEFT/**/RIGHT
int block_tail; /* block tail */
int line_tail; // line tail
int multi_tail; /*
block tail
*/
EOT
"$MCPU_CPP" --no-config "$src" -o "$out"
grep 'int c_side' "$out" >/dev/null
grep "y' = 1" "$out" >/dev/null
grep '^LEFT RIGHT$' "$out" >/dev/null
# Comment-only lines must be really empty; no synthetic or leading spaces remain.
if grep '^[[:blank:]][[:blank:]]*$' "$out" >/dev/null; then
exit 1
fi
# A comment ending a non-empty line must not leave trailing whitespace.
grep '^int block_tail;$' "$out" >/dev/null
grep '^int line_tail;$' "$out" >/dev/null
grep '^int multi_tail;$' "$out" >/dev/null
if grep '[[:blank:]]$' "$out" >/dev/null; then
exit 1
fi
|