diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-12 18:07:06 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-04-12 18:07:06 +0000 |
commit | d0a20a0fefdb8c2d535c660a2ed696e852a1be4b (patch) | |
tree | 5dc781e893303cba5531a0313f6b03e3fbcd2c77 /gcc/intl.c | |
parent | 48c9cd54610b0c89dcd1b1d73330277145915312 (diff) | |
download | gcc-d0a20a0fefdb8c2d535c660a2ed696e852a1be4b.tar.gz |
* configure.in: Check for wchar.h, mbstowcs, and wcswidth.
* configure, config.in: Regenerate.
* intl.c (gcc_gettext_width): New function.
* intl.h: Prototype it.
cp:
* call.c (print_z_candidates): Use gcc_gettext_width, not
strlen, to determine how much padding to use.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/intl.c')
-rw-r--r-- | gcc/intl.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/intl.c b/gcc/intl.c index 958e77af377..5a885bfec5d 100644 --- a/gcc/intl.c +++ b/gcc/intl.c @@ -45,4 +45,35 @@ gcc_init_libintl () (void) textdomain ("gcc"); } +#if defined HAVE_WCHAR_H && defined HAVE_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 (msgstr) + 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 (msgstr) + const char *msgstr; +{ + return strlen (msgstr); +} + #endif + +#endif /* ENABLE_NLS */ |