X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=gcc%2Fpo%2Fexgettext;fp=gcc%2Fpo%2Fexgettext;h=6b784e4aaa4c9afe35693af8d7bc657ae11774f5;hb=6fed43773c9b0ce596dca5686f37ac3fc0fa11c0;hp=712e3c4808aea0ba70def869c497017770f160bc;hpb=27b11d56b743098deb193d510b337ba22dc52e5c;p=msp430-gcc.git diff --git a/gcc/po/exgettext b/gcc/po/exgettext index 712e3c48..6b784e4a 100644 --- a/gcc/po/exgettext +++ b/gcc/po/exgettext @@ -1,24 +1,25 @@ #! /bin/sh # Wrapper around gettext for programs using the msgid convention. -# Copyright 1998, 2001, 2002 Free Software Foundation, Inc. +# Copyright 1998, 2001, 2002, 2003, 2009 Free Software Foundation, Inc. # Written by Paul Eggert . # Revised by Zack Weinberg for no-POTFILES operation. -# This program is free software; you can redistribute it and/or modify +# This file is part of GCC. + +# GCC is free software; you can redistribute it and/or modify # 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 3, or (at your option) # any later version. -# This program 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 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. +# along with GCC; see the file COPYING3. If not see +# . # Always operate in the C locale. LANG=C @@ -41,6 +42,12 @@ xgettext=$1 package=$2 srcdir=$3 +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].*) : ;; + *) echo "$xgettext is too old. GNU xgettext 0.14.5 is required" + exit 1 ;; +esac + nl=' ' @@ -51,10 +58,14 @@ T=exg$$.d mkdir $T trap "rm -r $T" 0 -pwd=`pwd` +pwd=`${PWDCMD-pwd}` kopt=$pwd/$T/keyword-options +kopt2=$pwd/$T/keyword2-options emsg=$pwd/$T/emsgids.c posr=$pwd/$T/po-sources +pottmp1=$pwd/$T/tmp1.pot +pottmp2=$pwd/$T/tmp2.pot +pottmp=$pwd/$T/tmp.pot # Locate files to scan, and generate the list. All .c, .h, and .def files # in $srcdir are examined, likewise $srcdir/config and $srcdir/config/* @@ -72,13 +83,14 @@ posr=$pwd/$T/po-sources echo "scanning for keywords and %e strings..." >&2 ( cd $srcdir - lang_subdirs=`echo */config-lang.in | sed -e 's|config-lang\.in||g'` - for dir in "" config/ config/*/ $lang_subdirs - do for glob in '*.c' '*.h' '*.def' - do eval echo $dir$glob - done - done | tr ' ' "$nl" | grep -v '\*' | - $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v emsg=$emsg ' + lang_subdirs=`echo */config-lang.in */*/config-lang.in | sed -e 's|config-lang\.in||g'` + { for dir in "" config/ config/*/ $lang_subdirs + do for glob in '*.c' '*.h' '*.def' + do eval echo $dir$glob + done + done; + } | tr ' ' "$nl" | grep -v '\*' | + $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg ' function keyword_option(line) { paren_index = index(line, "(") name = substr(line, 1, paren_index - 1) @@ -92,12 +104,30 @@ function keyword_option(line) { for (n = 1; sub(/^[^,]*,/, "", args); n++) { continue } + format="" + if (args ~ /g$/) + format="gcc-internal-format" + else if (args ~ /noc$/) + format="no-c-format" + else if (args ~ /c$/) + format="c-format" + + if (n == 1) { keyword = "--keyword=" name } + else { keyword = "--keyword=" name ":" n } + if (format) { + keyword=keyword "\n--flag=" name ":" n ":" format + } - if (n == 1) { keyword = name } - else { keyword = name ":" n } - - if (! keyword_seen[keyword]++) { - print "--keyword=" keyword > kopt + if (! keyword_seen[name]) { + if (format == "gcc-internal-format") + print keyword > kopt2 + else + print keyword > kopt + keyword_seen[name] = keyword + } else if (keyword_seen[name] != keyword) { + printf("%s used incompatibly as both %s and %s\n", + name, keyword_seen[name], keyword) + exit (1) } } @@ -105,18 +135,21 @@ function spec_error_string (line) { while ((percent_index = index(line, "%e")) != 0) { escape = substr(line, percent_index - 1, 1) line = substr(line, percent_index + 2) - if (escape == "%") return + if (escape == "%") continue bracket_index = index(line, "}") + quote_index = index(line, "\"") if (bracket_index == 0) return + if (quote_index != 0 && bracket_index > quote_index) return msgid = substr(line, 1, bracket_index - 1) - if (index(msgid, "%") != 0) return + line = substr(line, bracket_index + 1) + + if (index(msgid, "%") != 0) continue printf("#line %d \"%s\"\n", lineno, file) > emsg printf("_(\"%s\")\n", msgid) > emsg - line = substr(line, bracket_index + 1) } } @@ -149,10 +182,47 @@ END { } print emsg > posr }' -) +) || exit + +echo "scanning option files..." >&2 + +( cd $srcdir; find . -name '*.opt' -print | + $AWK '{ + file = $1 + lineno = 1 + field = 0 + while (getline < file) { + if (/^[ \t]*(;|$)/ || !/^[^ \t]/) { + field = 0 + } else { + if (field == 2) { + line = $0 + gsub(".*\t", "", line) + printf("#line %d \"%s\"\n", lineno, file) + printf("_(\"%s\")\n", line) + } + field++; + } + lineno++; + } + }') >> $emsg # Run the xgettext command, with temporary added as a file to scan. echo "running xgettext..." >&2 $xgettext --default-domain=$package --directory=$srcdir \ --add-comments `cat $kopt` --files-from=$posr \ - --language=c -o po/$package.pot + --copyright-holder="Free Software Foundation, Inc." \ + --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \ + --language=c -o $pottmp1 +$xgettext --default-domain=$package --directory=$srcdir \ + --add-comments --keyword= `cat $kopt2` --files-from=$posr \ + --copyright-holder="Free Software Foundation, Inc." \ + --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \ + --language=GCC-source -o $pottmp2 +$xgettext --default-domain=$package \ + --add-comments $pottmp1 $pottmp2 \ + --copyright-holder="Free Software Foundation, Inc." \ + --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \ + --language=PO -o $pottmp +# Remove local paths from .pot file. +sed "s:$srcdir/::g;s:$pwd/::g;" <$pottmp >po/$package.pot