aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/siprintf.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-11-24 00:45:41 +0000
committerJeff Johnston <jjohnstn@redhat.com>2004-11-24 00:45:41 +0000
commit3bf091476a0a544e388e9c8b7aab3371a7d936b5 (patch)
treeee3f3d8cf1be43b9a056e057e05def630503dace /newlib/libc/stdio/siprintf.c
parent4b8e88e31d7efb45cddf753611fdb55f70ccdc9d (diff)
downloadnewlib-3bf091476a0a544e388e9c8b7aab3371a7d936b5.zip
newlib-3bf091476a0a544e388e9c8b7aab3371a7d936b5.tar.gz
newlib-3bf091476a0a544e388e9c8b7aab3371a7d936b5.tar.bz2
2004-11-23 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h: Add new iprintf and iscanf variants. Also do some reordering. * libc/machine/powerpc/vfscanf.c: Remove __sccl function. * libc/stdio/Makefile.am: Add support for new iprintf and iscanf family functions. * libc/stdio/Makefile.in: Regenerated. * libc/stdio/fiprintf.c: Remove doc to siprintf.c. * libc/stdio/iprintf.c: Ditto. * libc/stdio/local.h (__svfiscanf_r): New prototype. * libc/stdio/siprintf.c: Add docs for various iprintf family functions. * libc/stdio/sniprintf.c: Move docs to siprintf.c. * libc/stdio/stdio.tex: Add new functions. * libc/stdio/vfscanf.c: Split out __sccl function to separate file and add special name defines so this file can be used to build vfiscanf.o. * libc/stdio/asiprintf.c: New file. * libc/stdio/fiscanf.c: Ditto. * libc/stdio/iscanf.c: Ditto. * libc/stdio/sccl.c: Ditto. * libc/stdio/siscanf.c: Ditto. * libc/stdio/vasiprintf.c: Ditto. * libc/stdio/viprintf.c: Ditto. * libc/stdio/viscanf.c: Ditto. * libc/stdio/vsiprintf.c: Ditto. * libc/stdio/vsiscanf.c: Ditto. * libc/stdio/vsniprintf.c: Ditto.
Diffstat (limited to 'newlib/libc/stdio/siprintf.c')
-rw-r--r--newlib/libc/stdio/siprintf.c96
1 files changed, 63 insertions, 33 deletions
diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c
index 8382008..18ba489 100644
--- a/newlib/libc/stdio/siprintf.c
+++ b/newlib/libc/stdio/siprintf.c
@@ -17,37 +17,68 @@
/*
FUNCTION
-<<siprintf>>---write formatted output (integer only)
+ <<iprintf>>, <<fiprintf>>, <<asiprintf>>, <<siprintf>>, <<sniprintf>>---format output
INDEX
+ fiprintf
+INDEX
+ iprintf
+INDEX
+ asiprintf
+INDEX
siprintf
+INDEX
+ sniprintf
ANSI_SYNOPSIS
#include <stdio.h>
+ int iprintf(const char *<[format]> [, <[arg]>, ...]);
+ int fiprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
int siprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]);
+ int asiprintf(char **<[strp]>, const char *<[format]> [, <[arg]>, ...]);
+ int sniprintf(char *<[str]>, size_t <[size]>, const char *<[format]> [, <[arg]>, ...]);
TRAD_SYNOPSIS
- #include <stdio.h>
+ #include <stdio.h>
- int siprintf(<[str]>, <[format]>, [, <[arg]>, ...])
- char *<[str]>;
- const char *<[format]>;
+ int iprintf(<[format]> [, <[arg]>, ...])
+ char *<[format]>;
+
+ int fiprintf(<[fd]>, <[format]> [, <[arg]>, ...]);
+ FILE *<[fd]>;
+ char *<[format]>;
+
+ int asiprintf(<[strp]>, <[format]> [, <[arg]>, ...]);
+ char **<[strp]>;
+ char *<[format]>;
+
+ int siprintf(<[str]>, <[format]> [, <[arg]>, ...]);
+ char *<[str]>;
+ char *<[format]>;
+
+ int sniprintf(<[str]>, size_t <[size]>, <[format]> [, <[arg]>, ...]);
+ char *<[str]>;
+ size_t <[size]>;
+ char *<[format]>;
DESCRIPTION
-<<siprintf>> is a restricted version of <<sprintf>>: it has the same
-arguments and behavior, save that it cannot perform any floating-point
-formatting: the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers
-are not recognized.
+ <<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>,
+ <<asiprintf>>, are the same as <<printf>>, <<fprintf>>,
+ <<sprintf>>, <<snprintf>>, and <<asprintf>>, respectively,
+ only that they restrict usage to non-floating-point format
+ specifiers.
RETURNS
- <<siprintf>> returns the number of bytes in the output string,
- save that the concluding <<NULL>> is not counted.
- <<siprintf>> returns when the end of the format string is
- encountered.
+<<siprintf>> and <<asiprintf>> return the number of bytes in the output string,
+save that the concluding <<NULL>> is not counted.
+<<iprintf>> and <<fiprintf>> return the number of characters transmitted.
+If an error occurs, <<iprintf>> and <<fiprintf>> return <<EOF>> and
+<<asiprintf>> returns -1. No error returns occur for <<siprintf>>.
PORTABILITY
-<<siprintf>> is not required by ANSI C.
+<<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>, and <<asprintf>>
+are newlib extensions.
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
@@ -64,18 +95,18 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <limits.h>
#include "local.h"
-#ifndef _REENT_ONLY
-
int
#ifdef _HAVE_STDC
-_DEFUN(siprintf, (str, fmt),
- char *str _AND
+_DEFUN(_siprintf_r, (ptr, str, fmt),
+ struct _reent *ptr _AND
+ char *str _AND
_CONST char *fmt _DOTS)
#else
-siprintf(str, fmt, va_alist)
- char *str;
- _CONST char *fmt;
- va_dcl
+_siprintf_r(ptr, str, fmt, va_alist)
+ struct _reent *ptr;
+ char *str;
+ _CONST char *fmt;
+ va_dcl
#endif
{
int ret;
@@ -91,26 +122,24 @@ siprintf(str, fmt, va_alist)
#else
va_start (ap);
#endif
- ret = vfiprintf (&f, fmt, ap);
+ ret = _vfiprintf_r (ptr, &f, fmt, ap);
va_end (ap);
*f._p = 0;
return (ret);
}
-#endif /* ! _REENT_ONLY */
+#ifndef _REENT_ONLY
int
#ifdef _HAVE_STDC
-_DEFUN(_siprintf_r, (rptr, str, fmt),
- struct _reent *rptr _AND
- char *str _AND
+_DEFUN(siprintf, (str, fmt),
+ char *str _AND
_CONST char *fmt _DOTS)
#else
-_siprintf_r(rptr, str, fmt, va_alist)
- struct _reent *rptr;
- char *str;
- _CONST char *fmt;
- va_dcl
+siprintf(str, fmt, va_alist)
+ char *str;
+ _CONST char *fmt;
+ va_dcl
#endif
{
int ret;
@@ -126,9 +155,10 @@ _siprintf_r(rptr, str, fmt, va_alist)
#else
va_start (ap);
#endif
- ret = _vfiprintf_r (rptr, &f, fmt, ap);
+ ret = _vfiprintf_r (_REENT, &f, fmt, ap);
va_end (ap);
*f._p = 0;
return (ret);
}
+#endif