/src/libsass/src/backtrace.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | #include "backtrace.hpp" |
2 | | |
3 | | namespace Sass { |
4 | | |
5 | 13 | const sass::string traces_to_string(Backtraces traces, sass::string indent) { |
6 | | |
7 | 13 | sass::ostream ss; |
8 | 13 | sass::string cwd(File::get_cwd()); |
9 | | |
10 | 13 | bool first = true; |
11 | 13 | size_t i_beg = traces.size() - 1; |
12 | 13 | size_t i_end = sass::string::npos; |
13 | 26 | for (size_t i = i_beg; i != i_end; i --) { |
14 | | |
15 | 13 | const Backtrace& trace = traces[i]; |
16 | | |
17 | | // make path relative to the current directory |
18 | 13 | sass::string rel_path(File::abs2rel(trace.pstate.getPath(), cwd, cwd)); |
19 | | |
20 | | // skip functions on error cases (unsure why ruby sass does this) |
21 | | // if (trace.caller.substr(0, 6) == ", in f") continue; |
22 | | |
23 | 13 | if (first) { |
24 | 13 | ss << indent; |
25 | 13 | ss << "on line "; |
26 | 13 | ss << trace.pstate.getLine(); |
27 | 13 | ss << ":"; |
28 | 13 | ss << trace.pstate.getColumn(); |
29 | 13 | ss << " of " << rel_path; |
30 | | // ss << trace.caller; |
31 | 13 | first = false; |
32 | 13 | } else { |
33 | 0 | ss << trace.caller; |
34 | 0 | ss << std::endl; |
35 | 0 | ss << indent; |
36 | 0 | ss << "from line "; |
37 | 0 | ss << trace.pstate.getLine(); |
38 | 0 | ss << ":"; |
39 | 0 | ss << trace.pstate.getColumn(); |
40 | 0 | ss << " of " << rel_path; |
41 | 0 | } |
42 | | |
43 | 13 | } |
44 | | |
45 | 13 | ss << std::endl; |
46 | 13 | return ss.str(); |
47 | | |
48 | 13 | } |
49 | | |
50 | | }; |