Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/support/assert.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * Copyright 2006 David A. Holland. All rights reserved. | |
5 * See the file COPYING for license and usage terms. | |
6 * | |
7 * assert.cpp | |
8 */ | |
9 | |
10 #include <stdio.h> | |
11 #include <string.h> | |
12 #include "port.h" | |
13 | |
14 #include "assert.h" | |
15 | |
16 //#define INCLUDE_LOGGING | |
17 #include "log.h" | |
18 | |
19 | |
20 int no_assertions = 1; | |
21 | |
22 void badAssertion(const char *file, int line) { | |
23 static char longjmp_msg[128]; | |
24 | |
25 if (no_assertions) { | |
26 return; | |
27 } | |
28 no_assertions = 1; | |
29 | |
30 const char *s = strrchr(file, '/'); | |
31 if (s) { | |
32 file = s+1; | |
33 } | |
34 | |
35 LOGSECTION_ON("Bad assertion"); | |
36 LOGSTACK; | |
37 LOGV(file); | |
38 LOGV(line); | |
39 snprintf(longjmp_msg, sizeof(longjmp_msg), | |
40 "AnaGram internal error: assertion, %s line %d", file, line); | |
41 LOGV(longjmp_msg); | |
42 bailOut(longjmp_msg); | |
43 } |