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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [intl.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Message translation utilities.
2
   Copyright (C) 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
6
GCC is free software; you can redistribute it and/or modify it under
7
the terms of the GNU General Public License as published by the Free
8
Software Foundation; either version 3, or (at your option) any later
9
version.
10
 
11
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GCC; see the file COPYING3.  If not see
18
<http://www.gnu.org/licenses/>.  */
19
 
20
#include "config.h"
21
#include "system.h"
22
#include "coretypes.h"
23
#include "tm.h"
24
#include "intl.h"
25
 
26
#ifdef HAVE_LANGINFO_CODESET
27
#include <langinfo.h>
28
#endif
29
 
30
/* Opening quotation mark for diagnostics.  */
31
const char *open_quote = "'";
32
 
33
/* Closing quotation mark for diagnostics.  */
34
const char *close_quote = "'";
35
 
36
#ifdef ENABLE_NLS
37
 
38
/* Initialize the translation library for GCC.  This performs the
39
   appropriate sequence of calls - setlocale, bindtextdomain,
40
   textdomain.  LC_CTYPE determines the character set used by the
41
   terminal, so it has be set to output messages correctly.  */
42
 
43
void
44
gcc_init_libintl (void)
45
{
46
#ifdef HAVE_LC_MESSAGES
47
  setlocale (LC_CTYPE, "");
48
  setlocale (LC_MESSAGES, "");
49
#else
50
  setlocale (LC_ALL, "");
51
#endif
52
 
53
  (void) bindtextdomain ("gcc", LOCALEDIR);
54
  (void) textdomain ("gcc");
55
 
56
  /* Opening quotation mark.  */
57
  open_quote = _("`");
58
 
59
  /* Closing quotation mark.  */
60
  close_quote = _("'");
61
 
62
  if (!strcmp (open_quote, "`") && !strcmp (close_quote, "'"))
63
    {
64
#if defined HAVE_LANGINFO_CODESET
65
      const char *encoding;
66
#endif
67
      /* Untranslated quotes that it may be possible to replace with
68
         U+2018 and U+2019; but otherwise use "'" instead of "`" as
69
         opening quote.  */
70
      open_quote = "'";
71
#if defined HAVE_LANGINFO_CODESET
72
      encoding = nl_langinfo (CODESET);
73
      if (encoding != NULL
74
          && (!strcasecmp (encoding, "utf-8")
75
              || !strcasecmp (encoding, "utf8")))
76
        {
77
          open_quote = "\xe2\x80\x98";
78
          close_quote = "\xe2\x80\x99";
79
        }
80
#endif
81
    }
82
}
83
 
84
#if defined HAVE_WCHAR_H && defined HAVE_WORKING_MBSTOWCS && defined HAVE_WCSWIDTH
85
#include <wchar.h>
86
 
87
/* Returns the width in columns of MSGSTR, which came from gettext.
88
   This is for indenting subsequent output.  */
89
 
90
size_t
91
gcc_gettext_width (const char *msgstr)
92
{
93
  size_t nwcs = mbstowcs (0, msgstr, 0);
94
  wchar_t *wmsgstr = alloca ((nwcs + 1) * sizeof (wchar_t));
95
 
96
  mbstowcs (wmsgstr, msgstr, nwcs + 1);
97
  return wcswidth (wmsgstr, nwcs);
98
}
99
 
100
#else  /* no wcswidth */
101
 
102
/* We don't have any way of knowing how wide the string is.  Guess
103
   the length of the string.  */
104
 
105
size_t
106
gcc_gettext_width (const char *msgstr)
107
{
108
  return strlen (msgstr);
109
}
110
 
111
#endif
112
 
113
#endif /* ENABLE_NLS */

powered by: WebSVN 2.1.0

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