
/* 
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/
#ident "$Header: error.c 1.1 90/01/19 $@(#)error.c	1.1 89/12/01"
/* #include "xs.h" */
#include <stdio.h>

extern int lineno;
extern char ftitle[];
static int nerrors;
extern char *gettxt();

reset_error()
{
  nerrors = 0;
}

where(c)
{
	 /* print location of error. c is either 'u', 'c', or 'w' */
	fprintf( stderr, gettxt("xs:28","%s, line %d: "), ftitle, lineno );
}

/* VARARGS1 */
uerror( s, a )
char *s, *a; 
{
	/* nonfatal error message 
	** the routine where is different for pass 1 and pass 2;
	** it tells where the error took place 
	*/
	++nerrors;
	where('u');
	fprintf( stderr, s, a );
	fprintf( stderr, "\n" );
	if( nerrors > 30 ) cerror( gettxt("xs:29","too many errors"));
	fflush(stderr);
}

/* VARARGS1 */
cerror( s, a, b, c )
char *s, *a, *b, *c; 
{
	 /* compiler error: die */
	where('c');
	if( nerrors && nerrors <= 30 )
	{
		/* give the compiler the benefit of the doubt */
		fprintf( stderr,
		gettxt("xs:30","cannot recover from earlier errors: goodbye!\n") );
	}
	else 
	{
		fprintf( stderr, gettxt("xs:31","compiler error: ") );
		fprintf( stderr, s, a, b, c );
		fprintf( stderr, "\n" );
		fflush( stdout );
	}
        intr_end();
}

/* VARARGS1 */
werror( s, a, b )
char *s, *a, *b; 
{
	/* warning */
	where('w');
	fprintf( stderr, gettxt("xs:32","warning: ") );
	fprintf( stderr, s, a, b );
	fprintf( stderr, "\n" );
}

yyerror(s, a)
  char *s, *a;
{
}
