aboutsummaryrefslogtreecommitdiff
path: root/lib/argp-fmtstream.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2008-07-10 00:52:03 +0000
committerPeter Wemm <peter@FreeBSD.org>2008-07-10 00:52:03 +0000
commit5715c7fb3cb3a3cbe3e156e13dee4e864943a72d (patch)
treea79e414d0b5fe7d2b7a8f6b24f1a1d7ed3edbb20 /lib/argp-fmtstream.c
parentbb7e869618a549ab9bde54c3a2cfa3a7fd96a28b (diff)
downloadsrc-5715c7fb3cb3a3cbe3e156e13dee4e864943a72d.tar.gz
src-5715c7fb3cb3a3cbe3e156e13dee4e864943a72d.zip
Notes
Diffstat (limited to 'lib/argp-fmtstream.c')
-rw-r--r--lib/argp-fmtstream.c51
1 files changed, 23 insertions, 28 deletions
diff --git a/lib/argp-fmtstream.c b/lib/argp-fmtstream.c
index c88c3db21471..0dd9256f570a 100644
--- a/lib/argp-fmtstream.c
+++ b/lib/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>.
@@ -15,13 +15,13 @@
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. */
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* This package emulates glibc `line_wrap_stream' semantics for systems that
don't have that. */
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
#include <stdlib.h>
@@ -101,11 +101,10 @@ __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", (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);
@@ -247,9 +246,10 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
Oh well. Put it on an overlong line by itself. */
p = buf + (r + 1 - fs->point_col);
/* Find the end of the long word. */
- do
- ++p;
- while (p < nl && !isblank (*p));
+ if (p < nl)
+ do
+ ++p;
+ while (p < nl && !isblank (*p));
if (p == nl)
{
/* It already ends a line. No fussing required. */
@@ -290,17 +290,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",
+ (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;
}
@@ -359,15 +357,12 @@ __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", (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;