Message-Id: Date: Wed, 14 Jan 98 15:13:56 MET From: Michel de Ruiter To: dj AT delorie DOT com cc: djgpp-workers AT delorie DOT com Subject: v*scanf Precedence: bulk DJ, I once submitted the file vsscanf.c for inclusion in libc. Now I completed it with vscanf.c, vfscanf.c, txh-files and changes in makefile and stdio.h. I just copied some code from v*printf, and I think it is kind of OK, though not thoroughly tested. Here's the diff: diff -cP ./makefile new/makefile *** ./makefile Sun Jun 4 03:01:06 1995 --- new/makefile Sun Jan 11 18:11:18 1998 *************** *** 4,8 **** --- 4,11 ---- SRC += mkstemp.c SRC += mktemp.c SRC += tempnam.c + SRC += vscanf.c + SRC += vfscanf.s + SRC += vsscanf.c include $(TOP)/../makefile.inc diff -cP ./stdio.h new/stdio.h *** ./stdio.h Sun Jan 11 18:10:44 1998 --- new/stdio.h Sun Jan 11 17:54:24 1998 *************** *** 130,135 **** --- 130,138 ---- void setlinebuf(FILE *_f); char * tempnam(const char *_dir, const char *_prefix); int _rename(const char *_old, const char *_new); /* Simple (no directory) */ + int vfscanf(FILE *_stream, const char *_format, va_list _ap); + int vscanf(const char *_format, va_list _ap); + int vsscanf(const char *_s, const char *_format, va_list _ap); #endif /* !_POSIX_SOURCE */ #endif /* !__STRICT_ANSI__ */ diff -cP ./vfscanf.s new/vfscanf.s *** ./vfscanf.s Thu Jan 1 01:00:00 1970 --- new/vfscanf.s Sun Jan 11 18:05:26 1998 *************** *** 0 **** --- 1,3 ---- + .global _vfscanf + _vfscanf: + jmp __doscan diff -cP ./vfscanf.txh new/vfscanf.txh *** ./vfscanf.txh Thu Jan 1 01:00:00 1970 --- new/vfscanf.txh Sun Jan 11 18:09:38 1998 *************** *** 0 **** --- 1,17 ---- + @node vfscanf, stdio + @subheading Syntax + + @example + #include + + int vfscanf(FILE *file, const char *format, va_list arguments); + @end example + + @subheading Description + + This function scans formatted text from @var{file} and stores it in the + variables pointed to by the @var{arguments}. @xref{scanf}. + + @subheading Return Value + + The number of items successfully scanned. diff -cP ./vscanf.c new/vscanf.c *** ./vscanf.c Thu Jan 1 01:00:00 1970 --- new/vscanf.c Sun Jan 11 17:44:42 1998 *************** *** 0 **** --- 1,8 ---- + #include + #include + + int + vscanf(const char *fmt, va_list ap) + { + return _doscan(stdin, fmt, ap); + } diff -cP ./vscanf.txh new/vscanf.txh *** ./vscanf.txh Thu Jan 1 01:00:00 1970 --- new/vscanf.txh Sun Jan 11 18:09:34 1998 *************** *** 0 **** --- 1,18 ---- + @node vscanf, stdio + @subheading Syntax + + @example + #include + + int vscanf(const char *format, va_list arguments); + @end example + + @subheading Description + + This function scans formatted text from @code{stdin} and stores it in the + variables pointed to by the @var{arguments}. @xref{scanf}. + @xref{vfscanf}. + + @subheading Return Value + + The number of items successfully scanned. diff -cP ./vsscanf.c new/vsscanf.c *** ./vsscanf.c Thu Jan 1 01:00:00 1970 --- new/vsscanf.c Sun Jan 11 17:44:38 1998 *************** *** 0 **** --- 1,18 ---- + #include + #include + #include + #include + + int + vsscanf(const char *str, const char *fmt, va_list ap) + { + FILE _strbuf; + + _strbuf._flag = _IOREAD|_IOSTRG; + _strbuf._ptr = _strbuf._base = unconst(str, char *); + _strbuf._cnt = 0; + while (*str++) + _strbuf._cnt++; + _strbuf._bufsiz = _strbuf._cnt; + return _doscan(&_strbuf, fmt, ap); + } diff -cP ./vsscanf.txh new/vsscanf.txh *** ./vsscanf.txh Thu Jan 1 01:00:00 1970 --- new/vsscanf.txh Sun Jan 11 18:09:44 1998 *************** *** 0 **** --- 1,18 ---- + @node vsscanf, stdio + @subheading Syntax + + @example + #include + + int vsscanf(const char *string, const char *format, va_list arguments); + @end example + + @subheading Description + + This function scans formatted text from the @var{string} and stores it + in the variables pointed to by the @var{arguments}. @xref{scanf}. + @xref{vfscanf}. + + @subheading Return Value + + The number of items successfully scanned. -- Groeten, Michel. http://www.cs.vu.nl/~mdruiter \----/==\----/ \ / \ / "You know, Beavis, you need things that suck, \/ \/ to have things that are cool", Butt-Head.