⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lerror.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	}}/* luerror - lint error message *	if the message is to be buffered, call the appropriate routine: *    bufhdr( ) for a header file *    bufsource( ) for a source file * *  if not, call uerror( ) *//* VARARGS1 */luerror( msgndx, arg1 )	short msgndx;{	extern char		*strip( );	extern char		*msgtext[ ];	extern short	msgbuf[ ];	char		*filename;	if ( htmpname == NULL ) uerror( msgtext[ msgndx ], arg1 );	else {		filename = strip( ftitle );		if ( iscfile( filename ) == true ) 			if ( msgbuf[ msgndx ] == 0 ) 				uerror( msgtext[ msgndx ], arg1 );			else 				bufsource( UERRTY, msgndx, arg1 );		else 			bufhdr( UERRTY, filename, msgndx, arg1 );	}}/* bufsource - buffer a message for the source file *//** With FLEXNAMES, keep the actual pointer to the name strings in* ctmpfile, then when the file's contents are examined leter, the* strings will still be in core, so the pointers will still be ok.*/# define nextslot(x)	((PERMSG * ((x) - 1)) + (CRECSZ * msgtotals[(x)]))static int	msgtotals[ NUMBUF ];/* VARARGS2 */bufsource( code, msgndx, arg1, arg2 ) int code, msgndx;{	extern short msgbuf[ ], msgtype[ ];	int		bufndx;	CRECORD	record;	bufndx = msgbuf[ msgndx ];	if (  bufndx == 0  ||  bufndx >= NUMBUF )		lerror( "message buffering scheme flakey",		  CCLOSE | HCLOSE | FATAL | ERRMSG );	else 		if ( msgtotals[ bufndx ] < MAXBUF ) {			record.code = code | msgtype[ msgndx ];			record.lineno = lineno;			switch( msgtype[ msgndx ]  & ~SIMPL ) {			case DBLSTRTY:				record.name2 = (char *) arg2;				/* no break */			case STRINGTY:				record.arg1.name1 = (char *) arg1;				break;			case CHARTY:				record.arg1.char1 = (char) arg1;				break;			case NUMTY:				record.arg1.number = (int) arg1;				break;			default:				break;			}			/* seek to slot in file for the message */			if ( fseek( ctmpfile, nextslot( bufndx ), 0 ) != OKFSEEK ) 				lerror( "cannot seek in message buffer file",				  CCLOSE | HCLOSE | FATAL | ERRMSG );			/* and write the message in the slot */			if ( fwrite( (char *) &record, CRECSZ, 1, ctmpfile ) != 1 ) 				lerror( "cannot write to message buffer file",				  CCLOSE | HCLOSE | FATAL | ERRMSG );		}		++msgtotals[ bufndx ];}/* bufhdr - buffer a message for a header file *//** With FLEXNAMES, since htmpfile lives until lint2 walks over it, the* name strings are dumped like they are to the normal output - as a null* terminated string after the record which would normally contain the* name(s).*/static int		curhdr = 0;static enum boolean	activehdr = false;/* VARARGS3 */bufhdr( code, filename, msgndx, arg1, arg2 )  int code; char *filename; int	msgndx;{	extern char			sourcename[ ];	extern short		msgtype[ ];	int		i,	emptyslot;	HRECORD	record;	if ( activehdr == false ||		( strcmp( hdrlist[ curhdr ].hname, filename ) != 0 ) ) {		/* that is, if we do not have a new (active) header file		 * or if this header file is not the same as the last one		 * see if we have already seen it		 */		activehdr = false;		i = curhdr;		emptyslot = curhdr;		while( hdrlist[ i ].hname == NULL		    || strcmp( hdrlist[ i ].hname, filename ) != 0 ) {			/* that is, while we haven't found a match on the filename */			if ( hdrlist[ i ].hname == NULL ) {				emptyslot = i;				i = 0;			}			else i = (i+1) % NUMHDRS;			if ( i == curhdr ) 				if ( hdrlist[ emptyslot ].hname != NULL ) {					lerror( "too many header files", ERRMSG );					return;				}				else {					activehdr = true;					hdrlist[ emptyslot ].hname = savestr( filename );					hdrlist[ emptyslot ].srcname = savestr( sourcename );					i = emptyslot;					curhdr = emptyslot;				}		}		if ( activehdr == false ) return;	}	/* activehdr is true, curhdr points to current header file name, buffer */	++hdrlist[ curhdr ].hcount;	record.msgndx = msgndx;	record.code = code | msgtype[ msgndx ];	record.lineno = lineno;	switch( msgtype[ msgndx ]  & ~SIMPL ) {	case CHARTY:		record.arg1.char1 = (char) arg1;		break;	case NUMTY:		record.arg1.number = (int) arg1;		break;	default:		break;	}	if ( fwrite( (char *) &record, HRECSZ, 1, htmpfile ) != 1 ) 		lerror( "cannot write to header message buffer file",		  CCLOSE | HCLOSE | FATAL | ERRMSG );	switch ( msgtype[ msgndx ] & ~SIMPL )	{	case DBLSTRTY:		if ( fwrite( (char *) arg2, strlen( (char *) arg2 ) + 1, 1, htmpfile )			!= 1 )		{			lerror( "Cannot write to header message file",				CCLOSE | HCLOSE | FATAL | ERRMSG );		}		/* FALL THROUGH */	case STRINGTY:		if ( fwrite( (char *) arg1, strlen( (char *) arg1 ) + 1, 1, htmpfile )			!= 1 )		{			lerror( "Cannot write to header message file",				CCLOSE | HCLOSE | FATAL | ERRMSG );		}	}}/* unbuffer - write out information saved in ctmpfile */unbuffer( ){	extern char *outmsg[ ], *outformat[ ];	int	i, j, stop;	int	perline, toggle;	enum boolean	codeflag;	CRECORD	record;	fclose( ctmpfile );	if ( (ctmpfile = fopen( ctmpname, "r" )) == NULL ) 		lerror( "cannot open source buffer file for reading",		  CCLOSE | FATAL | ERRMSG );	/* loop for each message type - outer loop */	for ( i = 1; i < NUMBUF; ++i ) 		if ( msgtotals[ i ] != 0 ) {			codeflag = false;			if ( fseek( ctmpfile, (PERMSG * (i - 1)), 0 ) != OKFSEEK ) 				lerror( "cannot seek in source message buffer file",				  CCLOSE | FATAL | ERRMSG );			stop = msgtotals[ i ];			if ( stop > MAXBUF ) stop = MAXBUF;			/* loop for each occurrence of message - inner loop */			for ( j = 0; j < stop; ++j ) {				if ( fread( (char *) &record, CRECSZ, 1, ctmpfile ) != 1 )					lerror( "cannot read source message buffer file",					  CCLOSE | FATAL | ERRMSG );				if ( codeflag == false ) {					if ( record.code & WERRTY ) fprintf( stderr, "warning: " );					perline = 1;					toggle = 0;					if ( record.code & SIMPL ) perline = 2;					else						if ( !( record.code & ~WERRTY ) ) 							/* PLAINTY */							perline = 3;					fprintf( stderr, "%s\n", outmsg[ i ] );					codeflag = true;				}				fprintf( stderr, "    (%d)  ", record.lineno );				switch( record.code & ~( WERRTY | SIMPL ) ) {				case DBLSTRTY:					fprintf( stderr, outformat[ i ], record.arg1.name1,					    record.name2 );					break;				case STRINGTY:					fprintf( stderr, outformat[ i ], record.arg1.name1 );					break;				case CHARTY:					fprintf( stderr, outformat[ i ], record.arg1.char1 );					break;				case NUMTY:					fprintf( stderr, outformat[ i ], record.arg1.number );					break;				default:					fprintf( stderr, outformat[ i ] );					break;				}				if ( ++toggle == perline ) {					fprintf( stderr, "\n" );					toggle = 0;				}				else fprintf( stderr, "\t" );			} /* end, inner for loop */			if ( toggle != 0 ) fprintf( stderr, "\n" );			if ( stop < msgtotals[ i ] ) 				fprintf( stderr,				  "    %d messages suppressed for lack of space\n",				    msgtotals[ i ] - stop );	} /* end, outer for loop */	fclose( ctmpfile );	unlink( ctmpname );}

⌨️ 快捷键说明

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