annotate help/help_check.sh @ 37014:01b3cd8a1e76

Simplify string termination.
author ib
date Sat, 29 Mar 2014 14:21:45 +0000
parents e9044aed2250
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
1 #!/bin/sh
36697
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
2 # Check help message header files for conversion specifications and
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
3 # valid string constant definitions.
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
4
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
5 CHECK=checkhelp
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
6
36697
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
7 SYMCONST_REGEX="[A-Za-z0-9_]\\+"
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
8 CONVSPEC_REGEX="%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%][0-9]*"
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
9 # the [0-9]* is for inttypes' printf specifier macros and hopefully won't hurt otherwise
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
10
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
11 trap "rm -f ${CHECK}.c ${CHECK}.o" EXIT
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
12
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
13 CC=$1
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
14 shift
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
15
36697
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
16 # gather definitions containing conversion specifications from master file
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
17
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
18 while read line; do
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
19
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
20 DEFINE=$(echo "$line" | sed -n "s:^[ \t]*#define[ \t]\+\($SYMCONST_REGEX\)[ \t]\+\(.*\):\1=\2:; s:'::g; s:=:=':p")
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
21
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
22 case "$DEFINE" in
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
23 *%*) eval "$DEFINE'";;
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
24 esac
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
25
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
26 done < help/help_mp-en.h
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
27
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
28 # create statements from definitions in the translated header file for a test
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
29 # compilation and compare conversion specifications from the translated header
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
30 # file with those of the master file (if any specification in any of the two
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
31 # files)
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
32
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
33 for h in "$@"; do
36697
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
34
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
35 cat <<EOF > ${CHECK}.c
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
36 #include <inttypes.h>
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
37 #include <string.h>
36721
e9044aed2250 Fix issue with testing of the help message header files.
ib
parents: 36715
diff changeset
38 #ifndef CONFIG_VCD
e9044aed2250 Fix issue with testing of the help message header files.
ib
parents: 36715
diff changeset
39 #define CONFIG_VCD
e9044aed2250 Fix issue with testing of the help message header files.
ib
parents: 36715
diff changeset
40 #endif
e9044aed2250 Fix issue with testing of the help message header files.
ib
parents: 36715
diff changeset
41 #ifndef CONFIG_DVDREAD
e9044aed2250 Fix issue with testing of the help message header files.
ib
parents: 36715
diff changeset
42 #define CONFIG_DVDREAD
e9044aed2250 Fix issue with testing of the help message header files.
ib
parents: 36715
diff changeset
43 #endif
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
44 #include "$h"
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
45 void $CHECK () {
36715
47768e29af74 Improve testing of the help message header files.
ib
parents: 36697
diff changeset
46 strdup(help_text);
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
47 EOF
36697
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
48
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
49 while read line; do
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
50
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
51 DEFINE=$(echo "$line" | sed -n "s:^[ \t]*#define[ \t]\+\($SYMCONST_REGEX\)[ \t]\+\(.*\):NAME=\1;STRING=\2:; s:'::g; s:STRING=:STRING=':p")
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
52
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
53 if [ "$DEFINE" ]; then
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
54 eval "$DEFINE'"
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
55 echo "strdup($NAME);" >> ${CHECK}.c
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
56 ANY_CONVSPEC="$(eval "echo \$${NAME} \${STRING}")"
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
57 else
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
58 ANY_CONVSPEC=""
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
59 fi
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
60
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
61 case "$ANY_CONVSPEC" in
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
62 *%*) ;;
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
63 *) continue;;
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
64 esac
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
65
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
66 CONVSPECS=$(echo $STRING | sed -n "s:[^%]*\($CONVSPEC_REGEX\)[^%]*: \1:gp")
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
67 MCONVSPECS=$(eval echo \$${NAME} | sed -n "s:[^%]*\($CONVSPEC_REGEX\)[^%]*: \1:gp")
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
68
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
69 if [ "$CONVSPECS" != "$MCONVSPECS" ]; then
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
70 echo "$h: $NAME conversion specification mismatch:${MCONVSPECS:- (none)} has been translated${CONVSPECS:- (none)}"
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
71 exit 2
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
72 fi
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
73
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
74 done < "$h"
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
75
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
76 echo "}" >> ${CHECK}.c
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
77 $CC -Werror -c -o ${CHECK}.o ${CHECK}.c || exit
36697
fe87abe38ef3 Improve testing of the help message header files.
ib
parents: 36671
diff changeset
78
34890
4df5cb727be4 Add a Makefile target for testing the help message text headers.
ib
parents:
diff changeset
79 done