doscan.c revision 7257d1b4d25bfac0c802847390e98a464fd787ac
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * CDDL HEADER START
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * The contents of this file are subject to the terms of the
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Common Development and Distribution License (the "License").
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * You may not use this file except in compliance with the License.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * See the License for the specific language governing permissions
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * and limitations under the License.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * When distributing Covered Code, include this CDDL HEADER in each
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * If applicable, add the following below this CDDL HEADER, with the
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * fields enclosed by brackets "[]" replaced with your own identifying
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * information: Portions Copyright [yyyy] [name of copyright owner]
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * CDDL HEADER END
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * Use is subject to license terms.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff/* Copyright (c) 1988 AT&T */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff/* All Rights Reserved */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#pragma ident "%Z%%M% %I% %E% SMI"
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff/* if the _IOWRT flag is set, this must be a call from sscanf */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#define locgetc(cnt) (cnt += 1, (iop->_flag & _IOWRT) ? \
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#define locungetc(cnt, x) (cnt -= 1, (x == EOF) ? EOF : \
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#define MAXARGS 30 /* max. number of args for fast positional paramters */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * stva_list is used to subvert C's restriction that a variable with an
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * array type can not appear on the left hand side of an assignment operator.
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * By putting the array inside a structure, the functionality of assigning to
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff * the whole array through a simple assignment is achieved..
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcdufftypedef struct stva_list {
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int number(int *, int *, int, int, int, int, FILE *, va_list *);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int string(int *, int *, int, int, int, char *, FILE *, va_list *);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int wstring(int *, int *, int, int, int, FILE *, va_list *);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int wbrstring(int *, int *, int, int, int, FILE *,
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff unsigned char *, va_list *);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int brstring(int *, int *, int, int, int, FILE *,
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff unsigned char *, va_list *);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int _mkarglst(const wchar_t *, stva_list, stva_list[]);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#else /* _WIDE */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduffstatic int _mkarglst(const char *, stva_list, stva_list[]);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#endif /* _WIDE */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#endif /* _WIDE */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff/* ARGSUSED3 */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff__wdoscan_u(FILE *iop, const wchar_t *fmt, va_list va_Alist, int scflag)
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#else /* _WIDE */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff__doscan_u(FILE *iop, const char *sfmt, va_list va_Alist, int scflag)
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#endif /* _WIDE */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#else /* _WIDE */
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff#endif /* _WIDE */
#ifdef _WIDE
return (EOF);
* stdarg.h. (Remember that if va_list is an array, in_args will
#ifdef _WIDE
if (!flag_eof) {
if (!flag_eof) {
stow = 0;
#ifdef _WIDE
* in the portable doprnt.c should be used if this
if (fpos) {
return (EOF);
fpos = 0;
len = 0;
goto charswitch;
if (len == 0)
#ifdef _WIDE
#ifndef _LP64
#ifndef _LP64
#ifdef _WIDE
wchar_t c;
int negflg = 0;
wchar_t *p;
len = 0;
len++;
fmt++;
len++;
fmt++;
len++;
fmt++;
fmt++;
return (EOF);
return (EOF);
bracket_str = (unsigned char *)
return (EOF);
return (EOF);
int c, len, i;
int negflg = 0;
len = 0;
len++;
fmt++;
len++;
fmt++;
return (EOF);
} else if (isascii(c)) {
len++;
fmt++;
return (EOF);
len += i;
fmt += i;
fmt++;
bracket_str = (unsigned char *)
malloc(sizeof (unsigned char) *
return (EOF);
(const char *)p, len);
if (negflg &&
fmt++;
tab[c] = t;
fmt++;
return (EOF);
tab[c] = t;
fmt++;
fmt++;
#ifdef _WIDE
switch (ch) {
#ifdef _WIDE
#ifdef _WIDE
if (stow == 0)
(long long) chcount;
if (size)
if (bracket_str)
int lc;
switch (type) {
#ifdef _LP64
if (floater != 0) {
char *echar;
int nread;
#if defined(__sparc)
if ((int)form < 0)
&efs);
if ((int)form < 0)
&efs);
if ((int)form < 0)
if ((int)form < 0)
negflg++;
if (--len <= 0)
c = lookahead;
if (stow)
digitseen++;
switch (size) {
int inchar;
return (EOF);
return (inchar);
int ch;
char *ptr;
char *start;
#ifdef _WIDE
if (stow)
ptr++;
if (--len <= 0)
/* are the same. (Code similar to that in the portable doprnt.c */
#ifdef _WIDE
#ifdef _WIDE
size_t n;
curargno = 0;
fmt++;
#ifdef _WIDE
fmt++;
fmt++;
i = mblen((const char *)
fmt += i;
for (n = 0; n <= maxnum; n++) {
#ifdef _WIDE
int dummy;
if (stow)
ptr++;
if (--len <= 0)
int wch;
if (stow)
ptr++;
if (--len <= 0)
#ifdef _WIDE
static wint_t
int len;
(*chcount)++;
return (wc);
return (WEOF);
return (WEOF);
(*chcount)++;
return (wc);
static wint_t
int len;
return (WEOF);
return (WEOF);
(*chcount)--;
return (ret);
return (WEOF);
(*chcount)--;
#ifdef _WIDE
int dummy;
#ifdef _WIDE
FNM_NOESCAPE)) {
if (len > 0) {
#ifdef _WIDE
(*chcount)++;
len--;
if (stow) {
ptr++;
if (len <= 0)
#ifdef _WIDE
if (stow)
#ifdef _WIDE
int dummy;
p = str;
FNM_NOESCAPE)) {
if (len >= i) {
(*chcount)++;
len -= i;
if (stow) {
*ptr++ = *p++;
ptr++;
if (len <= 0)
if (stow)
return (WEOF);
return ((wint_t)c);
buff[0] = (char)c;
c = wlocgetc();
(void) wlocungetc(c);
if (c == EOF) {
buff[i] = (char)c;
while (i-- > nbytes) {
return ((int)intcode);
return (WEOF);
return (WEOF);
return (WEOF);
return (WEOF);
return (wc);