2001-10-19 17:17:39 +02:00
|
|
|
/* Message translation utilities.
|
2017-01-01 13:07:43 +01:00
|
|
|
Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
1998-08-02 08:46:46 +02:00
|
|
|
|
2001-10-19 17:17:39 +02:00
|
|
|
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
|
2007-07-26 10:37:01 +02:00
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
2001-10-19 17:17:39 +02:00
|
|
|
version.
|
|
|
|
|
|
|
|
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
|
2007-07-26 10:37:01 +02:00
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2001-10-19 17:17:39 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
2002-12-16 19:23:00 +01:00
|
|
|
#include "coretypes.h"
|
1998-08-02 08:46:46 +02:00
|
|
|
#include "intl.h"
|
|
|
|
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
#ifdef HAVE_LANGINFO_CODESET
|
|
|
|
#include <langinfo.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Opening quotation mark for diagnostics. */
|
|
|
|
const char *open_quote = "'";
|
|
|
|
|
|
|
|
/* Closing quotation mark for diagnostics. */
|
|
|
|
const char *close_quote = "'";
|
|
|
|
|
2009-05-04 14:23:50 +02:00
|
|
|
/* The name of the locale encoding. */
|
|
|
|
const char *locale_encoding = NULL;
|
|
|
|
|
|
|
|
/* Whether the locale is using UTF-8. */
|
|
|
|
bool locale_utf8 = false;
|
|
|
|
|
2001-10-19 17:17:39 +02:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
|
|
|
|
/* Initialize the translation library for GCC. This performs the
|
|
|
|
appropriate sequence of calls - setlocale, bindtextdomain,
|
|
|
|
textdomain. LC_CTYPE determines the character set used by the
|
|
|
|
terminal, so it has be set to output messages correctly. */
|
|
|
|
|
|
|
|
void
|
2003-06-01 17:59:10 +02:00
|
|
|
gcc_init_libintl (void)
|
2001-10-19 17:17:39 +02:00
|
|
|
{
|
|
|
|
#ifdef HAVE_LC_MESSAGES
|
|
|
|
setlocale (LC_CTYPE, "");
|
|
|
|
setlocale (LC_MESSAGES, "");
|
|
|
|
#else
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
#endif
|
|
|
|
|
gcc-version.m4: Delete.
config:
* gcc-version.m4: Delete.
fastjar:
* Makefile.am (fastjar_TEXINFOS): Add gcc-vers.texi.
(BASEVER, DEVPHASE): New variables.
(POD2MAN): Adjust setting of --release option.
(fastjar.1, grepjar.1, gcc-vers.texi): New rules.
* Makefile.in: Regenerate.
* configure.ac: Do not invoke TL_AC_GCC_VERSION.
* aclocal.m4, configure: Regenerate.
gcc:
* BASE-VER, DATESTAMP, DEV-PHASE: New files.
* Makefile.in (gcc_version, gcc_version_trigger, ): Delete.
(BASEVER, DEVPHASE, DATESTAMP, BASEVER_c, DEVPHASE_c, DATESTAMP_c)
(BASEVER_s, DEVPHASE_s, DATESTAMP_s): New variables.
(version): Define using $(BASEVER_c).
(Makefile, config.status, build/gcov-iov.o): No longer depends on
version.c.
(version.o): Depend on version files; add custom generation command.
(prefix.o): Define BASEVER on command line.
(s-iov): Depend on version files; adjust command.
(TEXI_CPP_FILES, TEX_IGCC_FILES, TEXI_GCCINT_FILES, TEXI_CPPINT_FILES):
Add gcc-vers.texi.
(gcc-vers.texi): New rule.
(doc/%.info, doc/%.dvi): Add -I . to command line.
(doc/gccinstall.dvi): Likewise.
(PACKAGE): Delete. All uses replaced with "gcc".
* aclocal.m4: Do not include gcc-version.m4.
* configure.ac: Do not invoke TL_AC_GCC_VERSION.
Do not AC_SUBST nor AC_DEFINE PACKAGE or VERSION.
Set is_release based on contents of DEV-PHASE.
Set gcc_version based on contents of BASE-VER.
Define WIN32_REGISTRY_KEY only if the user overrode the default.
* config.in, configure: Regenerate.
* gccbug.in: Determine version of GCC in use at runtime.
* gcov-iov.c: Get version number and development phase from
command line, not by including version.c.
* intl.c: Replace all uses of PACKAGE with "gcc".
* libada-mk.in: Delete unused "gcc_version" variable.
* prefix.c: Default WIN32_REGISTRY_KEY to BASEVER.
* version.c: (VERSUFFIX): New hook for redistributors; adjust
commentary to match.
(version_string): Put together from pieces.
* config/alpha/x-vms: Do not use $(gcc_version).
* config/i386/t-nwld: Likewise.
* doc/include/gcc-common.texi: Include gcc-vers.texi for
version-GCC and DEVELOPMENT.
gcc/ada:
* Make-lang.in (doc/gnat_ugn_unw.info, doc/gnat_rm.info)
(doc/gnat_ugn_unw.dvi, doc/gnat_rm.dvi): Add gcc-vers.texi
to dependencies.
gcc/fortran:
* Make-lang.in (GFORTRAN_TEXI): Add gcc-vers.texi.
gcc/java:
* Make-lang.in (TEXI_JAVA_FILES): Add gcc-vers.texi.
gcc/treelang:
* Make-lang.in (TEXI_TREELANG_FILES): Add gcc-vers.texi.
libstdc++-v3:
* include/Makefile.am (c++config.h): Depend on DATESTAMP from gcc
subdirectory. Generate #define of __GLIBCXX__ from contents of
that file.
* include/Makefile.in: Regenerate.
* include/bits/c++config: Do not define __GLIBCXX__.
maintainer-scripts:
* README: Update.
* gcc_release: Update gcc/DEV-PHASE if that file exists, instead
of gcc/version.c.
* update_version: Handle updating gcc/DATESTAMP.
* update_web_docs: Generate gcc-vers.texi first.
From-SVN: r96549
2005-03-16 07:04:10 +01:00
|
|
|
(void) bindtextdomain ("gcc", LOCALEDIR);
|
|
|
|
(void) textdomain ("gcc");
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
|
|
|
/* Opening quotation mark. */
|
|
|
|
open_quote = _("`");
|
|
|
|
|
|
|
|
/* Closing quotation mark. */
|
|
|
|
close_quote = _("'");
|
|
|
|
|
|
|
|
#if defined HAVE_LANGINFO_CODESET
|
2009-05-04 14:23:50 +02:00
|
|
|
locale_encoding = nl_langinfo (CODESET);
|
|
|
|
if (locale_encoding != NULL
|
|
|
|
&& (!strcasecmp (locale_encoding, "utf-8")
|
|
|
|
|| !strcasecmp (locale_encoding, "utf8")))
|
|
|
|
locale_utf8 = true;
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
#endif
|
2009-05-04 14:23:50 +02:00
|
|
|
|
|
|
|
if (!strcmp (open_quote, "`") && !strcmp (close_quote, "'"))
|
|
|
|
{
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
/* Untranslated quotes that it may be possible to replace with
|
|
|
|
U+2018 and U+2019; but otherwise use "'" instead of "`" as
|
|
|
|
opening quote. */
|
|
|
|
open_quote = "'";
|
|
|
|
#if defined HAVE_LANGINFO_CODESET
|
2009-05-04 14:23:50 +02:00
|
|
|
if (locale_utf8)
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
{
|
|
|
|
open_quote = "\xe2\x80\x98";
|
|
|
|
close_quote = "\xe2\x80\x99";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2001-10-19 17:17:39 +02:00
|
|
|
}
|
|
|
|
|
2003-04-24 20:35:45 +02:00
|
|
|
#if defined HAVE_WCHAR_H && defined HAVE_WORKING_MBSTOWCS && defined HAVE_WCSWIDTH
|
2003-04-12 20:07:06 +02:00
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
/* Returns the width in columns of MSGSTR, which came from gettext.
|
|
|
|
This is for indenting subsequent output. */
|
|
|
|
|
|
|
|
size_t
|
2003-06-01 17:59:10 +02:00
|
|
|
gcc_gettext_width (const char *msgstr)
|
2003-04-12 20:07:06 +02:00
|
|
|
{
|
|
|
|
size_t nwcs = mbstowcs (0, msgstr, 0);
|
2008-06-29 06:39:16 +02:00
|
|
|
wchar_t *wmsgstr = XALLOCAVEC (wchar_t, nwcs + 1);
|
2003-04-12 20:07:06 +02:00
|
|
|
|
|
|
|
mbstowcs (wmsgstr, msgstr, nwcs + 1);
|
|
|
|
return wcswidth (wmsgstr, nwcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* no wcswidth */
|
|
|
|
|
|
|
|
/* We don't have any way of knowing how wide the string is. Guess
|
|
|
|
the length of the string. */
|
|
|
|
|
|
|
|
size_t
|
2003-06-01 17:59:10 +02:00
|
|
|
gcc_gettext_width (const char *msgstr)
|
2003-04-12 20:07:06 +02:00
|
|
|
{
|
|
|
|
return strlen (msgstr);
|
|
|
|
}
|
|
|
|
|
2001-10-19 17:17:39 +02:00
|
|
|
#endif
|
2003-04-12 20:07:06 +02:00
|
|
|
|
|
|
|
#endif /* ENABLE_NLS */
|
2009-12-15 01:20:03 +01:00
|
|
|
|
2010-02-14 20:44:07 +01:00
|
|
|
#ifndef ENABLE_NLS
|
|
|
|
|
|
|
|
const char *
|
|
|
|
fake_ngettext (const char *singular, const char *plural, unsigned long n)
|
|
|
|
{
|
|
|
|
if (n == 1UL)
|
|
|
|
return singular;
|
|
|
|
|
|
|
|
return plural;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-12-15 01:20:03 +01:00
|
|
|
/* Return the indent for successive lines, using the width of
|
|
|
|
the STR. STR must have been translated already. The string
|
|
|
|
must be freed by the caller. */
|
|
|
|
|
|
|
|
char *
|
|
|
|
get_spaces (const char *str)
|
|
|
|
{
|
|
|
|
size_t len = gcc_gettext_width (str);
|
alloc-pool.c, [...]: Add missing whitespace before "(".
gcc/
* alloc-pool.c, asan.c, auto-inc-dec.c, basic-block.h, bb-reorder.c,
bitmap.c, bitmap.h, bt-load.c, builtins.c, calls.c, cfgcleanup.c,
cfgexpand.c, cfghooks.c, cfgloop.c, cfgloopmanip.c, cfgrtl.c, cgraph.c,
cgraph.h, cgraphbuild.c, cgraphclones.c, cgraphunit.c, collect2.c,
combine-stack-adj.c, combine.c, compare-elim.c, context.c, context.h,
cprop.c, cse.c, cselib.c, dbxout.c, dce.c, defaults.h, df-core.c,
df-problems.c, df-scan.c, df.h, diagnostic.c, double-int.c, dse.c,
dumpfile.c, dwarf2asm.c, dwarf2cfi.c, dwarf2out.c, emit-rtl.c,
errors.c, except.c, expmed.c, expr.c, file-find.c, final.c,
fixed-value.c, fold-const.c, function.c, fwprop.c, gcc-ar.c, gcc.c,
gcov-io.c, gcov-io.h, gcov.c, gcse.c, genattr-common.c, genattr.c,
genattrtab.c, genautomata.c, genconfig.c, genemit.c, genextract.c,
genflags.c, gengenrtl.c, gengtype-state.c, gengtype.c, genmodes.c,
genopinit.c, genoutput.c, genpeep.c, genpreds.c, genrecog.c,
gensupport.c, ggc-common.c, ggc-page.c, gimple-fold.c, gimple-low.c,
gimple-pretty-print.c, gimple-ssa-strength-reduction.c, gimple.c,
gimple.h, godump.c, graphite-clast-to-gimple.c,
graphite-optimize-isl.c, graphite-poly.h, graphite-sese-to-poly.c,
graphite.c, haifa-sched.c, hash-table.c, hash-table.h, hwint.c,
hwint.h, ifcvt.c, incpath.c, init-regs.c, input.h, intl.c, intl.h,
ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c, ipa-inline.c,
ipa-profile.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c,
ipa-utils.c, ipa.c, ira-build.c, ira.c, jump.c, loop-doloop.c,
loop-init.c, loop-invariant.c, loop-iv.c, lower-subreg.c, lto-cgraph.c,
lto-streamer-in.c, lto-streamer-out.c, lto-wrapper.c, mcf.c,
mode-switching.c, modulo-sched.c, omp-low.c, optabs.c, opts.c,
pass_manager.h, passes.c, plugin.c, postreload-gcse.c, postreload.c,
predict.c, prefix.c, pretty-print.c, print-rtl.c, print-tree.c,
profile.c, read-md.c, real.c, real.h, recog.c, ree.c, reg-stack.c,
regcprop.c, reginfo.c, regmove.c, regrename.c, regs.h, regstat.c,
reload1.c, reorg.c, rtl.c, rtl.h, rtlanal.c, sbitmap.c, sched-rgn.c,
sdbout.c, sel-sched-ir.c, sel-sched.c, sparseset.c, stack-ptr-mod.c,
statistics.c, stmt.c, stor-layout.c, store-motion.c, streamer-hooks.h,
system.h, target-hooks-macros.h, targhooks.c, targhooks.h, toplev.c,
tracer.c, trans-mem.c, tree-browser.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-data-ref.c, tree-data-ref.h,
tree-eh.c, tree-emutls.c, tree-flow.h, tree-if-conv.c, tree-into-ssa.c,
tree-iterator.c, tree-loop-distribution.c, tree-mudflap.c,
tree-nested.c, tree-nomudflap.c, tree-nrv.c, tree-object-size.c,
tree-optimize.c, tree-pass.h, tree-pretty-print.c, tree-profile.c,
tree-scalar-evolution.c, tree-sra.c, tree-ssa-ccp.c,
tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-copyrename.c,
tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-live.c, tree-ssa-loop-ch.c,
tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-threadedge.c, tree-ssa-threadupdate.c,
tree-ssa-uncprop.c, tree-ssa-uninit.c, tree-ssa.c, tree-ssanames.c,
tree-stdarg.c, tree-switch-conversion.c, tree-tailcall.c,
tree-vect-data-refs.c, tree-vect-generic.c, tree-vect-loop-manip.c,
tree-vect-stmts.c, tree-vectorizer.c, tree-vectorizer.h, tree-vrp.c,
tree.c, tree.h, tsan.c, tsystem.h, value-prof.c, var-tracking.c,
varasm.c, vec.h, vmsdbgout.c, vtable-verify.c, web.c: Add missing
whitespace before "(".
From-SVN: r203004
2013-09-28 10:42:34 +02:00
|
|
|
char *spaces = XNEWVEC (char, len + 1);
|
2009-12-15 01:20:03 +01:00
|
|
|
memset (spaces, ' ', len);
|
|
|
|
spaces[len] = '\0';
|
|
|
|
return spaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|