OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [po/] [exgettext] - Diff between revs 154 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
#! /bin/sh
#! /bin/sh
# Wrapper around gettext for programs using the msgid convention.
# Wrapper around gettext for programs using the msgid convention.
# Copyright 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
# Copyright 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
# Written by Paul Eggert .
# Written by Paul Eggert .
# Revised by Zack Weinberg  for no-POTFILES operation.
# Revised by Zack Weinberg  for no-POTFILES operation.
# This file is part of GCC.
# This file is part of GCC.
# GCC is free software; you can redistribute it and/or modify
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# any later version.
# GCC is distributed in the hope that it will be useful,
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING.  If not, write to
# along with GCC; see the file COPYING.  If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Boston, MA 02110-1301, USA.
# Always operate in the C locale.
# Always operate in the C locale.
LANG=C
LANG=C
LANGUAGE=C
LANGUAGE=C
LC_ALL=C
LC_ALL=C
export LANG LANGUAGE LC_ALL
export LANG LANGUAGE LC_ALL
# Set AWK if environment has not already set it.
# Set AWK if environment has not already set it.
AWK=${AWK-awk}
AWK=${AWK-awk}
# The arguments to this wrapper are: the program to execute, the
# The arguments to this wrapper are: the program to execute, the
# name of the "package", and the path to the source directory.
# name of the "package", and the path to the source directory.
if [ $# -ne 3 ]
if [ $# -ne 3 ]
then    echo "usage: $0   "
then    echo "usage: $0   "
        exit 1
        exit 1
fi
fi
xgettext=$1
xgettext=$1
package=$2
package=$2
srcdir=$3
srcdir=$3
case `$xgettext --version | sed -e 1q | sed -e 's/^\([^0-9]*\)//'` in
case `$xgettext --version | sed -e 1q | sed -e 's/^\([^0-9]*\)//'` in
  0.14.[5-9]* | 0.14.[1-9][0-9]* | 0.1[5-9]* | 0.[2-9][0-9]* | [1-9].*) : ;;
  0.14.[5-9]* | 0.14.[1-9][0-9]* | 0.1[5-9]* | 0.[2-9][0-9]* | [1-9].*) : ;;
  *) echo "$xgettext is too old.  GNU xgettext 0.14.5 is required"
  *) echo "$xgettext is too old.  GNU xgettext 0.14.5 is required"
     exit 1 ;;
     exit 1 ;;
