annotate lib/printf.c @ 8402:12b641f5a848

New module 'printf-posix'.
author Bruno Haible <bruno@clisp.org>
date Sat, 10 Mar 2007 01:20:26 +0000 (2007-03-10)
parents
children bbbbbf4cd1c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8402
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Formatted output to a stream.
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 Copyright (C) 2007 Free Software Foundation, Inc.
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 any later version.
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License along
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 with this program; if not, write to the Free Software Foundation,
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 #ifdef HAVE_CONFIG_H
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 # include <config.h>
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #endif
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 /* Specification. */
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <stdio.h>
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <stdarg.h>
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 /* Print formatted output to standard output.
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 Return string length of formatted string. On error, return a negative
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 value. */
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 int
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 printf (const char *format, ...)
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 {
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 int retval;
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 va_list args;
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 va_start (args, format);
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 retval = vfprintf (stdout, format, args);
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 va_end (args);
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 return retval;
12b641f5a848 New module 'printf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 }