Mercurial > mplayer.hg
annotate help/help_check.sh @ 37014:01b3cd8a1e76
Simplify string termination.
author | ib |
---|---|
date | Sat, 29 Mar 2014 14:21:45 +0000 |
parents | e9044aed2250 |
children |
rev | line source |
---|---|
34890
4df5cb727be4
Add a Makefile target for testing the help message text headers.
ib
parents:
diff
changeset
|
1 #!/bin/sh |
36697 | 2 # Check help message header files for conversion specifications and |
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 | 7 SYMCONST_REGEX="[A-Za-z0-9_]\\+" |
8 CONVSPEC_REGEX="%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%][0-9]*" | |
9 # the [0-9]* is for inttypes' printf specifier macros and hopefully won't hurt otherwise | |
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 | 16 # gather definitions containing conversion specifications from master file |
17 | |
18 while read line; do | |
19 | |
20 DEFINE=$(echo "$line" | sed -n "s:^[ \t]*#define[ \t]\+\($SYMCONST_REGEX\)[ \t]\+\(.*\):\1=\2:; s:'::g; s:=:=':p") | |
21 | |
22 case "$DEFINE" in | |
23 *%*) eval "$DEFINE'";; | |
24 esac | |
25 | |
26 done < help/help_mp-en.h | |
27 | |
28 # create statements from definitions in the translated header file for a test | |
29 # compilation and compare conversion specifications from the translated header | |
30 # file with those of the master file (if any specification in any of the two | |
31 # files) | |
32 | |
34890
4df5cb727be4
Add a Makefile target for testing the help message text headers.
ib
parents:
diff
changeset
|
33 for h in "$@"; do |
36697 | 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 | 46 strdup(help_text); |
34890
4df5cb727be4
Add a Makefile target for testing the help message text headers.
ib
parents:
diff
changeset
|
47 EOF |
36697 | 48 |
49 while read line; do | |
50 | |
51 DEFINE=$(echo "$line" | sed -n "s:^[ \t]*#define[ \t]\+\($SYMCONST_REGEX\)[ \t]\+\(.*\):NAME=\1;STRING=\2:; s:'::g; s:STRING=:STRING=':p") | |
52 | |
53 if [ "$DEFINE" ]; then | |
54 eval "$DEFINE'" | |
55 echo "strdup($NAME);" >> ${CHECK}.c | |
56 ANY_CONVSPEC="$(eval "echo \$${NAME} \${STRING}")" | |
57 else | |
58 ANY_CONVSPEC="" | |
59 fi | |
60 | |
61 case "$ANY_CONVSPEC" in | |
62 *%*) ;; | |
63 *) continue;; | |
64 esac | |
65 | |
66 CONVSPECS=$(echo $STRING | sed -n "s:[^%]*\($CONVSPEC_REGEX\)[^%]*: \1:gp") | |
67 MCONVSPECS=$(eval echo \$${NAME} | sed -n "s:[^%]*\($CONVSPEC_REGEX\)[^%]*: \1:gp") | |
68 | |
69 if [ "$CONVSPECS" != "$MCONVSPECS" ]; then | |
70 echo "$h: $NAME conversion specification mismatch:${MCONVSPECS:- (none)} has been translated${CONVSPECS:- (none)}" | |
71 exit 2 | |
72 fi | |
73 | |
74 done < "$h" | |
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 | 78 |
34890
4df5cb727be4
Add a Makefile target for testing the help message text headers.
ib
parents:
diff
changeset
|
79 done |