vfscanf in newlib

J. Johnston jjohnstn@cygnus.com
Wed Apr 18 16:14:00 GMT 2001


"Charles S. Wilson" wrote:
> 
> Is there a reason, other than 'nobody has gotten round tuit yet', that
> vfscanf is not implemented in newlib?
>

It's a glibc extension.  Nobody thus far has asked for it in newlib.

> newlib/libc/stdio/vfscanf.c contains a function "__svfscanf()" that is
> used as the guts of scanf(), fscanf(), and sscanf(). It seems to me as
> though vfscanf() would be a trivial wrapper around __svfscanf() -- or am
> I missing something?
> 

No, you are correct; they are straightforward to add.  I will do so when I get the chance.

-- Jeff J.

> 
> possible implementation (vfscanf, vscanf, vsscanf)...
> 
> #ifdef _HAVE_STDC
> _DEFUN (vfscanf, (fp, fmt, ap), register FILE *fp _AND _CONST char *fmt
> _AND va_list ap)
> #else
> int
> vfscanf (fp, fmt, ap)
>     register FILE *fp;
>     _CONST char *fmt;
>     va_list ap;
> #endif
> {
>   return __svfscanf (fp, fmt, ap);
> }
> 
> #ifdef _HAVE_STDC
> _DEFUN (vscanf, (fmt, ap), _CONST char *str _AND va_list ap)
> #else
> int
> vscanf (fmt, ap)
>     _CONST char *fmt;
>     va_list ap;
> #endif
> {
>   return __svfscanf (stdin, fmt0, ap);
> }
> 
> /* brazenly adapted from newlib's sscanf.c */
> #ifdef _HAVE_STDC
> _DEFUN (vsscanf, (str, fmt, ap), _CONST char *str _AND _CONST char *fmt
> _AND va_list ap)
> #else
> int
> vsscanf (str, fmt, ap)
>     _CONST char *str;
>     _CONST char *fmt;
>     va_list ap;
> #endif
> {
>   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;
>   return __svfscanf (&f, fmt, ap);
> }



More information about the Newlib mailing list