summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-27 22:03:21 +0000
committerdiego <diego@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-27 22:03:21 +0000
commit1bb19a7f48cccc40bac0af9d21870c3f87956e75 (patch)
treecb9b8d541aace96aa0c4aca8da6a89cb0b25a907
parentbc212e3500ef776f849a9ee6c04dfaa4994c62f6 (diff)
downloadmpv-1bb19a7f48cccc40bac0af9d21870c3f87956e75.tar.bz2
mpv-1bb19a7f48cccc40bac0af9d21870c3f87956e75.tar.xz
Move messages header file creation to a separate shell script.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26910 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--Makefile12
-rwxr-xr-xhelp/help_create.sh62
-rwxr-xr-xhelp/help_diff.sh29
3 files changed, 63 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index 10f8ce66db..c853648e00 100644
--- a/Makefile
+++ b/Makefile
@@ -743,17 +743,7 @@ config.mak: configure
@echo "############################################################"
help_mp.h: help/help_mp-en.h $(HELP_FILE)
- @echo '// WARNING! This is a generated file. Do NOT edit.' > $@
- @echo '// See the help/ subdir for the editable files.' >> $@
- @echo '#ifndef MPLAYER_HELP_MP_H' >> $@
- @echo '#define MPLAYER_HELP_MP_H' >> $@
- @cat "$(HELP_FILE)" >> $@
- @echo '// untranslated messages from the English master file:' >> $@
- help/help_diff.sh $(HELP_FILE) < help/help_mp-en.h >> $@
- @echo '#endif /* MPLAYER_HELP_MP_H */' >> $@
-ifneq ($(CHARSET),UTF-8)
- iconv -f UTF-8 -t $(CHARSET) $@ > $@.tmp; mv $@.tmp $@
-endif
+ help/help_create.sh $(HELP_FILE) $(CHARSET)
# rebuild version.h each time the working copy is updated
ifeq ($(wildcard .svn/entries),.svn/entries)
diff --git a/help/help_create.sh b/help/help_create.sh
new file mode 100755
index 0000000000..ccb756d6b9
--- /dev/null
+++ b/help/help_create.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Create the messages header file from the master source file or a translation.
+# Missing messages are filled in from the master message file and, if
+# requested, character set conversion is performed.
+
+MASTER=help/help_mp-en.h
+TARGET=help_mp.h
+
+TRANSLATION=$1
+CHARSET=$2
+
+missing_messages(){
+curr=""
+
+while read -r line; do
+ if echo "$line" | grep -q '^#define' ; then
+ curr=`printf "%s\n" "$line" | cut -d ' ' -f 2`
+ if grep -q "^#define $curr[ ]" "$TRANSLATION" ; then
+ curr=""
+ fi
+ else
+ if [ -z "$line" ]; then
+ curr=""
+ fi
+ fi
+
+ if [ -n "$curr" ]; then
+ printf "%s\n" "$line"
+ fi
+done
+}
+
+cat <<EOF > "$TARGET"
+/* WARNING! This is a generated file, do NOT edit.
+ * See the help/ subdirectory for the editable files. */
+
+#ifndef MPLAYER_HELP_MP_H
+#define MPLAYER_HELP_MP_H
+
+EOF
+
+cat "$TRANSLATION" >> "$TARGET"
+
+cat <<EOF >> "$TARGET"
+
+/* untranslated messages from the English master file */
+
+EOF
+
+if test "$MASTER" != "$TRANSLATION" ; then
+ missing_messages < "$MASTER" >> "$TARGET"
+fi
+
+cat <<EOF >> "$TARGET"
+
+#endif /* MPLAYER_HELP_MP_H */
+EOF
+
+if test $CHARSET != UTF-8 ; then
+ iconv -f UTF-8 -t "$CHARSET" "$TARGET" > "${TARGET}.tmp"
+ mv "${TARGET}.tmp" "$TARGET"
+fi
diff --git a/help/help_diff.sh b/help/help_diff.sh
deleted file mode 100755
index 17c8e83e36..0000000000
--- a/help/help_diff.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-# This script walks through the master (stdin) help/message file, and
-# prints (stdout) only those messages which are missing from the help
-# file given as parameter ($1).
-#
-# Example: help_diff.sh help_mp-hu.h < help_mp-en.h > missing.h
-
-# Processing the master file, nothing to do.
-test $1 = "help/help_mp-en.h" && exit 0
-
-curr=""
-
-while read -r line; do
- if echo "$line" | grep -q '^#define' ; then
- curr=`printf "%s\n" "$line" | cut -d ' ' -f 2`
- if grep -q "^#define $curr[ ]" $1 ; then
- curr=""
- fi
- else
- if [ -z "$line" ]; then
- curr=""
- fi
- fi
-
- if [ -n "$curr" ]; then
- printf "%s\n" "$line"
- fi
-done