From 30ab02977063217dcf16028d897a3e8cb0d9cff9 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 17 Apr 2015 15:10:36 -0700 Subject: 1082 Turns out I'm only able to define a 'raise' macro because I have include no system headers after that point. --- cpp/tangle/001trace.cc | 4 ++-- cpp/tangle/030tangle.cc | 12 +++--------- cpp/tangle/boot.cc | 5 +++++ 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'cpp/tangle') 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 -#include - size_t Line_number = 0; string Filename; @@ -84,7 +81,7 @@ void process_next_hunk(istream& in, const string& directive, list& out) if (cmd == "before" || cmd == "after" || cmd == "replace" || cmd == "replace{}" || cmd == "delete" || cmd == "delete{}") { list::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& out) return; } - RAISE << "unknown directive " << cmd << '\n'; + raise << "unknown directive " << cmd << '\n'; } list::iterator locate_target(list& out, istream& directive_stream) { @@ -158,7 +155,7 @@ list::iterator locate_target(list& 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& lines) { return false; } -#include -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 #include #include #include #include +#include #include #include #include @@ -42,6 +44,9 @@ using std::ostringstream; using std::ifstream; using std::ofstream; +#include +using std::isspace; // unicode-aware + #include "type_list" -- cgit 1.4.1-2-gfad0