#!/bin/sh set -eu out="${TMPDIR-/tmp}/mcpu-cpp-error-$$.out" err="${TMPDIR-/tmp}/mcpu-cpp-error-$$.err" bad="${TMPDIR-/tmp}/mcpu-cpp-nonucs2-$$.c" trap 'rm -f "$out" "$err" "$bad"' EXIT HUP INT TERM if "$MCPU_CPP" --no-config "$srcdir/data/unbalanced.c" -o "$out" 2>"$err"; then exit 1 fi grep 'unbalanced #lang/#endlang' "$err" >/dev/null # A valid UTF-8 scalar outside UCS-2 is harmless inside a comment. "$MCPU_CPP" --no-config "$srcdir/data/nonucs2.c" -o "$out" grep '^int x;$' "$out" >/dev/null # The same scalar in program text is rejected after comment removal. printf 'int x = \360\237\230\200;\n' > "$bad" if "$MCPU_CPP" --no-config "$bad" -o "$out" 2>"$err"; then exit 1 fi grep 'character outside UCS-2' "$err" >/dev/null