about summary refs log tree commit diff
path: root/argp
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-07-20 07:43:27 +0000
committerUlrich Drepper <drepper@redhat.com>2005-07-20 07:43:27 +0000
commitdf6f89692fd7e802f38f944ed73942354a9911f8 (patch)
tree12debd445b11886fcf433fc6f85e9abe615670cc /argp
parent10ffcd52f0578b13b48bdf84e73759353b29b673 (diff)
downloadglibc-df6f89692fd7e802f38f944ed73942354a9911f8.tar.gz
glibc-df6f89692fd7e802f38f944ed73942354a9911f8.tar.xz
glibc-df6f89692fd7e802f38f944ed73942354a9911f8.zip
* wcsmbs/bits/wchar2.h: Add definitions for wcrtomb, mbsrtowcs,
	wcsrtombs, mbsnrtowcs, and wcsnrtombs.
	* debug/Makefile (routines): Add wcrtomb_chk, mbsrtowcs_chk,
	wcsrtombs_chk, mbsnrtowcs_chk, and wcsnrtombs_chk.
	* debug/Versions: Add __wcrtomb_chk, __mbsrtowcs_chk,
	__wcsrtombs_chk, __mbsnrtowcs_chk, and __wcsnrtombs_chk.
	* debug/tst-chk1.c: Add tests for new functions.
	* debug/mbsnrtowcs_chk.c: New file.
	* debug/mbsrtowcs_chk.c: New file.
	* debug/wcrtomb_chk.c: New file.
	* debug/wcsnrtombs_chk.c: New file.
	* debug/wcsrtombs_chk.c: New file.

	* include/stdio.h: Add declaration for __fxprintf.
Diffstat (limited to 'argp')
-rw-r--r--argp/argp-fmtstream.c42
-rw-r--r--argp/argp-help.c103
2 files changed, 62 insertions, 83 deletions
diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 215160bdcd..efa8388a84 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -1,5 +1,5 @@
 /* Word-wrapping and line-truncating streams
-   Copyright (C) 1997,1998,1999,2001,2002,2003 Free Software Foundation, Inc.
+   Copyright (C) 1997-1999,2001,2002,2003,2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -102,11 +102,11 @@ __argp_fmtstream_free (argp_fmtstream_t fs)
   if (fs->p > fs->buf)
     {
 #ifdef USE_IN_LIBIO
-      if (_IO_fwide (fs->stream, 0) > 0)
-	__fwprintf (fs->stream, L"%.*s", (int) (fs->p - fs->buf), fs->buf);
-      else
+      __fxprintf (fs->stream, "%.*s", L"%.*s",
+		  (int) (fs->p - fs->buf), fs->buf);
+#else
+      fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
 #endif
-	fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
     }
   free (fs->buf);
   free (fs);
@@ -291,17 +291,15 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
 	      else
 		/* Output the first line so we can use the space.  */
 		{
-#ifdef USE_IN_LIBIO
-		  if (_IO_fwide (fs->stream, 0) > 0)
-		    __fwprintf (fs->stream, L"%.*s\n",
-				(int) (nl - fs->buf), fs->buf);
-		  else
+#ifdef _LIBC
+		  __fxprintf (fs->stream, "%.*s\n", L"%.*s\n",
+			      (int) (nl - fs->buf), fs->buf);
+#else
+		  if (nl > fs->buf)
+		    fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
+		  putc_unlocked ('\n', fs->stream);
 #endif
-		    {
-		      if (nl > fs->buf)
-			fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
-		      putc_unlocked ('\n', fs->stream);
-		    }
+
 		  len += buf - fs->buf;
 		  nl = buf = fs->buf;
 		}
@@ -360,15 +358,13 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
       /* Flush FS's buffer.  */
       __argp_fmtstream_update (fs);
 
-#ifdef USE_IN_LIBIO
-      if (_IO_fwide (fs->stream, 0) > 0)
-	{
-	  __fwprintf (fs->stream, L"%.*s", (int) (fs->p - fs->buf), fs->buf);
-	  wrote = fs->p - fs->buf;
-	}
-      else
+#ifdef _LIBC
+      __fxprintf (fs->stream, "%.*s", L"%.*s",
+		  (int) (fs->p - fs->buf), fs->buf);
+      wrote = fs->p - fs->buf;
+#else
+      wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
 #endif
