author | Michael Krelin <hacker@klever.net> | 2005-04-25 16:36:32 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-04-25 16:36:32 (UTC) |
commit | 981b219f5297ad2ccc1fc1d0e24e41ec009c35a3 (patch) (unidiff) | |
tree | 9fa81d7fe70883ad26d946c902ba06edcebd4516 /components/exception_dev | |
parent | 54e344b7e3623e807b893b7febad3adfc6c1648f (diff) | |
download | sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.zip sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.tar.gz sitecing-981b219f5297ad2ccc1fc1d0e24e41ec009c35a3.tar.bz2 |
moved a few utility functions to konforka and bumped konforka version requirement accordingly
-rw-r--r-- | components/exception_dev | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/components/exception_dev b/components/exception_dev index d8c84e1..d62f462 100644 --- a/components/exception_dev +++ b/components/exception_dev | |||
@@ -1,28 +1,29 @@ | |||
1 | %%decl using namespace std; | 1 | %%decl using namespace std; |
2 | <%impl> | 2 | <%impl> |
3 | #include <iostream> | 3 | #include <iostream> |
4 | #include <fstream> | 4 | #include <fstream> |
5 | #include <sstream> | 5 | #include <sstream> |
6 | #include <cassert> | 6 | #include <cassert> |
7 | #include <cstdarg> | 7 | #include <cstdarg> |
8 | #include <stdexcept> | 8 | #include <stdexcept> |
9 | #include <cxxabi.h> | 9 | #include <cxxabi.h> |
10 | #include <sitecing/sitecing_util.h> | 10 | #include <sitecing/sitecing_util.h> |
11 | #include <sitecing/util.h> | 11 | #include <sitecing/util.h> |
12 | #include <sitecing/magic.h> | 12 | #include <sitecing/magic.h> |
13 | #include <konforka/util.h> | ||
13 | #include <konforka/exception.h> | 14 | #include <konforka/exception.h> |
14 | </%impl> | 15 | </%impl> |
15 | %%var string message; | 16 | %%var string message; |
16 | %%var string root_source; | 17 | %%var string root_source; |
17 | %%var string root_intermediate; | 18 | %%var string root_intermediate; |
18 | %%var string root_so; | 19 | %%var string root_so; |
19 | %%var string component; | 20 | %%var string component; |
20 | %%var int line_number = -1; | 21 | %%var int line_number = -1; |
21 | %%var const exception* exception_caught; | 22 | %%var const exception* exception_caught; |
22 | <%code> | 23 | <%code> |
23 | __SCIF->headers.clear(); | 24 | __SCIF->headers.clear(); |
24 | __SCIF->out->seekp(0); | 25 | __SCIF->out->seekp(0); |
25 | int magic = _magic; | 26 | int magic = _magic; |
26 | va_list va = _args; | 27 | va_list va = _args; |
27 | switch(magic) { | 28 | switch(magic) { |
28 | case sitecing::__magic_compile_error: | 29 | case sitecing::__magic_compile_error: |
@@ -241,43 +242,43 @@ | |||
241 | string fn = line.substr(0,c); | 242 | string fn = line.substr(0,c); |
242 | string::size_type c1 = line.find(':',c+1); | 243 | string::size_type c1 = line.find(':',c+1); |
243 | if(c1!=string::npos) { | 244 | if(c1!=string::npos) { |
244 | string ln = line.substr(c+1,c1-c-1); | 245 | string ln = line.substr(c+1,c1-c-1); |
245 | string::size_type nd = ln.find_first_not_of("0123456789"); | 246 | string::size_type nd = ln.find_first_not_of("0123456789"); |
246 | if(nd==string::npos) { | 247 | if(nd==string::npos) { |
247 | try { | 248 | try { |
248 | error_file = sitecing::strip_prefix(fn,"In file included from "); | 249 | error_file = sitecing::strip_prefix(fn,"In file included from "); |
249 | }catch(sitecing::utility_no_prefix& unp) { | 250 | }catch(sitecing::utility_no_prefix& unp) { |
250 | error_file = fn; | 251 | error_file = fn; |
251 | } | 252 | } |
252 | error_line = strtol(ln.c_str(),0,10); | 253 | error_line = strtol(ln.c_str(),0,10); |
253 | } | 254 | } |
254 | } | 255 | } |
255 | } | 256 | } |
256 | if((oel>0 && !oef.empty()) && (oel!=error_line || oef!=error_file)) { | 257 | if((oel>0 && !oef.empty()) && (oel!=error_line || oef!=error_file)) { |
257 | string ef = "/"+sitecing::combine_path(root_source+component,oef); | 258 | string ef = "/"+konforka::combine_path(root_source+component,oef); |
258 | report_error(ef,oel,remove_roots(cumulative)); | 259 | report_error(ef,oel,remove_roots(cumulative)); |
259 | cumulative.clear(); | 260 | cumulative.clear(); |
260 | } | 261 | } |
261 | } | 262 | } |
262 | if(!cumulative.empty()) | 263 | if(!cumulative.empty()) |
263 | cumulative += '\n'; | 264 | cumulative += '\n'; |
264 | cumulative += line; | 265 | cumulative += line; |
265 | } | 266 | } |
266 | if(!(cumulative.empty() || error_file.empty() || error_line<0)) { | 267 | if(!(cumulative.empty() || error_file.empty() || error_line<0)) { |
267 | error_file = "/"+sitecing::combine_path(root_source+component,error_file); | 268 | error_file = "/"+konforka::combine_path(root_source+component,error_file); |
268 | report_error(error_file,error_line,remove_roots(cumulative)); | 269 | report_error(error_file,error_line,remove_roots(cumulative)); |
269 | } | 270 | } |
270 | } | 271 | } |
271 | </%code> | 272 | </%code> |
272 | </div> | 273 | </div> |
273 | </%method> | 274 | </%method> |
274 | <%method void handle_unknown_error() %> | 275 | <%method void handle_unknown_error() %> |
275 | <div class="exception-unknown"> | 276 | <div class="exception-unknown"> |
276 | <h1>unknown error</h1> | 277 | <h1>unknown error</h1> |
277 | </div> | 278 | </div> |
278 | </%method> | 279 | </%method> |
279 | <%method void report_error(const string& file,long line,const string& message) %> | 280 | <%method void report_error(const string& file,long line,const string& message) %> |
280 | <div class="exception-codepoint-report"> | 281 | <div class="exception-codepoint-report"> |
281 | <h3><% sitecing::html_escape(strip_roots(file)) %></h3> | 282 | <h3><% sitecing::html_escape(strip_roots(file)) %></h3> |
282 | <%code> | 283 | <%code> |
283 | if(line>=0) { | 284 | if(line>=0) { |
@@ -305,33 +306,33 @@ | |||
305 | snprintf(tln,sizeof(tln),"%5d",l); | 306 | snprintf(tln,sizeof(tln),"%5d",l); |
306 | <%output> | 307 | <%output> |
307 | <li class="<% l==line?"focused":"unfocused" %>"><span class="lineno"><% sitecing::html_escape(tln,sitecing::html_escape_nbsp) %></span> <span class="line"><% sitecing::html_escape(str,sitecing::html_escape_nbsp) %></span></li> | 308 | <li class="<% l==line?"focused":"unfocused" %>"><span class="lineno"><% sitecing::html_escape(tln,sitecing::html_escape_nbsp) %></span> <span class="line"><% sitecing::html_escape(str,sitecing::html_escape_nbsp) %></span></li> |
308 | </%output> | 309 | </%output> |
309 | } | 310 | } |
310 | <%output></ul></%output> | 311 | <%output></ul></%output> |
311 | } | 312 | } |
312 | } | 313 | } |
313 | } | 314 | } |
314 | </%code> | 315 | </%code> |
315 | <div class="what"> | 316 | <div class="what"> |
316 | <% sitecing::html_escape(message,sitecing::html_escape_br) %> | 317 | <% sitecing::html_escape(message,sitecing::html_escape_br) %> |
317 | </div> | 318 | </div> |
318 | </div> | 319 | </div> |
319 | </%method> | 320 | </%method> |
320 | <%codemethod string strip_roots(const string& filename) %> | 321 | <%codemethod string strip_roots(const string& filename) %> |
321 | string np = sitecing::normalize_path(filename); | 322 | string np = konforka::normalize_path(filename); |
322 | try{ | 323 | try{ |
323 | return sitecing::strip_prefix(np,root_source); | 324 | return sitecing::strip_prefix(np,root_source); |
324 | }catch(sitecing::utility_no_prefix& e){ } | 325 | }catch(sitecing::utility_no_prefix& e){ } |
325 | try{ | 326 | try{ |
326 | return sitecing::strip_prefix(np,root_intermediate); | 327 | return sitecing::strip_prefix(np,root_intermediate); |
327 | }catch(sitecing::utility_no_prefix& e){ } | 328 | }catch(sitecing::utility_no_prefix& e){ } |
328 | </%codemethod> | 329 | </%codemethod> |
329 | <%codemethod string remove_roots(const string& str) %> | 330 | <%codemethod string remove_roots(const string& str) %> |
330 | string rv = str; | 331 | string rv = str; |
331 | string::size_type rp; | 332 | string::size_type rp; |
332 | string::size_type rl = root_source.length(); | 333 | string::size_type rl = root_source.length(); |
333 | while((rp=rv.find(root_source))!=string::npos) { | 334 | while((rp=rv.find(root_source))!=string::npos) { |
334 | rv.erase(rp,rl); | 335 | rv.erase(rp,rl); |
335 | } | 336 | } |
336 | rl = root_intermediate.length(); | 337 | rl = root_intermediate.length(); |
337 | while((rp=rv.find(root_intermediate))!=string::npos) { | 338 | while((rp=rv.find(root_intermediate))!=string::npos) { |