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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [po/] [exgettext] - Blame information for rev 321

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 291 jeremybenn
#! /bin/sh
2
# Wrapper around gettext for programs using the msgid convention.
3
# Copyright 1998, 2001, 2002, 2003, 2009 Free Software Foundation, Inc.
4
 
5
# Written by Paul Eggert .
6
# Revised by Zack Weinberg  for no-POTFILES operation.
7
 
8
# This file is part of GCC.
9
 
10
# GCC is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 3, or (at your option)
13
# any later version.
14
 
15
# GCC is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
 
20
# You should have received a copy of the GNU General Public License
21
# along with GCC; see the file COPYING3.  If not see
22
# .
23
 
24
# Always operate in the C locale.
25
LANG=C
26
LANGUAGE=C
27
LC_ALL=C
28
export LANG LANGUAGE LC_ALL
29
 
30
# Set AWK if environment has not already set it.
31
AWK=${AWK-awk}
32
 
33
# The arguments to this wrapper are: the program to execute, the
34
# name of the "package", and the path to the source directory.
35
 
36
if [ $# -ne 3 ]
37
then    echo "usage: $0   "
38
        exit 1
39
fi
40
 
41
xgettext=$1
42
package=$2
43
srcdir=$3
44
 
45
case `$xgettext --version | sed -e 1q | sed -e 's/^\([^0-9]*\)//'` in
46
  0.14.[5-9]* | 0.14.[1-9][0-9]* | 0.1[5-9]* | 0.[2-9][0-9]* | [1-9].*) : ;;
47
  *) echo "$xgettext is too old.  GNU xgettext 0.14.5 is required"
48
     exit 1 ;;
49
esac
50
 
51
nl='
52
'
53
 
54
set -e
55
 
56
# Create temporary directory for scratch files.
57
T=exg$$.d
58
mkdir $T
59
trap "rm -r $T" 0
60
 
61
pwd=`${PWDCMD-pwd}`
62
kopt=$pwd/$T/keyword-options
63
kopt2=$pwd/$T/keyword2-options
64
emsg=$pwd/$T/emsgids.c
65
posr=$pwd/$T/po-sources
66
pottmp1=$pwd/$T/tmp1.pot
67
pottmp2=$pwd/$T/tmp2.pot
68
pottmp=$pwd/$T/tmp.pot
69
 
70
# Locate files to scan, and generate the list.  All .c, .h, and .def files
71
# in $srcdir are examined, likewise $srcdir/config and $srcdir/config/*
72
# (directories).  Also, all subdirectories of $srcdir that contain a
73
# config-lang.in.  Exclusions come from $srcdir/po/EXCLUDE.
74
#
75
# Then generate keyword options for xgettext, by scanning for declarations
76
# of functions whose parameter names end in "msgid".
77
#
78
# Finally, generate a source file containing all %e and %n strings from
79
# driver specs, so those can be translated too.
80
#
81
# All in one huge awk script.
82
 
83
echo "scanning for keywords, %e and %n strings..." >&2
84
 
85
( cd $srcdir
86
  lang_subdirs=`echo */config-lang.in */*/config-lang.in | sed -e 's|config-lang\.in||g'`
87
  { for dir in "" config/ config/*/ $lang_subdirs
88
    do  for glob in '*.c' '*.h' '*.def'
89
        do  eval echo $dir$glob
90
        done
91
    done;
92
  } | tr ' ' "$nl" | grep -v '\*' |
93
  $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg '
94
function keyword_option(line) {
95
    paren_index = index(line, "(")
96
    name = substr(line, 1, paren_index - 1)
97
    sub(/[^0-9A-Z_a-z]*$/, "", name)
98
    sub(/[       ]+PARAMS/, "", name)
99
    sub(/[       ]+VPARAMS/, "", name)
100
    sub(/.*[^0-9A-Z_a-z]/, "", name)
101
 
102
    args = substr(line, paren_index)
103
    sub(/msgid[,\)].*/, "", args)
104
    for (n = 1; sub(/^[^,]*,/, "", args); n++) {
105
        continue
106
    }
107
    format=""
108
    if (args ~ /g$/)
109
        format="gcc-internal-format"
110
    else if (args ~ /noc$/)
111
        format="no-c-format"
112
    else if (args ~ /c$/)
113
        format="c-format"
114
 
115
    if (n == 1) { keyword = "--keyword=" name }
116
    else {
117
       keyword = "--keyword=" name ":" n
118
       if (name ~ /_n$/)
119
         keyword = keyword "," (n + 1)
120
    }
121
    if (format) {
122
        keyword=keyword "\n--flag=" name ":" n ":" format
123
        if (name ~ /_n$/)
124
          keyword = keyword "\n--flag=" name ":" (n + 1) ":" format
125
    }
126
 
127
    if (! keyword_seen[name]) {
128
        if (format == "gcc-internal-format")
129
                print keyword > kopt2
130
        else
131
                print keyword > kopt
132
        keyword_seen[name] = keyword
133
    } else if (keyword_seen[name] != keyword) {
134
        printf("%s used incompatibly as both %s and %s\n",
135
               name, keyword_seen[name], keyword)
136
        exit (1)
137
    }
138
}
139
 
