Pristine Ack-5.5
[Ack-5.5.git] / modules / src / assert / BadAssert.c
1 /* $Id: BadAssert.c,v 1.6 1994/06/24 11:07:07 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /* _BadAssertion: used for debugging purposes. It should give an error message
7         indicated by the parameters, and then give a core dump
8 */
9
10 #include <system.h>
11
12 static
13 wr_num(fd, n)
14         File *fd;
15         int n;
16 {
17         char s[2];
18
19         s[1] = '\0';
20         if (n >= 10) {
21                 wr_num(fd, n/10);
22         }
23         s[0] = (n % 10) + '0';
24         sys_write(fd, s, 1);
25 }
26
27 int
28 _BadAssertion(file, lineno, assertion)
29         char *file, *assertion;
30         int lineno;
31 {
32
33         sys_write(STDERR, file, strlen(file));
34         sys_write(STDERR, ", line ", 7);
35         wr_num(STDERR, lineno);
36         sys_write(STDERR, ": assertion \"", 13);
37         sys_write(STDERR, assertion, strlen(assertion));
38         sys_write(STDERR, "\" failed\n", 9);
39         sys_stop(S_ABORT);
40         return 0;
41 }