diff options
author | Robert de Bath <rdebath@poboxes.com> | 1997-02-25 20:42:19 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:38:07 +0200 |
commit | 4c36e9a0c125ccfff37aa440dab2cf58c4152fff (patch) | |
tree | a5d9c84ba2661029ddb2223dacd50529a361c3d5 /unproto/error.c | |
parent | f8de35da65c5d93bb733073cf40da154bc1c0748 (diff) | |
parent | 9696d7b0e1f3a1b0f5fd4a0428eb75afe8ad4ed6 (diff) | |
download | dev86-4c36e9a0c125ccfff37aa440dab2cf58c4152fff.tar.gz |
Import Dev86src-0.0.11.tar.gzv0.0.11
Diffstat (limited to 'unproto/error.c')
-rw-r--r-- | unproto/error.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/unproto/error.c b/unproto/error.c index bc9702b..667d978 100644 --- a/unproto/error.c +++ b/unproto/error.c @@ -8,18 +8,22 @@ /* SYNOPSIS /* #include "error.h" /* -/* void error(quit, text) -/* int quit; +/* int errcount; +/* +/* void error(text) /* char *text; /* -/* void error_where(quit, path, line, text) -/* int quit; +/* void error_where(path, line, text) /* char *path; /* int line; /* char *text; +/* +/* void fatal(text) +/* char *text; /* DESCRIPTION -/* The routines in this file print a diagnostic (text) and optionally -/* terminate the program (quit != 0) with exit status "quit". +/* The routines in this file print a diagnostic (text). Some also +/* terminate the program. Upon each error*() call, the errcount variable +/* is incremented. /* /* error() provides a default context, i.e. the source-file /* coordinate of the last read token. @@ -27,6 +31,9 @@ /* error_where() allows the caller to explicitly specify context: path /* is a source-file name, and line is a line number. /* +/* fatal() is like error() but terminates the program with a non-zero +/* exit status. +/* /* context is ignored if the line number is zero or if the path /* is an empty string. /* AUTHOR(S) @@ -35,44 +42,56 @@ /* Department of Mathematics and Computer Science /* Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands /* LAST MODIFICATION -/* 91/11/30 21:10:35 +/* 92/01/15 21:53:10 /* VERSION/RELEASE -/* 1.1 +/* 1.2 /*--*/ -static char error_sccsid[] = "@(#) error.c 1.1 91/11/30 21:10:35"; +static char error_sccsid[] = "@(#) error.c 1.2 92/01/15 21:53:10"; /* C library */ #include <stdio.h> -void exit(); +extern void exit(); /* Application-specific stuff */ #include "token.h" #include "error.h" -/* error - report problem (implicit context) and optionally quit */ +int errcount = 0; /* error counter */ -void error(quit, text) -int quit; +/* error - report problem (implicit context) */ + +void error(text) char *text; { - error_where(quit, curr_path, curr_line, text); + error_where(in_path, in_line, text); } -/* error_where - report problem (explicit context) and optionally quit */ +/* error_where - report problem (explicit context) */ -void error_where(quit, path, line, text) -int quit; +void error_where(path, line, text) char *path; int line; char *text; { + errcount++; + + /* Suppress context info if there is none. */ + if (line && path[0]) fprintf(stderr, "%s, line %d: ", path, line); + fprintf(stderr, "%s\n", text); - if (quit) - exit(quit); +} + +/* fatal - report problem and terminate unsuccessfully */ + +void fatal(text) +char *text; +{ + error(text); + exit(1); } |