# # # add_file "vector.hh" # content [d89d098e94f5ef800383b9ccd0d52f9a9c8e6b66] # # patch "Makefile.am" # from [2bbc5c3f98f24c81c68d2947f27e42cf012520a6] # to [e02ee885d04cc7a04ab944830f39cff90b637d5a] # # patch "app_state.cc" # from [d3bca41d60f83745111e44f868cf05847d4aaf8b] # to [3bcb75b8497965bd13fc4762f1c1bf7c9fa44db3] # # patch "app_state.hh" # from [c417b99837f0a2de58f1e8f9b059ab3d25f611c1] # to [6f23fadcd338a7b5864a935fbcb6a44f661b178d] # # patch "asciik.hh" # from [9822c026c2b57802ea1d1872670f017315151c78] # to [b1c45a89506145446b33457ca62c836c9f255689] # # patch "automate.cc" # from [f5e20383f535cdb67c487301422031aec585807d] # to [9b2d2c6438d01423cde0615b3df1a753454bb506] # # patch "basic_io.hh" # from [d843284e57239ab9616400b179882b56ffc5fcb1] # to [9ad16beabaf2b1c272a356e8cf41bba97f7e1562] # # patch "cert.cc" # from [a9e316071a5d773e6a7c0477f840889bc64073dd] # to [4e4b08193ea8d1cafeebe2c1e227c0a70424062a] # # patch "cert.hh" # from [0fb047d90d13c230b6d3a616052b294624718819] # to [f34ca707b7e36e98331a580c2b411b65719e3116] # # patch "charset.cc" # from [5f3f37f70f5bc3ef4a5f793a25f77a0aecdf81c0] # to [b7b1395ae6b35e49c503ed858223ff54dbfbf161] # # patch "commands.hh" # from [255a1ffe65f28f2a88c6526092f9a63c78ef11ac] # to [18235ed79ea9bf22f0a6957e6bb7d2486b824db7] # # patch "cset.hh" # from [c99e08758e5c07150b55364101f7c4ebb0b42c16] # to [d76a7276730c9649ea326745abfd0d2be1c19a82] # # patch "cycle_detector.hh" # from [82e82e8c4401a964bb405a97802c5f554774fad9] # to [c8ee3bc84304bebe227f3fe2c3e43910cf8fbcbd] # # patch "database.cc" # from [0a9272ee0e88d9e935871e8ab788a0f844695404] # to [d7f4a2b811c26b90da6815f13249a18b1b3f4b9f] # # patch "database.hh" # from [df490ba6c815f5afca05231b2e8077b917ef9e14] # to [0cf5bf163523720b681afd1739903947c8d8af65] # # patch "diff_patch.cc" # from [943b5d68699b7ae6e06c5f335d8445cb961dabff] # to [329d20d3cb5f1a7b67ef62ce5583f919285f76d5] # # patch "diff_patch.hh" # from [681984533e6cb27a293e72d159ec24457f7cf804] # to [9035f2d57120bd8d9f6c70bf9702e87d1cb42d48] # # patch "enumerator.cc" # from [81b5bcc7dbb9e02db1eec42411b681c33566e1b0] # to [bbf94536322448b253ba46c2a679f658e2393c70] # # patch "enumerator.hh" # from [8574278f53e06d0a6d1a80a6983f6ae04a0043f4] # to [051909004ac5fdeed44714e2d49acb5e1af4fe48] # # patch "graph.hh" # from [dfb30a026f9dcbb139d13d96eadc7ed591e09aaf] # to [6384f6bd01b8b43383ba2e6adf6ae10b6f725bac] # # patch "key_store.hh" # from [6dd1c25123305d42dfbf957f6ee872fae601e96b] # to [44eedad6a981d25603d458c675187c0c740ce3d2] # # patch "lcs.cc" # from [3e6a13b291a0d7cd12b700ad3c13fe5d527c841f] # to [435ebb80d063b1036a962fea5f800784db804811] # # patch "lcs.hh" # from [f69386c0998c472802d3cb7092d8aeea3d68bcaf] # to [3b862f707ecadc59ea9204714fb2068bf8fec66c] # # patch "lua.cc" # from [7bdc5718a8d1db646ab3093d05cb8faa65e4fd0e] # to [cdff2c5d72b8deecf8d8f95fd9a1d82cdc73f077] # # patch "merkle_tree.hh" # from [40e3ce0f83ba3a41bcca9a4896792d52627f0955] # to [88d7a2e577684e0a283f4fd0cc2d634f8c2479b8] # # patch "netcmd.cc" # from [eaf56a9400d6bc15eccb6114c19cc7ce5cde9622] # to [584773446209355dabaaba6c8a88db4b06fb778c] # # patch "netcmd.hh" # from [91da5034baab3bc9dec528c24ca5b8b2ff484d5c] # to [8b17081341db6c09ae654998957b61c2d790edd2] # # patch "netxx_pipe.hh" # from [a20357be17876b21d53d2bf237e0a0024d716018] # to [873bc7d111d59db057cba5ea5f9ce31ad7608e1f] # # patch "option.hh" # from [b84098e030a8b5982930a0d6c093958792d38f13] # to [7b18a9e8807a29cd59fd8a9e727f89e82a694366] # # patch "options_list.hh" # from [3d15836cb0ce2d42fef9e00d9c14f7f19a9868c2] # to [eabdd6463a42ed5bbbedbadfceb42925f90e5c2a] # # patch "project.cc" # from [bff2c8ff7455f6e988707c7cd7627ecf59f1a8c1] # to [bc5f626244e7e3de2cd2e5b6bee4832201c52570] # # patch "randomfile.hh" # from [10edb3699a38484b52912a8ef33cc937a0a9f520] # to [b6b680a21c57b786686cedc7330d3ecbf847c924] # # patch "rcs_file.cc" # from [73064ea1d3e228d0cd5c811973c492b4657e14a6] # to [ff879adf81e7dd34604af8338e376b0692d1dcb6] # # patch "rcs_file.hh" # from [1cc24800d1d2c57e32cc8e2fc89c5cbb3faa8a1f] # to [4f97971ca41a02c642818bf4a6dda13010bbe28f] # # patch "rcs_import.cc" # from [7e735462858d40848d763833eccc88f656ebb3ec] # to [f6ce4f02b7f5e254f6be4e5e98739fce77b62947] # # patch "restrictions.cc" # from [b1a0ddef5614aa652daa4d5e51fbe405e827e07d] # to [0ed28c124d4af8fbaab01d6d8445980ca7d0bdc9] # # patch "roster.cc" # from [cc0a1bbc54cef7ff0360cb9f48aed726d6fe1645] # to [e36b1e83bf7a5a3538f0a882feaccb9f32250118] # # patch "sanity.cc" # from [87ade97fa69cae5b9558e6358ceadfe172828e01] # to [a25e5e09451b0ea2219c650a1a64502148ab5005] # # patch "sanity.hh" # from [f66a2562e653712b305795333187b96343dec036] # to [199cc212e369ac57a758556faf52d530565b54c6] # # patch "selectors.hh" # from [83f7e51e0ae9c30864e8f39eeef0368ab1000315] # to [a580067010375b01e72094ebc255e26da4894384] # # patch "simplestring_xform.hh" # from [501041263b4eb2b04c61e753b5bc636276716040] # to [0280d49b889bc0b7b2900d5d123cc8ec95a115eb] # # patch "smap.hh" # from [bf9bd78d9e317a89f27f5cecaa0aafff8007b6b0] # to [d47fcb8010470dbe063bab5c669547cf601e80fc] # # patch "ssh_agent.hh" # from [13e3cf45bfa19a9f8832bd6cdcca502271bb8047] # to [b5cf999ba112dc33279647aac778a458258f7e06] # # patch "transforms.cc" # from [91ed3086b19a25d7d28258a984bcdd8a32a8a549] # to [2a2510681a0dccdc471ef508dc51f5c568d58963] # # patch "ui.cc" # from [4de898f353d62cc49f8cb22330527983f589277e] # to [989194f7bb73d7cc55e7197508b9203dde9d164f] # # patch "ui.hh" # from [ad79ebfa9e7e5935b75230d47e85684da844b30b] # to [e2c82fd7f5fb014e3cacf951bb4a5c165c16d13b] # # patch "unit_tests.cc" # from [1fac50797304ac4b4addf8b5153fd9dbb02863da] # to [6c18091f527b9b38ae589bf9b6dede0896abdcd7] # # patch "update.cc" # from [bc9c39135d1e082cf2c4dfbe425ef08e6013ffc4] # to [974b6d54d36ef82389781738f2b247417d5def27] # # patch "xdelta.cc" # from [3f540c8b573608425e174ded788c6597e8b77a1b] # to [d17efefc2d804088f5dc02c888c5f4a8536d7e17] # ============================================================ --- vector.hh d89d098e94f5ef800383b9ccd0d52f9a9c8e6b66 +++ vector.hh d89d098e94f5ef800383b9ccd0d52f9a9c8e6b66 @@ -0,0 +1,89 @@ +#ifndef __VECTOR_HH__ +#define __VECTOR_HH__ + +// Copyright (C) 2002 Graydon Hoare +// +// This program is made available under the GNU GPL version 2.0 or +// greater. See the accompanying file COPYING for details. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the +// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. + +// we're interested in trapping index overflows early and precisely, +// because they usually represent *very significant* logic errors. we use +// an inline template function because the idx(...) needs to be used as an +// expression, not as a statement. + +// to ensure that our index checkers are always visible when std::vector +// is in use, this header is the only file that should include ; +// all others should include this file instead. + +#include +#include "sanity.hh" +#include "quick_alloc.hh" // to get the QA() macro + +template +inline T & checked_index(std::vector & v, + typename std::vector::size_type i, + char const * vec, + char const * index, + char const * file, + int line) +{ + if (UNLIKELY(i >= v.size())) + global_sanity.index_failure(vec, index, v.size(), i, file, line); + return v[i]; +} + +template +inline T const & checked_index(std::vector const & v, + typename std::vector::size_type i, + char const * vec, + char const * index, + char const * file, + int line) +{ + if (UNLIKELY(i >= v.size())) + global_sanity.index_failure(vec, index, v.size(), i, file, line); + return v[i]; +} + +#ifdef QA_SUPPORTED +template +inline T & checked_index(std::vector & v, + typename std::vector::size_type i, + char const * vec, + char const * index, + char const * file, + int line) +{ + if (UNLIKELY(i >= v.size())) + global_sanity.index_failure(vec, index, v.size(), i, file, line); + return v[i]; +} + +template +inline T const & checked_index(std::vector const & v, + typename std::vector::size_type i, + char const * vec, + char const * index, + char const * file, + int line) +{ + if (UNLIKELY(i >= v.size())) + global_sanity.index_failure(vec, index, v.size(), i, file, line); + return v[i]; +} +#endif // QA_SUPPORTED + +#define idx(v, i) checked_index((v), (i), #v, #i, __FILE__, __LINE__) + +// Local Variables: +// mode: C++ +// c-file-style: "gnu" +// indent-tabs-mode: nil +// End: +// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: + +#endif // __VECTOR_HH__ ============================================================ --- Makefile.am 2bbc5c3f98f24c81c68d2947f27e42cf012520a6 +++ Makefile.am e02ee885d04cc7a04ab944830f39cff90b637d5a @@ -7,7 +7,7 @@ SANITY_CORE_SOURCES = \ cmd_othervcs.cc cmd_automate.cc cmd_files.cc SANITY_CORE_SOURCES = \ - sanity.cc sanity.hh quick_alloc.hh base.hh \ + sanity.cc sanity.hh quick_alloc.hh vector.hh base.hh \ simplestring_xform.cc simplestring_xform.hh \ constants.cc constants.hh numeric_vocab.hh \ platform.hh numeric_vocab.cc ============================================================ --- app_state.cc d3bca41d60f83745111e44f868cf05847d4aaf8b +++ app_state.cc 3bcb75b8497965bd13fc4762f1c1bf7c9fa44db3 @@ -8,7 +8,7 @@ // PURPOSE. #include "base.hh" -#include +#include "vector.hh" #include "botan/pubkey.h" #include "botan/rsa.h" ============================================================ --- app_state.hh c417b99837f0a2de58f1e8f9b059ab3d25f611c1 +++ app_state.hh 6f23fadcd338a7b5864a935fbcb6a44f661b178d @@ -14,7 +14,7 @@ class lua_hooks; class lua_hooks; #include -#include +#include "vector.hh" #include ============================================================ --- asciik.hh 9822c026c2b57802ea1d1872670f017315151c78 +++ asciik.hh b1c45a89506145446b33457ca62c836c9f255689 @@ -1,8 +1,8 @@ #ifndef __ASCIIK_HH__ #define __ASCIIK_HH__ #include -#include +#include "vector.hh" #include "revision.hh" ============================================================ --- automate.cc f5e20383f535cdb67c487301422031aec585807d +++ automate.cc 9b2d2c6438d01423cde0615b3df1a753454bb506 @@ -12,7 +12,7 @@ #include #include #include -#include +#include "vector.hh" #include #include ============================================================ --- basic_io.hh d843284e57239ab9616400b179882b56ffc5fcb1 +++ basic_io.hh 9ad16beabaf2b1c272a356e8cf41bba97f7e1562 @@ -11,7 +11,7 @@ // PURPOSE. -#include +#include "vector.hh" #include #include "paths.hh" ============================================================ --- cert.cc a9e316071a5d773e6a7c0477f840889bc64073dd +++ cert.cc 4e4b08193ea8d1cafeebe2c1e227c0a70424062a @@ -10,7 +10,7 @@ #include "base.hh" #include #include -#include +#include "vector.hh" #include #include ============================================================ --- cert.hh 0fb047d90d13c230b6d3a616052b294624718819 +++ cert.hh f34ca707b7e36e98331a580c2b411b65719e3116 @@ -12,7 +12,7 @@ #include #include -#include +#include "vector.hh" #include "vocab.hh" #include "dates.hh" ============================================================ --- charset.cc 5f3f37f70f5bc3ef4a5f793a25f77a0aecdf81c0 +++ charset.cc b7b1395ae6b35e49c503ed858223ff54dbfbf161 @@ -8,7 +8,7 @@ // PURPOSE. #include "base.hh" -#include +#include "vector.hh" #include ============================================================ --- commands.hh 255a1ffe65f28f2a88c6526092f9a63c78ef11ac +++ commands.hh 18235ed79ea9bf22f0a6957e6bb7d2486b824db7 @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include "options.hh" class app_state; class utf8; ============================================================ --- cset.hh c99e08758e5c07150b55364101f7c4ebb0b42c16 +++ cset.hh d76a7276730c9649ea326745abfd0d2be1c19a82 @@ -12,7 +12,7 @@ #include #include -#include +#include "vector.hh" #include "numeric_vocab.hh" #include "paths.hh" ============================================================ --- cycle_detector.hh 82e82e8c4401a964bb405a97802c5f554774fad9 +++ cycle_detector.hh c8ee3bc84304bebe227f3fe2c3e43910cf8fbcbd @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include #include ============================================================ --- database.cc 0a9272ee0e88d9e935871e8ab788a0f844695404 +++ database.cc d7f4a2b811c26b90da6815f13249a18b1b3f4b9f @@ -15,7 +15,7 @@ #include #include #include -#include +#include "vector.hh" #include ============================================================ --- database.hh df490ba6c815f5afca05231b2e8077b917ef9e14 +++ database.hh 0cf5bf163523720b681afd1739903947c8d8af65 @@ -15,7 +15,7 @@ int sqlite3_finalize(sqlite3_stmt *); struct cert; int sqlite3_finalize(sqlite3_stmt *); -#include +#include "vector.hh" #include #include ============================================================ --- diff_patch.cc 943b5d68699b7ae6e06c5f335d8445cb961dabff +++ diff_patch.cc 329d20d3cb5f1a7b67ef62ce5583f919285f76d5 @@ -12,7 +12,7 @@ #include #include #include -#include +#include "vector.hh" #include #include ============================================================ --- diff_patch.hh 681984533e6cb27a293e72d159ec24457f7cf804 +++ diff_patch.hh 9035f2d57120bd8d9f6c70bf9702e87d1cb42d48 @@ -16,7 +16,7 @@ #include #include -#include +#include "vector.hh" class app_state; ============================================================ --- enumerator.cc 81b5bcc7dbb9e02db1eec42411b681c33566e1b0 +++ enumerator.cc bbf94536322448b253ba46c2a679f658e2393c70 @@ -11,7 +11,7 @@ #include #include #include -#include +#include "vector.hh" #include "cset.hh" #include "enumerator.hh" ============================================================ --- enumerator.hh 8574278f53e06d0a6d1a80a6983f6ae04a0043f4 +++ enumerator.hh 051909004ac5fdeed44714e2d49acb5e1af4fe48 @@ -13,7 +13,7 @@ #include #include #include -#include +#include "vector.hh" #include "vocab.hh" class app_state; ============================================================ --- graph.hh dfb30a026f9dcbb139d13d96eadc7ed591e09aaf +++ graph.hh 6384f6bd01b8b43383ba2e6adf6ae10b6f725bac @@ -18,7 +18,7 @@ // opportunity permits. #include -#include +#include "vector.hh" #include #include "vocab.hh" ============================================================ --- key_store.hh 6dd1c25123305d42dfbf957f6ee872fae601e96b +++ key_store.hh 44eedad6a981d25603d458c675187c0c740ce3d2 @@ -1,8 +1,8 @@ #ifndef __KEY_STORE_H__ #define __KEY_STORE_H__ #include -#include +#include "vector.hh" #include "vocab.hh" #include "paths.hh" ============================================================ --- lcs.cc 3e6a13b291a0d7cd12b700ad3c13fe5d527c841f +++ lcs.cc 435ebb80d063b1036a962fea5f800784db804811 @@ -40,7 +40,7 @@ #include "base.hh" #include -#include +#include "vector.hh" #include "lcs.hh" #include "sanity.hh" ============================================================ --- lcs.hh f69386c0998c472802d3cb7092d8aeea3d68bcaf +++ lcs.hh 3b862f707ecadc59ea9204714fb2068bf8fec66c @@ -11,7 +11,7 @@ // PURPOSE. #include -#include +#include "vector.hh" #include "quick_alloc.hh" void ============================================================ --- lua.cc 7bdc5718a8d1db646ab3093d05cb8faa65e4fd0e +++ lua.cc cdff2c5d72b8deecf8d8f95fd9a1d82cdc73f077 @@ -8,7 +8,7 @@ #include "platform.hh" #include -#include +#include "vector.hh" #include #include ============================================================ --- merkle_tree.hh 40e3ce0f83ba3a41bcca9a4896792d52627f0955 +++ merkle_tree.hh 88d7a2e577684e0a283f4fd0cc2d634f8c2479b8 @@ -16,6 +16,7 @@ #include #include +#include "vector.hh" #include "vocab.hh" #include "transforms.hh" #include "hash_map.hh" ============================================================ --- netcmd.cc eaf56a9400d6bc15eccb6114c19cc7ce5cde9622 +++ netcmd.cc 584773446209355dabaaba6c8a88db4b06fb778c @@ -8,7 +8,7 @@ // PURPOSE. #include "base.hh" -#include +#include "vector.hh" #include #include "constants.hh" ============================================================ --- netcmd.hh 91da5034baab3bc9dec528c24ca5b8b2ff484d5c +++ netcmd.hh 8b17081341db6c09ae654998957b61c2d790edd2 @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include #include "merkle_tree.hh" ============================================================ --- netxx_pipe.hh a20357be17876b21d53d2bf237e0a0024d716018 +++ netxx_pipe.hh 873bc7d111d59db057cba5ea5f9ce31ad7608e1f @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include #include #ifdef WIN32 ============================================================ --- option.hh b84098e030a8b5982930a0d6c093958792d38f13 +++ option.hh 7b18a9e8807a29cd59fd8a9e727f89e82a694366 @@ -1,10 +1,10 @@ #ifndef __OPTION_HH__ #define __OPTION_HH__ #include #include #include -#include +#include "vector.hh" #include #include "lexical_cast.hh" ============================================================ --- options_list.hh 3d15836cb0ce2d42fef9e00d9c14f7f19a9868c2 +++ options_list.hh eabdd6463a42ed5bbbedbadfceb42925f90e5c2a @@ -433,7 +433,7 @@ GOPT(quiet, "quiet", bool, false, { quiet = true; global_sanity.set_quiet(); - ui.set_tick_writer(new tick_write_nothing); + ui.set_tick_write_nothing(); } #endif @@ -451,7 +451,7 @@ gettext_noop("suppress warning, verbose, { reallyquiet = true; global_sanity.set_reallyquiet(); - ui.set_tick_writer(new tick_write_nothing); + ui.set_tick_write_nothing(); } #endif @@ -494,11 +494,11 @@ GOPT(ticker, "ticker", std::string, , { ticker = arg; if (ticker == "none" || global_sanity.quiet_p()) - ui.set_tick_writer(new tick_write_nothing); + ui.set_tick_write_nothing(); else if (ticker == "dot") - ui.set_tick_writer(new tick_write_dot); + ui.set_tick_write_dot(); else if (ticker == "count") - ui.set_tick_writer(new tick_write_count); + ui.set_tick_write_count(); else throw bad_arg_internal(F("argument must be 'none', 'dot', or 'count'").str()); } ============================================================ --- project.cc bff2c8ff7455f6e988707c7cd7627ecf59f1a8c1 +++ project.cc bc5f626244e7e3de2cd2e5b6bee4832201c52570 @@ -1,8 +1,8 @@ // 2007 Timothy Brownawell // GNU GPL V2 or later #include "base.hh" -#include +#include "vector.hh" #include "app_state.hh" #include "cert.hh" ============================================================ --- randomfile.hh 10edb3699a38484b52912a8ef33cc937a0a9f520 +++ randomfile.hh b6b680a21c57b786686cedc7330d3ecbf847c924 @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include "lexical_cast.hh" #include "randomizer.hh" ============================================================ --- rcs_file.cc 73064ea1d3e228d0cd5c811973c492b4657e14a6 +++ rcs_file.cc ff879adf81e7dd34604af8338e376b0692d1dcb6 @@ -10,7 +10,7 @@ #include "base.hh" #include -#include +#include "vector.hh" #ifdef WIN32 #include ============================================================ --- rcs_file.hh 1cc24800d1d2c57e32cc8e2fc89c5cbb3faa8a1f +++ rcs_file.hh 4f97971ca41a02c642818bf4a6dda13010bbe28f @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include #include ============================================================ --- rcs_import.cc 7e735462858d40848d763833eccc88f656ebb3ec +++ rcs_import.cc f6ce4f02b7f5e254f6be4e5e98739fce77b62947 @@ -16,7 +16,7 @@ #include #include #include -#include +#include "vector.hh" #include ============================================================ --- restrictions.cc b1a0ddef5614aa652daa4d5e51fbe405e827e07d +++ restrictions.cc 0ed28c124d4af8fbaab01d6d8445980ca7d0bdc9 @@ -9,7 +9,7 @@ #include "base.hh" #include -#include +#include "vector.hh" #include "restrictions.hh" #include "revision.hh" ============================================================ --- roster.cc cc0a1bbc54cef7ff0360cb9f48aed726d6fe1645 +++ roster.cc e36b1e83bf7a5a3538f0a882feaccb9f32250118 @@ -11,7 +11,7 @@ #include #include #include -#include +#include "vector.hh" #include #include "app_state.hh" ============================================================ --- sanity.cc 87ade97fa69cae5b9558e6358ceadfe172828e01 +++ sanity.cc a25e5e09451b0ea2219c650a1a64502148ab5005 @@ -12,7 +12,7 @@ #include #include #include -#include +#include "vector.hh" #include #include ============================================================ --- sanity.hh f66a2562e653712b305795333187b96343dec036 +++ sanity.hh 199cc212e369ac57a758556faf52d530565b54c6 @@ -11,13 +11,11 @@ // PURPOSE. #include -#include #include #include "boost/current_function.hpp" #include "i18n.h" -#include "quick_alloc.hh" // to get the QA() macro #include "numeric_vocab.hh" // our assertion / sanity / error logging system *was* based on GNU Nana, @@ -336,71 +334,6 @@ do { \ } \ } while(0) - -// we're interested in trapping index overflows early and precisely, -// because they usually represent *very significant* logic errors. we use -// an inline template function because the idx(...) needs to be used as an -// expression, not as a statement. - -template -inline T & checked_index(std::vector & v, - typename std::vector::size_type i, - char const * vec, - char const * index, - char const * file, - int line) -{ - if (UNLIKELY(i >= v.size())) - global_sanity.index_failure(vec, index, v.size(), i, file, line); - return v[i]; -} - -template -inline T const & checked_index(std::vector const & v, - typename std::vector::size_type i, - char const * vec, - char const * index, - char const * file, - int line) -{ - if (UNLIKELY(i >= v.size())) - global_sanity.index_failure(vec, index, v.size(), i, file, line); - return v[i]; -} - -#ifdef QA_SUPPORTED -template -inline T & checked_index(std::vector & v, - typename std::vector::size_type i, - char const * vec, - char const * index, - char const * file, - int line) -{ - if (UNLIKELY(i >= v.size())) - global_sanity.index_failure(vec, index, v.size(), i, file, line); - return v[i]; -} - -template -inline T const & checked_index(std::vector const & v, - typename std::vector::size_type i, - char const * vec, - char const * index, - char const * file, - int line) -{ - if (UNLIKELY(i >= v.size())) - global_sanity.index_failure(vec, index, v.size(), i, file, line); - return v[i]; -} -#endif // QA_SUPPORTED - - -#define idx(v, i) checked_index((v), (i), #v, #i, __FILE__, __LINE__) - - - // Last gasp dumps class MusingI ============================================================ --- selectors.hh 83f7e51e0ae9c30864e8f39eeef0368ab1000315 +++ selectors.hh a580067010375b01e72094ebc255e26da4894384 @@ -10,7 +10,7 @@ // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. -#include +#include "vector.hh" #include #include ============================================================ --- simplestring_xform.hh 501041263b4eb2b04c61e753b5bc636276716040 +++ simplestring_xform.hh 0280d49b889bc0b7b2900d5d123cc8ec95a115eb @@ -1,7 +1,7 @@ #ifndef __SIMPLESTRING_XFORM_HH__ #define __SIMPLESTRING_XFORM_HH__ -#include +#include "vector.hh" std::string uppercase(std::string const & in); std::string lowercase(std::string const & in); ============================================================ --- smap.hh bf9bd78d9e317a89f27f5cecaa0aafff8007b6b0 +++ smap.hh d47fcb8010470dbe063bab5c669547cf601e80fc @@ -12,7 +12,7 @@ #include #include -#include +#include "vector.hh" // this is a map that works by storing a sorted vector and doing binary ============================================================ --- ssh_agent.hh 13e3cf45bfa19a9f8832bd6cdcca502271bb8047 +++ ssh_agent.hh b5cf999ba112dc33279647aac778a458258f7e06 @@ -15,7 +15,7 @@ #include "botan/rsa.h" #include "botan/bigint.h" #include -#include +#include "vector.hh" #include "platform.hh" class ssh_agent : ssh_agent_platform ============================================================ --- transforms.cc 91ed3086b19a25d7d28258a984bcdd8a32a8a549 +++ transforms.cc 2a2510681a0dccdc471ef508dc51f5c568d58963 @@ -13,7 +13,7 @@ #include #include #include -#include +#include "vector.hh" #include ============================================================ --- ui.cc 4de898f353d62cc49f8cb22330527983f589277e +++ ui.cc 989194f7bb73d7cc55e7197508b9203dde9d164f @@ -99,7 +99,48 @@ ticker::operator+=(size_t t) } } +// We would like to put these in an anonymous namespace but we can't because +// struct user_interface needs to make them friends. +struct tick_writer +{ +public: + tick_writer() {} + virtual ~tick_writer() {} + virtual void write_ticks() = 0; + virtual void clear_line() = 0; +}; +struct tick_write_count : virtual public tick_writer +{ +public: + tick_write_count(); + ~tick_write_count(); + void write_ticks(); + void clear_line(); +private: + std::vector last_tick_widths; + size_t last_tick_len; +}; + +struct tick_write_dot : virtual public tick_writer +{ +public: + tick_write_dot(); + ~tick_write_dot(); + void write_ticks(); + void clear_line(); +private: + std::map last_ticks; + unsigned int chars_on_line; +}; + +struct tick_write_nothing : virtual public tick_writer +{ +public: + void write_ticks() {} + void clear_line() {} +}; + tick_write_count::tick_write_count() : last_tick_len(0) { } @@ -382,9 +423,9 @@ void user_interface::initialize() #endif clog.unsetf(ios_base::unitbuf); if (have_smart_terminal()) - set_tick_writer(new tick_write_count); + set_tick_write_count(); else - set_tick_writer(new tick_write_dot); + set_tick_write_dot(); } user_interface::~user_interface() @@ -414,14 +455,31 @@ void } void -user_interface::set_tick_writer(tick_writer * t) +user_interface::set_tick_write_dot() { if (t_writer != 0) delete t_writer; - t_writer = t; + t_writer = new tick_write_dot; } void +user_interface::set_tick_write_count() +{ + if (t_writer != 0) + delete t_writer; + t_writer = new tick_write_count; +} + +void +user_interface::set_tick_write_nothing() +{ + if (t_writer != 0) + delete t_writer; + t_writer = new tick_write_nothing; +} + + +void user_interface::write_ticks() { t_writer->write_ticks(); ============================================================ --- ui.hh ad79ebfa9e7e5935b75230d47e85684da844b30b +++ ui.hh e2c82fd7f5fb014e3cacf951bb4a5c165c16d13b @@ -20,8 +20,6 @@ #include "paths.hh" #include "sanity.hh" -struct user_interface; - struct ticker { size_t ticks; @@ -43,46 +41,10 @@ struct ticker ~ticker(); }; -struct tick_writer -{ -public: - tick_writer() {} - virtual ~tick_writer() {} - virtual void write_ticks() = 0; - virtual void clear_line() = 0; -}; +struct tick_writer; +struct tick_write_count; +struct tick_write_dot; -struct tick_write_count : virtual public tick_writer -{ -public: - tick_write_count(); - ~tick_write_count(); - void write_ticks(); - void clear_line(); -private: - std::vector last_tick_widths; - size_t last_tick_len; -}; - -struct tick_write_dot : virtual public tick_writer -{ -public: - tick_write_dot(); - ~tick_write_dot(); - void write_ticks(); - void clear_line(); -private: - std::map last_ticks; - unsigned int chars_on_line; -}; - -struct tick_write_nothing : virtual public tick_writer -{ -public: - void write_ticks() {} - void clear_line() {} -}; - struct user_interface { public: @@ -99,7 +61,9 @@ public: void fatal_exception(std::exception const & ex); void fatal_exception(); void set_tick_trailer(std::string const & trailer); - void set_tick_writer(tick_writer * t_writer); + void set_tick_write_dot(); + void set_tick_write_count(); + void set_tick_write_nothing(); void ensure_clean_line(); void redirect_log_to(system_path const & filename); @@ -117,9 +81,9 @@ private: void write_ticks(); std::string tick_trailer; - friend struct tick_write_dot; + friend struct ticker; friend struct tick_write_count; - friend struct ticker; + friend struct tick_write_dot; }; extern struct user_interface ui; ============================================================ --- unit_tests.cc 1fac50797304ac4b4addf8b5153fd9dbb02863da +++ unit_tests.cc 6c18091f527b9b38ae589bf9b6dede0896abdcd7 @@ -9,7 +9,7 @@ #include "base.hh" #include -#include +#include "vector.hh" #include #include #include ============================================================ --- update.cc bc9c39135d1e082cf2c4dfbe425ef08e6013ffc4 +++ update.cc 974b6d54d36ef82389781738f2b247417d5def27 @@ -10,7 +10,7 @@ #include "base.hh" #include #include -#include +#include "vector.hh" #include "lexical_cast.hh" #include "app_state.hh" ============================================================ --- xdelta.cc 3f540c8b573608425e174ded788c6597e8b77a1b +++ xdelta.cc d17efefc2d804088f5dc02c888c5f4a8536d7e17 @@ -26,7 +26,7 @@ #include "base.hh" #include -#include +#include "vector.hh" #include #include