C语言学习趣事_MSCRT_IO_SourceFile
前些时候,贴了一段微软的printf代码,园子里的大侠们说要看看output的代码,这不最近有幸看了微软的
output代码,所以贴上来给园子里大侠看看。
Tip:
源代码版权归微软所有,这里仅贴出来供大家看看。
?/***
*output.c - printf style output to a FILE
*
* Copyright (c) 1989-1991, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file contains the code that does all the work for the
* printf family of functions. It should not be called directly, only
* by the *printf functions. We don't make any assumtions about the
* sizes of ints, longs, shorts, or long doubles, but if types do overlap,
* we also try to be efficient. We do assume that pointers are the same
* size as either ints or longs.
* If CPRFLAG is defined, defines _cprintf instead.
* **** DOESN'T CURRENTLY DO MTHREAD LOCKING ****
*
*Revision History:
* 06-01-89 PHG Module created
* 08-28-89 JCR Added cast to get rid of warning (no object changes)
* 02-15-90 GJF Fixed copyright
* 03-19-90 GJF Made calling type _CALLTYPE1 and added #include
* <cruntime.h>.
* 03-26-90 GJF Changed LOCAL macro to incorporate _CALLTYPE4. Placed
* prototype for _output() in internal.h and #include-d
* it.
* 08-01-90 SBM Compiles cleanly with -W3, moved _cfltcvt_tab and
* typedefs DOUBLE and LONGDOUBLE to new header
* <fltintrn.h>, formerly named <struct.h>
* 09-05-90 SBM First attempt at adding CPRFLAG and code to generate
* cprintf. Anything in #ifdef CPRFLAG untested.
* Still needs to have locking added for MTHREAD case.
* 10-03-90 GJF New-style function declarators.
* 01-02-91 SRW Added _WIN32_ conditional for 'C' and 'S' format chars.
* 01-16-91 GJF ANSI naming.
* 01-16-91 SRW Added #include of maketabc.out (_WIN32_)
* 04-09-91 PNT Use the _CRUISER_ mapping for _MAC_
* 04-16-91 SRW Fixed #include of maketabc.out (_WIN32_)
* 04-25-91 SRW Made nullstring static
* 05-20-91 GJF Moved state table for Win32 inline (_WIN32_).
* 09-12-91 JCR Bumped conversion buffer size to be ANSI-compliant
* 09-17-91 IHJ Add partial UNICODE (%ws, %wc) support
* 09-28-91 GJF Merged with crt32 and crtdll versions. For now, 9-17-91
* change is built only for Win32, not Dosx32 (_WIN32_).
* 10-22-91 ETC Complete wchar_t/mb support under _INTL. For now,
* 9-28-91 change is additionally under !_INTL. Bug fix:
* ints and pointers are longs.
* 11-19-91 ETC Added support for _wsprintf, _vwsprintf with WPRFLAG;
* added %tc %ts (generic string handling).
* 12-05-91 GDP Bug fix: va_arg was used inconsistently for double
* 12-19-91 ETC Added some comments on wsprintf optimization, undones;
* check return on malloc.
* 03-25-92 DJM POSIX support
* 04-16-92 KRS Support new ISO {s|f}wprintf with Unicode format string.
* 06-08-92 SRW Modified to not use free and malloc for mbtowc conversion.
* 06-10-92 KRS Fix glitch in previous change.
* 07-14-92 TVB Added Alpha support (quad stuff).
* 07-17-92 KRS Fix typo which broke WPRFLAG support.
* 04-16-93 SKS Fix bug in 'S' option logic.
* 07-16-93 SRW ALPHA Merge
* 08-17-93 CFW Avoid mapping tchar macros incorrectly if _MBCS defined.
*
*******************************************************************************/
/* temporary hack to minimize changes. This should go into fltintrn.h */
#if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC)
#define DOUBLE double
#endif
#include <cruntime.h>
#include <limits.h>
#include <string.h>
#include <stddef.h>
#include <stdio.h>
#include <stdarg.h>
#include <cvt.h>
#include <conio.h>
#include <internal.h>
#include <fltintrn.h>
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
/* inline keyword is non-ANSI C7 extension */
/* CONSIDER: move to cruntime.h! */
#if !defined(_MSC_VER) || defined(__STDC__)
#define __inline static
#else
/* UNDONE: compiler is broken */
#define __inline static
#endif
#if defined(WPRFLAG) && !defined(_UNICODE)
#define _UNICODE 1
#endif
#ifdef _MBCS /* always want either Unicode or SBCS for tchar.h */
#undef _MBCS
#endif
#include <tchar.h>
/* this macro defines a function which is private and as fast as possible: */
/* for example, in C 6.0, it might be static _fastcall <type> near. */
#define LOCAL(x) static x _CALLTYPE4
/* int/long/short/pointer sizes */
/* the following should be set depending on the sizes of various types */
#define LONG_IS_INT 1 /* 1 means long is same size as int */
#define SHORT_IS_INT 0 /* 1 means short is same size as int */
#define LONGDOUBLE_IS_DOUBLE 1 /* 1 means long double is same as double */
#define PTR_IS_INT 1 /* 1 means ptr is same size as int */
#define PTR_IS_LONG 1 /* 1 means ptr is same size as long */
#if LONG_IS_INT
#define get_long_arg(x) (long)get_int_arg(x)
#endif
#ifndef WPRFLAG
#if SHORT_IS_INT
#define get_short_arg(x) (short)get_int_arg(x)
#endif
#endif
#if PTR_IS_INT
#define get_ptr_arg(x)
补充:软件开发 , C语言 ,