From 7a219c68bae6dbe214aec69a051015e851e32400 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 12 Oct 2017 23:55:19 -0700 Subject: 4054 --- html/subx/001help.cc.html | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'html/subx/001help.cc.html') diff --git a/html/subx/001help.cc.html b/html/subx/001help.cc.html index 73ad6bfb..2250a0c9 100644 --- a/html/subx/001help.cc.html +++ b/html/subx/001help.cc.html @@ -65,7 +65,7 @@ if ('onhashchange' in window) { 2 //: This should give you a sense for what to look forward to in later layers. 3 4 :(before "End Commandline Parsing") - 5 if (argc <= 1 || is_equal(argv[1], "--help")) { + 5 if (argc <= 1 || is_equal(argv[1], "--help")) { 6 //: this is the functionality later layers will provide 7 // currently no automated tests for commandline arg parsing 8 cerr << "Usage:\n" @@ -83,15 +83,15 @@ if ('onhashchange' in window) { 20 //: way, our 'build' script contains a little command to automatically 21 //: generate declarations for them. 22 :(code) - 23 bool is_equal(char* s, const char* lit) { + 23 bool is_equal(char* s, const char* lit) { 24 return strncmp(s, lit, strlen(lit)) == 0; 25 } 26 - 27 bool starts_with(const string& s, const string& pat) { + 27 bool starts_with(const string& s, const string& pat) { 28 string::const_iterator a=s.begin(), b=pat.begin(); - 29 for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) + 29 for (/*nada*/; a!=s.end() && b!=pat.end(); ++a, ++b) 30 ¦ if (*a != *b) return false; - 31 return b == pat.end(); + 31 return b == pat.end(); 32 } 33 34 //: I'll throw some style conventions here for want of a better place for them. @@ -157,20 +157,20 @@ if ('onhashchange' in window) { 94 //: to the compiler, supported by Clang (GCC version only works sometimes: 95 //: http://stackoverflow.com/questions/20851061/how-to-make-gcc-ftrapv-work). 96 :(before "atexit(reset)") - 97 initialize_signal_handlers(); // not always necessary, but doesn't hurt + 97 initialize_signal_handlers(); // not always necessary, but doesn't hurt 98 //? cerr << INT_MAX+1 << '\n'; // test overflow 99 //? assert(false); // test SIGABRT 100 :(code) 101 // based on https://spin.atomicobject.com/2013/01/13/exceptions-stack-traces-c -102 void initialize_signal_handlers() { +102 void initialize_signal_handlers() { 103 struct sigaction action; 104 bzero(&action, sizeof(action)); -105 action.sa_sigaction = dump_and_exit; +105 action.sa_sigaction = dump_and_exit; 106 sigemptyset(&action.sa_mask); 107 sigaction(SIGABRT, &action, NULL); // assert() failure or integer overflow on linux (with -ftrapv) 108 sigaction(SIGILL, &action, NULL); // integer overflow on OS X (with -ftrapv) 109 } -110 void dump_and_exit(int sig, unused siginfo_t* dummy1, unused void* dummy2) { +110 void dump_and_exit(int sig, unused siginfo_t* dummy1, unused void* dummy2) { 111 switch (sig) { 112 ¦ case SIGABRT: 113 ¦ ¦ #ifndef __APPLE__ @@ -193,7 +193,7 @@ if ('onhashchange' in window) { 130 131 //: For good measure we'll also enable SIGFPE. 132 :(before "atexit(reset)") -133 feenableexcept(FE_OVERFLOW | FE_UNDERFLOW); +133 feenableexcept(FE_OVERFLOW | FE_UNDERFLOW); 134 //? assert(sizeof(int) == 4 && sizeof(float) == 4); 135 //? // | exp | mantissa 136 //? int smallest_subnormal = 0b00000000000000000000000000000001; @@ -206,7 +206,7 @@ if ('onhashchange' in window) { 143 #ifdef __APPLE__ 144 // Public domain polyfill for feenableexcept on OS X 145 // http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c -146 int feenableexcept (unsigned int excepts) { +146 int feenableexcept (unsigned int excepts) { 147 static fenv_t fenv; 148 unsigned int new_excepts = excepts & FE_ALL_EXCEPT; 149 unsigned int old_excepts; @@ -223,22 +223,22 @@ if ('onhashchange' in window) { 160 // from http://stackoverflow.com/questions/152643/idiomatic-c-for-reading-from-a-const-map 161 template<typename T> typename T::mapped_type& get(T& map, typename T::key_type const& key) { 162 typename T::iterator iter(map.find(key)); -163 assert(iter != map.end()); +163 assert(iter != map.end()); 164 return iter->second; 165 } 166 template<typename T> typename T::mapped_type const& get(const T& map, typename T::key_type const& key) { 167 typename T::const_iterator iter(map.find(key)); -168 assert(iter != map.end()); +168 assert(iter != map.end()); 169 return iter->second; 170 } -171 template<typename T> typename T::mapped_type const& put(T& map, typename T::key_type const& key, typename T::mapped_type const& value) { +171 template<typename T> typename T::mapped_type const& put(T& map, typename T::key_type const& key, typename T::mapped_type const& value) { 172 map[key] = value; 173 return map[key]; 174 } -175 template<typename T> bool contains_key(T& map, typename T::key_type const& key) { -176 return map.find(key) != map.end(); +175 template<typename T> bool contains_key(T& map, typename T::key_type const& key) { +176 return map.find(key) != map.end(); 177 } -178 template<typename T> typename T::mapped_type& get_or_insert(T& map, typename T::key_type const& key) { +178 template<typename T> typename T::mapped_type& get_or_insert(T& map, typename T::key_type const& key) { 179 return map[key]; 180 } 181 //: The contract: any container that relies on get_or_insert should never call @@ -248,7 +248,7 @@ if ('onhashchange' in window) { 185 //: what subclass you try to putback into. You have to watch out for the pesky 186 //: failbit and badbit. Just avoid eof() and use this helper instead. 187 :(code) -188 bool has_data(istream& in) { +188 bool has_data(istream& in) { 189 return in && !in.eof(); 190 } 191 -- cgit 1.4.1-2-gfad0