Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2001-04-21 02:50:51 +0400
committerJeff Johnston <jjohnstn@redhat.com>2001-04-21 02:50:51 +0400
commit52cb9e6934c1417a03fe20f6be8f479b8f9fb3d5 (patch)
treea1446b632877f034bd4ff0892d7c89bcb099bb56 /newlib/libc/stdio/sscanf.c
parent3c8e92d9fc43e7b8c8e5ad4a0235599d7b285274 (diff)
2001-04-20 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/stdio.h[!_REENT_ONLY]: Moved various functions together into one list. [!__STRICT_ANSI__]: Moved non-ANSI I/O functions in this list. (vfscanf, vscanf, vsscanf, _vfscanf_r, _vscanf_r, _vsscanf_r): New function prototypes. (_fscanf_r, _sscanf_r): Ditto. * libc/include/stdlib.h: Added _strtod_r prototype. * libc/stdio/Makefile.am: Add new v*scanf functions. * libc/stdio/Makefile.in: Regenerate. * libc/stdio/fscanf.c: Reorganized so HAVE_STDC only affects prototype and code is shared. Added reentrant _fscanf_r which calls __svfscanf_r. * libc/stdio/scanf.c: Changed to call __svfscanf_r. * libc/stdio/sscanf.c: Changed documentation to add reentrant routines. (sscanf): Changed to call __svfscanf_r with _REENT argument. (_sscanf_r): New routine. * libc/stdio/local.h: Removed __svfscanf prototype and replaced it with __svfscanf_r prototype. * libc/stdio/vfscanf.c (vfscanf, _vfscanf_r: New routines. (__svfscanf_r): Reentrant version of __svfscanf which takes reetrancy structure as argument as calls reentrant versions of helper functions (e.g. _strtol_r, _strtoul_r). Also replaced calls to atol and atof to _strtol_r and _strtod_r respectively. * libc/stdio/vfscanf.c: Also changed __svfscanf to call __svfscanf_r. * libc/stdlib/strtod.c (strtod): Changed to call _strtod_r with _REENT argument. * libc/stdio/vscanf.c: New file. * libc/stdio/vsscanf.c: Ditto.
Diffstat (limited to 'newlib/libc/stdio/sscanf.c')
-rw-r--r--newlib/libc/stdio/sscanf.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c
index 5a403de5c..7cf897c5b 100644
--- a/newlib/libc/stdio/sscanf.c
+++ b/newlib/libc/stdio/sscanf.c
@@ -35,6 +35,11 @@ ANSI_SYNOPSIS
int sscanf(const char *<[str]>, const char *<[format]>
[, <[arg]>, ...]);
+ int _scanf_r(struct _reent *<[ptr]>, const char *<[format]> [, <[arg]>, ...]);
+ int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]);
+ int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>, const char *<[format]>
+ [, <[arg]>, ...]);
+
TRAD_SYNOPSIS
#include <stdio.h>
@@ -50,6 +55,20 @@ TRAD_SYNOPSIS
char *<[str]>;
char *<[format]>;
+ int _scanf_r(<[ptr]>, <[format]> [, <[arg]>, ...])
+ struct _reent *<[ptr]>;
+ char *<[format]>;
+
+ int _fscanf_r(<[ptr]>, <[fd]>, <[format]> [, <[arg]>, ...]);
+ struct _reent *<[ptr]>;
+ FILE *<[fd]>;
+ char *<[format]>;
+
+ int _sscanf_r(<[ptr]>, <[str]>, <[format]> [, <[arg]>, ...]);
+ struct _reent *<[ptr]>;
+ char *<[str]>;
+ char *<[format]>;
+
DESCRIPTION
<<scanf>> scans a series of input fields from standard input,
@@ -74,6 +93,10 @@ DESCRIPTION
source of input: <<fscanf>> reads from a file, and <<sscanf>>
from a string.
+ The routines <<_scanf_r>>, <<_fscanf_r>>, and <<_sscanf_r>> are reentrant
+ versions of <<scanf>>, <<fscanf>>, and <<sscanf>> that take an additional
+ first argument pointing to a reentrancy structure.
+
The string at <<*<[format]>>> is a character sequence composed
of zero or more directives. Directives are composed of
one or more whitespace characters, non-whitespace characters,
@@ -353,6 +376,8 @@ eofread (cookie, buf, len)
return 0;
}
+#ifndef _REENT_ONLY
+
#ifdef _HAVE_STDC
int
_DEFUN (sscanf, (str, fmt), _CONST char *str _AND _CONST char *fmt _DOTS)
@@ -380,7 +405,42 @@ sscanf (str, fmt, va_alist)
#else
va_start (ap);
#endif
- ret = __svfscanf (&f, fmt, ap);
+ ret = __svfscanf_r (_REENT, &f, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+#endif /* !_REENT_ONLY */
+
+#ifdef _HAVE_STDC
+int
+_DEFUN (_sscanf_r, (ptr, str, fmt), struct _reent *ptr _AND _CONST char *str _AND _CONST char *fmt _DOTS)
+#else
+int
+_sscanf_r (ptr, str, fmt, va_alist)
+ struct _reent *ptr;
+ _CONST char *str;
+ _CONST char *fmt;
+ va_dcl
+#endif
+{
+ int ret;
+ va_list ap;
+ FILE f;
+
+ f._flags = __SRD;
+ f._bf._base = f._p = (unsigned char *) str;
+ f._bf._size = f._r = strlen (str);
+ f._read = eofread;
+ f._ub._base = NULL;
+ f._lb._base = NULL;
+ f._data = _REENT;
+#ifdef _HAVE_STDC
+ va_start (ap, fmt);
+#else
+ va_start (ap);
+#endif
+ ret = __svfscanf_r (ptr, &f, fmt, ap);
va_end (ap);
return ret;
}