/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "sfhdr.h"
/* Dealing with $ argument addressing stuffs.
**
** Written by Kiem-Phong Vo.
*/
#if __STD_C
#else
char* str;
int* v;
#endif
{
*v -= 1;
return (char*)str;
}
#if __STD_C
#else
Sfio_t* f;
char* form;
int type; /* >0: scanf, =0: printf, -1: internal */
#endif
{
if(type < 0)
while((n = *form) )
{ if(n != '%') /* collect the non-pattern chars */
for(;;)
break;
}
continue;
}
else form += 1;
if(*form == 0)
break;
else if(*form == '%')
{ form += 1;
continue;
}
{ skip = 1;
form += 1;
argp = -1;
}
else /* get the position of this argument */
{ skip = 0;
if(*sp == '$')
{ dollar = 1;
}
else argp = -1;
}
for(n = 0; n < FP_INDEX; ++n)
need[n] = -1;
loop_flags: /* LOOP FOR \0, %, FLAGS, WIDTH, PRECISION, BASE, TYPE */
{
case LEFTP : /* get the type enclosed in balanced parens */
for(v = 1;;)
{ switch(*form++)
{
case 0 : /* not balancable, retract */
n_str = 0;
goto loop_flags;
case LEFTP : /* increasing nested level */
v += 1;
continue;
case RIGHTP : /* decreasing nested level */
if((v -= 1) != 0)
continue;
if(*t_str == '*')
if(*t_str == '$')
dollar = 1;
else n = -1;
maxp = n;
}
}
goto loop_flags;
}
}
case '-' :
flags |= SFFMT_LEFT;
flags &= ~SFFMT_ZERO;
goto loop_flags;
case '0' :
if(!(flags&SFFMT_LEFT) )
flags |= SFFMT_ZERO;
goto loop_flags;
case ' ' :
if(!(flags&SFFMT_SIGN) )
flags |= SFFMT_BLANK;
goto loop_flags;
case '+' :
flags |= SFFMT_SIGN;
flags &= ~SFFMT_BLANK;
goto loop_flags;
case '#' :
flags |= SFFMT_ALTER;
goto loop_flags;
case QUOTE:
if(thousand > 0)
flags |= SFFMT_THOUSAND;
goto loop_flags;
case '.' :
base = 0; /* for %s,%c */
goto dot_size;
}
else if(*form != '*')
goto loop_flags;
case '*' :
if(*form == '$' )
{ dollar = 1;
form += 1;
}
else n = -1;
maxp = n;
}
if(dot <= 2)
goto loop_flags;
case '1' : case '2' : case '3' :
case '4' : case '5' : case '6' :
case '7' : case '8' : case '9' :
dot_size :
if(dot == 0)
width = v;
else if(dot == 1)
precis = v;
else if(dot == 2)
base = v;
goto loop_flags;
case 'I' : /* object length */
}
else if(*form == '*')
if(*form == '$' )
{ dollar = 1;
form += 1;
}
else n = -1;
maxp = n;
}
}
goto loop_flags;
case 'l' :
if(*form == 'l')
{ form += 1;
flags |= SFFMT_LLONG;
}
else flags |= SFFMT_LONG;
goto loop_flags;
case 'h' :
if(*form == 'h')
{ form += 1;
flags |= SFFMT_SSHORT;
}
else flags |= SFFMT_SHORT;
goto loop_flags;
case 'L' :
goto loop_flags;
}
/* set object size for scalars */
if(flags & SFFMT_TYPES)
{ if(flags&SFFMT_LONG)
size = sizeof(long);
else if(flags&SFFMT_SHORT)
size = sizeof(short);
else if(flags&SFFMT_SSHORT)
size = sizeof(char);
else if(flags&SFFMT_TFLAG)
else if(flags&SFFMT_ZFLAG)
else if(flags&SFFMT_IFLAG)
{ if(size <= 0 ||
}
else if(size < 0)
size = sizeof(int);
}
size = sizeof(double);
else if(flags&SFFMT_LDOUBLE)
size = sizeof(Sfdouble_t);
else if(flags&SFFMT_IFLAG)
{ if(size <= 0)
size = sizeof(Sfdouble_t);
}
else if(size < 0)
size = sizeof(float);
}
{
#if _has_multibyte
sizeof(wchar_t) : sizeof(int);
} else
#endif
if(size < 0)
size = sizeof(int);
}
}
if(skip)
continue;
for(n = 0; n < FP_INDEX; ++n)
}
}
if(!fp) /* constructing position array only */
for(n = 0; n <= maxp; ++n)
return fp;
}
/* get value for positions */
if(ft)
for(n = 0; n <= maxp; ++n)
for(v = 0; v < FP_INDEX; ++v)
}
if(v < 0)
}
goto arg_list;
}
}
}
}
}
else
{ arg_list:
}
{ if(ft)
if(ft)
}
else if(type > 0) /* from sfvscanf */
{ case SFFMT_INT:
case SFFMT_UINT:
#if !_ast_intmax_long
else
#endif
if(size == sizeof(long) )
break;
case SFFMT_FLOAT:
#if !_ast_fltmax_double
if(size == sizeof(Sfdouble_t) )
else
#endif
break;
case SFFMT_POINTER:
break;
case SFFMT_CHAR:
#if _has_multibyte
{ if(sizeof(wchar_t) <= sizeof(int) )
}
#endif
/* observe promotion rule */
break;
default: /* unknown pattern */
break;
}
}
}
if(ft)
return fp;
}
#ifdef _ast_ldbl_nan_init
#endif
/* function to initialize conversion tables */
static int sfcvinit()
{ reg int d, l;
for(d = 0; d <= SF_MAXCHAR; ++d)
}
/* [0-9] */
for(d = 0; d < 10; ++d)
}
/* [a-z] */
for(; d < 36; ++d)
}
/* [A-Z] */
for(l = 10; d < 62; ++l, ++d)
}
/* remaining digits */
for(; d < SF_RADIX; ++d)
}
#if _has_multibyte
#endif
/* IEEE floating point computed constants */
#ifdef _ast_ldbl_nan_init
#else
#endif
return 1;
}
/* table for floating point and integer conversions */