-	wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
       if (wrote == fs->p - fs->buf)
 	{
 	  fs->p = fs->buf;
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 67018709d3..c5a9e84f7e 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -1,5 +1,5 @@
 /* Hierarchial argument parsing help output
-   Copyright (C) 1995-2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -1763,33 +1763,26 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)
 
 	  va_start (ap, fmt);
 
-#ifdef USE_IN_LIBIO
-	  if (_IO_fwide (stream, 0) > 0)
-	    {
-	      char *buf;
+#ifdef _LIBC
+	  char *buf;
 
-	      if (__asprintf (&buf, fmt, ap) < 0)
-		buf = NULL;
+	  if (__asprintf (&buf, fmt, ap) < 0)
+	    buf = NULL;
 
-	      __fwprintf (stream, L"%s: %s\n",
-			  state ? state->name : __argp_short_program_name (),
-			  buf);
+	  __fxprintf (stream, "%s: %s\n", L"%s: %s\n",
+		      state ? state->name : __argp_short_program_name (), buf);
 
-	      free (buf);
-	    }
-	  else
-#endif
-	    {
-	      fputs_unlocked (state
-			      ? state->name : __argp_short_program_name (),
-			      stream);
-	      putc_unlocked (':', stream);
-	      putc_unlocked (' ', stream);
+	  free (buf);
+#else
+	  fputs_unlocked (state ? state->name : __argp_short_program_name (),
+			  stream);
+	  putc_unlocked (':', stream);
+	  putc_unlocked (' ', stream);
 
-	      vfprintf (stream, fmt, ap);
+	  vfprintf (stream, fmt, ap);
 
-	      putc_unlocked ('\n', stream);
-	    }
+	  putc_unlocked ('\n', stream);
+#endif
 
 	  __argp_state_help (state, stream, ARGP_HELP_STD_ERR);
 
@@ -1827,41 +1820,34 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
 	  __flockfile (stream);
 #endif
 
-#ifdef USE_IN_LIBIO
-	  if (_IO_fwide (stream, 0) > 0)
-	    __fwprintf (stream, L"%s",
-			state ? state->name : __argp_short_program_name ());
-	  else
+#ifdef _LIBC
+	  __fxprintf (stream, "%s", L"%s",
+		      state ? state->name : __argp_short_program_name ());
+#else
+	  fputs_unlocked (state ? state->name : __argp_short_program_name (),
+			  stream);
 #endif
-	    fputs_unlocked (state
-			    ? state->name : __argp_short_program_name (),
-			    stream);
 
 	  if (fmt)
 	    {
 	      va_list ap;
 
 	      va_start (ap, fmt);
-#ifdef USE_IN_LIBIO
-	      if (_IO_fwide (stream, 0) > 0)
-		{
-		  char *buf;
+#ifdef _LIBC
+	      char *buf;
 
-		  if (__asprintf (&buf, fmt, ap) < 0)
-		    buf = NULL;
+	      if (__asprintf (&buf, fmt, ap) < 0)
+		buf = NULL;
 
-		  __fwprintf (stream, L": %s", buf);
+	      __fxprintf (stream, ": %s", L": %s", buf);
 
-		  free (buf);
-		}
-	      else
-#endif
-		{
-		  putc_unlocked (':', stream);
-		  putc_unlocked (' ', stream);
+	      free (buf);
+#else
+	      putc_unlocked (':', stream);
+	      putc_unlocked (' ', stream);
 
-		  vfprintf (stream, fmt, ap);
-		}
+	      vfprintf (stream, fmt, ap);
+#endif
 
 	      va_end (ap);
 	    }
@@ -1870,21 +1856,18 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
 	    {
 	      char buf[200];
 
-#ifdef USE_IN_LIBIO
-	      if (_IO_fwide (stream, 0) > 0)
-		__fwprintf (stream, L": %s",
-			    __strerror_r (errnum, buf, sizeof (buf)));
-	      else
-#endif
-		{
-		  putc_unlocked (':', stream);
-		  putc_unlocked (' ', stream);
-#if defined _LIBC || defined HAVE_STRERROR_R
-		  fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
+#ifdef _LIBC
+	      __fxprintf (stream, ": %s", L": %s",
+			  __strerror_r (errnum, buf, sizeof (buf)));
 #else
-		  fputs (strerror (errnum), stream);
+	      putc_unlocked (':', stream);
+	      putc_unlocked (' ', stream);
+# ifdef HAVE_STRERROR_R
+	      fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
+# else
+	      fputs (strerror (errnum), stream);
+# endif
 #endif
-		}
 	    }
 
 #ifdef USE_IN_LIBIO