diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-17 15:10:36 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-17 15:10:36 -0700 |
commit | 30ab02977063217dcf16028d897a3e8cb0d9cff9 (patch) | |
tree | 34785c21d93e6c1650b66b7bd987c9ab792a0c9c /cpp/tangle | |
parent | 1fba5d5d40136f74ee23250d5ccd5737e90bfd11 (diff) | |
download | mu-30ab02977063217dcf16028d897a3e8cb0d9cff9.tar.gz |
1082
Turns out I'm only able to define a 'raise' macro because I have include no system headers after that point.
Diffstat (limited to 'cpp/tangle')
-rw-r--r-- | cpp/tangle/001trace.cc | 4 | ||||
-rw-r--r-- | cpp/tangle/030tangle.cc | 12 | ||||
-rw-r--r-- | cpp/tangle/boot.cc | 5 |
3 files changed, 10 insertions, 11 deletions
diff --git a/cpp/tangle/001trace.cc b/cpp/tangle/001trace.cc index a99951e0..558b4922 100644 --- a/cpp/tangle/001trace.cc +++ b/cpp/tangle/001trace.cc @@ -69,11 +69,11 @@ trace_stream* Trace_stream = NULL; #define trace(layer) !Trace_stream ? cerr /*print nothing*/ : Trace_stream->stream(layer) // Warnings should go straight to cerr by default since calls to trace() have // some unfriendly constraints (they delay printing, they can't nest) -#define RAISE ((!Trace_stream || !Hide_warnings) ? cerr /*do print*/ : Trace_stream->stream("warn")) << __FILE__ << ":" << __LINE__ << " " +#define raise ((!Trace_stream || !Hide_warnings) ? cerr /*do print*/ : Trace_stream->stream("warn")) << __FILE__ << ":" << __LINE__ << " " // Just debug logging without any test support. #define dbg cerr << __FUNCTION__ << '(' << __FILE__ << ':' << __LINE__ << ") " -// RAISE << die exits after printing -- unless Hide_warnings is set. +// raise << die exits after printing -- unless Hide_warnings is set. struct die {}; ostream& operator<<(ostream& os, unused die) { if (Hide_warnings) return os; diff --git a/cpp/tangle/030tangle.cc b/cpp/tangle/030tangle.cc index 896e8f3e..fc40880f 100644 --- a/cpp/tangle/030tangle.cc +++ b/cpp/tangle/030tangle.cc @@ -2,9 +2,6 @@ // Insert #line directives to preserve line numbers in the original. // Clear lines starting with '//:' (tangle comments). -#include<assert.h> -#include<sys/param.h> - size_t Line_number = 0; string Filename; @@ -84,7 +81,7 @@ void process_next_hunk(istream& in, const string& directive, list<string>& out) if (cmd == "before" || cmd == "after" || cmd == "replace" || cmd == "replace{}" || cmd == "delete" || cmd == "delete{}") { list<string>::iterator target = locate_target(out, directive_stream); if (target == out.end()) { - RAISE << "Couldn't find target " << directive << '\n' << die(); + raise << "Couldn't find target " << directive << '\n' << die(); return; } @@ -131,7 +128,7 @@ void process_next_hunk(istream& in, const string& directive, list<string>& out) return; } - RAISE << "unknown directive " << cmd << '\n'; + raise << "unknown directive " << cmd << '\n'; } list<string>::iterator locate_target(list<string>& out, istream& directive_stream) { @@ -158,7 +155,7 @@ list<string>::iterator locate_target(list<string>& out, istream& directive_strea if (pat2 == "") return out.end(); return find_substr(out, intermediate, pat2); } - RAISE << "unknown keyword in directive: " << next_token << '\n'; + raise << "unknown keyword in directive: " << next_token << '\n'; return out.end(); } @@ -340,9 +337,6 @@ bool any_non_input_line(const list<string>& lines) { return false; } -#include <locale> -using std::isspace; // unicode-aware - // does s start with pat, after skipping whitespace? // pat can't start with whitespace bool starts_with(const string& s, const string& pat) { diff --git a/cpp/tangle/boot.cc b/cpp/tangle/boot.cc index 136d3382..0001c84c 100644 --- a/cpp/tangle/boot.cc +++ b/cpp/tangle/boot.cc @@ -1,9 +1,11 @@ #define unused __attribute__((unused)) +#include<assert.h> #include<cstdio> #include<cstring> #include<cstdlib> #include<errno.h> +#include<sys/param.h> #include<time.h> #include<math.h> #include<vector> @@ -42,6 +44,9 @@ using std::ostringstream; using std::ifstream; using std::ofstream; +#include <locale> +using std::isspace; // unicode-aware + #include "type_list" |