view help/help_create.sh @ 37159:d4fbf2eb4a04

Ensure up-to-dateness of global_sub information upon request. Some demuxers (like mpg) can detect subtitles only while playing, which is the reason why MPlayer always - indirectly - calls update_global_sub_size() prior to dealing with subtitles. Functions mpctx_get_global_sub_size() and mpctx_get_global_sub_pos(), however, merely return last determined values, thus missing information that may have been arisen after MPlayer has checked last for subtitles (when playback started). Merge the two mpctx_get_global_sub_*() functions into one for easier handling. Retrieve global_sub pos by a mp_property_do("sub") command which performs the necessary update of both global_sub variables, pos and size. Reported by Lode Leroy, lode.leroy gmail com.
author ib
date Sun, 17 Aug 2014 18:06:56 +0000
parents dc5355a5b42f
children
line wrap: on
line source

#!/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.

if test -z $2 ; then
    echo "Error: missing parameters"
    echo "Usage: $0 <messages file> <character set>"
    exit 1
fi

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
    elif [ -z "$line" ]; then
        curr=""
    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

#include <inttypes.h>
#include "config.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