From 1e9c326b7848ac4b08a1fec5116c33125890a0a0 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 4 Mar 2007 10:12:44 +0100 Subject: [PATCH] create msg.h from preferred language include Specified with configure --lang. Adds missing defines from english master file. --- Makefile | 18 +++++++++++++++--- client.c | 2 +- configure | 13 +++++++++++++ curses.c | 2 +- msg_diff.sh | 29 +++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 5 deletions(-) create mode 100755 msg_diff.sh diff --git a/Makefile b/Makefile index 0baead2..389503b 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,22 @@ DISTFILES = README FAQ INSTALL COPYING TODO CHANGES \ all: Makefile config.h $(PROG) $(SPROG) -$(PROG): $(OBJS) +msg.h: msg.en.h $(MSG_FILE) + @echo "Linking $(MSG_FILE) to msg.h" + @echo '// WARNING! This is a generated file. Do NOT edit.' > msg.h + @echo '// See msg.*.h for the editable files.' >> msg.h + @echo '#include "$(MSG_FILE)"' >> msg.h + +ifneq ($(MSG_FILE),msg.en.h) + @echo "Adding untranslated messages to msg.h" + @echo '// untranslated messages from the English master file:' >> msg.h + @./msg_diff.sh $(MSG_FILE) < msg.en.h >> msg.h +endif + +$(PROG): msg.h $(OBJS) $(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS) -$(SPROG): $(SOBJS) +$(SPROG): msg.h $(SOBJS) $(CC) -o $(SPROG) $(SOBJS) $(LFLAGS) $(CFLAGS) .c.o: @@ -47,7 +59,7 @@ dist: $(DISTFILES) tar -cvzof $$dir.tar.gz $$dir clean: - rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) a.out + rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) msg.h a.out cleandir: clean rm -f config.mak config.h diff --git a/client.c b/client.c index 64acecc..67d6f8d 100644 --- a/client.c +++ b/client.c @@ -31,7 +31,7 @@ #include "board.h" #include "curses.h" #include "inet.h" -#include "msg.en.h" +#include "msg.h" static struct option options[] = { { "ascii", 2, 0, 'a' }, diff --git a/configure b/configure index c3a63dc..6ae80bb 100755 --- a/configure +++ b/configure @@ -55,6 +55,10 @@ while [ $# -ge 1 ]; do --curses-hack) CURSES_HACK=true ;; + --lang) + lang="$1" + shift + ;; *) cat << "END" Usage: ./configure [options...] @@ -65,6 +69,7 @@ Usage: ./configure [options...] --cextra : Set extra C flags --lextra : Set extra linker flags --curses-hack: Disable scroll-optimization for broken curses + --lang : Preferred interface language (default "en") END exit 1 ;; @@ -135,6 +140,13 @@ fi rm -f test.c test.o a.out +test -z "$lang" && lang=en +MSG_FILE=msg.$lang.h +if [ ! -f $MSG_FILE ]; then + echo "Error: $MSG_FILE not found" + exit +fi + echo "Creating config.mak" cat > config.mak << END ### Automatically generated by ./configure ### @@ -145,6 +157,7 @@ CEXTRA = $CEXTRA LEXTRA = $LEXTRA LFLAGS = $LEXTRA $LFLAGS CFLAGS = \$(CEXTRA) \$(COPT) +MSG_FILE = $MSG_FILE END echo "Creating config.h" diff --git a/curses.c b/curses.c index 637e897..7b5a26d 100644 --- a/curses.c +++ b/curses.c @@ -29,7 +29,7 @@ #include "curses.h" #include "util.h" #include "board.h" -#include "msg.en.h" +#include "msg.h" #ifdef NCURSES_VERSION # define HAVE_NCURSES diff --git a/msg_diff.sh b/msg_diff.sh new file mode 100755 index 0000000..7f246b1 --- /dev/null +++ b/msg_diff.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Copied help_diff.sh from the MPlayer project +# copyright MPlayer team + +# 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: msg_diff.sh msg.eo.h < msg.en.h > missing.h + +curr="" + +while read -r line; do + if echo "$line" | grep '^#define' > /dev/null 2>&1; then + curr=`printf "%s\n" "$line" | cut -d ' ' -f 2` + if grep "^#define $curr[ ]" $1 > /dev/null 2>&1; then + curr="" + fi + else + if [ -z "$line" ]; then + curr="" + fi + fi + + if [ -n "$curr" ]; then + printf "%s\n" "$line" + fi +done -- 2.30.0