summaryrefslogtreecommitdiff
path: root/unproto/error.c
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1996-03-24 17:45:55 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:29:43 +0200
commitfe22c37817ce338fbbc90b239320248c270957fa (patch)
treed9550410c4a20bdd382fcc58d2d3d7c5e04e5245 /unproto/error.c
parenta7aba15e8efffb1c5d3097656f1a93955a64f01f (diff)
parent42192453ea219b80d0bf9f41e51e36d3d4d0740b (diff)
downloaddev86-fe22c37817ce338fbbc90b239320248c270957fa.tar.gz
Import Dev86-0.0.4.tar.gzv0.0.4
Diffstat (limited to 'unproto/error.c')
-rw-r--r--unproto/error.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/unproto/error.c b/unproto/error.c
new file mode 100644
index 0000000..bc9702b
--- /dev/null
+++ b/unproto/error.c
@@ -0,0 +1,78 @@
+/*++
+/* NAME
+/* error 3
+/* SUMMARY
+/* diagnostics
+/* PACKAGE
+/* unproto
+/* SYNOPSIS
+/* #include "error.h"
+/*
+/* void error(quit, text)
+/* int quit;
+/* char *text;
+/*
+/* void error_where(quit, path, line, text)
+/* int quit;
+/* char *path;
+/* int line;
+/* char *text;
+/* DESCRIPTION
+/* The routines in this file print a diagnostic (text) and optionally
+/* terminate the program (quit != 0) with exit status "quit".
+/*
+/* error() provides a default context, i.e. the source-file
+/* coordinate of the last read token.
+/*
+/* error_where() allows the caller to explicitly specify context: path
+/* is a source-file name, and line is a line number.
+/*
+/* context is ignored if the line number is zero or if the path
+/* is an empty string.
+/* AUTHOR(S)
+/* Wietse Venema
+/* Eindhoven University of Technology
+/* 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
+/* VERSION/RELEASE
+/* 1.1
+/*--*/
+
+static char error_sccsid[] = "@(#) error.c 1.1 91/11/30 21:10:35";
+
+/* C library */
+
+#include <stdio.h>
+
+void exit();
+
+/* Application-specific stuff */
+
+#include "token.h"
+#include "error.h"
+
+/* error - report problem (implicit context) and optionally quit */
+
+void error(quit, text)
+int quit;
+char *text;
+{
+ error_where(quit, curr_path, curr_line, text);
+}
+
+/* error_where - report problem (explicit context) and optionally quit */
+
+void error_where(quit, path, line, text)
+int quit;
+char *path;
+int line;
+char *text;
+{
+ if (line && path[0])
+ fprintf(stderr, "%s, line %d: ", path, line);
+ fprintf(stderr, "%s\n", text);
+ if (quit)
+ exit(quit);
+}