/minix/commands/cawf/error.c
C | 95 lines | 41 code | 10 blank | 44 comment | 19 complexity | 476641f5ec0d304e465e25df0610a6c6 MD5 | raw file
Possible License(s): MIT, WTFPL, AGPL-1.0, BSD-3-Clause, GPL-3.0, LGPL-2.0, JSON, 0BSD
- /*
- * error.c - error handling functions for cawf(1)
- */
- /*
- * Copyright (c) 1991 Purdue University Research Foundation,
- * West Lafayette, Indiana 47907. All rights reserved.
- *
- * Written by Victor A. Abell <abe@mace.cc.purdue.edu>, Purdue
- * University Computing Center. Not derived from licensed software;
- * derived from awf(1) by Henry Spencer of the University of Toronto.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The author is not responsible for any consequences of use of
- * this software, even if they arise from flaws in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission. Credits must appear in the
- * documentation.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software. Credits must
- * appear in the documentation.
- *
- * 4. This notice may not be removed or altered.
- */
- #include "cawf.h"
- /*
- * Error(t, l, s1, s2) - issue error message
- */
- void Error(int t, int l, char *s1, char *s2) {
- /* type: WARN or FATAL t
- * LINE: display Line[] l
- * optional text s1 and s2
- */
- char msg[MAXLINE]; /* message */
- if (t == WARN && !Dowarn) return;
- if (l == LINE)
- (void) fprintf(Efs, "%s: (%s, %d):%s%s - %s\n",
- Pname,
- Inname,
- NR,
- (s1 == NULL) ? "" : s1,
- (s2 == NULL) ? "" : s2,
- Line);
- else
- (void) fprintf(Efs, "%s:%s%s\n",
- Pname,
- (s1 == NULL) ? "" : s1,
- (s2 == NULL) ? "" : s2);
- if (t == FATAL)
- exit(1);
- Err = 1;
- return;
- }
- /*
- * Error3(len, word, sarg, narg) - process error in pass3
- */
- void Error3(int len, char* word, char *sarg, int narg, char *msg) {
- /* length (negative is special) len
- * word word
- * string argument sarg
- * numeric argument narg
- * message msg
- */
- if (len == MESSAGE) {
- (void) fprintf(Efs, "%s: (%s, %d) %s\n",
- Pname,
- (word == NULL) ? "<none>" : word,
- narg,
- (sarg == NULL) ? "<none>" : sarg);
- return;
- }
- (void) fprintf(Efs,
- "%s: pass3, len=%d, word=\"%s\", sarg=\"%s\", narg=%d%s%s\n",
- Pname, len,
- (word == NULL) ? "" : word,
- (sarg == NULL) ? "" : sarg,
- narg,
- (msg == NULL) ? "" : " - ",
- (msg == NULL) ? "" : msg);
- Err = 1;
- }