vfprintf.c

来自「mips架构的bootloader,99左右的版本 但源代码现在没人更新了」· C语言 代码 · 共 55 行

C
55
字号
/************************************************************* * File: lib/vfprintf.c * Purpose: Part of C runtime library * Author: Phil Bunce (pjb@carmel.com) * Revision History: *	970304	Start of revision history *	980618	Removed fudge factor calc for fmt length. Now using vstrlen. */#include <varargs.h>#include <stdio.h>#ifndef PMCC#define vfprintf xvfprintf#define vsprintf xvsprintfchar outputbuffer[1000];#endifchar errmsg[] = "vfprintf: out of memory";/**************************************************************  int vfprintf(fp,fmt,ap)*/int vfprintf(fp,fmt,ap)FILE *fp;char *fmt;va_list ap;{char *p,buf[100];int n;n = vstrlen(fmt,ap);if (n > 99) {	p = (char *)malloc(n);	if (p) {		n = vsprintf(p,fmt,ap);		fputs(p,fp);#ifndef PMCC		if (strlen(outputbuffer)+strlen(p)<1000) strcat(outputbuffer,p);#endif		free(p);		}	else fputs(errmsg,fp);	}else {	n = vsprintf(buf,fmt,ap);	fputs(buf,fp);#ifndef PMCC	if (strlen(outputbuffer)+strlen(buf)<1000) strcat(outputbuffer,buf);#endif	}return(n);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?