diff options
author | Jim Meyering <jim@meyering.net> | 2003-08-18 08:53:29 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-08-18 08:53:29 +0000 |
commit | 024b29b7e8d26172255bfc2c0bf0d6e1cc84d110 (patch) | |
tree | 4f7c18d448300cb94a26ca8b1645f3c24308e495 | |
parent | f8a1a4ef0c180924371bcd7d9fb0cb546692c4ba (diff) | |
download | coreutils-024b29b7e8d26172255bfc2c0bf0d6e1cc84d110.tar.xz |
Sync with gnulib.
-rw-r--r-- | lib/vasnprintf.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index b3ab2d612..9c701f1c6 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1,20 +1,19 @@ /* vsprintf with automatic memory allocation. Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) + This program 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 Software Foundation; either version 2, or (at your option) any later version. This program 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 - Library General Public License for more details. + 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 Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Tell glibc's <stdio.h> to provide a prototype for snprintf(). This must come before <config.h> because <config.h> may include @@ -48,6 +47,24 @@ # define freea(p) free (p) #endif +#ifdef HAVE_WCHAR_T +# ifdef HAVE_WCSLEN +# define local_wcslen wcslen +# else + /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid + a dependency towards this library, here is a local substitute. */ +static size_t +local_wcslen (const wchar_t *s) +{ + const wchar_t *ptr; + + for (ptr = s; *ptr != (wchar_t) 0; ptr++) + ; + return ptr - s; +} +# endif +#endif + char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) { @@ -369,7 +386,7 @@ vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) # ifdef HAVE_WCHAR_T if (type == TYPE_WIDE_STRING) tmp_length = - wcslen (a.arg[dp->arg_index].a.a_wide_string) + local_wcslen (a.arg[dp->arg_index].a.a_wide_string) * MB_CUR_MAX; else # endif |