设为首页 加入收藏

TOP

C语言学习趣事_MSCRT_IO_SourceFile (六)
2014-11-24 00:40:18 来源: 作者: 【 】 浏览:255
Tags:语言学习 趣事 _MSCRT_IO_SourceFile
eak;

case ST_PRECIS:
/* update precison value */
if (ch == _T('*')) {
/* get precision from arg list */
precision = get_int_arg(&argptr);
if (precision < 0)
precision = -1; /* neg precision means default */
}
else {
/* add digit to current precision */
precision = precision * 10 + (ch - _T('0'));
}
break;

case ST_SIZE:
/* just read a size specifier, set the flags based on it */
switch (ch) {
#if !LONG_IS_INT || !defined(_UNICODE)
case _T('l'):
flags |= FL_LONG; /* 'l' => long int or wchar_t */
break;
#endif

#if !LONGDOUBLE_IS_DOUBLE || defined(_ALPHA_)
/*
* Alpha has native 64-bit integer registers and operations.
* The int and long types are 32 bits and an Alpha specific
* __int64 type is 64 bits. We also use the 'L' flag for
* integer arguments to indicate 64-bit conversions (%Lx).
*/

case _T('L'):
flags |= FL_LONGDOUBLE; /* 'L' => long double */
break;
#endif

#if !SHORT_IS_INT || defined(_UNICODE)
case _T('h'):
flags |= FL_SHORT; /* 'h' => short int or char */
break;
#endif

/* UNDONE: support %wc and %ws for now only for compatibility */
case _T('w'):
flags |= FL_WIDECHAR; /* 'w' => wide character */
break;

}
break;

case ST_TYPE:
/* we have finally read the actual type character, so we */
/* now format and "print" the output. We use a big switch */
/* statement that sets 'text' to point to the text that should */
/* be printed, and 'textlen' to the length of this text. */
/* Common code later on takes care of justifying it and */
/* other miscellaneous chores. Note that cases share code, */
/* in particular, all integer formatting is done in one place. */
/* Look at those funky goto statements! */

switch (ch) {

case _T('C'): /* ISO wide character */
if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR)))
#ifdef WPRFLAG
/* CONSIDER: non-standard */
flags |= FL_SHORT;
#else
flags |= FL_WIDECHAR; /* ISO std. */
#endif
/* fall into 'c' case */

case _T('c'): {
/* print a single character specified by int argument */
#ifdef WPRFLAG
bufferiswide = 1;
wchar = (wchar_t) get_int_arg(&argptr);
if (flags & FL_SHORT)
{
/* format multibyte character */
/* this is an extension of ANSI */
char tempchar[2];
#ifdef _OUT
if (isleadbyte(wchar >> 8))
{
tempchar[0] = (wchar >> 8);
tempchar[1] = (wchar & 0x00ff);
}
else
#endif /* _OUT */
{
tempchar[0] = (char)(wchar & 0x00ff);
tempchar[1] = '\0';
}
if (mbtowc(buffer.wz,tempchar,MB_CUR_MAX) < 0)
{
/* ignore if conversion was unsuccessful */
no_output = 1;
}
}
else
{
buffer.wz[0] = wchar;
}
text.wz = buffer.wz;
textlen = 1; /* print just a single character */
#else /* WPRFLAG */
if (flags & (FL_LONG|FL_WIDECHAR))
{
wchar = (wchar_t) get_short_arg(&argptr);
/* convert t
首页 上一页 3 4 5 6 7 8 9 下一页 尾页 6/12/12
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇STL 应用之set 下一篇快速计算32位数中1的位数

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: