Mercurial > hg > octave-shane > gnulib-hg
annotate lib/argp-fmtstream.h @ 15727:144db791c6fa
Ensure EBADF returns for socket functions on mingw.
* lib/accept.c (rpl_accept): Fail with error EBADF if the file
descriptor is invalid.
* lib/bind.c (rpl_bind): Likewise.
* lib/connect.c (rpl_connect): Likewise.
* lib/getpeername.c (rpl_getpeername): Likewise.
* lib/getsockname.c (rpl_getsockname): Likewise.
* lib/getsockopt.c (rpl_getsockopt): Likewise.
* lib/listen.c (rpl_listen): Likewise.
* lib/recv.c (rpl_recv): Likewise.
* lib/recvfrom.c (rpl_recvfrom): Likewise.
* lib/send.c (rpl_send): Likewise.
* lib/sendto.c (rpl_sendto): Likewise.
* lib/setsockopt.c (rpl_setsockopt): Likewise.
* lib/shutdown.c (rpl_shutdown): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 21 Sep 2011 00:20:59 +0200 |
parents | 4cf3b58aaf12 |
children | 8250f2777afc |
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. |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12762
diff
changeset
|
2 Copyright (C) 1997, 2006-2011 Free Software Foundation, Inc. |
4385
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 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6542
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
4419
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 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6542
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6542
diff
changeset
|
9 (at your option) 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 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6542
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
6542
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 /* 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
|
20 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
|
21 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
|
22 shouldn't be installed. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #ifndef _ARGP_FMTSTREAM_H |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 #define _ARGP_FMTSTREAM_H |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 #include <stdio.h> |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 #include <string.h> |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #include <unistd.h> |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 |
12762
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
31 /* The __attribute__ feature is available in gcc versions 2.5 and later. |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
32 The __-protected variants of the attributes 'format' and 'printf' are |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
33 accepted by gcc versions 2.6.4 (effectively 2.7) and later. |
14350
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
34 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because |
12762
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
35 gnulib and libintl do '#define printf __printf__' when they override |
410eaa89fb57
Avoid a link error due to the __printf__ symbol.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
36 the 'printf' function. */ |
14350
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
37 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) |
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
38 # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) |
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
39 #else |
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
40 # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ |
4767 | 41 #endif |
42 | |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 /* line_wrap_stream is available, so use that. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 #define ARGP_FMTSTREAM_USE_LINEWRAP |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 #endif |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 #ifdef ARGP_FMTSTREAM_USE_LINEWRAP |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 /* 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
|
51 *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
|
52 object, it just modifies the given stream (reversibly) to do |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 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
|
54 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 #include <linewrap.h> |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 typedef FILE *argp_fmtstream_t; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 #define argp_make_fmtstream line_wrap_stream |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 #define __argp_make_fmtstream line_wrap_stream |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 #define argp_fmtstream_free line_unwrap_stream |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 #define __argp_fmtstream_free line_unwrap_stream |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 #define __argp_fmtstream_putc(fs,ch) putc(ch,fs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 #define argp_fmtstream_putc(fs,ch) putc(ch,fs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 #define __argp_fmtstream_puts(fs,str) fputs(str,fs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 #define argp_fmtstream_puts(fs,str) fputs(str,fs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 #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
|
69 #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
|
70 #define __argp_fmtstream_printf fprintf |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 #define argp_fmtstream_printf fprintf |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 #define __argp_fmtstream_lmargin line_wrap_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 #define argp_fmtstream_lmargin line_wrap_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 #define __argp_fmtstream_set_lmargin line_wrap_set_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 #define argp_fmtstream_set_lmargin line_wrap_set_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 #define __argp_fmtstream_rmargin line_wrap_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 #define argp_fmtstream_rmargin line_wrap_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 #define __argp_fmtstream_set_rmargin line_wrap_set_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 #define argp_fmtstream_set_rmargin line_wrap_set_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 #define __argp_fmtstream_wmargin line_wrap_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 #define argp_fmtstream_wmargin line_wrap_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 #define __argp_fmtstream_set_wmargin line_wrap_set_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 #define argp_fmtstream_set_wmargin line_wrap_set_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 #define __argp_fmtstream_point line_wrap_point |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 #define argp_fmtstream_point line_wrap_point |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 #else /* !ARGP_FMTSTREAM_USE_LINEWRAP */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 /* Guess we have to define our own version. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 struct argp_fmtstream |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
92 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
93 FILE *stream; /* The stream we're outputting to. */ |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
95 size_t lmargin, rmargin; /* Left and right margins. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
96 ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */ |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 /* 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
|
99 size_t point_offs; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 /* 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
|
101 ssize_t point_col; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
103 char *buf; /* Output buffer. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
104 char *p; /* Current end of text in BUF. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
105 char *end; /* Absolute end of BUF. */ |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
106 }; |
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 typedef struct argp_fmtstream *argp_fmtstream_t; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
110 /* 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
|
111 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
|
112 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
|
113 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
|
114 Otherwise, chars beyond RMARGIN are simply dropped until a newline. |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
115 Returns NULL if there was an error. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
116 extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
117 size_t __lmargin, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
118 size_t __rmargin, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
119 ssize_t __wmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
121 size_t __lmargin, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
122 size_t __rmargin, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
123 ssize_t __wmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 /* 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
|
126 extern void __argp_fmtstream_free (argp_fmtstream_t __fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 extern void argp_fmtstream_free (argp_fmtstream_t __fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
130 const char *__fmt, ...) |
14350
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
131 _GL_ATTRIBUTE_FORMAT ((printf, 2, 3)); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
133 const char *__fmt, ...) |
14350
4cf3b58aaf12
Don't interfere with a program's definition of __attribute__.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
134 _GL_ATTRIBUTE_FORMAT ((printf, 2, 3)); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
136 #if _LIBC || !defined __OPTIMIZE__ |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 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
|
138 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
|
139 |
6542
08a1fd25e68a
* argp.h (__const): Remove macro. Use const instead.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6314
diff
changeset
|
140 extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str); |
08a1fd25e68a
* argp.h (__const): Remove macro. Use const instead.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6314
diff
changeset
|
141 extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
144 const char *__str, size_t __len); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
145 extern size_t argp_fmtstream_write (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
146 const char *__str, size_t __len); |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
147 #endif |
4385
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 /* Access macros for various bits of state. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
150 #define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
151 #define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
152 #define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 #define __argp_fmtstream_lmargin argp_fmtstream_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
154 #define __argp_fmtstream_rmargin argp_fmtstream_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
155 #define __argp_fmtstream_wmargin argp_fmtstream_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
156 |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
157 #if _LIBC || !defined __OPTIMIZE__ |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 /* 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
|
159 extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
160 size_t __lmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
162 size_t __lmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 /* 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
|
165 extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
166 size_t __rmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
168 size_t __rmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
170 /* 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
|
171 extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
172 size_t __wmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
173 extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
174 size_t __wmargin); |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
175 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
176 /* 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
|
177 extern size_t argp_fmtstream_point (argp_fmtstream_t __fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
178 extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs); |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
179 #endif |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
180 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
181 /* Internal routines. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
182 extern void _argp_fmtstream_update (argp_fmtstream_t __fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
183 extern void __argp_fmtstream_update (argp_fmtstream_t __fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
184 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
|
185 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
|
186 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
187 #ifdef __OPTIMIZE__ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
188 /* Inline versions of above routines. */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
189 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
190 #if !_LIBC |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
191 #define __argp_fmtstream_putc argp_fmtstream_putc |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
192 #define __argp_fmtstream_puts argp_fmtstream_puts |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 #define __argp_fmtstream_write argp_fmtstream_write |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
194 #define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
195 #define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
196 #define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
197 #define __argp_fmtstream_point argp_fmtstream_point |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
198 #define __argp_fmtstream_update _argp_fmtstream_update |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
199 #define __argp_fmtstream_ensure _argp_fmtstream_ensure |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
200 #endif |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
201 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
202 #ifndef ARGP_FS_EI |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
203 # ifdef __GNUC__ |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
204 /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
205 inline semantics, unless -fgnu89-inline is used. It defines a macro |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
206 __GNUC_STDC_INLINE__ to indicate this situation or a macro |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
207 __GNUC_GNU_INLINE__ to indicate the opposite situation. |
9897
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
208 |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
209 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
210 semantics but warns, unless -fgnu89-inline is used: |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
211 warning: C99 inline functions are not supported; using GNU89 |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
212 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute |
9897
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
213 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
214 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
215 Whereas Apple GCC 4.0.1 build 5479 without -std=c99 or -std=gnu99 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
216 implements the GNU C inline semantics and defines the macro |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
217 __GNUC_GNU_INLINE__, but it does not warn and does not support |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
218 __attribute__ ((__gnu_inline__)). |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
219 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
220 All in all, these are the possible combinations. For every compiler, |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
221 we need to choose ARGP_FS_EI so that the corresponding table cell |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
222 contains an "ok". |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
223 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
224 \ ARGP_FS_EI inline extern extern |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
225 \ inline inline |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
226 CC \ __attribute__ |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
227 ((gnu_inline)) |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
228 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
229 gcc 4.3.0 error ok ok |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
230 gcc 4.3.0 -std=gnu99 -fgnu89-inline error ok ok |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
231 gcc 4.3.0 -std=gnu99 ok error ok |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
232 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
233 gcc 4.2.2 error ok ok |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
234 gcc 4.2.2 -std=gnu99 -fgnu89-inline error ok ok |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
235 gcc 4.2.2 -std=gnu99 error warning ok |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
236 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
237 gcc 4.1.2 error ok warning |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
238 gcc 4.1.2 -std=gnu99 error ok warning |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
239 |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
240 Apple gcc 4.0.1 error ok warning |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
241 Apple gcc 4.0.1 -std=gnu99 ok error warning |
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
242 */ |
9339
06538f749e42
Prefer the ISO C99 inline semantics over the old GNU C inline semantics.
Bruno Haible <bruno@clisp.org>
parents:
9338
diff
changeset
|
243 # if defined __GNUC_STDC_INLINE__ |
06538f749e42
Prefer the ISO C99 inline semantics over the old GNU C inline semantics.
Bruno Haible <bruno@clisp.org>
parents:
9338
diff
changeset
|
244 # define ARGP_FS_EI inline |
9897
ebc67bd296ad
Adapt to future versions of Apple GCC.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
245 # elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
246 # define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__)) |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
247 # else |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
248 # define ARGP_FS_EI extern inline |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
249 # endif |
9336
5c22ca8dc833
* lib/argp-fmtstream.h (ARGP_FS_EI): Work around GCC 4.2.1 diagnostic
Paul Eggert <eggert@cs.ucla.edu>
parents:
9309
diff
changeset
|
250 # else |
9338
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
251 /* With other compilers, assume the ISO C99 meaning of 'inline', if |
ac948d4118d2
Handle 'inline' change in gcc 4.3.0.
Bruno Haible <bruno@clisp.org>
parents:
9336
diff
changeset
|
252 the compiler supports 'inline' at all. */ |
9336
5c22ca8dc833
* lib/argp-fmtstream.h (ARGP_FS_EI): Work around GCC 4.2.1 diagnostic
Paul Eggert <eggert@cs.ucla.edu>
parents:
9309
diff
changeset
|
253 # define ARGP_FS_EI inline |
5c22ca8dc833
* lib/argp-fmtstream.h (ARGP_FS_EI): Work around GCC 4.2.1 diagnostic
Paul Eggert <eggert@cs.ucla.edu>
parents:
9309
diff
changeset
|
254 # endif |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
255 #endif |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
256 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
257 ARGP_FS_EI size_t |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
258 __argp_fmtstream_write (argp_fmtstream_t __fs, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9897
diff
changeset
|
259 const char *__str, size_t __len) |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
260 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
261 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
|
262 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
263 memcpy (__fs->p, __str, __len); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
264 __fs->p += __len; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
265 return __len; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
266 } |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
267 else |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
268 return 0; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
269 } |
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 ARGP_FS_EI int |
6542
08a1fd25e68a
* argp.h (__const): Remove macro. Use const instead.
Paul Eggert <eggert@cs.ucla.edu>
parents:
6314
diff
changeset
|
272 __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str) |
4385
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
273 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
274 size_t __len = strlen (__str); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
275 if (__len) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
276 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
277 size_t __wrote = __argp_fmtstream_write (__fs, __str, __len); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
278 return __wrote == __len ? 0 : -1; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
279 } |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
280 else |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
281 return 0; |
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 ARGP_FS_EI int |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
285 __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
286 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
287 if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1)) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
288 return *__fs->p++ = __ch; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
289 else |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
290 return EOF; |
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 /* 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
|
294 ARGP_FS_EI size_t |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
295 __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
|
296 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
297 size_t __old; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
298 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
299 __argp_fmtstream_update (__fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
300 __old = __fs->lmargin; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
301 __fs->lmargin = __lmargin; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
302 return __old; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
303 } |
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 /* 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
|
306 ARGP_FS_EI size_t |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
307 __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
|
308 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
309 size_t __old; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
310 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
311 __argp_fmtstream_update (__fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
312 __old = __fs->rmargin; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
313 __fs->rmargin = __rmargin; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
314 return __old; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
315 } |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
316 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
317 /* 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
|
318 ARGP_FS_EI size_t |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
319 __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
|
320 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
321 size_t __old; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
322 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
323 __argp_fmtstream_update (__fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
324 __old = __fs->wmargin; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
325 __fs->wmargin = __wmargin; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
326 return __old; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
327 } |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
328 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
329 /* 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
|
330 ARGP_FS_EI size_t |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
331 __argp_fmtstream_point (argp_fmtstream_t __fs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
332 { |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
333 if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs) |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
334 __argp_fmtstream_update (__fs); |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
335 return __fs->point_col >= 0 ? __fs->point_col : 0; |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
336 } |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
337 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
338 #if !_LIBC |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
339 #undef __argp_fmtstream_putc |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
340 #undef __argp_fmtstream_puts |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
341 #undef __argp_fmtstream_write |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
342 #undef __argp_fmtstream_set_lmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
343 #undef __argp_fmtstream_set_rmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
344 #undef __argp_fmtstream_set_wmargin |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
345 #undef __argp_fmtstream_point |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
346 #undef __argp_fmtstream_update |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
347 #undef __argp_fmtstream_ensure |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
348 #endif |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
349 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
350 #endif /* __OPTIMIZE__ */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
351 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
352 #endif /* ARGP_FMTSTREAM_USE_LINEWRAP */ |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
353 |
1c170fb33fa6
argp facility from glibc-20030610.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
354 #endif /* argp-fmtstream.h */ |