esac
esac
nl='
nl='
'
'
set -e
set -e
# Create temporary directory for scratch files.
# Create temporary directory for scratch files.
T=exg$$.d
T=exg$$.d
mkdir $T
mkdir $T
trap "rm -r $T" 0
trap "rm -r $T" 0
pwd=`${PWDCMD-pwd}`
pwd=`${PWDCMD-pwd}`
kopt=$pwd/$T/keyword-options
kopt=$pwd/$T/keyword-options
kopt2=$pwd/$T/keyword2-options
kopt2=$pwd/$T/keyword2-options
emsg=$pwd/$T/emsgids.c
emsg=$pwd/$T/emsgids.c
posr=$pwd/$T/po-sources
posr=$pwd/$T/po-sources
pottmp1=$pwd/$T/tmp1.pot
pottmp1=$pwd/$T/tmp1.pot
pottmp2=$pwd/$T/tmp2.pot
pottmp2=$pwd/$T/tmp2.pot
pottmp=$pwd/$T/tmp.pot
pottmp=$pwd/$T/tmp.pot
# Locate files to scan, and generate the list.  All .c, .h, and .def files
# Locate files to scan, and generate the list.  All .c, .h, and .def files
# in $srcdir are examined, likewise $srcdir/config and $srcdir/config/*
# in $srcdir are examined, likewise $srcdir/config and $srcdir/config/*
# (directories).  Also, all subdirectories of $srcdir that contain a
# (directories).  Also, all subdirectories of $srcdir that contain a
# config-lang.in.  Exclusions come from $srcdir/po/EXCLUDE.
# config-lang.in.  Exclusions come from $srcdir/po/EXCLUDE.
#
#
# Then generate keyword options for xgettext, by scanning for declarations
# Then generate keyword options for xgettext, by scanning for declarations
# of functions whose parameter names end in "msgid".
# of functions whose parameter names end in "msgid".
#
#
# Finally, generate a source file containing all %e strings from
# Finally, generate a source file containing all %e strings from
# driver specs, so those can be translated too.
# driver specs, so those can be translated too.
#
#
# All in one huge awk script.
# All in one huge awk script.
echo "scanning for keywords and %e strings..." >&2
echo "scanning for keywords and %e strings..." >&2
( cd $srcdir
( cd $srcdir
  lang_subdirs=`echo */config-lang.in | sed -e 's|config-lang\.in||g'`
  lang_subdirs=`echo */config-lang.in | sed -e 's|config-lang\.in||g'`
  { for dir in "" config/ config/*/ $lang_subdirs
  { for dir in "" config/ config/*/ $lang_subdirs
    do  for glob in '*.c' '*.h' '*.def'
    do  for glob in '*.c' '*.h' '*.def'
        do  eval echo $dir$glob
        do  eval echo $dir$glob
        done
        done
    done;
    done;
  } | tr ' ' "$nl" | grep -v '\*' |
  } | tr ' ' "$nl" | grep -v '\*' |
  $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg '
  $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg '
function keyword_option(line) {
function keyword_option(line) {
    paren_index = index(line, "(")
    paren_index = index(line, "(")
    name = substr(line, 1, paren_index - 1)
    name = substr(line, 1, paren_index - 1)
    sub(/[^0-9A-Z_a-z]*$/, "", name)
    sub(/[^0-9A-Z_a-z]*$/, "", name)
    sub(/[       ]+PARAMS/, "", name)
    sub(/[       ]+PARAMS/, "", name)
    sub(/[       ]+VPARAMS/, "", name)
    sub(/[       ]+VPARAMS/, "", name)
    sub(/.*[^0-9A-Z_a-z]/, "", name)
    sub(/.*[^0-9A-Z_a-z]/, "", name)
    args = substr(line, paren_index)
    args = substr(line, paren_index)
    sub(/msgid[,\)].*/, "", args)
    sub(/msgid[,\)].*/, "", args)
    for (n = 1; sub(/^[^,]*,/, "", args); n++) {
    for (n = 1; sub(/^[^,]*,/, "", args); n++) {
        continue
        continue
    }
    }
    format=""
    format=""
    if (args ~ /g$/)
    if (args ~ /g$/)
        format="gcc-internal-format"
        format="gcc-internal-format"
    else if (args ~ /noc$/)
    else if (args ~ /noc$/)
        format="no-c-format"
        format="no-c-format"
    else if (args ~ /c$/)
    else if (args ~ /c$/)
        format="c-format"
        format="c-format"
    if (n == 1) { keyword = "--keyword=" name }
    if (n == 1) { keyword = "--keyword=" name }
    else { keyword = "--keyword=" name ":" n }
    else { keyword = "--keyword=" name ":" n }
    if (format) {
    if (format) {
        keyword=keyword "\n--flag=" name ":" n ":" format
        keyword=keyword "\n--flag=" name ":" n ":" format
    }
    }
    if (! keyword_seen[name]) {
    if (! keyword_seen[name]) {
        if (format == "gcc-internal-format")
        if (format == "gcc-internal-format")
                print keyword > kopt2
                print keyword > kopt2
        else
        else
                print keyword > kopt
                print keyword > kopt
        keyword_seen[name] = keyword
        keyword_seen[name] = keyword
    } else if (keyword_seen[name] != keyword) {
    } else if (keyword_seen[name] != keyword) {
        printf("%s used incompatibly as both %s and %s\n",
        printf("%s used incompatibly as both %s and %s\n",
               name, keyword_seen[name], keyword)
               name, keyword_seen[name], keyword)
        exit (1)
        exit (1)
    }
    }
}
}
function spec_error_string (line) {
function spec_error_string (line) {
    while ((percent_index = index(line, "%e")) != 0) {
    while ((percent_index = index(line, "%e")) != 0) {
        escape = substr(line, percent_index - 1, 1)
        escape = substr(line, percent_index - 1, 1)
        line = substr(line, percent_index + 2)
        line = substr(line, percent_index + 2)
        if (escape == "%") continue
        if (escape == "%") continue
        bracket_index = index(line, "}")
        bracket_index = index(line, "}")
        quote_index = index(line, "\"")
        quote_index = index(line, "\"")
        if (bracket_index == 0) return
        if (bracket_index == 0) return
        if (quote_index != 0 && bracket_index > quote_index) return
        if (quote_index != 0 && bracket_index > quote_index) return
        msgid = substr(line, 1, bracket_index - 1)
        msgid = substr(line, 1, bracket_index - 1)
        line = substr(line, bracket_index + 1)
        line = substr(line, bracket_index + 1)
        if (index(msgid, "%") != 0) continue
        if (index(msgid, "%") != 0) continue
        printf("#line %d \"%s\"\n", lineno, file) > emsg
        printf("#line %d \"%s\"\n", lineno, file) > emsg
        printf("_(\"%s\")\n", msgid) > emsg
        printf("_(\"%s\")\n", msgid) > emsg
    }
    }
}
}
BEGIN {
BEGIN {
  while ((getline < excl) > 0) {
  while ((getline < excl) > 0) {
    if ($0 ~ /^#/ || $0 ~ /^[   ]*$/)
    if ($0 ~ /^#/ || $0 ~ /^[   ]*$/)
      continue
      continue
    excludes[$1] = 1
    excludes[$1] = 1
  }
  }
}
}
{ if (!($0 in excludes)) {
{ if (!($0 in excludes)) {
    print > posr
    print > posr
    files[NR] = $0
    files[NR] = $0
  }
  }
}
}
END {
END {
    for (f in files) {
    for (f in files) {
        file = files[f]
        file = files[f]
        lineno = 1
        lineno = 1
        while (getline < file) {
        while (getline < file) {
            if (/^(#[   ]*define[       ]*)?[A-Za-z_].*\(.*msgid[,\)]/) {
            if (/^(#[   ]*define[       ]*)?[A-Za-z_].*\(.*msgid[,\)]/) {
                keyword_option($0)
                keyword_option($0)
            } else if (/%e/) {
            } else if (/%e/) {
                spec_error_string($0)
                spec_error_string($0)
            }
            }
            lineno++
            lineno++
        }
        }
    }
    }
    print emsg > posr
    print emsg > posr
}'
}'
) || exit
) || exit
echo "scanning option files..." >&2
echo "scanning option files..." >&2
( cd $srcdir; find . -name '*.opt' -print |
( cd $srcdir; find . -name '*.opt' -print |
  $AWK '{
  $AWK '{
    file = $1
    file = $1
    lineno = 1
    lineno = 1
    field = 0
    field = 0
    while (getline < file) {
    while (getline < file) {
        if (/^[ \t]*(;|$)/ || !/^[^ \t]/) {
        if (/^[ \t]*(;|$)/ || !/^[^ \t]/) {
            field = 0
            field = 0
        } else {
        } else {
            if (field == 2) {
            if (field == 2) {
                line = $0
                line = $0
                gsub(".*\t", "", line)
                gsub(".*\t", "", line)
                printf("#line %d \"%s\"\n", lineno, file)
                printf("#line %d \"%s\"\n", lineno, file)
                printf("_(\"%s\")\n", line)
                printf("_(\"%s\")\n", line)
            }
            }
            field++;
            field++;
        }
        }
        lineno++;
        lineno++;
    }
    }
  }') >> $emsg
  }') >> $emsg
# Run the xgettext command, with temporary added as a file to scan.
# Run the xgettext command, with temporary added as a file to scan.
echo "running xgettext..." >&2
echo "running xgettext..." >&2
$xgettext --default-domain=$package --directory=$srcdir \
$xgettext --default-domain=$package --directory=$srcdir \
          --add-comments `cat $kopt` --files-from=$posr \
          --add-comments `cat $kopt` --files-from=$posr \
          --copyright-holder="Free Software Foundation, Inc." \
          --copyright-holder="Free Software Foundation, Inc." \
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
          --language=c -o $pottmp1
          --language=c -o $pottmp1
$xgettext --default-domain=$package --directory=$srcdir \
$xgettext --default-domain=$package --directory=$srcdir \
          --add-comments --keyword= `cat $kopt2` --files-from=$posr \
          --add-comments --keyword= `cat $kopt2` --files-from=$posr \
          --copyright-holder="Free Software Foundation, Inc." \
          --copyright-holder="Free Software Foundation, Inc." \
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
          --language=GCC-source -o $pottmp2
          --language=GCC-source -o $pottmp2
$xgettext --default-domain=$package \
$xgettext --default-domain=$package \
          --add-comments $pottmp1 $pottmp2 \
          --add-comments $pottmp1 $pottmp2 \
          --copyright-holder="Free Software Foundation, Inc." \
          --copyright-holder="Free Software Foundation, Inc." \
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
          --language=PO -o $pottmp
          --language=PO -o $pottmp
# Remove local paths from .pot file.
# Remove local paths from .pot file.
sed "s:$srcdir/::g;s:$pwd/::g;" <$pottmp >po/$package.pot
sed "s:$srcdir/::g;s:$pwd/::g;" <$pottmp >po/$package.pot
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.