Version:
~ [ 10.0 ] ~
** Warning: Cannot open xref database.
1
2 /* $Id: assert.c,v 1.7 2005/01/11 22:48:04 andreradke Exp $ */
3
4 /******************************************************************************
5
6 UserLand Frontier(tm) -- High performance Web content management,
7 object database, system-level and Internet scripting environment,
8 including source code editing and debugging.
9
10 Copyright (C) 1992-2004 UserLand Software, Inc.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
26 ******************************************************************************/
27
28 #include "frontier.h"
29 #include "standard.h"
30
31 #ifdef fldebug
32
33 #ifdef MACVERSION
34
35 #include "memory.h"
36 #include "strings.h"
37 #include "ops.h"
38 #include "shell.h"
39
40 #if TARGET_API_MAC_CARBON
41 #include "file.h"
42 #include "launch.h"
43 #include "timedate.h"
44 #endif
45
46
47 #if 0 //TARGET_API_MAC_CARBON /* 2004-10-23 aradke: rely on Debugging.h instead */
48
49 short __assert (char *expr, char *file, short line) {
50
51 /*
52 On OS X, DebugStr output gets automatically rerouted to stderr
53 which in turn gets logged to console.log, viewable via Console.app.
54
55 2003-05-26 AR: Include date/time, app name, and app version.
56 */
57
58 static boolean flnorentry = false;
59 short day, month, year, hour, minute, second;
60 tyfilespec myfspec;
61 bigstring bs, bslogstamp, bsline, bsfile, bsmessage;
62
63 if (flnorentry)
64 return (0);
65
66 flnorentry = true;
67
68 /*get timestamp*/
69
70 secondstodatetime (timenow (), &day, &month, &year, &hour, &minute, &second);
71
72 numbertostring ((long) year, bs);
73
74 pushstring (bs, bslogstamp);
75
76 pushchar ('-', bslogstamp);
77
78 numbertostring ((long) month, bs);
79
80 padwithzeros (bs, 2);
81
82 pushstring (bs, bslogstamp);
83
84 pushchar ('-', bslogstamp);
85
86 numbertostring ((long) day, bs);
87
88 padwithzeros (bs, 2);
89
90 pushstring (bs, bslogstamp);
91
92 pushchar (' ', bslogstamp);
93
94 numbertostring ((long) hour, bs);
95
96 padwithzeros (bs, 2);
97
98 pushstring (bs, bslogstamp);
99
100 pushchar (':', bslogstamp);
101
102 numbertostring ((long) minute, bs);
103
104 padwithzeros (bs, 2);
105
106 pushstring (bs, bslogstamp);
107
108 pushchar (':', bslogstamp);
109
110 numbertostring ((long) second, bs);
111
112 padwithzeros (bs, 2);
113
114 pushstring (bs, bslogstamp);
115
116 pushchar (' ', bslogstamp);
117
118 /*get filespec for app*/
119
120 getapplicationfilespec (nil, &myfspec);
121
122 pushstring (fsname (&myfspec), bslogstamp);
123
124 pushchar (' ', bslogstamp);
125
126 /*get version of app*/
127
128 filegetprogramversion (bs);
129
130 pushchar ('(', bslogstamp);
131
132 pushstring (bs, bslogstamp);
133
134 pushchar (')', bslogstamp);
135
136 /*get file name*/
137
138 moveleft (file, bsfile, (long) lenbigstring);
139
140 convertcstring (bsfile);
141
142 /*get line number*/
143
144 numbertostring ((long) line, bsline);
145
146 /*ouput message*/
147
148 parsedialogstring (
149 "\p\r^0: Assertion failed in file ^1, at line ^2.\r",
150 bslogstamp, bsfile, bsline, nil,
151 bsmessage);
152
153 DebugStr (bsmessage);
154
155 /*send message to stderr*/
156
157 flnorentry = false;
158
159 return (0);
160 } /*__assert*/
161
162 #endif /*TARGET_API_MAC_CARBON*/
163
164 #if TARGET_API_MAC_OS8
165
166 short __assert (char *expr, char *file, short line) {
167
168 bigstring bsfile, bsline, bsmessage;
169 static boolean flnorentry = false;
170
171 if (flnorentry)
172 return (0);
173
174 flnorentry = true;
175
176 moveleft (file, bsfile, (long) lenbigstring);
177
178 convertcstring (bsfile);
179
180 numbertostring ((long) line, bsline);
181
182 parsedialogstring (
183 "\pAssertion failed in file ^0, at line ^1.",
184 bsfile, bsline, nil, nil,
185 bsmessage);
186
187 DebugStr (bsmessage);
188
189 flnorentry = false;
190
191 return (0);
192 } /*__assert*/
193
194 #endif /*TARGET_API_MAC_OS8*/
195
196 #endif /*MACVERSION*/
197
198
199 #ifdef WIN95VERSION
200
201 #include "threads.h"
202 #include <stdio.h>
203
204 #ifdef _MSC_VER /* 2002-11-09 AR: use _assert from debug version of Microsoft C runtime library*/
205
206 #include <assert.h>
207 #include "threads.h"
208
209 short __assert (char *expr, char *file, short line) {
210
211 #ifdef _DEBUG
212
213 static boolean flnorentry = false;
214
215 if (flnorentry)
216 return (0);
217
218 flnorentry = true;
219
220 releasethreadglobals ();
221
222 _assert (expr, file, line);
223
224 grabthreadglobals ();
225
226 flnorentry = false;
227
228 #endif /*_DEBUG*/
229
230 return (0);
231 } /*__assert*/
232
233 #endif /* _MSC_VER */
234
235 #ifdef __MWERKS__ /* 2002-11-09 AR: put up MessageBox with Cancel button to abort application */
236
237 short __assert (char *expr, char *file, short line) {
238
239 #ifdef _DEBUG
240
241 static boolean flnorentry = false;
242 char buf[4096];
243 int itemnum;
244
245 if (flnorentry)
246 return (0);
247
248 flnorentry = true;
249
250 sprintf(buf,"Assertion failed in %s, at line %d.\n\nExpression: %s\n\n", file, line, expr);
251
252 //releasethreadglobals (); /* 2002-11-10 AR: other threads should not continue running if we hit an assertion failure */
253
254 itemnum = MessageBox (hwndMDIClient, buf, "Assertion Failure", MB_ABORTRETRYIGNORE | MB_ICONSTOP | MB_APPLMODAL);
255
256 //grabthreadglobals ();
257
258 flnorentry = false;
259
260 if (itemnum == IDABORT)
261 abort();
262
263 if (itemnum == IDRETRY) {
264
265 if (IsDebuggerPresent ())
266 OutputDebugString (buf);
267
268 DebugBreak();
269 }
270
271 #endif /*_DEBUG*/
272
273 return (0);
274 } /*__assert*/
275
276 #endif /*__MWERKS__*/
277
278 #endif /*WIN95VERSION*/
279
280 #endif /*fldebug*/
281
282
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.