summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/intl.c
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2004-07-28 03:11:36 +0000
committerkan <kan@FreeBSD.org>2004-07-28 03:11:36 +0000
commit5e00ec74d8ce58f99801200d4d3d0412c7cc1b28 (patch)
tree052f4bb635f2bea2c5e350bd60c902be100a0d1e /contrib/gcc/intl.c
parent87b8398a7d9f9bf0e28bbcd54a4fc27db2125f38 (diff)
downloadFreeBSD-src-5e00ec74d8ce58f99801200d4d3d0412c7cc1b28.zip
FreeBSD-src-5e00ec74d8ce58f99801200d4d3d0412c7cc1b28.tar.gz
Gcc 3.4.2 20040728.
Diffstat (limited to 'contrib/gcc/intl.c')
-rw-r--r--contrib/gcc/intl.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/contrib/gcc/intl.c b/contrib/gcc/intl.c
index 87dad51..0461329 100644
--- a/contrib/gcc/intl.c
+++ b/contrib/gcc/intl.c
@@ -1,5 +1,5 @@
/* Message translation utilities.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003 Free Software Foundation, Inc.
This file is part of GCC.
@@ -20,6 +20,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "config.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "intl.h"
#ifdef ENABLE_NLS
@@ -30,7 +32,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
terminal, so it has be set to output messages correctly. */
void
-gcc_init_libintl ()
+gcc_init_libintl (void)
{
#ifdef HAVE_LC_MESSAGES
setlocale (LC_CTYPE, "");
@@ -43,4 +45,33 @@ gcc_init_libintl ()
(void) textdomain ("gcc");
}
+#if defined HAVE_WCHAR_H && defined HAVE_WORKING_MBSTOWCS && defined HAVE_WCSWIDTH
+#include <wchar.h>
+
+/* Returns the width in columns of MSGSTR, which came from gettext.
+ This is for indenting subsequent output. */
+
+size_t
+gcc_gettext_width (const char *msgstr)
+{
+ size_t nwcs = mbstowcs (0, msgstr, 0);
+ wchar_t *wmsgstr = alloca ((nwcs + 1) * sizeof (wchar_t));
+
+ 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
+gcc_gettext_width (const char *msgstr)
+{
+ return strlen (msgstr);
+}
+
#endif
+
+#endif /* ENABLE_NLS */
OpenPOWER on IntegriCloud