140
function spec_error_string (line) {
141
    if (index(line, "%e") != 0 && index(line, "%n") != 0) return
142
    while ((percent_index = index(line, "%e")) != 0 ||
143
           (percent_index = index(line, "%n")) != 0) {
144
        line = substr(line, percent_index + 2)
145
 
146
        bracket_index = index(line, "}")
147
        newline_index = index(line, "\\n")
148
 
149
        quote_index = index(line, "\"")
150
        if (bracket_index == 0 && newline_index == 0) return
151
 
152
        if (bracket_index != 0) {
153
          if (quote_index != 0 && bracket_index > quote_index) return
154
          msgid = substr(line, 1, bracket_index - 1)
155
          line = substr(line, bracket_index + 1)
156
        }
157
        else if (newline_index != 0) {
158
          if (quote_index != 0 && quote_index > newline_index) return
159
          msgid = substr(line, 1, newline_index - 1)
160
          line = substr(line, newline_index + 1)
161
        }
162
 
163
        if (index(msgid, "%") != 0) continue
164
 
165
        if ((newline_index = index(msgid, "\\n")) != 0)
166
          msgid = substr(msgid, 1, newline_index - 1)
167
        printf("#line %d \"%s\"\n", lineno, file) > emsg
168
        printf("_(\"%s\")\n", msgid) > emsg
169
    }
170
}
171
 
172
BEGIN {
173
  while ((getline < excl) > 0) {
174
    if ($0 ~ /^#/ || $0 ~ /^[   ]*$/)
175
      continue
176
    excludes[$1] = 1
177
  }
178
}
179
 
180
{ if (!($0 in excludes)) {
181
    print > posr
182
    files[NR] = $0
183
  }
184
}
185
 
186
END {
187
    for (f in files) {
188
        file = files[f]
189
        lineno = 1
190
        while (getline < file) {
191
            if (/^(#[   ]*define[       ]*)?[A-Za-z_].*\(.*msgid[,\)]/) {
192
                keyword_option($0)
193
            } else if (/^(#[   ]*define[       ]*)?[A-Za-z_].*(\(|\(.*,)$/) {
194
                name_line = $0
195
                while (getline < file) {
196
                  lineno++
197
                  if (/msgid[,\)]/){
198
                    keyword_option(name_line $0)
199
                    break
200
                  } else if (/,$/) {
201
                      name_line = name_line $0
202
                      continue
203
                  } else break
204
                }
205
            } else if (/%e/ || /%n/) {
206
                spec_error_string($0)
207
            }
208
            lineno++
209
        }
210
    }
211
    print emsg > posr
212
}'
213
) || exit
214
 
215
echo "scanning option files..." >&2
216
 
217
( cd $srcdir; find . -name '*.opt' -print |
218
  $AWK '{
219
    file = $1
220
    lineno = 1
221
    field = 0
222
    while (getline < file) {
223
        if (/^[ \t]*(;|$)/ || !/^[^ \t]/) {
224
            field = 0
225
        } else {
226
            if (field == 2) {
227
                line = $0
228
                printf("#line %d \"%s\"\n", lineno, file)
229
                printf("_(\"%s\")\n", line)
230
            }
231
            field++;
232
        }
233
        lineno++;
234
    }
235
  }') >> $emsg
236
 
237
# Run the xgettext command, with temporary added as a file to scan.
238
echo "running xgettext..." >&2
239
$xgettext --default-domain=$package --directory=$srcdir \
240
          --add-comments `cat $kopt` --files-from=$posr \
241
          --copyright-holder="Free Software Foundation, Inc." \
242
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
243
          --language=c -o $pottmp1
244
$xgettext --default-domain=$package --directory=$srcdir \
245
          --add-comments --keyword= `cat $kopt2` --files-from=$posr \
246
          --copyright-holder="Free Software Foundation, Inc." \
247
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
248
          --language=GCC-source -o $pottmp2
249
$xgettext --default-domain=$package \
250
          --add-comments $pottmp1 $pottmp2 \
251
          --copyright-holder="Free Software Foundation, Inc." \
252
          --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
253
          --language=PO -o $pottmp
254
# Remove local paths from .pot file.
255
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.