annotate lib/argp-fmtstream.h @ 4767:0a9cf348c2ec

argp update from libc
author Karl Berry <karl@freefriends.org>
date Sat, 04 Oct 2003 12:28:06 +0000
parents 9b828c973b9d
children a48fb0e98c8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4385
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Word-wrapping and line-truncating streams.
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 Copyright (C) 1997 Free Software Foundation, Inc.
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 This file is part of the GNU C Library.
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 Written by Miles Bader <miles@gnu.ai.mit.edu>.
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5
4419
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
6 This program is free software; you can redistribute it and/or modify
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
7 it under the terms of the GNU General Public License as published by
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
9 any later version.
4385
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10
4419
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
11 This program is distributed in the hope that it will be useful,
4385
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
4419
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
14 GNU General Public License for more details.
4385
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15
4419
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
16 You should have received a copy of the GNU General Public License along
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
17 with this program; if not, write to the Free Software Foundation,
9b828c973b9d Get lib/argp* from glibc.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4385
diff changeset
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
4385
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 /* This package emulates glibc `line_wrap_stream' semantics for systems that
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 don't have that. If the system does have it, it is just a wrapper for
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 that. This header file is only used internally while compiling argp, and
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 shouldn't be installed. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #ifndef _ARGP_FMTSTREAM_H
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #define _ARGP_FMTSTREAM_H
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #ifdef HAVE_CONFIG_H
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #include <config.h>
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #endif
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #include <stdio.h>
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 #include <string.h>
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #include <unistd.h>
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
4767
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
36 #ifndef __attribute__
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
37 /* This feature is available in gcc versions 2.5 and later. */
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
38 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
39 # define __attribute__(Spec) /* empty */
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
40 # endif
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
41 /* The __-protected variants of `format' and `printf' attributes
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
42 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
43 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
44 # define __format__ format
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
45 # define __printf__ printf
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
46 # endif
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
47 #endif
0a9cf348c2ec argp update from libc
Karl Berry <karl@freefriends.org>
parents: 4419
diff changeset
48
4385
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H))
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 /* line_wrap_stream is available, so use that. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 #define ARGP_FMTSTREAM_USE_LINEWRAP
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 #endif
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 #ifdef ARGP_FMTSTREAM_USE_LINEWRAP
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 /* Just be a simple wrapper for line_wrap_stream; the semantics are
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 *slightly* different, as line_wrap_stream doesn't actually make a new
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 object, it just modifies the given stream (reversibly) to do
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 line-wrapping. Since we control who uses this code, it doesn't matter. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 #include <linewrap.h>
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 typedef FILE *argp_fmtstream_t;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 #define argp_make_fmtstream line_wrap_stream
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 #define __argp_make_fmtstream line_wrap_stream
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 #define argp_fmtstream_free line_unwrap_stream
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 #define __argp_fmtstream_free line_unwrap_stream
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 #define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 #define argp_fmtstream_putc(fs,ch) putc(ch,fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 #define __argp_fmtstream_puts(fs,str) fputs(str,fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 #define argp_fmtstream_puts(fs,str) fputs(str,fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 #define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 #define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 #define __argp_fmtstream_printf fprintf
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 #define argp_fmtstream_printf fprintf
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 #define __argp_fmtstream_lmargin line_wrap_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 #define argp_fmtstream_lmargin line_wrap_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 #define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 #define argp_fmtstream_set_lmargin line_wrap_set_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 #define __argp_fmtstream_rmargin line_wrap_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 #define argp_fmtstream_rmargin line_wrap_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 #define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 #define argp_fmtstream_set_rmargin line_wrap_set_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 #define __argp_fmtstream_wmargin line_wrap_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 #define argp_fmtstream_wmargin line_wrap_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 #define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 #define argp_fmtstream_set_wmargin line_wrap_set_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 #define __argp_fmtstream_point line_wrap_point
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 #define argp_fmtstream_point line_wrap_point
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 #else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 /* Guess we have to define our own version. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 #ifndef __const
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 #define __const const
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 #endif
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 struct argp_fmtstream
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 FILE *stream; /* The stream we're outputting to. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 size_t lmargin, rmargin; /* Left and right margins. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 /* Point in buffer to which we've processed for wrapping, but not output. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 size_t point_offs;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 ssize_t point_col;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 char *buf; /* Output buffer. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 char *p; /* Current end of text in BUF. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 char *end; /* Absolute end of BUF. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 };
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 typedef struct argp_fmtstream *argp_fmtstream_t;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 /* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 written on it with LMARGIN spaces and limits them to RMARGIN columns
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 replacing the whitespace before them with a newline and WMARGIN spaces.
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 Otherwise, chars beyond RMARGIN are simply dropped until a newline.
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 Returns NULL if there was an error. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 size_t __lmargin,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 size_t __rmargin,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 ssize_t __wmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 size_t __lmargin,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 size_t __rmargin,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 ssize_t __wmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 /* Flush __FS to its stream, and free it (but don't close the stream). */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 extern void argp_fmtstream_free (argp_fmtstream_t __fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 __const char *__fmt, ...)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 __attribute__ ((__format__ (printf, 2, 3)));
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 __const char *__fmt, ...)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 __attribute__ ((__format__ (printf, 2, 3)));
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 extern int argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 __const char *__str, size_t __len);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 __const char *__str, size_t __len);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 /* Access macros for various bits of state. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 #define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 #define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 #define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 #define __argp_fmtstream_lmargin argp_fmtstream_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 #define __argp_fmtstream_rmargin argp_fmtstream_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 #define __argp_fmtstream_wmargin argp_fmtstream_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 /* Set __FS's left margin to LMARGIN and return the old value. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 size_t __lmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 size_t __lmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 /* Set __FS's right margin to __RMARGIN and return the old value. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 size_t __rmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 size_t __rmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 /* Set __FS's wrap margin to __WMARGIN and return the old value. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 size_t __wmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 size_t __wmargin);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 /* Return the column number of the current output point in __FS. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184 extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 /* Internal routines. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 #ifdef __OPTIMIZE__
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 /* Inline versions of above routines. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 #if !_LIBC
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 #define __argp_fmtstream_putc argp_fmtstream_putc
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 #define __argp_fmtstream_puts argp_fmtstream_puts
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 #define __argp_fmtstream_write argp_fmtstream_write
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 #define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 #define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 #define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 #define __argp_fmtstream_point argp_fmtstream_point
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 #define __argp_fmtstream_update _argp_fmtstream_update
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 #define __argp_fmtstream_ensure _argp_fmtstream_ensure
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 #endif
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 #ifndef ARGP_FS_EI
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 #define ARGP_FS_EI extern inline
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 #endif
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 ARGP_FS_EI size_t
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 __argp_fmtstream_write (argp_fmtstream_t __fs,
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 __const char *__str, size_t __len)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218 memcpy (__fs->p, __str, __len);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 __fs->p += __len;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220 return __len;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222 else
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 return 0;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 ARGP_FS_EI int
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229 size_t __len = strlen (__str);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 if (__len)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 return __wrote == __len ? 0 : -1;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 else
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 return 0;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 ARGP_FS_EI int
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 return *__fs->p++ = __ch;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 else
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 return EOF;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 /* Set __FS's left margin to __LMARGIN and return the old value. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 ARGP_FS_EI size_t
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250 __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 size_t __old;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 __argp_fmtstream_update (__fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 __old = __fs->lmargin;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 __fs->lmargin = __lmargin;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 return __old;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 /* Set __FS's right margin to __RMARGIN and return the old value. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 ARGP_FS_EI size_t
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
262 __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 size_t __old;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 __argp_fmtstream_update (__fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 __old = __fs->rmargin;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 __fs->rmargin = __rmargin;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 return __old;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 /* Set FS's wrap margin to __WMARGIN and return the old value. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 ARGP_FS_EI size_t
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 size_t __old;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 __argp_fmtstream_update (__fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279 __old = __fs->wmargin;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 __fs->wmargin = __wmargin;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 return __old;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 /* Return the column number of the current output point in __FS. */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 ARGP_FS_EI size_t
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 __argp_fmtstream_point (argp_fmtstream_t __fs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 {
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 __argp_fmtstream_update (__fs);
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 return __fs->point_col >= 0 ? __fs->point_col : 0;
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 }
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 #if !_LIBC
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 #undef __argp_fmtstream_putc
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295 #undef __argp_fmtstream_puts
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296 #undef __argp_fmtstream_write
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
297 #undef __argp_fmtstream_set_lmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
298 #undef __argp_fmtstream_set_rmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299 #undef __argp_fmtstream_set_wmargin
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
300 #undef __argp_fmtstream_point
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
301 #undef __argp_fmtstream_update
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
302 #undef __argp_fmtstream_ensure
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 #endif
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305 #endif /* __OPTIMIZE__ */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
307 #endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
308
1c170fb33fa6 argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
309 #endif /* argp-fmtstream.h */