# HG changeset patch # User diego # Date 1211925801 0 # Node ID 73921138ff302cd7d82f87aec02542ce8a0d9727 # Parent 4ab1cfcee43060de26e3087c14e0a103b3039a24 Move messages header file creation to a separate shell script. diff -r 4ab1cfcee430 -r 73921138ff30 Makefile --- a/Makefile Tue May 27 18:39:57 2008 +0000 +++ b/Makefile Tue May 27 22:03:21 2008 +0000 @@ -743,17 +743,7 @@ @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 -r 4ab1cfcee430 -r 73921138ff30 help/help_create.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/help/help_create.sh Tue May 27 22:03:21 2008 +0000 @@ -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 < "$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 <> "$TARGET" + +/* untranslated messages from the English master file */ + +EOF + +if test "$MASTER" != "$TRANSLATION" ; then + missing_messages < "$MASTER" >> "$TARGET" +fi + +cat <> "$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 -r 4ab1cfcee430 -r 73921138ff30 help/help_diff.sh --- a/help/help_diff.sh Tue May 27 18:39:57 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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