[Mplayer-cvslog] CVS: main/help help_diff.sh,1.6,1.7
Diego Biurrun
diego at biurrun.de
Sun Aug 17 04:14:21 CEST 2003
Diego Biurrun CVS schrieb:
> Modified Files:
> help_diff.sh
> Log Message:
> shorter, sweeter, more portable, better calling syntax
>
> --- help_diff.sh 3 Jan 2003 12:14:34 -0000 1.6
> +++ help_diff.sh 17 Aug 2003 01:20:48 -0000 1.7
> @@ -1,28 +1,19 @@
> #!/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).
> +# This script compares a translated help file to the master file and prints
> +# out any missing messages. Needs the language code as parameter ($1).
> #
> -# Example: help_diff.sh help_mp-hu.h < help_mp-en.h > missing.h
> +# Example: help_diff.sh hu
>
> -curr=""
> +exec < help_mp-en.h
>
> -while read -r line; do
> - if echo "$line" | grep -q '^#define'; then
> +while read line; do
> + if echo "$line" | grep '^#define' > /dev/null 2>&1; then
> curr=`echo "$line" | cut -d ' ' -f 2`
> - if grep -q "^#define $curr " $1; then
> - curr=""
> + if grep "^#define $curr" help_mp-$1.h > /dev/null 2>&1; then
> + true
: should be better here
> + else
> + echo "$line"
> fi
> - else
> - if [ -z "$line" ]; then
> - curr=""
> - fi
> - fi
> -
> - if [ -n "$curr" ]; then
> - echo "$line"
> fi
> done
> -
> -
Yes, it runs on Solaris ... ;-)
And even in the Cygwin ash... (it does not like read -r)
As Rich just noticed this does not exactly match the previous version of
the script, since this one only outputs one line of each untranslated
message, while the old one printed multiline untranslated messages to
the screen. I'm not completely sure if this is a disadvantage or not.
Seeing the whole untranslated message is nice to directly translate it,
of course, but you have to open the file for editing anyway and check in
the master file at which point you have to insert the newly translated
message.. So maybe some translator has an opinion on this, otherwise I
am tempted to remain with the new version.
Another point is that this does not solve the general performance
bottleneck of grepping through the whole master file for each message.
Rich came up with some sed/regexp wizardry to solve this:
sed "`sed '/^#define *[^ ][^ ]* .*$/!d;s@^#define *\([^ ][^ ]*\)
.*$@/^#define *\1 /d@' < help_mp-$1.h ; echo '/^#define/!d'`" < help_mp-en.h
This version is way faster and should probably committed instead if we
stay with the new version. Or maybe the sed voodoo can be extended to
match the old behavior. I'll see if I manage to do it and else prod
Rich ;-)
Diego
More information about the MPlayer-cvslog
mailing list