# # # patch "ChangeLog" # from [6fd1a6142213717f77714ccf5c5cd8ba62c52b98] # to [ef6248816b6ec203ff1acf3a672b35115eab6e61] # # patch "annotate.cc" # from [38c2d6394975e071ddc09d8349cc2a7001f88511] # to [abc86290badfdb97601384d7e8ed9cc5fc012adf] # # patch "app_state.cc" # from [88da1b9a775ea7933815df732c3a42905b2b9aaf] # to [529abdc0b8e7c48095f8ba0ba30dad96cba42d60] # # patch "automate.cc" # from [cbc2ecddb1fa890faa7b99fd0c35d7d656fffb8e] # to [0b608759447d6c0c9f4aed5289f60a89decac403] # # patch "basic_io.cc" # from [97faeabccb3e6a0bfffd6ed752c690f4e9445c84] # to [f335df2f41cf065b3162f49a8192b36ae1848913] # # patch "cert.cc" # from [fb3486083d858f9181317ac8551bff9e85d6f51c] # to [9165f65c27fb4d4dbec9ca11c0a09bb0a5281f9f] # # patch "commands.cc" # from [7c49b073e4ce5f01840bc6db28a128665cd05f62] # to [bdfa44835aa991d7690fb8a65fd50565b894219b] # # patch "crypto_tests.cc" # from [ee8d14f02237e0143cb3ebe666a03aa76ea93de5] # to [fe11fba313681ddc34596fdf66e61dadba5b541b] # # patch "cset.cc" # from [9af93a73d83ada86b58dd0133a477dfb2f9c9d42] # to [7596f4bf16c8591f073c6c18df29668474c499c8] # # patch "database.cc" # from [115a0a271a57f991e5cf58cb03b4325fde5aa1d4] # to [b6d0d424585587bb8b0ed480342b1a7b5c7830f3] # # patch "database_check.cc" # from [21a47ed13250bea14120762831143647ea258d9b] # to [fad94d02675bd77a91d4c44cfe0ffb4436cad46a] # # patch "diff_patch.cc" # from [130f530b183998cd8f860b5e6471a42fa3d52f2e] # to [622032933fcadaeec86c9fd3c90f157d96b3f6e3] # # patch "enumerator.cc" # from [74107b3a01a0dbdf3d44fad97534c676403f3124] # to [31a5efd62fdaaada910d5b15b7fe31648a0ad17a] # # patch "file_io.cc" # from [17c31d838b489fe9dcdbf7efdeaa0b9641917647] # to [3214c2cad3ec630d8466926bd4bae693de9184a0] # # patch "file_io.hh" # from [62d02358ee6b7b6ba7c4dd93d4f7d387d4e1bf6b] # to [78b32a51c65a8e43b200d72c1dc8f6871bb59267] # # patch "globish.cc" # from [989f71f06fc4a19a71280d3459e836dbc4be3b89] # to [9bb3f311393edb3c7bc58e64337e55bedd9549e7] # # patch "key_store.cc" # from [5df53c5db38d4a3fa7048bc03e046714c8b72ca8] # to [6172f23db28ae65b163cad20e26448cf596ec896] # # patch "keys.cc" # from [a2f02dffc377c4d2f0f8ba613db1b0c4230d3949] # to [95e14385943c9849f15bf7324c856e25f29bedb1] # # patch "lua.cc" # from [46be8289e2ca1d6213289fba84c22e1f82dac091] # to [326015cf1f74950cd726753937ee396a02cdbf05] # # patch "merge.cc" # from [0a43fd276379e6739d864e075976c393c25cbacf] # to [a7ae4085f45df539b091156d211d7e1f4c0cadda] # # patch "monotone.cc" # from [8b65d26abe840735e4ac7939ceaa299af5899b61] # to [c9b57f6d4766f66cdae43b60461a143fa6923893] # # patch "netio.hh" # from [e973154d8e441e5d4446d75a0112f1450b826b7f] # to [3936f2192869d73c5b9b2c6756c99ec50956a4e0] # # patch "netsync.cc" # from [c4d21be3ffe869bbabd36024cbdb71ece5ed7f7d] # to [81c12af4a0791840ac675220fd06bee263434554] # # patch "packet.cc" # from [e0d4ed1e5b82b9ce34bc77bef7d24049409221cf] # to [06b93709b49bc581a5274afc7762f503abf89dc2] # # patch "paths.cc" # from [7eb379a0548c1a6047eddac67dc9e47c16b15cd0] # to [a88d2a803ce9e069bd8b0b6d5db4d2c2593de689] # # patch "rcs_import.cc" # from [9498b94192bc37771313b1daff2f88b564b4dc2c] # to [0de2b62e2c973f4c94592cff4990f0a43eb70294] # # patch "refiner.cc" # from [bdd5b3093fa59253e64ec0de0273058b97af994a] # to [fc755a9526c0d0abac8c91375e05800b9983112d] # # patch "restrictions.cc" # from [7cd8387ff7d2274e95fada7faf9e38e19dda9f04] # to [5ae2c8255b6eb1e65662d68d5889ac9d4d3c24c8] # # patch "revision.cc" # from [8a61fd6efae0fe4a76264c5134dfd7e75e9d19ab] # to [c5a08a3f68665482a0dee20500612884dcc591ca] # # patch "roster.cc" # from [239ae8135b1d73bb14f44c2a88e8383c1767fc75] # to [58d2dba402a7b908ea0153d72f2432ec6bc0c5b1] # # patch "sanity.cc" # from [f31ca82c00210f3a4ddbf7e25863cc714f391e8d] # to [af6834773f23069a1157847d8dccf4741d1aeaf3] # # patch "sanity.hh" # from [30ca10f5630908ddf9b0ec48523211436891f98b] # to [d2494fb0f9188882227ca0ce6584efadb48fbb8b] # # patch "schema_migration.cc" # from [47d3fde2b6c37af0e06704ad0e1f2b2c997a4b7c] # to [a13abc3a8c750aadb1ad07114c8f5b0cfc0cc67b] # # patch "selectors.cc" # from [7ae313b2c960a3f68e40a68db0f883bd48b59ac3] # to [36e7fe5c942ab58a0adff4bfd240a9e075370359] # # patch "transforms.cc" # from [1c3e80c7243e5c569f7c6d0f29900cf1af73cbb0] # to [1f17068bcfa0609f9962200eb33920168f10e7be] # # patch "ui.hh" # from [e0e20f167b6f3abad9608477d61bc1a29f8cefff] # to [496479433aee1e5ff51e96a22ae7cb662d71c4b8] # # patch "unix/get_system_flavour.cc" # from [e75e9a4586becb842532cd9abfb8d9b4107c0131] # to [cbbb43edbaf647bf4005887684a98c94633d2cfb] # # patch "unix/process.cc" # from [43e718ca7819cf146a0c3204a7cb69802b689d96] # to [3a10d73ce7457e22b104777f87d29f8d5fdd2ea8] # # patch "update.cc" # from [4ef16214b35aa9f9b73a60f5e6d9f630cdc70e68] # to [bc5d41f3a5879e36ee2fe60f98d59ba4e181ba24] # # patch "win32/fs.cc" # from [bf1ed69810fd107a33cf9c8ea8327574f2271bfe] # to [d4bbd27d041e4767ef6b1d3e341c5ee65ce1f44f] # # patch "win32/process.cc" # from [6d0e1e94d431f4fe5d724187101ec9c921355283] # to [79552c8593362854390fe3560b13ab682a31c434] # # patch "work.cc" # from [f3a80d9f0f9466e6bc2d6a8a78d94ec86d2c10ef] # to [5f27cea289f3b61f7f645643bf7d6b158ca031ce] # # patch "xdelta.cc" # from [7c8499810d4afe6687979cdccbaef6ecf65c20fe] # to [623dce88e91af3d9f610b47d7596408fa4876dda] # ============================================================ --- ChangeLog 6fd1a6142213717f77714ccf5c5cd8ba62c52b98 +++ ChangeLog ef6248816b6ec203ff1acf3a672b35115eab6e61 @@ -1,5 +1,15 @@ 2006-01-11 Nathaniel Smith + * sanity.hh (struct i18n_format): Make internationalized format + strings and non-internationalized format strings type-distinct. + (This hopefully sets up for fixing some of the charset mess later + down the road.) + (FL): New macro; like F but without the i18n glue. + Use FL with L, and F/FP with everything else. + * *.hh, *.cc: Adjust existing F/L/etc. usage accordingly. + +2006-01-11 Nathaniel Smith + * database.cc (fetch): Don't log all SQL unless requested by user. ============================================================ --- annotate.cc 38c2d6394975e071ddc09d8349cc2a7001f88511 +++ annotate.cc abc86290badfdb97601384d7e8ed9cc5fc012adf @@ -179,14 +179,14 @@ app.db.get_file_version(fid, fpacked); std::string encoding = default_encoding; // FIXME split_into_lines(fpacked.inner()(), encoding, file_lines); - L(F("annotate_context::annotate_context initialized with %d file lines\n") % file_lines.size()); + L(FL("annotate_context::annotate_context initialized with %d file lines\n") % file_lines.size()); // initialize annotations revision_id nullid; annotations.clear(); annotations.reserve(file_lines.size()); annotations.insert(annotations.begin(), file_lines.size(), nullid); - L(F("annotate_context::annotate_context initialized with %d entries in annotations\n") % annotations.size()); + L(FL("annotate_context::annotate_context initialized with %d entries in annotations\n") % annotations.size()); // initialize copied_lines and touched_lines copied_lines.clear(); @@ -219,12 +219,12 @@ for (i = credit_lines.begin(); i != credit_lines.end(); i++) { I(*i >= 0 && *i < annotations.size()); if (annotations[*i] == nullid) { - //L(F("evaluate setting annotations[%d] -> %s, since touched_lines contained %d, copied_lines didn't and annotations[%d] was nullid\n") + //L(FL("evaluate setting annotations[%d] -> %s, since touched_lines contained %d, copied_lines didn't and annotations[%d] was nullid\n") // % *i % rev % *i % *i); annotations[*i] = rev; annotated_lines_completed++; } else { - //L(F("evaluate LEAVING annotations[%d] -> %s\n") % *i % annotations[*i]); + //L(FL("evaluate LEAVING annotations[%d] -> %s\n") % *i % annotations[*i]); } } @@ -235,7 +235,7 @@ void annotate_context::set_copied(int index) { - //L(F("annotate_context::set_copied %d\n") % index); + //L(FL("annotate_context::set_copied %d\n") % index); if (index == -1) return; @@ -246,7 +246,7 @@ void annotate_context::set_touched(int index) { - //L(F("annotate_context::set_touched %d\n") % index); + //L(FL("annotate_context::set_touched %d\n") % index); if (index == -1) return; @@ -257,7 +257,7 @@ void annotate_context::set_equivalent(int index, int index2) { - L(F("annotate_context::set_equivalent index %d index2 %d\n") % index % index2); + L(FL("annotate_context::set_equivalent index %d index2 %d\n") % index % index2); equivalent_lines[index] = index2; } @@ -270,7 +270,7 @@ if (annotations[i] == null_id) { std::map::const_iterator j = equivalent_lines.find(i); if (j == equivalent_lines.end()) { - L(F("annotate_equivalent_lines unable to find equivalent for line %d\n") % i); + L(FL("annotate_equivalent_lines unable to find equivalent for line %d\n") % i); } I(j != equivalent_lines.end()); annotations[i] = annotations[j->second]; @@ -331,7 +331,7 @@ bool result = true; if (file_interned.size() != rhs.file_interned.size()) { - L(F("annotate_lineage_mapping::equal_interned lhs size %d != rhs size %d\n") + L(FL("annotate_lineage_mapping::equal_interned lhs size %d != rhs size %d\n") % file_interned.size() % rhs.file_interned.size()); result = false; } @@ -339,7 +339,7 @@ size_t limit = std::min(file_interned.size(), rhs.file_interned.size()); for (size_t i=0; ifile_interned.size() % lcs.size()); // do the copied lines thing for our annotate_context @@ -396,7 +396,7 @@ while (i < file_interned.size() && j < lcs.size()) { //if (verbose) if (file_interned[i] == 14) - L(F("%s file_interned[%d]: %ld\tlcs[%d]: %ld\tmapping[%d]: %ld\n") + L(FL("%s file_interned[%d]: %ld\tlcs[%d]: %ld\tmapping[%d]: %ld\n") % parent_rev % i % file_interned[i] % j % lcs[j] % i % mapping[i]); if (file_interned[i] == lcs[j]) { @@ -410,7 +410,7 @@ i++; } if (verbose) - L(F("loop ended with i: %d, j: %d, lcs.size(): %d\n") % i % j % lcs.size()); + L(FL("loop ended with i: %d, j: %d, lcs.size(): %d\n") % i % j % lcs.size()); I(j == lcs.size()); // set touched for the rest of the lines in the file @@ -421,7 +421,7 @@ // determine the mapping for parent lineage if (verbose) - L(F("build_parent_lineage: building mapping now for parent_rev %s\n") % parent_rev); + L(FL("build_parent_lineage: building mapping now for parent_rev %s\n") % parent_rev); i = j = 0; while (i < parent_lineage->file_interned.size() && j < lcs.size()) { if (parent_lineage->file_interned[i] == lcs[j]) { @@ -431,7 +431,7 @@ parent_lineage->mapping[i] = -1; } if (verbose) - L(F("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); + L(FL("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); i++; } @@ -440,7 +440,7 @@ while (i < parent_lineage->file_interned.size()) { parent_lineage->mapping[i] = -1; if (verbose) - L(F("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); + L(FL("mapping[%d] -> %d\n") % i % parent_lineage->mapping[i]); i++; } @@ -501,7 +501,7 @@ const std::map &paths_to_nodes, std::map &pending_merge_nodes) { - L(F("do_annotate_node for node %s\n") % work_unit.revision); + L(FL("do_annotate_node for node %s\n") % work_unit.revision); I(nodes_complete.find(work_unit.revision) == nodes_complete.end()); // nodes_seen.insert(std::make_pair(work_unit.revision, work_unit.lineage)); @@ -515,7 +515,7 @@ if (marks.file_content.size() == 0) { - L(F("found empty content-mark set at rev %s\n") % work_unit.revision); + L(FL("found empty content-mark set at rev %s\n") % work_unit.revision); work_unit.lineage->credit_mapped_lines(work_unit.annotations); work_unit.annotations->evaluate(work_unit.revision); nodes_complete.insert(work_unit.revision); @@ -549,7 +549,7 @@ roster_t parent_roster; marking_map parent_marks; - L(F("do_annotate_node processing edge from parent %s to child %s\n") + L(FL("do_annotate_node processing edge from parent %s to child %s\n") % parent_revision % work_unit.revision); I(!(work_unit.revision == parent_revision)); @@ -557,7 +557,7 @@ if (!parent_roster.has_node(work_unit.fid)) { - L(F("file added in %s, continuing\n") % work_unit.revision); + L(FL("file added in %s, continuing\n") % work_unit.revision); added_in_parent_count++; continue; } @@ -570,7 +570,7 @@ if (file_in_parent->content == file_in_child->content) { - L(F("parent file identical, set copied all mapped and copy lineage\n")); + L(FL("parent file identical, set copied all mapped and copy lineage\n")); parent_lineage = work_unit.lineage; parent_lineage->set_copied_all_mapped(work_unit.annotations); } @@ -578,7 +578,7 @@ { file_data data; app.db.get_file_version(file_in_parent->content, data); - L(F("building parent lineage for parent file %s\n") % file_in_parent->content); + L(FL("building parent lineage for parent file %s\n") % file_in_parent->content); parent_lineage = work_unit.lineage->build_parent_lineage(work_unit.annotations, parent_revision, data); @@ -605,14 +605,14 @@ { lineage_merge_node nmn(newunit, ptn->second); pending_merge_nodes.insert(std::make_pair(parent_revision, nmn)); - L(F("put new merge node on pending_merge_nodes for parent %s\n") + L(FL("put new merge node on pending_merge_nodes for parent %s\n") % parent_revision); // just checking... //(pending_merge_nodes.find(parent_revision))->second.dump(); } else { - L(F("single path to node, just stick work on the queue for parent %s\n") + L(FL("single path to node, just stick work on the queue for parent %s\n") % parent_revision); nodes_to_process.push_back(newunit); } @@ -622,10 +622,10 @@ // Already a pending node, so we just have to merge the lineage // and decide whether to move it over to the nodes_to_process // queue. - L(F("merging lineage from node %s to parent %s\n") + L(FL("merging lineage from node %s to parent %s\n") % work_unit.revision % parent_revision); lmn->second.merge(parent_lineage, work_unit.annotations); - //L(F("after merging from work revision %s to parent %s" + //L(FL("after merging from work revision %s to parent %s" // " lineage_merge_node is:\n") % work_unit.revision // % parent_revision); lmn->second.dump(); if (lmn->second.iscomplete()) { @@ -679,7 +679,7 @@ void do_annotate (app_state &app, file_t file_node, revision_id rid) { - L(F("annotating file %s with content %s in revision %s\n") % file_node->self % file_node->content % rid); + L(FL("annotating file %s with content %s in revision %s\n") % file_node->self % file_node->content % rid); boost::shared_ptr acp(new annotate_context(file_node->content, app)); boost::shared_ptr lineage = acp->initial_lineage(); ============================================================ --- app_state.cc 88da1b9a775ea7933815df732c3a42905b2b9aaf +++ app_state.cc 529abdc0b8e7c48095f8ba0ba30dad96cba42d60 @@ -64,7 +64,7 @@ void app_state::allow_working_copy() { - L(F("initializing from directory %s\n") % fs::initial_path().string()); + L(FL("initializing from directory %s\n") % fs::initial_path().string()); found_working_copy = find_and_go_to_working_copy(search_root); if (found_working_copy) @@ -85,14 +85,14 @@ if (branch_name().empty()) branch_name = options[branch_option]; - L(F("branch name is '%s'\n") % branch_name()); + L(FL("branch name is '%s'\n") % branch_name()); internalize_rsa_keypair_id(options[key_option], signing_key); if (global_sanity.filename.empty()) { bookkeeping_path dump_path; get_local_dump_path(dump_path); - L(F("setting dump path to %s\n") % dump_path); + L(FL("setting dump path to %s\n") % dump_path); // the 'true' means that, e.g., if we're running checkout, then it's // okay for dumps to go into our starting working dir's MT rather // than the checked-out dir's MT. @@ -116,7 +116,7 @@ { N(!new_dir.empty(), F("invalid directory ''")); - L(F("creating working copy in %s\n") % new_dir); + L(FL("creating working copy in %s\n") % new_dir); mkdir_p(new_dir); go_to_working_copy(new_dir); @@ -125,7 +125,7 @@ F("monotone bookkeeping directory '%s' already exists in '%s'\n") % bookkeeping_root % new_dir); - L(F("creating bookkeeping directory '%s' for working copy in '%s'\n") + L(FL("creating bookkeeping directory '%s' for working copy in '%s'\n") % bookkeeping_root % new_dir); mkdir_p(bookkeeping_root); @@ -163,7 +163,7 @@ p == root || valid_paths.find(sp) != valid_paths.end(), F("unknown path '%s'\n") % p); - L(F("'%s' added to restricted path set\n") % p); + L(FL("'%s' added to restricted path set\n") % p); restrictions.insert(sp); } @@ -178,7 +178,7 @@ p == root || valid_paths.find(sp) != valid_paths.end(), F("unknown path '%s'\n") % p); - L(F("'%s' added to excluded path set\n") % p); + L(FL("'%s' added to excluded path set\n") % p); excludes.insert(sp); } @@ -239,13 +239,13 @@ while (!test.empty()) { - L(F("checking excluded path set for '%s'\n") % file_path(test)); + L(FL("checking excluded path set for '%s'\n") % file_path(test)); path_set::const_iterator i = excludes.find(test); if (i != excludes.end()) { - L(F("path '%s' found in excluded path set; '%s' excluded\n") + L(FL("path '%s' found in excluded path set; '%s' excluded\n") % file_path(test) % path); return false; } @@ -264,20 +264,20 @@ while (!test.empty()) { - L(F("checking restricted path set for '%s'\n") % file_path(test)); + L(FL("checking restricted path set for '%s'\n") % file_path(test)); path_set::const_iterator i = restrictions.find(test); path_set::const_iterator j = excludes.find(test); if (i != restrictions.end()) { - L(F("path '%s' found in restricted path set; '%s' included\n") + L(FL("path '%s' found in restricted path set; '%s' included\n") % file_path(test) % path); return true; } else if (j != excludes.end()) { - L(F("path '%s' found in excluded path set; '%s' excluded\n") + L(FL("path '%s' found in excluded path set; '%s' excluded\n") % file_path(test) % path); return false; } @@ -362,7 +362,7 @@ F("search root '%s' does not exist") % path, F("search root '%s' is not a directory\n") % path); search_root = path; - L(F("set search root to %s\n") % search_root); + L(FL("set search root to %s\n") % search_root); } void ============================================================ --- automate.cc cbc2ecddb1fa890faa7b99fd0c35d7d656fffb8e +++ automate.cc 0b608759447d6c0c9f4aed5289f60a89decac403 @@ -557,7 +557,7 @@ { for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(F("%d %d %s\n") % inventory[*i].pre_state % pre_state % file_path(*i)); + L(FL("%d %d %s\n") % inventory[*i].pre_state % pre_state % file_path(*i)); I(inventory[*i].pre_state == inventory_item::UNCHANGED_PATH); inventory[*i].pre_state = pre_state; if (rename_id != 0) @@ -576,7 +576,7 @@ { for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(F("%d %d %s\n") % inventory[*i].post_state % post_state % file_path(*i)); + L(FL("%d %d %s\n") % inventory[*i].post_state % post_state % file_path(*i)); I(inventory[*i].post_state == inventory_item::UNCHANGED_PATH); inventory[*i].post_state = post_state; if (rename_id != 0) @@ -594,7 +594,7 @@ { for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) { - L(F("%d %d %s\n") % inventory[*i].node_state % node_state % file_path(*i)); + L(FL("%d %d %s\n") % inventory[*i].node_state % node_state % file_path(*i)); I(inventory[*i].node_state == inventory_item::UNCHANGED_NODE); inventory[*i].node_state = node_state; } @@ -957,7 +957,7 @@ app.db.get_revision(ident, dat); } - L(F("dumping revision %s\n") % ident); + L(FL("dumping revision %s\n") % ident); output.write(dat.inner()().data(), dat.inner()().size()); } @@ -1000,7 +1000,7 @@ calculate_ident(new_roster, mid); write_manifest_of_roster(new_roster, dat); - L(F("dumping manifest %s\n") % mid); + L(FL("dumping manifest %s\n") % mid); output.write(dat().data(), dat().size()); } @@ -1029,7 +1029,7 @@ F("no file version %s found in database") % ident); file_data dat; - L(F("dumping file %s\n") % ident); + L(FL("dumping file %s\n") % ident); app.db.get_file_version(ident, dat); output.write(dat.inner()().data(), dat.inner()().size()); } ============================================================ --- basic_io.cc 97faeabccb3e6a0bfffd6ed752c690f4e9445c84 +++ basic_io.cc f335df2f41cf065b3162f49a8192b36ae1848913 @@ -23,7 +23,7 @@ void basic_io::input_source::err(std::string const & s) { - L(F("error in %s:%d:%d:E: %s") % name % line % col % s); + L(FL("error in %s:%d:%d:E: %s") % name % line % col % s); throw std::logic_error((F("error in %s:%d:%d:E: %s") % name % line % col % s).str()); } ============================================================ --- cert.cc fb3486083d858f9181317ac8551bff9e85d6f51c +++ cert.cc 9165f65c27fb4d4dbec9ca11c0a09bb0a5281f9f @@ -48,7 +48,7 @@ cert_status status = check_cert(app, c); if (status == cert_ok) { - L(F("cert ok\n")); + L(FL("cert ok\n")); return false; } else if (status == cert_bad) @@ -120,7 +120,7 @@ get<1>(i->first), decoded_value)) { - L(F("trust function liked %d signers of %s cert on manifest %s\n") + L(FL("trust function liked %d signers of %s cert on manifest %s\n") % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); tmp_certs.push_back(*(i->second.second)); } @@ -173,7 +173,7 @@ get<1>(i->first), decoded_value)) { - L(F("trust function liked %d signers of %s cert on revision %s\n") + L(FL("trust function liked %d signers of %s cert on revision %s\n") % i->second.first->size() % get<1>(i->first) % get<0>(i->first)); tmp_certs.push_back(*(i->second.second)); } @@ -302,7 +302,7 @@ string & out) { out = (boost::format("address@hidden:%s]") % t.name % t.ident % remove_ws(t.value())).str(); - L(F("cert: signable text %s\n") % out); + L(FL("cert: signable text %s\n") % out); } void ============================================================ --- commands.cc 7c49b073e4ce5f01840bc6db28a128665cd05f62 +++ commands.cc bdfa44835aa991d7690fb8a65fd50565b894219b @@ -134,7 +134,7 @@ { if (cmd.length() == 0 || cmds.find(cmd) != cmds.end()) return cmd; - L(F("expanding command '%s'\n") % cmd); + L(FL("expanding command '%s'\n") % cmd); vector matched; @@ -151,7 +151,7 @@ if (matched.size() == 1) { string completed = *matched.begin(); - L(F("expanded command to '%s'\n") % completed); + L(FL("expanded command to '%s'") % completed); return completed; } else if (matched.size() > 1) @@ -160,7 +160,7 @@ for (vector::iterator i = matched.begin(); i != matched.end(); ++i) err += (*i + "\n"); - W(boost::format(err)); + W(i18n_format(err)); } return cmd; @@ -244,13 +244,13 @@ { if (cmds.find(cmd) != cmds.end()) { - L(F("executing command '%s'\n") % cmd); + L(FL("executing command '%s'\n") % cmd); cmds[cmd]->exec(app, args); return 0; } else { - ui.inform(F("unknown command '%s'\n") % cmd); + P(F("unknown command '%s'\n") % cmd); return 1; } } @@ -420,7 +420,7 @@ _("branch '%s' has multiple heads\n" "perhaps consider 'monotone merge'"), prefixedline); - P(boost::format(prefixedline) % app.branch_name); + P(i18n_format(prefixedline) % app.branch_name); } } @@ -499,7 +499,7 @@ for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) err += (describe_revision(app, revision_id(*i)) + "\n"); - N(completions.size() == 1, boost::format(err)); + N(completions.size() == 1, i18n_format(err)); } completion = revision_id(*(completions.begin())); P(F("expanded to '%s'\n") % completion); @@ -529,7 +529,7 @@ for (typename set::const_iterator i = completions.begin(); i != completions.end(); ++i) err += (i->inner()() + "\n"); - N(completions.size() == 1, boost::format(err)); + N(completions.size() == 1, i18n_format(err)); } completion = *(completions.begin()); P(F("expanded partial id '%s' to '%s'\n") @@ -618,14 +618,14 @@ I(lines.size() > 0); cout << std::string(guess_terminal_width(), '-') << '\n' - << boost::format(str) - % idx(certs, i).key() - % stat - % idx(certs, i).name() - % idx(lines, 0); + << (i18n_format(str) + % idx(certs, i).key() + % stat + % idx(certs, i).name() + % idx(lines, 0)); for (size_t i = 1; i < lines.size(); ++i) - cout << boost::format(extra_str) % idx(lines, i); + cout << (i18n_format(extra_str) % idx(lines, i)); } if (certs.size() > 0) @@ -932,7 +932,7 @@ key_deleted = true; } - boost::format fmt; + i18n_format fmt; if (checked_db) fmt = F("public or private key '%s' does not exist in keystore or database"); else @@ -1391,7 +1391,7 @@ file_t file_node = downcast_to_file_t(node); file_id ident = file_node->content; file_data dat; - L(F("dumping file '%s'\n") % ident); + L(FL("dumping file '%s'\n") % ident); app.db.get_file_version(ident, dat); cout.write(dat.inner()().data(), dat.inner()().size()); @@ -1460,7 +1460,7 @@ vector< revision > certs; app.db.get_revision_certs(ident, branch_cert_name, branch_encoded, certs); - L(F("found %d %s branch certs on revision %s\n") + L(FL("found %d %s branch certs on revision %s\n") % certs.size() % app.branch_name % ident); @@ -1477,7 +1477,7 @@ put_revision_id(ident); - L(F("checking out revision %s to directory %s\n") % ident % dir); + L(FL("checking out revision %s to directory %s\n") % ident % dir); app.db.get_roster(ident, ros, mm); node_map const & nodes = ros.all_nodes(); @@ -1503,7 +1503,7 @@ % file->content % path); file_data dat; - L(F("writing file %s to %s\n") + L(FL("writing file %s to %s\n") % file->content % path); app.db.get_file_version(file->content, dat); write_localized_data(path, dat.inner(), app.lua); @@ -1967,7 +1967,7 @@ var_value addr_value; app.db.get_var(default_server_key, addr_value); addr = utf8(addr_value()); - L(F("using default server address: %s\n") % addr); + L(FL("using default server address: %s\n") % addr); } } @@ -1999,7 +1999,7 @@ var_value pattern_value; app.db.get_var(default_include_pattern_key, pattern_value); include_pattern = utf8(pattern_value()); - L(F("using default branch include pattern: '%s'\n") % include_pattern); + L(FL("using default branch include pattern: '%s'\n") % include_pattern); if (app.db.var_exists(default_exclude_pattern_key)) { app.db.get_var(default_exclude_pattern_key, pattern_value); @@ -2007,7 +2007,7 @@ } else exclude_pattern = utf8(""); - L(F("excluding: %s\n") % exclude_pattern); + L(FL("excluding: %s\n") % exclude_pattern); } } @@ -2302,7 +2302,7 @@ guess_branch(edge_old_revision(rs.edges.begin()), app, branchname); P(F("beginning commit on branch '%s'\n") % branchname); - L(F("new manifest '%s'\n" + L(FL("new manifest '%s'\n" "new revision '%s'\n") % rs.new_manifest % rid); @@ -2344,7 +2344,7 @@ else { // new revision - L(F("inserting new revision %s\n") % rid); + L(FL("inserting new revision %s\n") % rid); I(rs.edges.size() == 1); edge_map::const_iterator edge = rs.edges.begin(); @@ -2362,12 +2362,12 @@ if (app.db.file_version_exists(new_content)) { - L(F("skipping file delta %s, already in database\n") + L(FL("skipping file delta %s, already in database\n") % delta_entry_dst(i)); } else if (app.db.file_version_exists(old_content)) { - L(F("inserting delta %s -> %s\n") + L(FL("inserting delta %s -> %s\n") % old_content % new_content); file_data old_data; data new_data; @@ -2387,7 +2387,7 @@ } else { - L(F("inserting full version %s\n") % new_content); + L(FL("inserting full version %s\n") % new_content); data new_data; read_localized_data(path, new_data, app.lua); // sanity check @@ -2406,7 +2406,7 @@ file_path path(i->first); file_id new_content = i->second; - L(F("inserting full version %s\n") % new_content); + L(FL("inserting full version %s\n") % new_content); data new_data; read_localized_data(path, new_data, app.lua); // sanity check @@ -2843,7 +2843,7 @@ P(F("multiple update candidates:\n")); for (set::const_iterator i = candidates.begin(); i != candidates.end(); ++i) - P(boost::format(" %s\n") % describe_revision(app, *i)); + P(i18n_format(" %s\n") % describe_revision(app, *i)); P(F("choose one with 'monotone update -r'\n")); N(false, F("multiple candidates remain after selection")); } @@ -3258,14 +3258,14 @@ find_missing(app, args, missing); if (missing.empty()) { - L(F("no missing files in restriction.")); + L(FL("no missing files in restriction.")); return; } vector missing_args; for (path_set::const_iterator i = missing.begin(); i != missing.end(); i++) { - L(F("missing files are '%s'") % file_path(*i)); + L(FL("missing files are '%s'") % file_path(*i)); missing_args.push_back(file_path(*i).as_external()); } app.set_restriction(valid_paths, missing_args); @@ -3307,14 +3307,14 @@ } P(F("reverting %s") % fp); - L(F("reverting %s to [%s]\n") % fp % f->content); + L(FL("reverting %s to [%s]\n") % fp % f->content); N(app.db.file_version_exists(f->content), F("no file version %s found in database for %s") % f->content % fp); file_data dat; - L(F("writing file %s to %s\n") + L(FL("writing file %s to %s\n") % f->content % fp); app.db.get_file_version(f->content, dat); write_localized_data(fp, dat.inner(), app.lua); @@ -3437,7 +3437,7 @@ N(!null_id(rid), F("no revision for file '%s' in database") % file); N(app.db.revision_exists(rid), F("no such revision '%s'") % rid); - L(F("annotate file file_path '%s'\n") % file); + L(FL("annotate file file_path '%s'\n") % file); // find the version of the file requested roster_t roster; @@ -3447,7 +3447,7 @@ N((!null_node(node->self) && is_file_t(node)), F("no file '%s' found in revision '%s'\n") % file % rid); file_t file_node = downcast_to_file_t(node); - L(F("annotate for file_id %s\n") % file_node->self); + L(FL("annotate for file_id %s\n") % file_node->self); do_annotate(app, file_node, rid); } @@ -3532,7 +3532,7 @@ if (!app.db.revision_exists(rid)) { - L(F("revision %s does not exist in db, skipping\n") % rid); + L(FL("revision %s does not exist in db, skipping\n") % rid); continue; } ============================================================ --- crypto_tests.cc ee8d14f02237e0143cb3ebe666a03aa76ea93de5 +++ crypto_tests.cc fe11fba313681ddc34596fdf66e61dadba5b541b @@ -1055,11 +1055,11 @@ calculate_ident(input, output); - //L(F(" Input: %s\n") % input); - //L(F("Output: %s\n") % output); + //L(FL(" Input: %s\n") % input); + //L(FL("Output: %s\n") % output); BOOST_CHECK(output() == ident); - L(F("SHA Short Message Test: Passed\n\n")); + L(FL("SHA Short Message Test: Passed\n\n")); //SHA Monte Carlo Test @@ -1095,18 +1095,18 @@ for (int i = 3; i < 1003; i++) { std::string messageString = MD[i - 3] + MD[i - 2] + MD[i - 1]; - // L(F("messageString: %s\n") % messageString ); + // L(FL("messageString: %s\n") % messageString ); data messageData(decode_hexenc(messageString)); - // L(F("message: %s\n") % messageString ); + // L(FL("message: %s\n") % messageString ); calculate_ident(messageData, output2); - // L(F("output: %s\n") % output2 ); + // L(FL("output: %s\n") % output2 ); MD[i] = output2(); } - L(F(" %03d: %s\n") % j % output2 ); + L(FL(" %03d: %s\n") % j % output2 ); BOOST_CHECK(output2() == expected_SHA_MCT[j]); @@ -1114,7 +1114,7 @@ Seed = MD[j]; } - L(F("SHA Monte Carlo Test: Passed\n\n")); + L(FL("SHA Monte Carlo Test: Passed\n\n")); } ============================================================ --- cset.cc 9af93a73d83ada86b58dd0133a477dfb2f9c9d42 +++ cset.cc 7596f4bf16c8591f073c6c18df29668474c499c8 @@ -506,7 +506,7 @@ cset_written_test() { { - L(F("TEST: cset reading - operation misordering")); + L(FL("TEST: cset reading - operation misordering")); // bad cset, add_dir should be before add_file string s("delete \"foo\"\n" "\n" @@ -530,7 +530,7 @@ } { - L(F("TEST: cset reading - misordered files in delete")); + L(FL("TEST: cset reading - misordered files in delete")); // bad cset, bar should be before foo data dat("delete \"foo\"\n" "\n" @@ -540,7 +540,7 @@ } { - L(F("TEST: cset reading - misordered files in rename")); + L(FL("TEST: cset reading - misordered files in rename")); // bad cset, bar should be before foo data dat("rename \"foo\"\n" " to \"foonew\"\n" @@ -552,7 +552,7 @@ } { - L(F("TEST: cset reading - misordered files in add_dir")); + L(FL("TEST: cset reading - misordered files in add_dir")); // bad cset, bar should be before foo data dat("add_dir \"foo\"\n" "\n" @@ -562,7 +562,7 @@ } { - L(F("TEST: cset reading - misordered files in add_file")); + L(FL("TEST: cset reading - misordered files in add_file")); // bad cset, bar should be before foo data dat("add_file \"foo\"\n" " content [0000000000000000000000000000000000000000]\n" @@ -574,7 +574,7 @@ } { - L(F("TEST: cset reading - misordered files in add_file")); + L(FL("TEST: cset reading - misordered files in add_file")); // bad cset, bar should be before foo data dat("add_file \"foo\"\n" " content [0000000000000000000000000000000000000000]\n" @@ -586,7 +586,7 @@ } { - L(F("TEST: cset reading - misordered files in patch")); + L(FL("TEST: cset reading - misordered files in patch")); // bad cset, bar should be before foo data dat("patch \"foo\"\n" " from [0000000000000000000000000000000000000000]\n" @@ -600,7 +600,7 @@ } { - L(F("TEST: cset reading - misordered files in clear")); + L(FL("TEST: cset reading - misordered files in clear")); // bad cset, bar should be before foo data dat("clear \"foo\"\n" " attr \"flavoursome\"\n" @@ -612,7 +612,7 @@ } { - L(F("TEST: cset reading - misordered files in set")); + L(FL("TEST: cset reading - misordered files in set")); // bad cset, bar should be before foo data dat(" set \"foo\"\n" " attr \"flavoursome\"\n" @@ -626,7 +626,7 @@ } { - L(F("TEST: cset reading - duplicate entries")); + L(FL("TEST: cset reading - duplicate entries")); data dat("delete \"foo\"\n" "\n" "delete \"foo\"\n"); @@ -635,7 +635,7 @@ } { - L(F("TEST: cset reading - multiple different attrs")); + L(FL("TEST: cset reading - multiple different attrs")); // should succeed data dat( " set \"bar\"\n" " attr \"flavoursome\"\n" @@ -649,7 +649,7 @@ } { - L(F("TEST: cset reading - wrong attr ordering in clear")); + L(FL("TEST: cset reading - wrong attr ordering in clear")); // fooish should be before quuxy data dat( "clear \"bar\"\n" " attr \"quuxy\"\n" @@ -661,7 +661,7 @@ } { - L(F("TEST: cset reading - wrong attr ordering in set")); + L(FL("TEST: cset reading - wrong attr ordering in set")); // fooish should be before quuxy data dat( " set \"bar\"\n" " attr \"quuxy\"\n" @@ -675,7 +675,7 @@ } { - L(F("TEST: cset reading - duplicate attrs")); + L(FL("TEST: cset reading - duplicate attrs")); // can't have dups. data dat( " set \"bar\"\n" " attr \"flavoursome\"\n" @@ -689,7 +689,7 @@ } { - L(F("TEST: cset writing - normalisation")); + L(FL("TEST: cset writing - normalisation")); cset cs; MM(cs); split_path foo, bar, quux, foo_quux, idle, fish, womble, policeman; file_id f1(std::string("1234567800000000000000000000000000000000")); @@ -776,7 +776,7 @@ // some basic tests that should succeed { - L(F("TEST: cset add file")); + L(FL("TEST: cset add file")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.files_added.insert(make_pair(baz, f2)); @@ -787,7 +787,7 @@ } { - L(F("TEST: cset add dir")); + L(FL("TEST: cset add dir")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.dirs_added.insert(quux); @@ -797,7 +797,7 @@ } { - L(F("TEST: cset delete")); + L(FL("TEST: cset delete")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo_bar); @@ -807,7 +807,7 @@ } { - L(F("TEST: cset rename file")); + L(FL("TEST: cset rename file")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo_bar, quux)); @@ -819,7 +819,7 @@ } { - L(F("TEST: cset rename dir")); + L(FL("TEST: cset rename dir")); split_path quux_bar; file_path_internal("quux/bar").split(quux_bar); setup_roster(r, f1, nis); @@ -833,7 +833,7 @@ } { - L(F("TEST: patch file")); + L(FL("TEST: patch file")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.deltas_applied.insert(make_pair(foo_bar, make_pair(f1, f2))); @@ -845,7 +845,7 @@ } { - L(F("TEST: set attr")); + L(FL("TEST: set attr")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), @@ -862,7 +862,7 @@ } { - L(F("TEST: clear attr file")); + L(FL("TEST: clear attr file")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.attrs_set.insert(make_pair(make_pair(foo_bar, attr_key("ping")), @@ -876,7 +876,7 @@ // some renaming tests { - L(F("TEST: renaming at different levels")); + L(FL("TEST: renaming at different levels")); setup_roster(r, f1, nis); split_path quux_sub, foo_sub, foo_sub_deep, foo_subsub, foo_subsub_deep, quux_bar, foo_bar, @@ -925,7 +925,7 @@ } { - L(F("delete targets pre-renamed nodes")); + L(FL("delete targets pre-renamed nodes")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_renamed.insert(make_pair(foo_bar, foo)); @@ -955,7 +955,7 @@ file_path_internal("quux").split(quux); { - L(F("TEST: can't double-delete")); + L(FL("TEST: can't double-delete")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo_bar); @@ -963,7 +963,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't double-add file")); + L(FL("TEST: can't double-add file")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.files_added.insert(std::make_pair(baz, f2)); @@ -971,14 +971,14 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't add file on top of dir")); + L(FL("TEST: can't add file on top of dir")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.files_added.insert(std::make_pair(foo, f2)); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't delete+rename")); + L(FL("TEST: can't delete+rename")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo_bar); @@ -986,7 +986,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't add+rename")); + L(FL("TEST: can't add+rename")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.dirs_added.insert(baz); @@ -994,14 +994,14 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't rename 'a' 'a'")); + L(FL("TEST: can't rename 'a' 'a'")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_renamed.insert(std::make_pair(foo_bar, foo_bar)); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't rename 'a' 'b'; rename 'a/foo' 'b/foo'")); + L(FL("TEST: can't rename 'a' 'b'; rename 'a/foo' 'b/foo'")); setup_roster(r, f1, nis); cset cs; MM(cs); split_path baz_bar; @@ -1011,7 +1011,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't attr_set + attr_cleared")); + L(FL("TEST: can't attr_set + attr_cleared")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.attrs_set.insert(std::make_pair(std::make_pair(foo_bar, attr_key("blah")), @@ -1020,7 +1020,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't no-op attr_set")); + L(FL("TEST: can't no-op attr_set")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.attrs_set.insert(std::make_pair(std::make_pair(foo_bar, attr_key("attr_file")), @@ -1028,14 +1028,14 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't clear non-existent attr")); + L(FL("TEST: can't clear non-existent attr")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.attrs_cleared.insert(std::make_pair(foo_bar, attr_key("blah"))); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't clear non-existent attr that once existed")); + L(FL("TEST: can't clear non-existent attr that once existed")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.attrs_cleared.insert(std::make_pair(foo_bar, attr_key("attr_file"))); @@ -1045,7 +1045,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't have no-op deltas")); + L(FL("TEST: can't have no-op deltas")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.deltas_applied.insert(std::make_pair(foo_bar, @@ -1053,7 +1053,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't have add+delta")); + L(FL("TEST: can't have add+delta")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.files_added.insert(std::make_pair(baz, f1)); @@ -1062,7 +1062,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't delta a directory")); + L(FL("TEST: can't delta a directory")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.deltas_applied.insert(std::make_pair(foo, @@ -1070,7 +1070,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't rename root (for now)")); + L(FL("TEST: can't rename root (for now)")); setup_roster(r, f1, nis); cset cs; MM(cs); split_path sp1, sp2; @@ -1079,14 +1079,14 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't delete non-empty directory")); + L(FL("TEST: can't delete non-empty directory")); setup_roster(r, f1, nis); cset cs; MM(cs); cs.nodes_deleted.insert(foo); BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't delete root")); + L(FL("TEST: can't delete root")); // for this test, make sure root has no contents r = roster_t(); cset cs; MM(cs); @@ -1094,7 +1094,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't delete and replace root")); + L(FL("TEST: can't delete and replace root")); // for this test, make sure root has no contents r = roster_t(); cset cs; MM(cs); @@ -1103,7 +1103,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: attach node with no root directory present")); + L(FL("TEST: attach node with no root directory present")); // for this test, make sure root has no contents r = roster_t(); cset cs; MM(cs); @@ -1113,7 +1113,7 @@ BOOST_CHECK_THROW(cs.apply_to(tree), std::logic_error); } { - L(F("TEST: can't move a directory underneath itself")); + L(FL("TEST: can't move a directory underneath itself")); setup_roster(r, f1, nis); cset cs; MM(cs); split_path foo_blah; ============================================================ --- database.cc 115a0a271a57f991e5cf58cb03b4325fde5aa1d4 +++ database.cc b6d0d424585587bb8b0ed480342b1a7b5c7830f3 @@ -195,19 +195,17 @@ // first log the code so we can find _out_ what the confusing code // was... note that code does not uniquely identify the errmsg, unlike // errno's. - L(F("sqlite error: %d: %s") % errcode % errmsg); + L(FL("sqlite error: %d: %s") % errcode % errmsg); } std::string auxiliary_message = ""; if (errcode == SQLITE_ERROR) { - auxiliary_message = _("make sure database and containing directory are writeable"); + auxiliary_message += _("make sure database and containing directory are writeable"); } // if the last message is empty, the \n will be stripped off too E(errcode == SQLITE_OK, // kind of string surgery to avoid ~duplicate strings - boost::format("%s\n%s") - % (F("sqlite error: %d: %s") % errcode % errmsg).str() - % auxiliary_message); + F("sqlite error: %d: %s\n%s") % errcode % errmsg % auxiliary_message); } struct sqlite3 * @@ -514,12 +512,12 @@ database::~database() { - L(F("statement cache statistics\n")); - L(F("prepared %d statements\n") % statement_cache.size()); + L(FL("statement cache statistics\n")); + L(FL("prepared %d statements\n") % statement_cache.size()); for (map::const_iterator i = statement_cache.begin(); i != statement_cache.end(); ++i) - L(F("%d executions of %s\n") % i->second.count % i->first); + L(FL("%d executions of %s\n") % i->second.count % i->first); // trigger destructors to finalize cached statements statement_cache.clear(); @@ -572,7 +570,7 @@ const char * tail; sqlite3_prepare(sql(), query, -1, i->second.stmt.paddr(), &tail); assert_sqlite3_ok(sql()); - L(F("prepared statement %s\n") % query); + L(FL("prepared statement %s\n") % query); // no support for multiple statements here E(*tail == 0, @@ -590,7 +588,7 @@ // profiling finds this logging to be quite expensive if (global_sanity.debug) - L(F("binding %d parameters for %s\n") % params % query); + L(FL("binding %d parameters for %s\n") % params % query); for (int param = 1; param <= params; param++) { @@ -604,7 +602,7 @@ if (log.size() > constants::log_line_sz) log = log.substr(0, constants::log_line_sz); - L(F("binding %d with value '%s'\n") % param % log); + L(FL("binding %d with value '%s'\n") % param % log); } sqlite3_bind_text(i->second.stmt(), param, value, -1, SQLITE_TRANSIENT); @@ -623,7 +621,7 @@ const char * value = sqlite3_column_text_s(i->second.stmt(), col); E(value, F("null result in query: %s\n") % query); row.push_back(value); - //L(F("row %d col %d value='%s'\n") % nrow % col % value); + //L(FL("row %d col %d value='%s'\n") % nrow % col % value); } res.push_back(row); } @@ -845,7 +843,7 @@ } I(i != cache.end()); I(use >= i->second().size()); - L(F("version cache expiring %s\n") % i->first); + L(FL("version cache expiring %s\n") % i->first); use -= i->second().size(); cache.erase(i->first); } @@ -867,7 +865,7 @@ if (i == cache.end()) return false; // ++cache_hits; - L(F("version cache hit on %s\n") % ident); + L(FL("version cache hit on %s\n") % ident); dat = i->second; return true; } @@ -936,7 +934,7 @@ // // we also maintain a cycle-detecting set, just to be safe - L(F("reconstructing %s in %s\n") % ident % delta_table); + L(FL("reconstructing %s in %s\n") % ident % delta_table); I(delta_exists(ident, delta_table)); // Our reconstruction algorithm involves keeping a set of parallel @@ -1043,7 +1041,7 @@ vcache.put(curr, tmp); } - L(F("following delta %s -> %s\n") % curr % nxt); + L(FL("following delta %s -> %s\n") % curr % nxt); delta del; get_delta(nxt, curr, del, delta_table); apply_delta (app, del()); @@ -1527,7 +1525,7 @@ I(!children.size()); - L(F("Killing revision %s locally\n") % rid); + L(FL("Killing revision %s locally\n") % rid); // Kill the certs, ancestry, and rev itself. execute("DELETE from revision_certs WHERE id = ?",rid.inner()().c_str()); @@ -1563,7 +1561,7 @@ { base64 encoded; encode_base64(branch, encoded); - L(F("Deleting all references to branch %s\n") % branch); + L(FL("Deleting all references to branch %s\n") % branch); execute("DELETE FROM revision_certs WHERE name='branch' AND value =?", encoded().c_str()); execute("DELETE FROM branch_epochs WHERE branch=?", @@ -1576,7 +1574,7 @@ { base64 encoded; encode_base64(tag, encoded); - L(F("Deleting all references to tag %s\n") % tag); + L(FL("Deleting all references to tag %s\n") % tag); execute("DELETE FROM revision_certs WHERE name='tag' AND value =?", encoded().c_str()); } @@ -2144,7 +2142,7 @@ vector > const & limit, set & completions) { - //L(F("database::complete for partial '%s'\n") % partial); + //L(FL("database::complete for partial '%s'\n") % partial); completions.clear(); // step 1: the limit is transformed into an SQL select statement which @@ -2242,7 +2240,7 @@ set branch_heads; get_branch_heads(*bn, *__app, branch_heads); heads.insert(branch_heads.begin(), branch_heads.end()); - L(F("after get_branch_heads for %s, heads has %d entries\n") % (*bn) % heads.size()); + L(FL("after get_branch_heads for %s, heads has %d entries\n") % (*bn) % heads.size()); } lim += "SELECT id FROM revision_certs WHERE id IN ("; @@ -2265,14 +2263,14 @@ string prefix; string suffix; selector_to_certname(i->first, certname, prefix, suffix); - L(F("processing selector type %d with i->second '%s'\n") % ty % i->second); + L(FL("processing selector type %d with i->second '%s'\n") % ty % i->second); if ((i->first == selectors::sel_branch) && (i->second.size() == 0)) { __app->require_working_copy("the empty branch selector b: refers to the current branch"); // FIXME: why do we have to glob on the unbase64(value), rather than being able to use == ? lim += (boost::format("SELECT id FROM revision_certs WHERE name='%s' AND unbase64(value) glob '%s'") % branch_cert_name % __app->branch_name).str(); - L(F("limiting to current branch '%s'\n") % __app->branch_name); + L(FL("limiting to current branch '%s'\n") % __app->branch_name); } else { @@ -2292,7 +2290,7 @@ } } } - //L(F("found selector type %d, selecting_head is now %d\n") % i->first % selecting_head); + //L(FL("found selector type %d, selecting_head is now %d\n") % i->first % selecting_head); } } lim += ")"; @@ -2830,7 +2828,7 @@ void close_all_databases() { - L(F("attempting to rollback and close %d databases") % sql_contexts.size()); + L(FL("attempting to rollback and close %d databases") % sql_contexts.size()); for (set::iterator i = sql_contexts.begin(); i != sql_contexts.end(); i++) { @@ -2839,7 +2837,7 @@ int exec_err = sqlite3_exec(*i, "ROLLBACK", NULL, NULL, NULL); int close_err = sqlite3_close(*i); - L(F("exec_err = %d, close_err = %d") % exec_err % close_err); + L(FL("exec_err = %d, close_err = %d") % exec_err % close_err); } sql_contexts.clear(); } ============================================================ --- database_check.cc 21a47ed13250bea14120762831143647ea258d9b +++ database_check.cc fad94d02675bd77a91d4c44cfe0ffb4436cad46a @@ -120,14 +120,14 @@ std::set files; app.db.get_file_ids(files); - L(F("checking %d files\n") % files.size()); + L(FL("checking %d files\n") % files.size()); ticker ticks(_("files"), "f", files.size()/70+1); for (std::set::const_iterator i = files.begin(); i != files.end(); ++i) { - L(F("checking file %s\n") % *i); + L(FL("checking file %s\n") % *i); file_data data; app.db.get_file_version(*i, data); checked_files[*i].found = true; @@ -149,7 +149,7 @@ set< hexenc > rosters; app.db.get_roster_ids(rosters); - L(F("checking %d rosters, manifest pass\n") % rosters.size()); + L(FL("checking %d rosters, manifest pass\n") % rosters.size()); ticker ticks(_("rosters"), "r", rosters.size()/70+1); @@ -157,7 +157,7 @@ i != rosters.end(); ++i) { - L(F("checking roster %s\n") % *i); + L(FL("checking roster %s\n") % *i); data dat; app.db.get_roster(*i, dat); checked_rosters[*i].found = true; @@ -170,7 +170,7 @@ } catch (std::logic_error & e) { - L(F("error parsing roster %s: %s") % *i % e.what()); + L(FL("error parsing roster %s: %s") % *i % e.what()); checked_rosters[*i].parseable = false; continue; } @@ -216,7 +216,7 @@ std::map, checked_roster> & checked_rosters, std::map & checked_revisions) { - L(F("checking %d rosters, marking pass\n") % checked_rosters.size()); + L(FL("checking %d rosters, marking pass\n") % checked_rosters.size()); ticker ticks(_("markings"), "m", checked_rosters.size()/70+1); @@ -224,7 +224,7 @@ = checked_rosters.begin(); i != checked_rosters.end(); i++) { hexenc ros_id = i->first; - L(F("checking roster %s\n") % i->first); + L(FL("checking roster %s\n") % i->first); if (!i->second.parseable) continue; @@ -314,14 +314,14 @@ std::set revisions; app.db.get_revision_ids(revisions); - L(F("checking %d revisions\n") % revisions.size()); + L(FL("checking %d revisions\n") % revisions.size()); ticker ticks(_("revisions"), "r", revisions.size()/70+1); for (std::set::const_iterator i = revisions.begin(); i != revisions.end(); ++i) { - L(F("checking revision %s\n") % *i); + L(FL("checking revision %s\n") % *i); revision_data data; app.db.get_revision(*i, data); checked_revisions[*i].found = true; @@ -333,7 +333,7 @@ } catch (std::logic_error & e) { - L(F("error parsing revision %s: %s") % *i % e.what()); + L(FL("error parsing revision %s: %s") % *i % e.what()); checked_revisions[*i].parseable = false; continue; } @@ -401,7 +401,7 @@ } } - L(F("checked %d revisions after starting with %d\n") + L(FL("checked %d revisions after starting with %d\n") % checked_revisions.size() % revisions.size()); } @@ -413,7 +413,7 @@ std::multimap graph; app.db.get_revision_ancestry(graph); - L(F("checking %d ancestry edges\n") % graph.size()); + L(FL("checking %d ancestry edges\n") % graph.size()); ticker ticks(_("ancestry"), "a", graph.size()/70+1); @@ -446,7 +446,7 @@ app.db.get_public_keys(pubkeys); - L(F("checking %d public keys\n") % pubkeys.size()); + L(FL("checking %d public keys\n") % pubkeys.size()); ticker ticks(_("keys"), "k", 1); @@ -472,7 +472,7 @@ total_certs = certs.size(); - L(F("checking %d revision certs\n") % certs.size()); + L(FL("checking %d revision certs\n") % certs.size()); ticker ticks(_("certs"), "c", certs.size()/70+1); @@ -502,7 +502,7 @@ check_sane(app_state & app, std::map & checked_revisions) { - L(F("checking local history of %d revisions\n") % checked_revisions.size()); + L(FL("checking local history of %d revisions\n") % checked_revisions.size()); ticker ticks(_("revisions"), "r", 1); @@ -718,7 +718,7 @@ if (key.found) { - L(F("key %s signed %d certs\n") + L(FL("key %s signed %d certs\n") % i->first % key.sigs); } ============================================================ --- diff_patch.cc 130f530b183998cd8f860b5e6471a42fa3d52f2e +++ diff_patch.cc 622032933fcadaeec86c9fd3c90f157d96b3f6e3 @@ -105,7 +105,7 @@ for (vector::const_iterator i = a_b_edits.begin(); i != a_b_edits.end(); ++i) { - // L(F("edit: %d") % *i); + // L(FL("edit: %d") % *i); if (*i < 0) { // negative elements code the negation of the one-based index into A @@ -119,7 +119,7 @@ extents.push_back(extent(b_pos++, 1, preserved)); } - // L(F(" -- delete at A-pos %d (B-pos = %d)\n") % a_deleted % b_pos); + // L(FL(" -- delete at A-pos %d (B-pos = %d)\n") % a_deleted % b_pos); // skip the deleted line a_pos++; @@ -138,7 +138,7 @@ extents.push_back(extent(b_pos++, 1, preserved)); } - // L(F(" -- insert at B-pos %d (A-pos = %d) : '%s'\n") + // L(FL(" -- insert at B-pos %d (A-pos = %d) : '%s'\n") // % b_inserted % a_pos % intern.lookup(b.at(b_inserted))); // record that there was an insertion, but a_pos did not move. @@ -211,7 +211,7 @@ // Now all the 'changed' extents are normalised to the // earliest possible position. - L(F("exchanging preserved extent [%d+%d] with changed extent [%d+%d]\n") + L(FL("exchanging preserved extent [%d+%d] with changed extent [%d+%d]\n") % a_b_map.at(j-1).pos % a_b_map.at(j-1).len % a_b_map.at(j).pos @@ -238,7 +238,7 @@ // step 1: move a chunk from this insert extent to its // predecessor size_t piece = a_b_map.at(j).len - 1; - // L(F("moving change piece of len %d from pos %d to pos %d\n") + // L(FL("moving change piece of len %d from pos %d to pos %d\n") // % piece // % a_b_map.at(j).pos // % a_b_map.at(j-1).pos); @@ -251,7 +251,7 @@ // extent. if (b.at(a_b_map.at(j).pos) == a.at(j)) { - // L(F("changing normalized 'changed' extent at %d to 'preserved'\n") + // L(FL("changing normalized 'changed' extent at %d to 'preserved'\n") // % a_b_map.at(j).pos); a_b_map.at(j).type = preserved; } @@ -278,7 +278,7 @@ // for (; i != a_b_map.end(); ++i, ++j) // { - // L(F("trying to merge: [%s %d %d] vs. [%s %d %d] \n") + // L(FL("trying to merge: [%s %d %d] vs. [%s %d %d] \n") // % etab[i->type] % i->pos % i->len // % etab[j->type] % j->pos % j->len); // } @@ -289,7 +289,7 @@ for (; i != a_b_map.end(); ++i, ++j) { - // L(F("trying to merge: [%s %d %d] vs. [%s %d %d] \n") + // L(FL("trying to merge: [%s %d %d] vs. [%s %d %d] \n") // % etab[i->type] % i->pos % i->len // % etab[j->type] % j->pos % j->len); @@ -302,7 +302,7 @@ { if (b.at(i->pos + k) != c.at(j->pos + k)) { - L(F("conflicting edits: %s %d[%d] '%s' vs. %s %d[%d] '%s'\n") + L(FL("conflicting edits: %s %d[%d] '%s' vs. %s %d[%d] '%s'\n") % etab[i->type] % i->pos % k % in.lookup(b.at(i->pos + k)) % etab[j->type] % j->pos % k % in.lookup(c.at(j->pos + k))); throw conflict(); @@ -330,16 +330,16 @@ else { - L(F("conflicting edits: [%s %d %d] vs. [%s %d %d]\n") + L(FL("conflicting edits: [%s %d %d] vs. [%s %d %d]\n") % etab[i->type] % i->pos % i->len % etab[j->type] % j->pos % j->len); throw conflict(); } // if (merged.empty()) - // L(F(" --> EMPTY\n")); + // L(FL(" --> EMPTY\n")); // else - // L(F(" --> [%d]: %s\n") % (merged.size() - 1) % in.lookup(merged.back())); + // L(FL(" --> [%d]: %s\n") % (merged.size() - 1) % in.lookup(merged.back())); } } @@ -378,7 +378,7 @@ i != right.end(); ++i) right_interned.push_back(in.intern(*i)); - L(F("calculating left edit script on %d -> %d lines\n") + L(FL("calculating left edit script on %d -> %d lines\n") % anc_interned.size() % left_interned.size()); edit_script(anc_interned.begin(), anc_interned.end(), @@ -386,7 +386,7 @@ std::min(ancestor.size(), left.size()), left_edits); - L(F("calculating right edit script on %d -> %d lines\n") + L(FL("calculating right edit script on %d -> %d lines\n") % anc_interned.size() % right_interned.size()); edit_script(anc_interned.begin(), anc_interned.end(), @@ -394,36 +394,36 @@ std::min(ancestor.size(), right.size()), right_edits); - L(F("calculating left extents on %d edits\n") % left_edits.size()); + L(FL("calculating left extents on %d edits\n") % left_edits.size()); calculate_extents(left_edits, left_interned, left_prefix, left_extents, left_suffix, anc_interned.size(), in); - L(F("calculating right extents on %d edits\n") % right_edits.size()); + L(FL("calculating right extents on %d edits\n") % right_edits.size()); calculate_extents(right_edits, right_interned, right_prefix, right_extents, right_suffix, anc_interned.size(), in); - L(F("normalizing %d right extents\n") % right_extents.size()); + L(FL("normalizing %d right extents\n") % right_extents.size()); normalize_extents(right_extents, anc_interned, right_interned); - L(F("normalizing %d left extents\n") % left_extents.size()); + L(FL("normalizing %d left extents\n") % left_extents.size()); normalize_extents(left_extents, anc_interned, left_interned); if ((!right_prefix.empty()) && (!left_prefix.empty())) { - L(F("conflicting prefixes\n")); + L(FL("conflicting prefixes\n")); throw conflict(); } if ((!right_suffix.empty()) && (!left_suffix.empty())) { - L(F("conflicting suffixes\n")); + L(FL("conflicting suffixes\n")); throw conflict(); } - L(F("merging %d left, %d right extents\n") + L(FL("merging %d left, %d right extents\n") % left_extents.size() % right_extents.size()); copy(left_prefix.begin(), left_prefix.end(), back_inserter(merged_interned)); @@ -454,7 +454,7 @@ } catch(conflict & c) { - L(F("conflict detected. no merge.\n")); + L(FL("conflict detected. no merge.\n")); return false; } return true; @@ -485,7 +485,7 @@ file_data const & left_data, file_data const & merged_data) { - L(F("recording successful merge of %s <-> %s into %s\n") + L(FL("recording successful merge of %s <-> %s into %s\n") % left_ident % right_ident % merged_ident); delta left_delta, right_delta; @@ -558,7 +558,7 @@ file_data const & left_data, file_data const & merged_data) { - L(F("temporarily recording merge of %s <-> %s into %s\n") + L(FL("temporarily recording merge of %s <-> %s into %s\n") % left_id % right_id % merged_id); I(temporary_store.find(merged_id) == temporary_store.end()); temporary_store.insert(make_pair(merged_id, merged_data)); @@ -650,12 +650,12 @@ I(!null_id(left_id)); I(!null_id(right_id)); - L(F("trying to merge %s <-> %s (ancestor: %s)\n") + L(FL("trying to merge %s <-> %s (ancestor: %s)\n") % left_id % right_id % ancestor_id); if (left_id == right_id) { - L(F("files are identical\n")); + L(FL("files are identical\n")); merged_id = left_id; return true; } @@ -697,7 +697,7 @@ file_data merge_data; string tmp; - L(F("internal 3-way merged ok\n")); + L(FL("internal 3-way merged ok\n")); join_lines(merged_lines, tmp); calculate_ident(data(tmp), tmp_id); file_id merged_fid(tmp_id); @@ -728,7 +728,7 @@ hexenc tmp_id; file_data merge_data; - L(F("lua merge3 hook merged ok\n")); + L(FL("lua merge3 hook merged ok\n")); calculate_ident(merged_unpacked, tmp_id); file_id merged_fid(tmp_id); merge_data = file_data(merged_unpacked); ============================================================ --- enumerator.cc 74107b3a01a0dbdf3d44fad97534c676403f3124 +++ enumerator.cc 31a5efd62fdaaada910d5b15b7fe31648a0ad17a @@ -115,7 +115,7 @@ if (cb.process_this_rev(r)) { - L(F("revision_enumerator::step expanding " + L(FL("revision_enumerator::step expanding " "contents of rev '%d'\n") % r); revision_set rs; @@ -181,7 +181,7 @@ if (!items.empty()) { - L(F("revision_enumerator::step extracting item\n")); + L(FL("revision_enumerator::step extracting item\n")); enumerator_item i = items.front(); items.pop_front(); ============================================================ --- file_io.cc 17c31d838b489fe9dcdbf7efdeaa0b9641917647 +++ file_io.cc 3214c2cad3ec630d8466926bd4bae693de9184a0 @@ -44,15 +44,15 @@ void require_path_is_nonexistent(any_path const & path, - boost::format const & message) + i18n_format const & message) { N(!path_exists(path), message); } void require_path_is_file(any_path const & path, - boost::format const & message_if_nonexistent, - boost::format const & message_if_directory) + i18n_format const & message_if_nonexistent, + i18n_format const & message_if_directory) { switch (get_path_status(path)) { @@ -69,8 +69,8 @@ void require_path_is_directory(any_path const & path, - boost::format const & message_if_nonexistent, - boost::format const & message_if_file) + i18n_format const & message_if_nonexistent, + i18n_format const & message_if_file) { switch (get_path_status(path)) { @@ -506,7 +506,7 @@ if (bookkeeping_path::is_bookkeeping_path(rel_entry.normalize().string())) { - L(F("ignoring book keeping entry %s\n") % rel_entry.string()); + L(FL("ignoring book keeping entry %s\n") % rel_entry.string()); continue; } ============================================================ --- file_io.hh 62d02358ee6b7b6ba7c4dd93d4f7d387d4e1bf6b +++ file_io.hh 78b32a51c65a8e43b200d72c1dc8f6871bb59267 @@ -10,6 +10,7 @@ #include "vocab.hh" #include "paths.hh" +#include "sanity.hh" // this layer deals with talking to the filesystem, loading and saving // files, walking trees, etc. @@ -27,13 +28,13 @@ // use N() void require_path_is_nonexistent(any_path const & path, - boost::format const & message); + i18n_format const & message); void require_path_is_file(any_path const & path, - boost::format const & message_if_nonexistent, - boost::format const & message_if_directory); + i18n_format const & message_if_nonexistent, + i18n_format const & message_if_directory); void require_path_is_directory(any_path const & path, - boost::format const & message_if_nonexistent, - boost::format const & message_if_file); + i18n_format const & message_if_nonexistent, + i18n_format const & message_if_file); // returns true if there is a file or directory at 'path' bool path_exists(any_path const & path); ============================================================ --- globish.cc 989f71f06fc4a19a71280d3459e836dbc4be3b89 +++ globish.cc 9bb3f311393edb3c7bc58e64337e55bedd9549e7 @@ -46,7 +46,7 @@ regex.clear(); regex.reserve(glob.size() * 2); - L(F("checked_globish_to_regex: input = '%s'\n") % glob); + L(FL("checked_globish_to_regex: input = '%s'\n") % glob); if (glob == "") { @@ -96,7 +96,7 @@ N(in_braces == 0, F("run-away brace expression in pattern '%s'") % glob); - L(F("checked_globish_to_regex: output = '%s'\n") % regex); + L(FL("checked_globish_to_regex: output = '%s'\n") % regex); } void @@ -138,7 +138,7 @@ bool inc_match = boost::regex_match(s, r_inc); bool exc_match = boost::regex_match(s, r_exc); bool result = inc_match && !exc_match; - L(F("matching '%s' against '%s' excluding '%s': %s, %s: %s\n") + L(FL("matching '%s' against '%s' excluding '%s': %s, %s: %s\n") % s % r_inc % r_exc % (inc_match ? "included" : "not included") % (exc_match ? "excluded" : "not excluded") ============================================================ --- key_store.cc 5df53c5db38d4a3fa7048bc03e046714c8b72ca8 +++ key_store.cc 6172f23db28ae65b163cad20e26448cf596ec896 @@ -39,7 +39,7 @@ hexenc hash; key_hash_code(ident, kp.pub, hash); ks->hashes.insert(std::make_pair(hash, ident)); - L(F("Read key pair '%s' from key store.") % ident); + L(FL("Read key pair '%s' from key store.") % ident); } }; @@ -195,7 +195,7 @@ keypair const & kp) { maybe_read_key_dir(); - L(F("putting key pair '%s'") % ident); + L(FL("putting key pair '%s'") % ident); std::pair::iterator, bool> res; res = keys.insert(std::make_pair(ident, kp)); if (res.second) ============================================================ --- keys.cc a2f02dffc377c4d2f0f8ba613db1b0c4230d3949 +++ keys.cc 95e14385943c9849f15bf7324c856e25f29bedb1 @@ -39,7 +39,7 @@ do_arc4(SecureVector & sym_key, SecureVector & payload) { - L(F("running arc4 process on %d bytes of data\n") % payload.size()); + L(FL("running arc4 process on %d bytes of data\n") % payload.size()); Pipe enc(get_cipher("ARC4", sym_key, ENCRYPTION)); enc.process_msg(payload); payload = enc.read_all(); @@ -174,7 +174,7 @@ // if all that worked, we can return our results to caller encode_base64(raw_priv_key, kp_out.priv); encode_base64(raw_pub_key, kp_out.pub); - L(F("generated %d-byte public key\n" + L(FL("generated %d-byte public key\n" "generated %d-byte (encrypted) private key\n") % kp_out.pub().size() % kp_out.priv().size()); @@ -191,12 +191,12 @@ string phrase; bool force = force_from_user; - L(F("base64-decoding %d-byte private key\n") % priv().size()); + L(FL("base64-decoding %d-byte private key\n") % priv().size()); decode_base64(priv, decoded_key); for (int i = 0; i < 3; ++i) { get_passphrase(lua, id, phrase, false, force); - L(F("have %d-byte encrypted private key\n") % decoded_key().size()); + L(FL("have %d-byte encrypted private key\n") % decoded_key().size()); shared_ptr pkcs8_key; try @@ -241,7 +241,7 @@ // need to decrypt the old key shared_ptr priv_key; - L(F("base64-decoding %d-byte old private key\n") % old_priv().size()); + L(FL("base64-decoding %d-byte old private key\n") % old_priv().size()); decode_base64(old_priv, decoded_key); for (int i = 0; i < 3; ++i) { @@ -252,7 +252,7 @@ sym_key.set(reinterpret_cast(phrase.data()), phrase.size()); do_arc4(sym_key, decrypted_key); - L(F("building signer from %d-byte decrypted private key\n") % decrypted_key.size()); + L(FL("building signer from %d-byte decrypted private key\n") % decrypted_key.size()); shared_ptr pkcs8_key; try @@ -352,7 +352,7 @@ sig = signer->sign_message(reinterpret_cast(tosign.data()), tosign.size()); sig_string = string(reinterpret_cast(sig.begin()), sig.size()); - L(F("produced %d-byte signature\n") % sig_string.size()); + L(FL("produced %d-byte signature\n") % sig_string.size()); encode_base64(rsa_sha1_signature(sig_string), signature); } @@ -380,7 +380,7 @@ SecureVector pub_block; pub_block.set(reinterpret_cast(pub().data()), pub().size()); - L(F("building verifier for %d-byte pub key\n") % pub_block.size()); + L(FL("building verifier for %d-byte pub key\n") % pub_block.size()); shared_ptr x509_key = shared_ptr(X509::load_key(pub_block)); pub_key = shared_dynamic_cast(x509_key); @@ -402,7 +402,7 @@ decode_base64(signature, sig_decoded); // check the text+sig against the key - L(F("checking %d-byte (%d decoded) signature\n") % + L(FL("checking %d-byte (%d decoded) signature\n") % signature().size() % sig_decoded().size()); bool valid_sig = verifier->verify_message( ============================================================ --- lua.cc 46be8289e2ca1d6213289fba84c22e1f82dac091 +++ lua.cc 326015cf1f74950cd726753937ee396a02cdbf05 @@ -116,14 +116,14 @@ void fail(std::string const & reason) { - L(F("lua failure: %s; stack = %s\n") % reason % dump_stack(st)); + L(FL("lua failure: %s; stack = %s\n") % reason % dump_stack(st)); failed = true; } bool ok() { if (failed) - L(F("Lua::ok(): failed")); + L(FL("Lua::ok(): failed")); return !failed; } @@ -131,8 +131,8 @@ { I(lua_isstring(st, -1)); string err = string(lua_tostring(st, -1), lua_strlen(st, -1)); - W(boost::format("%s\n") % err); - L(F("lua stack: %s") % dump_stack(st)); + W(i18n_format("%s\n") % err); + L(FL("lua stack: %s") % dump_stack(st)); lua_pop(st, 1); failed = true; } @@ -212,7 +212,7 @@ return *this; } str = string(lua_tostring(st, -1), lua_strlen(st, -1)); - L(F("lua: extracted string = %s") % str); + L(FL("lua: extracted string = %s") % str); return *this; } @@ -225,7 +225,7 @@ return *this; } i = static_cast(lua_tonumber(st, -1)); - L(F("lua: extracted int = %i") % i); + L(FL("lua: extracted int = %i") % i); return *this; } @@ -238,7 +238,7 @@ return *this; } i = lua_tonumber(st, -1); - L(F("lua: extracted double = %i") % i); + L(FL("lua: extracted double = %i") % i); return *this; } @@ -252,7 +252,7 @@ return *this; } i = (lua_toboolean(st, -1) == 1); - L(F("lua: extracted bool = %i") % i); + L(FL("lua: extracted bool = %i") % i); return *this; } @@ -372,7 +372,7 @@ Lua & func(string const & fname) { - L(F("loading lua hook %s") % fname); + L(FL("loading lua hook %s") % fname); if (!failed) { if (missing_functions.find(fname) != missing_functions.end()) @@ -701,7 +701,7 @@ break; case basic_io::TOK_STRING: case basic_io::TOK_HEX: - E(!res.empty(), boost::format("bad input to parse_basic_io")); + E(!res.empty(), F("bad input to parse_basic_io")); res.back().second.push_back(got); break; default: @@ -901,11 +901,11 @@ } } data dat; - L(F("opening rcfile '%s' ...\n") % rc); + L(FL("opening rcfile '%s' ...\n") % rc); read_data_for_command_line(rc, dat); N(run_string(st, dat(), rc().c_str()), F("lua error while loading rcfile '%s'") % rc); - L(F("'%s' is ok\n") % rc); + L(FL("'%s' is ok\n") % rc); } void @@ -914,15 +914,15 @@ I(st); if (path_exists(rc)) { - L(F("opening rcfile '%s' ...\n") % rc); + L(FL("opening rcfile '%s' ...\n") % rc); N(run_file(st, rc.as_external()), F("lua error while loading '%s'") % rc); - L(F("'%s' is ok\n") % rc); + L(FL("'%s' is ok\n") % rc); } else { N(!required, F("rcfile '%s' does not exist") % rc); - L(F("skipping nonexistent rcfile '%s'\n") % rc); + L(FL("skipping nonexistent rcfile '%s'\n") % rc); } } @@ -1306,11 +1306,11 @@ .push_str("attr_init_functions") .get_tab(); - L(F("calling attr_init_function for %s") % filename); + L(FL("calling attr_init_function for %s") % filename); ll.begin(); while (ll.next()) { - L(F(" calling an attr_init_function for %s") % filename); + L(FL(" calling an attr_init_function for %s") % filename); ll.push_str(filename.as_external()); ll.call(1, 1); @@ -1323,11 +1323,11 @@ ll.extract_str(key); attrs[key] = value; - L(F(" added attr %s = %s") % key % value); + L(FL(" added attr %s = %s") % key % value); } else { - L(F(" no attr added")); + L(FL(" no attr added")); ll.pop(); } } ============================================================ --- merge.cc 0a43fd276379e6739d864e075976c393c25cbacf +++ merge.cc a7ae4085f45df539b091156d211d7e1f4c0cadda @@ -51,7 +51,7 @@ if (!result.is_clean()) { - L(F("unclean mark-merge: %d name conflicts, %d content conflicts, %d attr conflicts, " + L(FL("unclean mark-merge: %d name conflicts, %d content conflicts, %d attr conflicts, " "%d orphaned node conflicts, %d rename target conflicts, %d directory loop conflicts\n") % result.node_name_conflicts.size() % result.file_content_conflicts.size() @@ -61,7 +61,7 @@ % result.directory_loop_conflicts.size()); for (size_t i = 0; i < result.node_name_conflicts.size(); ++i) - L(F("name conflict on node %d: [parent %d, self %s] vs. [parent %d, self %s]\n") + L(FL("name conflict on node %d: [parent %d, self %s] vs. [parent %d, self %s]\n") % result.node_name_conflicts[i].nid % result.node_name_conflicts[i].left.first % result.node_name_conflicts[i].left.second @@ -69,13 +69,13 @@ % result.node_name_conflicts[i].right.second); for (size_t i = 0; i < result.file_content_conflicts.size(); ++i) - L(F("content conflict on node %d: [%s] vs. [%s]\n") + L(FL("content conflict on node %d: [%s] vs. [%s]\n") % result.file_content_conflicts[i].nid % result.file_content_conflicts[i].left % result.file_content_conflicts[i].right); for (size_t i = 0; i < result.node_attr_conflicts.size(); ++i) - L(F("attribute conflict on node %d, key %s: [%d, %s] vs. [%d, %s]\n") + L(FL("attribute conflict on node %d, key %s: [%d, %s] vs. [%d, %s]\n") % result.node_attr_conflicts[i].nid % result.node_attr_conflicts[i].key % result.node_attr_conflicts[i].left.first @@ -84,20 +84,20 @@ % result.node_attr_conflicts[i].right.second); for (size_t i = 0; i < result.orphaned_node_conflicts.size(); ++i) - L(F("orphaned node conflict on node %d, dead parent %d, name %s") + L(FL("orphaned node conflict on node %d, dead parent %d, name %s") % result.orphaned_node_conflicts[i].nid % result.orphaned_node_conflicts[i].parent_name.first % result.orphaned_node_conflicts[i].parent_name.second); for (size_t i = 0; i < result.rename_target_conflicts.size(); ++i) - L(F("rename target conflict: nodes %d, %d, both want parent %d, name %s") + L(FL("rename target conflict: nodes %d, %d, both want parent %d, name %s") % result.rename_target_conflicts[i].nid1 % result.rename_target_conflicts[i].nid2 % result.rename_target_conflicts[i].parent_name.first % result.rename_target_conflicts[i].parent_name.second); for (size_t i = 0; i < result.directory_loop_conflicts.size(); ++i) - L(F("directory loop conflict: node %d, wanted parent %d, name %s") + L(FL("directory loop conflict: node %d, wanted parent %d, name %s") % result.directory_loop_conflicts[i].nid % result.directory_loop_conflicts[i].parent_name.first % result.directory_loop_conflicts[i].parent_name.second); @@ -107,7 +107,7 @@ if (!result.file_content_conflicts.empty()) { - L(F("examining content conflicts\n")); + L(FL("examining content conflicts\n")); std::vector residual_conflicts; for (size_t i = 0; i < result.file_content_conflicts.size(); ++i) @@ -136,7 +136,7 @@ if (cm.try_to_merge_files(anc_path, left_path, right_path, right_path, anc_id, left_id, right_id, merged_id)) { - L(F("resolved content conflict %d / %d\n") + L(FL("resolved content conflict %d / %d\n") % (i+1) % result.file_content_conflicts.size()); file_t f = downcast_to_file_t(result.roster.get_node(conflict.nid)); f->content = merged_id; ============================================================ --- monotone.cc 8b65d26abe840735e4ac7939ceaa299af5899b61 +++ monotone.cc c9b57f6d4766f66cdae43b60461a143fa6923893 @@ -259,10 +259,10 @@ cmdline_ss << ", "; cmdline_ss << "'" << argv[i] << "'"; } - L(F("command line: %s\n") % cmdline_ss.str()); + L(FL("command line: %s\n") % cmdline_ss.str()); } - L(F("set locale: LC_ALL=%s\n") + L(FL("set locale: LC_ALL=%s\n") % (setlocale(LC_ALL, NULL) == NULL ? "n/a" : setlocale(LC_ALL, NULL))); // Set up secure memory allocation etc @@ -585,13 +585,13 @@ if (command_options.find(o->val) != command_options.end()) { o->argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN; - L(F("Removed 'hidden' from option # %d\n") % o->argInfo); + L(FL("Removed 'hidden' from option # %d\n") % o->argInfo); count++; } else { o->argInfo |= POPT_ARGFLAG_DOC_HIDDEN; - L(F("Added 'hidden' to option # %d\n") % o->argInfo); + L(FL("Added 'hidden' to option # %d\n") % o->argInfo); } } free((void *)options[0].descrip); options[0].descrip = NULL; @@ -602,7 +602,7 @@ options[0].descrip = strdup(sstr.str().c_str()); options[0].argInfo |= POPT_ARGFLAG_DOC_HIDDEN; - L(F("Added 'hidden' to option # %d\n") % options[0].argInfo); + L(FL("Added 'hidden' to option # %d\n") % options[0].argInfo); } poptPrintHelp(ctx(), stdout, 0); ============================================================ --- netio.hh e973154d8e441e5d4446d75a0112f1450b826b7f +++ netio.hh 3936f2192869d73c5b9b2c6756c99ec50956a4e0 @@ -17,15 +17,15 @@ #include "string_queue.hh" struct bad_decode { - bad_decode(boost::format const & fmt) : what(fmt.str()) {} + bad_decode(i18n_format const & fmt) : what(fmt.str()) {} std::string what; }; inline void require_bytes(std::string const & str, - size_t pos, - size_t len, - std::string const & name) + size_t pos, + size_t len, + std::string const & name) { // if you've gone past the end of the buffer, there's a logic error, // and this program is not safe to keep running. shut down. @@ -36,7 +36,7 @@ return; if (str.size() < pos + len) throw bad_decode(F("need %d bytes to decode %s at %d, only have %d") - % len % name % pos % (str.size() - pos)); + % len % name % pos % (str.size() - pos)); } inline void @@ -60,9 +60,9 @@ template inline bool try_extract_datum_uleb128(std::string const & in, - size_t & pos, - std::string const & name, - T & out) + size_t & pos, + std::string const & name, + T & out) { BOOST_STATIC_ASSERT(std::numeric_limits::is_signed == false); size_t shift = 0; @@ -71,23 +71,23 @@ while (maxbytes > 0) { if (pos >= in.size()) - return false; + return false; T curr = widen(in[pos]); ++pos; out |= ((static_cast(curr) - & static_cast(0x7f)) << shift); + & static_cast(0x7f)) << shift); bool finished = ! static_cast(static_cast(curr) - & static_cast(0x80)); + & static_cast(0x80)); if (finished) - break; + break; else if (maxbytes == 1) - throw bad_decode(F("uleb128 decode for '%s' into %d-byte datum overflowed") - % name % maxbytes); + throw bad_decode(F("uleb128 decode for '%s' into %d-byte datum overflowed") + % name % maxbytes); else - { - --maxbytes; - shift += 7; - } + { + --maxbytes; + shift += 7; + } } return true; } @@ -154,16 +154,16 @@ T remainder = in >> 7; bool finished = ! static_cast(remainder); if (finished) - { - out += item; - break; - } + { + out += item; + break; + } else - { - out += (item | static_cast(0x80)); - --maxbytes; - in = remainder; - } + { + out += (item | static_cast(0x80)); + --maxbytes; + in = remainder; + } } } @@ -195,8 +195,8 @@ template inline T extract_datum_lsb(std::string const & in, - size_t & pos, - std::string const & name) + size_t & pos, + std::string const & name) { size_t nbytes = sizeof(T); T out = 0; @@ -290,7 +290,7 @@ inline void insert_variable_length_string(std::string const & in, - string_queue & buf) + string_queue & buf) { size_t len = in.size(); insert_datum_uleb128(len, buf); @@ -299,9 +299,9 @@ inline std::string extract_substring(std::string const & buf, - size_t & pos, - size_t len, - std::string const & name) + size_t & pos, + size_t len, + std::string const & name) { require_bytes(buf, pos, len, name); std::string tmp = buf.substr(pos, len); ============================================================ --- netsync.cc c4d21be3ffe869bbabd36024cbdb71ece5ed7f7d +++ netsync.cc 81c12af4a0791840ac675220fd06bee263434554 @@ -880,7 +880,7 @@ outbuf_size += buf.size(); } else - L(F("dropping outgoing netcmd (because we're in error unwind mode)\n")); + L(FL("dropping outgoing netcmd (because we're in error unwind mode)\n")); // FIXME: this helps keep the protocol pipeline full but it seems to // interfere with initial and final sequences. careful with it. // write_some(); @@ -927,10 +927,10 @@ Netxx::signed_size_type count = str.read(tmp, sizeof(tmp)); if (count > 0) { - L(F("read %d bytes from fd %d (peer %s)\n") % count % fd % peer_id); + L(FL("read %d bytes from fd %d (peer %s)\n") % count % fd % peer_id); if (encountered_error) { - L(F("in error unwind mode, so throwing them into the bit bucket\n")); + L(FL("in error unwind mode, so throwing them into the bit bucket\n")); return true; } inbuf.append(tmp,count); @@ -962,7 +962,7 @@ { outbuf.front().second += count; } - L(F("wrote %d bytes to fd %d (peer %s)\n") + L(FL("wrote %d bytes to fd %d (peer %s)\n") % count % fd % peer_id); mark_recent_io(); if (byte_out_ticker.get() != NULL) @@ -970,7 +970,7 @@ if (encountered_error && outbuf.empty()) { // we've flushed our error message, so it's time to get out. - L(F("finished flushing output queue in error unwind mode, disconnecting\n")); + L(FL("finished flushing output queue in error unwind mode, disconnecting\n")); return false; } return true; @@ -984,7 +984,7 @@ void session::queue_error_cmd(string const & errmsg) { - L(F("queueing 'error' command\n")); + L(FL("queueing 'error' command\n")); netcmd cmd; cmd.write_error_cmd(errmsg); write_netcmd_and_try_flush(cmd); @@ -993,7 +993,7 @@ void session::queue_bye_cmd(u8 phase) { - L(F("queueing 'bye' command, phase %d\n") + L(FL("queueing 'bye' command, phase %d\n") % static_cast(phase)); netcmd cmd; cmd.write_bye_cmd(phase); @@ -1006,7 +1006,7 @@ { string typestr; netcmd_item_type_to_string(type, typestr); - L(F("queueing 'done' command for %s (%d items)\n") + L(FL("queueing 'done' command for %s (%d items)\n") % typestr % n_items); netcmd cmd; cmd.write_done_cmd(type, n_items); @@ -1076,7 +1076,7 @@ hexenc hpref; node.get_hex_prefix(hpref); netcmd_item_type_to_string(node.type, typestr); - L(F("queueing refinement %s of %s node '%s', level %d\n") + L(FL("queueing refinement %s of %s node '%s', level %d\n") % (ty == refinement_query ? "query" : "response") % typestr % hpref % static_cast(node.level)); netcmd cmd; @@ -1096,12 +1096,12 @@ if (role == sink_role) { - L(F("not queueing %s data for '%s' as we are in pure sink role\n") + L(FL("not queueing %s data for '%s' as we are in pure sink role\n") % typestr % hid); return; } - L(F("queueing %d bytes of data for %s item '%s'\n") + L(FL("queueing %d bytes of data for %s item '%s'\n") % dat.size() % typestr % hid); netcmd cmd; @@ -1135,12 +1135,12 @@ if (role == sink_role) { - L(F("not queueing %s delta '%s' -> '%s' as we are in pure sink role\n") + L(FL("not queueing %s delta '%s' -> '%s' as we are in pure sink role\n") % typestr % base_hid % ident_hid); return; } - L(F("queueing %s delta '%s' -> '%s'\n") + L(FL("queueing %s delta '%s' -> '%s'\n") % typestr % base_hid % ident_hid); netcmd cmd; cmd.write_delta_cmd(type, base, ident, del); @@ -1178,7 +1178,7 @@ base64 their_key_encoded; encode_base64(their_key, their_key_encoded); key_hash_code(their_keyname, their_key_encoded, their_key_hash); - L(F("server key has name %s, hash %s\n") % their_keyname % their_key_hash); + L(FL("server key has name %s, hash %s\n") % their_keyname % their_key_hash); var_key their_key_key(known_servers_domain, var_name(peer_id)); if (app.db.var_exists(their_key_key)) { @@ -1215,7 +1215,7 @@ { hexenc hnonce; encode_hexenc(nonce, hnonce); - L(F("received 'hello' netcmd from server '%s' with nonce '%s'\n") + L(FL("received 'hello' netcmd from server '%s' with nonce '%s'\n") % their_key_hash % hnonce); } @@ -1460,7 +1460,7 @@ if (check_signature(app, their_id, their_key, nonce1(), sig)) { // Get our private key and sign back. - L(F("client signature OK, accepting authentication\n")); + L(FL("client signature OK, accepting authentication\n")); this->authenticated = true; this->remote_peer_key_name = their_id; @@ -1495,7 +1495,7 @@ { string typestr; netcmd_item_type_to_string(node.type, typestr); - L(F("processing refine cmd for %s node at level %d\n") + L(FL("processing refine cmd for %s node at level %d\n") % typestr % node.level); switch (node.type) @@ -1700,7 +1700,7 @@ rsa_keypair_id keyid; base64 pub_encoded; app.db.get_pubkey(hitem, keyid, pub_encoded); - L(F("public key '%s' is also called '%s'\n") % hitem % keyid); + L(FL("public key '%s' is also called '%s'\n") % hitem % keyid); write_pubkey(keyid, pub_encoded, out); } else @@ -1768,26 +1768,26 @@ case epoch_item: if (this->app.db.epoch_exists(epoch_id(hitem))) { - L(F("epoch '%s' already exists in our database\n") % hitem); + L(FL("epoch '%s' already exists in our database\n") % hitem); } else { cert_value branch; epoch_data epoch; read_epoch(dat, branch, epoch); - L(F("received epoch %s for branch %s\n") % epoch % branch); + L(FL("received epoch %s for branch %s\n") % epoch % branch); std::map epochs; app.db.get_epochs(epochs); std::map::const_iterator i; i = epochs.find(branch); if (i == epochs.end()) { - L(F("branch %s has no epoch; setting epoch to %s\n") % branch % epoch); + L(FL("branch %s has no epoch; setting epoch to %s\n") % branch % epoch); app.db.set_epoch(branch, epoch); } else { - L(F("branch %s already has an epoch; checking\n") % branch); + L(FL("branch %s already has an epoch; checking\n") % branch); // If we get here, then we know that the epoch must be // different, because if it were the same then the // if (epoch_exists()) branch up above would have been taken. @@ -1811,7 +1811,7 @@ case key_item: if (this->app.db.public_key_exists(hitem)) - L(F("public key '%s' already exists in our database\n") % hitem); + L(FL("public key '%s' already exists in our database\n") % hitem); else { rsa_keypair_id keyid; @@ -1829,7 +1829,7 @@ case cert_item: if (this->app.db.revision_cert_exists(hitem)) - L(F("cert '%s' already exists in our database\n") % hitem); + L(FL("cert '%s' already exists in our database\n") % hitem); else { cert c; @@ -1846,10 +1846,10 @@ { revision_id rid(hitem); if (this->app.db.revision_exists(rid)) - L(F("revision '%s' already exists in our database\n") % hitem); + L(FL("revision '%s' already exists in our database\n") % hitem); else { - L(F("received revision '%s'\n") % hitem); + L(FL("received revision '%s'\n") % hitem); this->dbw.consume_revision_data(rid, revision_data(dat)); } } @@ -1859,10 +1859,10 @@ { file_id fid(hitem); if (this->app.db.file_version_exists(fid)) - L(F("file version '%s' already exists in our database\n") % hitem); + L(FL("file version '%s' already exists in our database\n") % hitem); else { - L(F("received file '%s'\n") % hitem); + L(FL("received file '%s'\n") % hitem); this->dbw.consume_file_data(fid, file_data(dat)); } } @@ -1900,7 +1900,7 @@ break; default: - L(F("ignoring delta received for item type %s\n") % typestr); + L(FL("ignoring delta received for item type %s\n") % typestr); break; } return true; @@ -1914,12 +1914,12 @@ if (msg()[0] == '!') P(F("Received warning from usher: %s") % msg().substr(1)); else - L(F("Received greeting from usher: %s") % msg().substr(1)); + L(FL("Received greeting from usher: %s") % msg().substr(1)); } netcmd cmdout; cmdout.write_usher_reply_cmd(peer_id, our_include_pattern); write_netcmd_and_try_flush(cmdout); - L(F("Sent reply.")); + L(FL("Sent reply.")); return true; } @@ -1996,7 +1996,7 @@ utf8 their_include_pattern, their_exclude_pattern; rsa_oaep_sha_data hmac_key_encrypted; cmd.read_anonymous_cmd(role, their_include_pattern, their_exclude_pattern, hmac_key_encrypted); - L(F("received 'anonymous' netcmd from client for pattern '%s' excluding '%s' " + L(FL("received 'anonymous' netcmd from client for pattern '%s' excluding '%s' " "in %s mode\n") % their_include_pattern % their_exclude_pattern % (role == source_and_sink_role ? _("source and sink") : @@ -2027,7 +2027,7 @@ hexenc hnonce1; encode_hexenc(nonce1, hnonce1); - L(F("received 'auth(hmac)' netcmd from client '%s' for pattern '%s' " + L(FL("received 'auth(hmac)' netcmd from client '%s' for pattern '%s' " "exclude '%s' in %s mode with nonce1 '%s'\n") % their_key_hash % their_include_pattern % their_exclude_pattern % (role == source_and_sink_role ? _("source and sink") : @@ -2178,7 +2178,7 @@ return true; armed = false; - L(F("processing %d byte input buffer from peer %s\n") + L(FL("processing %d byte input buffer from peer %s\n") % inbuf.size() % peer_id); size_t sz = cmd.encoded_size(); @@ -2191,7 +2191,7 @@ guard.maybe_checkpoint(sz); if (!ret) - L(F("finishing processing with '%d' packet") + L(FL("finishing processing with '%d' packet") % cmd.get_cmd_code()); return ret; } @@ -2343,7 +2343,7 @@ { if (i->second->arm()) { - L(F("fd %d is armed\n") % i->first); + L(FL("fd %d is armed\n") % i->first); armed_sessions.insert(i->first); } probe.add(i->second->str, i->second->which_events()); @@ -2372,13 +2372,13 @@ map > & sessions, app_state & app) { - L(F("accepting new connection on %s : %s\n") + L(FL("accepting new connection on %s : %s\n") % addr.get_name() % lexical_cast(addr.get_port())); Netxx::Peer client = server.accept_connection(); if (!client) { - L(F("accept() returned a dead client\n")); + L(FL("accept() returned a dead client\n")); } else { @@ -2581,7 +2581,7 @@ arm_sessions_and_calculate_probe(probe, sessions, armed_sessions); - L(F("i/o probe with %d armed\n") % armed_sessions.size()); + L(FL("i/o probe with %d armed\n") % armed_sessions.size()); Netxx::Probe::result_type res = probe.ready(sessions.empty() ? forever : (armed_sessions.empty() ? timeout : instant)); @@ -2596,7 +2596,7 @@ if (fd == -1) { if (armed_sessions.empty()) - L(F("timed out waiting for I/O (listening on %s : %s)\n") + L(FL("timed out waiting for I/O (listening on %s : %s)\n") % addr.get_name() % lexical_cast(addr.get_port())); } @@ -2613,7 +2613,7 @@ i = sessions.find(fd); if (i == sessions.end()) { - L(F("got woken up for action on unknown fd %d\n") % fd); + L(FL("got woken up for action on unknown fd %d\n") % fd); } else { @@ -2687,7 +2687,7 @@ P(F("finding items to synchronize:\n")); for (set::const_iterator i = branchnames.begin(); i != branchnames.end(); ++i) - L(F("including branch %s") % *i); + L(FL("including branch %s") % *i); // xgettext: please use short message and try to avoid multibytes chars ticker revisions_ticker(_("revisions"), "r", 64); @@ -2745,7 +2745,7 @@ // Set to zero any epoch which is not yet set. if (j == epochs.end()) { - L(F("setting epoch on %s to zero\n") % branch); + L(FL("setting epoch on %s to zero\n") % branch); epochs.insert(std::make_pair(branch, epoch_zero)); app.db.set_epoch(branch, epoch_zero); } @@ -2817,7 +2817,7 @@ app.db.get_key(*key, pub_encoded); hexenc keyhash; key_hash_code(*key, pub_encoded, keyhash); - L(F("noting key '%s' = '%s' to send\n") % *key % keyhash); + L(FL("noting key '%s' = '%s' to send\n") % *key % keyhash); id key_item; decode_hexenc(keyhash, key_item); key_refiner.note_local_item(key_item); ============================================================ --- packet.cc e0d4ed1e5b82b9ce34bc77bef7d24049409221cf +++ packet.cc 06b93709b49bc581a5274afc7762f503abf89dc2 @@ -67,7 +67,7 @@ { if (app.db.file_version_exists(ident)) { - L(F("file version '%s' already exists in db\n") % ident); + L(FL("file version '%s' already exists in db\n") % ident); return; } @@ -85,7 +85,7 @@ if (app.db.file_version_exists(new_id)) { - L(F("file version '%s' already exists in db\n") % new_id); + L(FL("file version '%s' already exists in db\n") % new_id); return; } @@ -121,7 +121,7 @@ transaction_guard guard(app.db); if (app.db.revision_exists(ident)) { - L(F("revision '%s' already exists in db\n") % ident); + L(FL("revision '%s' already exists in db\n") % ident); return; } @@ -190,7 +190,7 @@ if (app.db.revision_cert_exists(t)) { - L(F("revision cert on '%s' already exists in db\n") + L(FL("revision cert on '%s' already exists in db\n") % t.inner().ident); return; } @@ -223,11 +223,11 @@ app.db.get_key(ident, tmp); if (!keys_match(ident, tmp, ident, k)) W(F("key '%s' is not equal to key '%s' in database\n") % ident % ident); - L(F("skipping existing public key %s\n") % ident); + L(FL("skipping existing public key %s\n") % ident); return; } - L(F("putting public key %s\n") % ident); + L(FL("putting public key %s\n") % ident); app.db.put_key(ident, k); if (on_pubkey_written) on_pubkey_written(ident); @@ -243,7 +243,7 @@ if (app.keys.key_pair_exists(ident)) { - L(F("skipping existing key pair %s\n") % ident); + L(FL("skipping existing key pair %s\n") % ident); return; } @@ -362,7 +362,7 @@ std::string body(res[3].first, res[3].second); if (regex_match(type, regex("[fr]data"))) { - L(F("read data packet")); + L(FL("read data packet")); require(regex_match(args, regex(ident))); require(regex_match(body, regex(base))); base64 > body_packed(trim_ws(body)); @@ -379,7 +379,7 @@ } else if (type == "fdelta") { - L(F("read delta packet")); + L(FL("read delta packet")); match_results matches; require(regex_match(args, matches, regex(ident + sp + ident))); string src_id(matches[1].first, matches[1].second); @@ -394,7 +394,7 @@ } else if (type == "rcert") { - L(F("read cert packet")); + L(FL("read cert packet")); match_results matches; require(regex_match(args, matches, regex(ident + sp + certname + sp + key + sp + base))); @@ -414,7 +414,7 @@ } else if (type == "pubkey") { - L(F("read pubkey data packet")); + L(FL("read pubkey data packet")); require(regex_match(args, regex(key))); require(regex_match(body, regex(base))); string contents(trim_ws(body)); @@ -423,7 +423,7 @@ } else if (type == "keypair") { - L(F("read keypair data packet")); + L(FL("read keypair data packet")); require(regex_match(args, regex(key))); match_results matches; require(regex_match(body, matches, regex(base + "#" + base))); @@ -433,7 +433,7 @@ } else if (type == "privkey") { - L(F("read pubkey data packet")); + L(FL("read pubkey data packet")); require(regex_match(args, regex(key))); require(regex_match(body, regex(base))); string contents(trim_ws(body)); ============================================================ --- paths.cc 7eb379a0548c1a6047eddac67dc9e47c16b15cd0 +++ paths.cc a88d2a803ce9e069bd8b0b6d5db4d2c2593de689 @@ -85,7 +85,7 @@ // We still use boost::fs, so let's continue to initialize it properly. fs::initial_path(); fs::path::default_name_check(fs::native); - L(F("initial abs path is: %s") % initial_abs_path.get_but_unused()); + L(FL("initial abs path is: %s") % initial_abs_path.get_but_unused()); } /////////////////////////////////////////////////////////////////////////// @@ -480,7 +480,7 @@ fs::path removed; fs::path check = current / bookdir; - L(F("searching for '%s' directory with root '%s'\n") + L(FL("searching for '%s' directory with root '%s'\n") % bookdir.string() % root.string()); @@ -489,40 +489,40 @@ && current.has_leaf() && !fs::exists(check)) { - L(F("'%s' not found in '%s' with '%s' removed\n") + L(FL("'%s' not found in '%s' with '%s' removed\n") % bookdir.string() % current.string() % removed.string()); removed = fs::path(current.leaf(), fs::native) / removed; current = current.branch_path(); check = current / bookdir; } - L(F("search for '%s' ended at '%s' with '%s' removed\n") + L(FL("search for '%s' ended at '%s' with '%s' removed\n") % bookdir.string() % current.string() % removed.string()); if (!fs::exists(check)) { - L(F("'%s' does not exist\n") % check.string()); + L(FL("'%s' does not exist\n") % check.string()); return false; } if (!fs::is_directory(check)) { - L(F("'%s' is not a directory\n") % check.string()); + L(FL("'%s' is not a directory\n") % check.string()); return false; } // check for MT/. and MT/.. to see if mt dir is readable if (!fs::exists(check / ".") || !fs::exists(check / "..")) { - L(F("problems with '%s' (missing '.' or '..')\n") % check.string()); + L(FL("problems with '%s' (missing '.' or '..')\n") % check.string()); return false; } working_root.set(current.native_file_string(), true); initial_rel_path.set(removed, true); - L(F("working root is '%s'") % working_root.get_but_unused()); - L(F("initial relative path is '%s'") % initial_rel_path.get_but_unused().string()); + L(FL("working root is '%s'") % working_root.get_but_unused()); + L(FL("initial relative path is '%s'") % initial_rel_path.get_but_unused().string()); change_current_working_dir(working_root.get_but_unused()); @@ -623,9 +623,9 @@ static void check_fp_normalizes_to(char * before, char * after) { - L(F("check_fp_normalizes_to: '%s' -> '%s'") % before % after); + L(FL("check_fp_normalizes_to: '%s' -> '%s'") % before % after); file_path fp = file_path_external(std::string(before)); - L(F(" (got: %s)") % fp); + L(FL(" (got: %s)") % fp); BOOST_CHECK(fp.as_internal() == after); BOOST_CHECK(file_path_internal(fp.as_internal()) == fp); // we compare after to the external form too, since as far as we know @@ -661,7 +661,7 @@ 0 }; for (char const ** c = baddies; *c; ++c) { - L(F("test_file_path_external_null_prefix: trying baddie: %s") % *c); + L(FL("test_file_path_external_null_prefix: trying baddie: %s") % *c); BOOST_CHECK_THROW(file_path_external(utf8(*c)), informative_failure); } @@ -726,7 +726,7 @@ 0 }; for (char const ** c = baddies; *c; ++c) { - L(F("test_file_path_external_prefix_a_b: trying baddie: %s") % *c); + L(FL("test_file_path_external_prefix_a_b: trying baddie: %s") % *c); BOOST_CHECK_THROW(file_path_external(utf8(*c)), informative_failure); } @@ -839,7 +839,7 @@ static void check_bk_normalizes_to(char * before, char * after) { bookkeeping_path bp(bookkeeping_root / before); - L(F("normalizing %s to %s (got %s)") % before % after % bp); + L(FL("normalizing %s to %s (got %s)") % before % after % bp); BOOST_CHECK(bp.as_external() == after); BOOST_CHECK(bookkeeping_path(bp.as_internal()).as_internal() == bp.as_internal()); } @@ -865,7 +865,7 @@ for (char const ** c = baddies; *c; ++c) { - L(F("test_bookkeeping_path baddie: trying '%s'") % *c); + L(FL("test_bookkeeping_path baddie: trying '%s'") % *c); BOOST_CHECK_THROW(bookkeeping_path(tmp_path_string.assign(*c)), std::logic_error); BOOST_CHECK_THROW(bookkeeping_root / tmp_path_string.assign(*c), std::logic_error); } @@ -881,7 +881,7 @@ static void check_system_normalizes_to(char * before, char * after) { system_path sp(before); - L(F("normalizing '%s' to '%s' (got '%s')") % before % after % sp); + L(FL("normalizing '%s' to '%s' (got '%s')") % before % after % sp); BOOST_CHECK(sp.as_external() == after); BOOST_CHECK(system_path(sp.as_internal()).as_internal() == sp.as_internal()); } ============================================================ --- rcs_import.cc 9498b94192bc37771313b1daff2f88b564b4dc2c +++ rcs_import.cc 0de2b62e2c973f4c94592cff4990f0a43eb70294 @@ -241,7 +241,7 @@ // our output. memset(&t, 0, sizeof(t)); char const * dp = delta->second->date.c_str(); - L(F("Calculating time of %s\n") % dp); + L(FL("Calculating time of %s\n") % dp); #ifdef HAVE_STRPTIME if (strptime(dp, "%y.%m.%d.%H.%M.%S", &t) == NULL) I(strptime(dp, "%Y.%m.%d.%H.%M.%S", &t) != NULL); @@ -255,7 +255,7 @@ t.tm_year-=1900; #endif time = mktime(&t); - L(boost::format("= %i\n") % time); + L(FL("= %i\n") % time); is_synthetic_branch_root = is_sbr(delta->second, deltatext->second); @@ -275,7 +275,7 @@ { if (i->first == rcs_version) { - L(F("version %s -> tag %s\n") % rcs_version % i->second); + L(FL("version %s -> tag %s\n") % rcs_version % i->second); tags.push_back(cvs.tag_interner.intern(i->second)); } } @@ -442,7 +442,7 @@ { if (old_id == new_id) { - L(F("skipping identity file edge\n")); + L(FL("skipping identity file edge\n")); return; } @@ -450,7 +450,7 @@ { // we already have a way to get to this old version, // no need to insert another reconstruction path - L(F("existing path to %s found, skipping\n") % old_id); + L(FL("existing path to %s found, skipping\n") % old_id); } else { @@ -562,7 +562,7 @@ while(! (r.deltas.find(curr_version) == r.deltas.end())) { - L(F("version %s has %d lines\n") % curr_version % curr_lines->size()); + L(FL("version %s has %d lines\n") % curr_version % curr_lines->size()); cvs_commit curr_commit(r, curr_version, curr_id, cvs); if (!curr_commit.is_synthetic_branch_root) @@ -575,10 +575,10 @@ if (! next_version.empty()) { - L(F("following RCS edge %s -> %s\n") % curr_version % next_version); + L(FL("following RCS edge %s -> %s\n") % curr_version % next_version); construct_version(*curr_lines, next_version, *next_lines, r); - L(F("constructed RCS version %s, inserting into database\n") % + L(FL("constructed RCS version %s, inserting into database\n") % next_version); insert_into_db(curr_data, curr_id, @@ -621,7 +621,7 @@ else priv = true; - L(F("following RCS branch %s = '%s'\n") % (*i) % branch); + L(FL("following RCS branch %s = '%s'\n") % (*i) % branch); construct_version(*curr_lines, *i, branch_lines, r); insert_into_db(curr_data, curr_id, @@ -631,7 +631,7 @@ process_branch(*i, branch_lines, branch_data, branch_id, r, db, cvs); cvs.pop_branch(); - L(F("finished RCS branch %s = '%s'\n") % (*i) % branch); + L(FL("finished RCS branch %s = '%s'\n") % (*i) % branch); } if (!r.deltas.find(curr_version)->second->next.empty()) @@ -652,9 +652,9 @@ import_rcs_file_with_cvs(string const & filename, database & db, cvs_history & cvs) { rcs_file r; - L(F("parsing RCS file %s\n") % filename); + L(FL("parsing RCS file %s\n") % filename); parse_rcs_file(filename, r); - L(F("parsed RCS file %s OK\n") % filename); + L(FL("parsed RCS file %s OK\n") % filename); { vector< piece > head_lines; @@ -678,7 +678,7 @@ // create the head state in case it is a loner // cvs_key k; // shared_ptr s; - // L(F("noting head version %s : %s\n") % cvs.curr_file % r.admin.head); + // L(FL("noting head version %s : %s\n") % cvs.curr_file % r.admin.head); // cvs.find_key_and_state (r, r.admin.head, k, s); } @@ -743,7 +743,7 @@ cvs_history::set_filename(string const & file, file_id const & ident) { - L(F("importing file '%s'\n") % file); + L(FL("importing file '%s'\n") % file); I(file.size() > 2); I(file.substr(file.size() - 2) == string(",v")); string ss = file; @@ -815,14 +815,14 @@ string first_entry_version; join_version(first_entry_components, first_entry_version); - L(F("first version in branch %s would be %s\n") + L(FL("first version in branch %s would be %s\n") % sym % first_entry_version); branch_first_entries.insert(make_pair(first_entry_version, sym)); string branchpoint_version; join_version(branchpoint_components, branchpoint_version); - L(F("file branchpoint for %s at %s\n") % sym % branchpoint_version); + L(FL("file branchpoint for %s at %s\n") % sym % branchpoint_version); branchpoints.insert(make_pair(branchpoint_version, sym)); } } @@ -896,7 +896,7 @@ } } else - L(F("skipping non-RCS file %s\n") % file); + L(FL("skipping non-RCS file %s\n") % file); } virtual ~cvs_tree_walker() {} }; @@ -1072,7 +1072,7 @@ { commits_remaining--; - L(F("examining next commit [t:%d] [p:%s] [a:%s] [c:%s]\n") + L(FL("examining next commit [t:%d] [p:%s] [a:%s] [c:%s]\n") % i->time % cvs.path_interner.lookup(i->path) % cvs.author_interner.lookup(i->author) @@ -1085,7 +1085,7 @@ cluster_set::const_iterator j = clusters.begin(); if ((*j)->first_time + constants::cvs_window < i->time) { - L(F("expiring cluster\n")); + L(FL("expiring cluster\n")); cons.consume_cluster(**j); clusters.erase(j); } @@ -1101,7 +1101,7 @@ for (cluster_set::const_iterator j = clusters.begin(); j != clusters.end(); ++j) { - L(F("examining cluster %d to see if it touched %d\n") + L(FL("examining cluster %d to see if it touched %d\n") % clu++ % i->path); @@ -1109,7 +1109,7 @@ if ((k != (*j)->entries.end()) && (k->second.time > time_of_last_cluster_touching_this_file)) { - L(F("found cluster touching %d: [t:%d] [a:%d] [c:%d]\n") + L(FL("found cluster touching %d: [t:%d] [a:%d] [c:%d]\n") % i->path % (*j)->first_time % (*j)->author @@ -1117,7 +1117,7 @@ time_of_last_cluster_touching_this_file = (*j)->first_time; } } - L(F("last modification time is %d\n") + L(FL("last modification time is %d\n") % time_of_last_cluster_touching_this_file); // step 4: find a cluster which starts on or after the @@ -1133,7 +1133,7 @@ && ((*j)->changelog == i->changelog) && ((*j)->entries.find(i->path) == (*j)->entries.end())) { - L(F("picked existing cluster [t:%d] [a:%d] [c:%d]\n") + L(FL("picked existing cluster [t:%d] [a:%d] [c:%d]\n") % (*j)->first_time % (*j)->author % (*j)->changelog); @@ -1147,7 +1147,7 @@ // a new one. if (!target) { - L(F("building new cluster [t:%d] [a:%d] [c:%d]\n") + L(FL("building new cluster [t:%d] [a:%d] [c:%d]\n") % i->time % i->author % i->changelog); @@ -1172,13 +1172,13 @@ // now we are done this lineage; flush all remaining clusters - L(F("finished branch commits, writing all pending clusters\n")); + L(FL("finished branch commits, writing all pending clusters\n")); while (!clusters.empty()) { cons.consume_cluster(**clusters.begin()); clusters.erase(clusters.begin()); } - L(F("finished writing pending clusters\n")); + L(FL("finished writing pending clusters\n")); cons.store_revisions(); @@ -1231,7 +1231,7 @@ map >::const_iterator i = cvs.branches.begin(); string branchname = i->first; shared_ptr branch = i->second; - L(F("branch %s has %d entries\n") % branchname % branch->lineage.size()); + L(FL("branch %s has %d entries\n") % branchname % branch->lineage.size()); import_branch(cvs, app, branchname, branch, n_revs); // free up some memory @@ -1241,7 +1241,7 @@ { transaction_guard guard(app.db); - L(F("trunk has %d entries\n") % cvs.trunk->lineage.size()); + L(FL("trunk has %d entries\n") % cvs.trunk->lineage.size()); import_branch(cvs, app, cvs.base_branch, cvs.trunk, n_revs); guard.commit(); } @@ -1292,14 +1292,14 @@ synthetic_author, synthetic_cl); - L(F("initial cluster on branch %s has %d live entries\n") % + L(FL("initial cluster on branch %s has %d live entries\n") % branchname % branch.live_at_beginning.size()); for (map::const_iterator i = branch.live_at_beginning.begin(); i != branch.live_at_beginning.end(); ++i) { cvs_cluster::entry e(true, i->second, synthetic_time); - L(F("initial cluster contains %s at %s\n") % + L(FL("initial cluster contains %s at %s\n") % cvs.path_interner.lookup(i->first) % cvs.file_version_interner.lookup(i->second)); initial_cluster.entries.insert(make_pair(i->first, e)); @@ -1410,14 +1410,14 @@ if (e == live_files.end()) { add_missing_parents(sp, cs); - L(F("adding entry state '%s' on '%s'\n") % fid % pth); + L(FL("adding entry state '%s' on '%s'\n") % fid % pth); safe_insert(cs.files_added, make_pair(sp, fid)); live_files[i->first] = i->second.version; } else if (e->second != i->second.version) { file_id old_fid(cvs.file_version_interner.lookup(e->second)); - L(F("applying state delta on '%s' : '%s' -> '%s'\n") + L(FL("applying state delta on '%s' : '%s' -> '%s'\n") % pth % old_fid % fid); safe_insert(cs.deltas_applied, make_pair(sp, make_pair(old_fid, fid))); @@ -1429,7 +1429,7 @@ map::const_iterator e = live_files.find(i->first); if (e != live_files.end()) { - L(F("deleting entry state '%s' on '%s'\n") % fid % pth); + L(FL("deleting entry state '%s' on '%s'\n") % fid % pth); safe_insert(cs.nodes_deleted, sp); live_files.erase(i->first); } ============================================================ --- refiner.cc bdd5b3093fa59253e64ec0de0273058b97af994a +++ refiner.cc fc755a9526c0d0abac8c91375e05800b9983112d @@ -97,7 +97,7 @@ string typestr; netcmd_item_type_to_string(type, typestr); - L(F("determined %d %s items to send") % items_to_send.size() % typestr); + L(FL("determined %d %s items to send") % items_to_send.size() % typestr); calculated_items_to_send = true; } @@ -153,8 +153,7 @@ string typestr; netcmd_item_type_to_string(their_node.type, typestr); - L(boost::format("peer has %s '%s' at slot %d " - "(in node '%s', level %d)\n") + L(FL("peer has %s '%s' at slot %d (in node '%s', level %d)\n") % typestr % hslotval % slot % hpref % their_node.level); } } @@ -179,7 +178,7 @@ calculate_items_to_send(); items_to_receive = n_items; - L(F("finished %s refinement: %d to send, %d to receive") + L(FL("finished %s refinement: %d to send, %d to receive") % typestr % items_to_send.size() % items_to_receive); if (voice == server_voice) @@ -191,7 +190,7 @@ void refiner::process_refinement_command(refinement_type ty, - merkle_node const & their_node) + merkle_node const & their_node) { prefix pref; hexenc hpref; @@ -202,7 +201,7 @@ netcmd_item_type_to_string(their_node.type, typestr); size_t lev = static_cast(their_node.level); - L(F("received refinement %s netcmd on %s node '%s', level %d") + L(FL("received refinement %s netcmd on %s node '%s', level %d") % (ty == refinement_query ? "query" : "response") % typestr % hpref % lev); merkle_ptr our_node; @@ -222,25 +221,25 @@ { // Note any leaves they have. if (their_node.get_slot_state(slot) == leaf_state) - note_item_in_peer(their_node, slot); + note_item_in_peer(their_node, slot); // Compare any subtrees, if we both have subtrees. if (our_node->get_slot_state(slot) == subtree_state - && their_node.get_slot_state(slot) == subtree_state) - { - id our_slotval, their_slotval; - their_node.get_raw_slot(slot, their_slotval); - our_node->get_raw_slot(slot, our_slotval); - - // Always note when you share a subtree. - if (their_slotval == our_slotval) - note_subtree_shared_with_peer(*our_node, slot); - - // Send subqueries when you have a different subtree - // and you're answering a query message. - else if (ty == refinement_query) - send_subquery(*our_node, slot); - } + && their_node.get_slot_state(slot) == subtree_state) + { + id our_slotval, their_slotval; + their_node.get_raw_slot(slot, their_slotval); + our_node->get_raw_slot(slot, our_slotval); + + // Always note when you share a subtree. + if (their_slotval == our_slotval) + note_subtree_shared_with_peer(*our_node, slot); + + // Send subqueries when you have a different subtree + // and you're answering a query message. + else if (ty == refinement_query) + send_subquery(*our_node, slot); + } // Note: if they had a leaf (or empty) where I had a subtree, I // will have noted the leaf and will not send it. They will not @@ -251,15 +250,15 @@ if (ty == refinement_response) { E((queries_in_flight > 0), - F("underflow on query-in-flight counter")); + F("underflow on query-in-flight counter")); --queries_in_flight; // Possibly this signals the end of refinement. if (voice == client_voice && queries_in_flight == 0) - { - calculate_items_to_send(); - cb.queue_done_cmd(type, items_to_send.size()); - } + { + calculate_items_to_send(); + cb.queue_done_cmd(type, items_to_send.size()); + } } else { ============================================================ --- restrictions.cc 7cd8387ff7d2274e95fada7faf9e38e19dda9f04 +++ restrictions.cc 5ae2c8255b6eb1e65662d68d5889ac9d4d3c24c8 @@ -230,7 +230,7 @@ update_restricted_roster_from_filesystem(new_roster, app); calculate_ident(new_roster, rev.new_manifest); - L(F("new manifest_id is %s\n") % rev.new_manifest); + L(FL("new manifest_id is %s\n") % rev.new_manifest); { // We did the following: ============================================================ --- revision.cc 8a61fd6efae0fe4a76264c5134dfd7e75e9d19ab +++ revision.cc c5a08a3f68665482a0dee20500612884dcc591ca @@ -274,7 +274,7 @@ revision_id const & descendent_id, app_state & app) { - L(F("checking whether %s is an ancestor of %s\n") % ancestor_id % descendent_id); + L(FL("checking whether %s is an ancestor of %s\n") % ancestor_id % descendent_id); std::multimap graph; app.db.get_revision_ancestry(graph); @@ -386,7 +386,7 @@ { // now stick them in our ordering (if wanted) and remove them from the // graph, calculating the new roots as we go - L(F("new root: %s\n") % (roots.front())); + L(FL("new root: %s\n") % (roots.front())); if (revisions.find(roots.front()) != revisions.end()) sorted.push_back(roots.front()); for(gi i = graph.lower_bound(roots.front()); @@ -401,7 +401,7 @@ for (std::set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) { - L(F("new leaf: %s\n") % (*i)); + L(FL("new leaf: %s\n") % (*i)); if (revisions.find(*i) != revisions.end()) sorted.push_back(*i); } @@ -620,7 +620,7 @@ void anc_graph::add_node_ancestry(u64 child, u64 parent) { - L(F("noting ancestry from child %d -> parent %d\n") % child % parent); + L(FL("noting ancestry from child %d -> parent %d\n") % child % parent); ancestry.insert(std::make_pair(child, parent)); } @@ -643,7 +643,7 @@ hexenc hexdata; encode_hexenc(data(std::string(buf, buf + constants::epochlen_bytes)), hexdata); epoch_data new_epoch(hexdata); - L(F("setting epoch for %s to %s\n") % *i % new_epoch); + L(FL("setting epoch for %s to %s\n") % *i % new_epoch); app.db.set_epoch(cert_value(*i), new_epoch); } } @@ -716,7 +716,7 @@ { if (j->first == i->first) { - L(F("considering old merge edge %s\n") % + L(FL("considering old merge edge %s\n") % safe_get(node_to_old_rev, i->first)); u64 parent1 = i->second; u64 parent2 = j->second; @@ -781,7 +781,7 @@ { node = max_node++; ++n_nodes; - L(F("node %d = manifest %s\n") % node % man); + L(FL("node %d = manifest %s\n") % node % man); old_man_to_node.insert(std::make_pair(man, node)); node_to_old_man.insert(std::make_pair(node, man)); @@ -792,7 +792,7 @@ for(std::vector< manifest >::const_iterator i = mcerts.begin(); i != mcerts.end(); ++i) { - L(F("loaded '%s' manifest cert for node %s\n") % i->inner().name % node); + L(FL("loaded '%s' manifest cert for node %s\n") % i->inner().name % node); cert_value tv; decode_base64(i->inner().value, tv); ++n_certs_in; @@ -821,7 +821,7 @@ legacy::renames_map renames; legacy::get_manifest_and_renames_for_rev(app, rev, man, renames); - L(F("node %d = revision %s = manifest %s\n") % node % rev % man); + L(FL("node %d = revision %s = manifest %s\n") % node % rev % man); old_rev_to_node.insert(std::make_pair(rev, node)); node_to_old_rev.insert(std::make_pair(node, rev)); node_to_old_man.insert(std::make_pair(node, man)); @@ -834,7 +834,7 @@ for(std::vector< revision >::const_iterator i = rcerts.begin(); i != rcerts.end(); ++i) { - L(F("loaded '%s' revision cert for node %s\n") % i->inner().name % node); + L(FL("loaded '%s' revision cert for node %s\n") % i->inner().name % node); cert_value tv; decode_base64(i->inner().value, tv); ++n_certs_in; @@ -871,12 +871,12 @@ // "Dead" means, the node does not exist in the revision's tree, and the // node's birth revision _is_ an ancestor of the revision. - // L(F("testing liveliness of node %d, born in rev %d\n") % nid % birth_rev); + // L(FL("testing liveliness of node %d, born in rev %d\n") % nid % birth_rev); for (parent_roster_map::const_iterator r = parent_rosters.begin(); r != parent_rosters.end(); ++r) { boost::shared_ptr parent = r->second.first; - // L(F("node %d %s in parent roster %d\n") + // L(FL("node %d %s in parent roster %d\n") // % nid // % (parent->has_node(n->first) ? "exists" : "does not exist" ) // % r->first); @@ -890,7 +890,7 @@ { u64 curr = work.front(); work.pop_front(); - // L(F("examining ancestor %d of parent roster %d, looking for anc=%d\n") + // L(FL("examining ancestor %d of parent roster %d, looking for anc=%d\n") // % curr % r->first % birth_rev); if (seen.find(curr) != seen.end()) @@ -899,7 +899,7 @@ if (curr == birth_rev) { - // L(F("node is dead in %d") % r->first); + // L(FL("node is dead in %d") % r->first); return false; } typedef std::multimap::const_iterator ci; @@ -913,7 +913,7 @@ } } } - // L(F("node is alive in all parents, returning true")); + // L(FL("node is alive in all parents, returning true")); return true; } @@ -1189,7 +1189,7 @@ if (parents_all_done && (node_to_new_rev.find(child) == node_to_new_rev.end())) { - L(F("processing node %d\n") % child); + L(FL("processing node %d\n") % child); manifest_id old_child_mid; legacy::manifest_map old_child_man; @@ -1336,13 +1336,13 @@ if (!app.db.revision_exists (new_rid)) { - L(F("mapped node %d to revision %s\n") % child % new_rid); + L(FL("mapped node %d to revision %s\n") % child % new_rid); app.db.put_revision(new_rid, rev); ++n_revs_out; } else { - L(F("skipping already existing revision %s\n") % new_rid); + L(FL("skipping already existing revision %s\n") % new_rid); } // Mark this child as done, hooray! ============================================================ --- roster.cc 239ae8135b1d73bb14f44c2a88e8383c1767fc75 +++ roster.cc 58d2dba402a7b908ea0153d72f2432ec6bc0c5b1 @@ -310,13 +310,13 @@ split_path & dirname, path_component & basename) { I(!sp.empty()); - // L(F("dirname_basename('%s' [%d components],...)\n") % file_path(sp) % sp.size()); + // L(FL("dirname_basename('%s' [%d components],...)\n") % file_path(sp) % sp.size()); split_path::const_iterator penultimate = sp.begin() + (sp.size()-1); dirname = split_path(sp.begin(), penultimate); basename = *penultimate; if (dirname.empty()) { - // L(F("basename %d vs. null component %d\n") % basename % the_null_component); + // L(FL("basename %d vs. null component %d\n") % basename % the_null_component); I(null_name(basename)); } } @@ -918,39 +918,39 @@ node_id editable_roster_base::detach_node(split_path const & src) { - // L(F("detach_node('%s')") % file_path(src)); + // L(FL("detach_node('%s')") % file_path(src)); return r.detach_node(src); } void editable_roster_base::drop_detached_node(node_id nid) { - // L(F("drop_detached_node(%d)") % nid); + // L(FL("drop_detached_node(%d)") % nid); r.drop_detached_node(nid); } node_id editable_roster_base::create_dir_node() { - // L(F("create_dir_node()\n")); + // L(FL("create_dir_node()\n")); node_id n = r.create_dir_node(nis); - // L(F("create_dir_node() -> %d\n") % n); + // L(FL("create_dir_node() -> %d\n") % n); return n; } node_id editable_roster_base::create_file_node(file_id const & content) { - // L(F("create_file_node('%s')\n") % content); + // L(FL("create_file_node('%s')\n") % content); node_id n = r.create_file_node(content, nis); - // L(F("create_file_node('%s') -> %d\n") % content % n); + // L(FL("create_file_node('%s') -> %d\n") % content % n); return n; } void editable_roster_base::attach_node(node_id nid, split_path const & dst) { - // L(F("attach_node(%d, '%s')") % nid % file_path(dst)); + // L(FL("attach_node(%d, '%s')") % nid % file_path(dst)); MM(dst); MM(this->r); r.attach_node(nid, dst); @@ -961,7 +961,7 @@ file_id const & old_id, file_id const & new_id) { - // L(F("clear_attr('%s', '%s', '%s')") % file_path(pth) % old_id % new_id); + // L(FL("clear_attr('%s', '%s', '%s')") % file_path(pth) % old_id % new_id); r.apply_delta(pth, old_id, new_id); } @@ -969,7 +969,7 @@ editable_roster_base::clear_attr(split_path const & pth, attr_key const & name) { - // L(F("clear_attr('%s', '%s')") % file_path(pth) % name); + // L(FL("clear_attr('%s', '%s')") % file_path(pth) % name); r.clear_attr(pth, name); } @@ -978,7 +978,7 @@ attr_key const & name, attr_value const & val) { - // L(F("set_attr('%s', '%s', '%s')") % file_path(pth) % name % val); + // L(FL("set_attr('%s', '%s', '%s')") % file_path(pth) % name % val); r.set_attr(pth, name, val); } @@ -2184,7 +2184,7 @@ basic_io::stanza st; if (is_dir_t(curr)) { - // L(F("printing dir %s\n") % fp); + // L(FL("printing dir %s\n") % fp); st.push_file_pair(syms::dir, fp); } else @@ -2192,7 +2192,7 @@ file_t ftmp = downcast_to_file_t(curr); st.push_file_pair(syms::file, fp); st.push_hex_pair(syms::content, ftmp->content.inner()()); - // L(F("printing file %s\n") % fp); + // L(FL("printing file %s\n") % fp); } if (print_local_parts) @@ -2208,7 +2208,7 @@ if (j->second.first) { I(!j->second.second().empty()); - // L(F("printing attr %s : %s = %s\n") % fp % j->first % j->second); + // L(FL("printing attr %s : %s = %s\n") % fp % j->first % j->second); st.push_str_triple(syms::attr, j->first(), j->second.second()); } } @@ -2642,7 +2642,7 @@ is_parent = (c_anchor == c.begin()); } - // L(F("path '%s' is%s parent of '%s'") + // L(FL("path '%s' is%s parent of '%s'") // % file_path(p) // % (is_parent ? "" : " not") // % file_path(c)); @@ -2676,7 +2676,7 @@ node_t n = random_element(r.all_nodes())->second; split_path pth; r.get_name(n->self, pth); - // L(F("considering acting on '%s'\n") % file_path(pth)); + // L(FL("considering acting on '%s'\n") % file_path(pth)); switch (rand() % 7) { @@ -2694,12 +2694,12 @@ if (flip()) { - // L(F("adding dir '%s'\n") % file_path(pth)); + // L(FL("adding dir '%s'\n") % file_path(pth)); safe_insert(c.dirs_added, pth); } else { - // L(F("adding file '%s'\n") % file_path(pth)); + // L(FL("adding file '%s'\n") % file_path(pth)); safe_insert(c.files_added, make_pair(pth, new_ident())); } break; @@ -2725,21 +2725,21 @@ if (is_file_t(n2) || (pth2.size() > 1 && flip())) { - // L(F("renaming to a sibling of an existing entry '%s'\n") % file_path(pth2)); + // L(FL("renaming to a sibling of an existing entry '%s'\n") % file_path(pth2)); // Move to a sibling of an existing entry. pth2[pth2.size() - 1] = new_component(); } else { - // L(F("renaming to a child of an existing entry '%s'\n") % file_path(pth2)); + // L(FL("renaming to a child of an existing entry '%s'\n") % file_path(pth2)); // Move to a child of an existing entry. pth2.push_back(new_component()); } if (!parent_of(pth, pth2)) { - // L(F("renaming '%s' -> '%s\n") % file_path(pth) % file_path(pth2)); + // L(FL("renaming '%s' -> '%s\n") % file_path(pth) % file_path(pth2)); safe_insert(c.nodes_renamed, make_pair(pth, pth2)); } } @@ -2749,7 +2749,7 @@ if (!null_node(n->parent) && (is_file_t(n) || downcast_to_dir_t(n)->children.empty())) { - // L(F("deleting '%s'\n") % file_path(pth)); + // L(FL("deleting '%s'\n") % file_path(pth)); safe_insert(c.nodes_deleted, pth); } break; @@ -2762,24 +2762,24 @@ { if (flip()) { - // L(F("clearing attr on '%s'\n") % file_path(pth)); + // L(FL("clearing attr on '%s'\n") % file_path(pth)); safe_insert(c.attrs_cleared, make_pair(pth, k)); } else { - // L(F("changing attr on '%s'\n) % file_path(pth)); + // L(FL("changing attr on '%s'\n) % file_path(pth)); safe_insert(c.attrs_set, make_pair(make_pair(pth, k), new_word())); } } else { - // L(F("setting previously set attr on '%s'\n") % file_path(pth)); + // L(FL("setting previously set attr on '%s'\n") % file_path(pth)); safe_insert(c.attrs_set, make_pair(make_pair(pth, k), new_word())); } } else { - // L(F("setting attr on '%s'\n") % file_path(pth)); + // L(FL("setting attr on '%s'\n") % file_path(pth)); safe_insert(c.attrs_set, make_pair(make_pair(pth, new_word()), new_word())); } break; @@ -2797,7 +2797,7 @@ testing_node_id_source() : curr(first_node) {} virtual node_id next() { - // L(F("creating node %x\n") % curr); + // L(FL("creating node %x\n") % curr); node_id n = curr++; I(!temp_node(n)); return n; @@ -2853,7 +2853,7 @@ // bunch of times, and each time we do only one of these potentially // corrupting tests. Test numbers are in the range [0, total). -#define MAYBE(code) if (total == to_run) { L(F(#code)); code; return; } ++total +#define MAYBE(code) if (total == to_run) { L(FL(#code)); code; return; } ++total static void check_sane_roster_do_tests(int to_run, int& total) @@ -2920,7 +2920,7 @@ check_sane_roster_do_tests(-1, total); for (int to_run = 0; to_run < total; ++to_run) { - L(F("check_sane_roster_test: loop = %i (of %i)") % to_run % (total - 1)); + L(FL("check_sane_roster_test: loop = %i (of %i)") % to_run % (total - 1)); int tmp; check_sane_roster_do_tests(to_run, tmp); } @@ -3667,16 +3667,16 @@ static void test_all_0_scalar_parent_mark_scenarios() { - L(F("TEST: begin checking 0-parent marking")); + L(FL("TEST: begin checking 0-parent marking")); // a* run_a_0_scalar_parent_mark_scenario(); - L(F("TEST: end checking 0-parent marking")); + L(FL("TEST: end checking 0-parent marking")); } static void test_all_1_scalar_parent_mark_scenarios() { - L(F("TEST: begin checking 1-parent marking")); + L(FL("TEST: begin checking 1-parent marking")); // a // | // a @@ -3711,13 +3711,13 @@ // b* run_a_1_scalar_parent_mark_scenario(scalar_a, doubleton(left_rid, right_rid), scalar_b, singleton(new_rid)); - L(F("TEST: end checking 1-parent marking")); + L(FL("TEST: end checking 1-parent marking")); } static void test_all_2_scalar_parent_mark_scenarios() { - L(F("TEST: begin checking 2-parent marking")); + L(FL("TEST: begin checking 2-parent marking")); /////////////////////////////////////////////////////////////////// // a a // \ / @@ -3806,7 +3806,7 @@ // a / // \ / // a - L(F("TEST: end checking 2-parent marking")); + L(FL("TEST: end checking 2-parent marking")); } // there is _one_ remaining case that the above tests miss, because they @@ -3892,7 +3892,7 @@ static void test_residual_attr_mark_scenario() { - L(F("TEST: begin checking residual attr marking case")); + L(FL("TEST: begin checking residual attr marking case")); { testing_node_id_source nis; X_attr_mixed_scalar s(nis); @@ -3929,7 +3929,7 @@ scalar_a, singleton(new_rid), nis); } - L(F("TEST: end checking residual attr marking case")); + L(FL("TEST: end checking residual attr marking case")); } static void @@ -4073,7 +4073,7 @@ static void write_roster_test() { - L(F("TEST: write_roster_test")); + L(FL("TEST: write_roster_test")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4234,7 +4234,7 @@ node_id nid; { - L(F("TEST: check_sane_against_test, no extra nodes in rosters")); + L(FL("TEST: check_sane_against_test, no extra nodes in rosters")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4257,7 +4257,7 @@ } { - L(F("TEST: check_sane_against_test, no extra nodes in markings")); + L(FL("TEST: check_sane_against_test, no extra nodes in markings")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4281,7 +4281,7 @@ } { - L(F("TEST: check_sane_against_test, missing birth rev")); + L(FL("TEST: check_sane_against_test, missing birth rev")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4300,7 +4300,7 @@ } { - L(F("TEST: check_sane_against_test, missing path mark")); + L(FL("TEST: check_sane_against_test, missing path mark")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4319,7 +4319,7 @@ } { - L(F("TEST: check_sane_against_test, missing content mark")); + L(FL("TEST: check_sane_against_test, missing content mark")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4338,7 +4338,7 @@ } { - L(F("TEST: check_sane_against_test, extra content mark")); + L(FL("TEST: check_sane_against_test, extra content mark")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4357,7 +4357,7 @@ } { - L(F("TEST: check_sane_against_test, missing attr mark")); + L(FL("TEST: check_sane_against_test, missing attr mark")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4372,7 +4372,7 @@ } { - L(F("TEST: check_sane_against_test, empty attr mark")); + L(FL("TEST: check_sane_against_test, empty attr mark")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4387,7 +4387,7 @@ } { - L(F("TEST: check_sane_against_test, extra attr mark")); + L(FL("TEST: check_sane_against_test, extra attr mark")); roster_t r; MM(r); marking_map mm; MM(mm); @@ -4481,7 +4481,7 @@ static void test_unify_rosters_randomized() { - L(F("TEST: begin checking unification of rosters (randomly)")); + L(FL("TEST: begin checking unification of rosters (randomly)")); temp_node_id_source tmp_nis; testing_node_id_source test_nis; roster_t left, right; @@ -4493,13 +4493,13 @@ unify_rosters(left, left_new, right, right_new, resolved_new, test_nis); check_post_roster_unification_ok(left, right); } - L(F("TEST: end checking unification of rosters (randomly)")); + L(FL("TEST: end checking unification of rosters (randomly)")); } static void test_unify_rosters_end_to_end() { - L(F("TEST: begin checking unification of rosters (end to end)")); + L(FL("TEST: begin checking unification of rosters (end to end)")); revision_id has_rid = left_rid; revision_id has_not_rid = right_rid; file_id my_fid(std::string("9012901290129012901290129012901290129012")); @@ -4574,7 +4574,7 @@ I(new_roster.get_node(split("foo"))->self != has_roster.get_node(split("foo"))->self); } - L(F("TEST: end checking unification of rosters (end to end)")); + L(FL("TEST: end checking unification of rosters (end to end)")); } ============================================================ --- sanity.cc f31ca82c00210f3a4ddbf7e25863cc714f391e8d +++ sanity.cc af6834773f23069a1157847d8dccf4741d1aeaf3 @@ -35,7 +35,7 @@ { std::string flavour; get_system_flavour(flavour); - L(F("started up on %s\n") % flavour); + L(FL("started up on %s\n") % flavour); } sanity::~sanity() @@ -99,6 +99,12 @@ } string +sanity::do_format(i18n_format const & i18nfmt, char const * file, int line) +{ + return do_format(i18nfmt.fmt, file, line); +} + +string sanity::do_format(format const & fmt, char const * file, int line) { try @@ -136,10 +142,10 @@ } void -sanity::progress(format const & fmt, +sanity::progress(i18n_format const & i18nfmt, char const * file, int line) { - string str = do_format(fmt, file, line); + string str = do_format(i18nfmt, file, line); if (str.size() > constants::log_line_sz) { @@ -155,10 +161,10 @@ } void -sanity::warning(format const & fmt, +sanity::warning(i18n_format const & i18nfmt, char const * file, int line) { - string str = do_format(fmt, file, line); + string str = do_format(i18nfmt, file, line); if (str.size() > constants::log_line_sz) { @@ -175,25 +181,25 @@ } void -sanity::naughty_failure(string const & expr, format const & explain, +sanity::naughty_failure(string const & expr, i18n_format const & explain, string const & file, int line) { string message; - log(format("%s:%d: usage constraint '%s' violated\n") % file % line % expr, + log(FL("%s:%d: usage constraint '%s' violated\n") % file % line % expr, file.c_str(), line); - prefix_lines_with(_("misuse: "), explain.str(), message); + prefix_lines_with(_("misuse: "), do_format(explain, file.c_str(), line), message); gasp(); throw informative_failure(message); } void -sanity::error_failure(string const & expr, format const & explain, - string const & file, int line) +sanity::error_failure(string const & expr, i18n_format const & explain, + string const & file, int line) { string message; - log(format("%s:%d: detected error '%s' violated\n") % file % line % expr, + log(FL("%s:%d: detected error '%s' violated\n") % file % line % expr, file.c_str(), line); - prefix_lines_with(_("error: "), explain.str(), message); + prefix_lines_with(_("error: "), do_format(explain, file.c_str(), line), message); throw informative_failure(message); } @@ -201,12 +207,10 @@ sanity::invariant_failure(string const & expr, string const & file, int line) { - format fmt = - format("%s:%d: invariant '%s' violated\n") - % file % line % expr; - log(fmt, file.c_str(), line); + char const * pattern = N_("%s:%d: invariant '%s' violated"); + log(FL(pattern) % file % line % expr, file.c_str(), line); gasp(); - throw logic_error(fmt.str()); + throw logic_error((F(pattern) % file % line % expr).str()); } void @@ -216,12 +220,12 @@ unsigned long idx, string const & file, int line) { - format fmt = - format("%s:%d: index '%s' = %d overflowed vector '%s' with size %d\n") - % file % line % idx_expr % idx % vec_expr % sz; - log(fmt, file.c_str(), line); + char const * pattern = N_("%s:%d: index '%s' = %d overflowed vector '%s' with size %d\n"); + log(FL(pattern) % file % line % idx_expr % idx % vec_expr % sz, + file.c_str(), line); gasp(); - throw logic_error(fmt.str()); + throw logic_error((F(pattern) + % file % line % idx_expr % idx % vec_expr % sz).str()); } // Last gasp dumps @@ -231,11 +235,11 @@ { if (already_dumping) { - L(F("ignoring request to give last gasp; already in process of dumping\n")); + L(FL("ignoring request to give last gasp; already in process of dumping\n")); return; } already_dumping = true; - L(F("saving current work set: %i items") % musings.size()); + L(FL("saving current work set: %i items") % musings.size()); std::ostringstream out; out << F("Current work set: %i items\n") % musings.size(); for (std::vector::const_iterator @@ -251,17 +255,17 @@ { out << tmp; out << "\n"; - L(F("ignoring error trigged by saving work set to debug log")); + L(FL("ignoring error trigged by saving work set to debug log")); } catch (informative_failure) { out << tmp; out << "\n"; - L(F("ignoring error trigged by saving work set to debug log")); + L(FL("ignoring error trigged by saving work set to debug log")); } } gasp_dump = out.str(); - L(F("finished saving work set")); + L(FL("finished saving work set")); if (debug) { ui.inform("contents of work set:"); @@ -310,14 +314,40 @@ } -boost::format F(const char * str) +i18n_format::i18n_format(const char * localized_pattern) + : fmt(localized_pattern, get_user_locale()) { - return boost::format(gettext(str), get_user_locale()); } +i18n_format::i18n_format(std::string const & localized_pattern) + : fmt(localized_pattern, get_user_locale()) +{ +} -boost::format FP(const char * str1, const char * strn, unsigned long count) +std::string +i18n_format::str() const { - return boost::format(ngettext(str1, strn, count), get_user_locale()); + return fmt.str(); } +std::ostream & +operator<<(std::ostream & os, i18n_format const & fmt) +{ + return os << fmt.str(); +} + +i18n_format F(const char * str) +{ + return i18n_format(gettext(str)); +} + + +i18n_format FP(const char * str1, const char * strn, unsigned long count) +{ + return i18n_format(ngettext(str1, strn, count)); +} + +boost::format FL(const char * str) +{ + return boost::format(str); +} ============================================================ --- sanity.hh 30ca10f5630908ddf9b0ec48523211436891f98b +++ sanity.hh d2494fb0f9188882227ca0ce6584efadb48fbb8b @@ -10,6 +10,7 @@ #include #include #include +#include #include "boost/format.hpp" #include "boost/circular_buffer.hpp" @@ -17,7 +18,6 @@ #include // Required for ENABLE_NLS #include "i18n.h" -#include "ui.hh" #include "quick_alloc.hh" // to get the QA() macro @@ -44,6 +44,8 @@ class MusingI; +struct i18n_format; + struct sanity { sanity(); ~sanity(); @@ -66,24 +68,26 @@ void log(boost::format const & fmt, char const * file, int line); - void progress(boost::format const & fmt, + void progress(i18n_format const & fmt, char const * file, int line); - void warning(boost::format const & fmt, + void warning(i18n_format const & fmt, char const * file, int line); - void naughty_failure(std::string const & expr, boost::format const & explain, + void naughty_failure(std::string const & expr, i18n_format const & explain, std::string const & file, int line) NORETURN; - void error_failure(std::string const & expr, boost::format const & explain, + void error_failure(std::string const & expr, i18n_format const & explain, std::string const & file, int line) NORETURN; void invariant_failure(std::string const & expr, std::string const & file, int line) NORETURN; - void index_failure(std::string const & vec_expr, - std::string const & idx_expr, + void index_failure(std::string const & vec_expr, + std::string const & idx_expr, unsigned long sz, unsigned long idx, std::string const & file, int line) NORETURN; void gasp(); private: + std::string do_format(i18n_format const & fmt, + char const * file, int line); std::string do_format(boost::format const & fmt, char const * file, int line); }; @@ -92,12 +96,37 @@ extern sanity global_sanity; +struct i18n_format +{ + boost::format fmt; + i18n_format() {} + explicit i18n_format(const char * localized_pattern); + explicit i18n_format(std::string const & localized_pattern); + std::string str() const; + template i18n_format & operator%(T const & t) + { + fmt % t; + return *this; + } + template i18n_format & operator%(T & t) + { + fmt % t; + return *this; + } +}; + +std::ostream & operator<<(std::ostream & os, i18n_format const & fmt); + // F is for when you want to build a boost formatter for display -boost::format F(const char * str); +i18n_format F(const char * str); // FP is for when you want to build a boost formatter for displaying a plural -boost::format FP(const char * str1, const char * strn, unsigned long count); +i18n_format FP(const char * str1, const char * strn, unsigned long count); +// FL is for when you want to build a boost formatter for the developers -- it +// is not gettextified. Think of the L as "literal" or "log". +boost::format FL(const char * str); + // L is for logging, you can log all you want #define L(fmt) global_sanity.log(fmt, __FILE__, __LINE__) ============================================================ --- schema_migration.cc 47d3fde2b6c37af0e06704ad0e1f2b2c997a4b7c +++ schema_migration.cc a13abc3a8c750aadb1ad07114c8f5b0cfc0cc67b @@ -44,11 +44,11 @@ void* data, char** errmsg) { - L(F("executing SQL '%s'") % sql); + L(FL("executing SQL '%s'") % sql); int res = sqlite3_exec(db, sql, cb, data, errmsg); - L(F("result: %i (%s)") % res % sqlite3_errmsg(db)); + L(FL("result: %i (%s)") % res % sqlite3_errmsg(db)); if (errmsg && ((*errmsg)!=0)) - L(F("errmsg: %s") % *errmsg); + L(FL("errmsg: %s") % *errmsg); return res; } ============================================================ --- selectors.cc 7ae313b2c960a3f68e40a68db0f883bd48b59ac3 +++ selectors.cc 36e7fe5c942ab58a0adff4bfd240a9e075370359 @@ -20,14 +20,14 @@ { sel = orig_sel; - L(F("decoding selector '%s'\n") % sel); + L(FL("decoding selector '%s'\n") % sel); std::string tmp; if (sel.size() < 2 || sel[1] != ':') { if (!app.lua.hook_expand_selector(sel, tmp)) { - L(F("expansion of selector '%s' failed\n") % sel); + L(FL("expansion of selector '%s' failed\n") % sel); } else { ============================================================ --- transforms.cc 1c3e80c7243e5c569f7c6d0f29900cf1af73cbb0 +++ transforms.cc 1f17068bcfa0609f9962200eb33920168f10e7be @@ -468,7 +468,7 @@ dst = src; else { - L(F("converting %d bytes from %s to %s\n") % src.size() + L(FL("converting %d bytes from %s to %s\n") % src.size() % src_charset % dst_charset); char * converted = stringprep_convert(src.c_str(), dst_charset.c_str(), @@ -618,7 +618,7 @@ ace_to_utf8(ace const & a, utf8 & utf) { char *out = NULL; - L(F("converting %d bytes from IDNA ACE to UTF-8\n") % a().size()); + L(FL("converting %d bytes from IDNA ACE to UTF-8\n") % a().size()); int res = idna_to_unicode_8z8z(a().c_str(), &out, IDNA_USE_STD3_ASCII_RULES); N(res == IDNA_SUCCESS || res == IDNA_NO_ACE_PREFIX, F("error converting %d UTF-8 bytes to IDNA ACE: %s") @@ -632,7 +632,7 @@ utf8_to_ace(utf8 const & utf, ace & a) { char *out = NULL; - L(F("converting %d bytes from UTF-8 to IDNA ACE\n") % utf().size()); + L(FL("converting %d bytes from UTF-8 to IDNA ACE\n") % utf().size()); int res = idna_to_ascii_8z(utf().c_str(), &out, IDNA_USE_STD3_ASCII_RULES); N(res == IDNA_SUCCESS, F("error converting %d UTF-8 bytes to IDNA ACE: %s") @@ -780,7 +780,7 @@ else if (linesep == "LF"|| linesep == "\n") linesep_str = "\n"; - L(F("doing linesep conversion to %s\n") % linesep); + L(FL("doing linesep conversion to %s\n") % linesep); vector tmp; split_into_lines(src, tmp); join_lines(tmp, dst, linesep_str); ============================================================ --- ui.hh e0e20f167b6f3abad9608477d61bc1a29f8cefff +++ ui.hh 496479433aee1e5ff51e96a22ae7cb662d71c4b8 @@ -15,6 +15,8 @@ #include #include +#include "sanity.hh" + struct user_interface; struct ticker @@ -85,6 +87,7 @@ void fatal(boost::format const & fmt) { warn(fmt.str()); } void inform(std::string const & line); void inform(boost::format const & fmt) { inform(fmt.str()); } + void inform(i18n_format const & fmt) { inform(fmt.str()); } void set_tick_trailer(std::string const & trailer); void set_tick_writer(tick_writer * t_writer); void ensure_clean_line(); ============================================================ --- unix/get_system_flavour.cc e75e9a4586becb842532cd9abfb8d9b4107c0131 +++ unix/get_system_flavour.cc cbbb43edbaf647bf4005887684a98c94633d2cfb @@ -13,7 +13,7 @@ Linux only knows 0 - as >0 is not an error condition there, relax a bit */ I(uname(&n) >= 0); - ident = (F("%s %s %s %s") + ident = (boost::format("%s %s %s %s") % n.sysname % n.release % n.version ============================================================ --- unix/process.cc 43e718ca7819cf146a0c3204a7cb69802b689d96 +++ unix/process.cc 3a10d73ce7457e22b104777f87d29f8d5fdd2ea8 @@ -19,7 +19,7 @@ int existsonpath(const char *exe) { - L(F("checking for program '%s'\n") % exe); + L(FL("checking for program '%s'\n") % exe); // this is horribly ugly, but at least it is rather portable std::string cmd_str = (F("command -v '%s' >/dev/null 2>&1") % exe).str(); const char * const args[] = {"sh", "-c", cmd_str.c_str(), NULL}; @@ -28,20 +28,20 @@ pid = process_spawn(args); if (pid==-1) { - L(F("error in process_spawn\n")); + L(FL("error in process_spawn\n")); return -1; } if (process_wait(pid, &res)) { - L(F("error in process_wait\n")); + L(FL("error in process_wait\n")); return -1; } if (res==0) { - L(F("successful return; %s exists\n") % exe); + L(FL("successful return; %s exists\n") % exe); return 0; } - L(F("failure; %s does not exist\n") % exe); + L(FL("failure; %s does not exist\n") % exe); return -1; } @@ -80,7 +80,7 @@ cmdline_ss << ", "; cmdline_ss << "'" << *i << "'"; } - L(F("spawning command: %s\n") % cmdline_ss.str()); + L(FL("spawning command: %s\n") % cmdline_ss.str()); } pid_t pid; pid = fork(); ============================================================ --- update.cc 4ef16214b35aa9f9b73a60f5e6d9f630cdc70e68 +++ update.cc bc5d41f3a5879e36ee2fe60f98d59ba4e181ba24 @@ -74,7 +74,7 @@ revision_id const & target, app_state & app) { - L(F("Considering update target %s\n") % target); + L(FL("Considering update target %s\n") % target); // step 1: check the branch base64 val; @@ -84,7 +84,7 @@ erase_bogus_certs(certs, app); if (certs.empty()) { - L(F("%s not in branch %s\n") % target % branch); + L(FL("%s not in branch %s\n") % target % branch); return false; } @@ -93,12 +93,12 @@ get_test_results_for_revision(target, target_results, app); if (app.lua.hook_accept_testresult_change(base_results, target_results)) { - L(F("%s is acceptable update candidate\n") % target); + L(FL("%s is acceptable update candidate\n") % target); return true; } else { - L(F("%s has unacceptable test results\n") % target); + L(FL("%s has unacceptable test results\n") % target); return false; } } ============================================================ --- win32/fs.cc bf1ed69810fd107a33cf9c8ea8327574f2271bfe +++ win32/fs.cc d4bbd27d041e4767ef6b1d3e341c5ee65ce1f44f @@ -67,7 +67,7 @@ home = getenv("HOME"); if (home != NULL) { - L(F("Home directory from HOME\n")); + L(FL("Home directory from HOME\n")); return std::string(home); } // Otherwise, try USERPROFILE. We could also use SHGetFolderPath() to get @@ -76,7 +76,7 @@ char * userprofile = getenv("USERPROFILE"); if (userprofile != NULL) { - L(F("Home directory from USERPROFILE\n")); + L(FL("Home directory from USERPROFILE\n")); return std::string(userprofile); } // Try concatenating HOMEDRIVE and HOMEPATH @@ -84,13 +84,13 @@ char * homepath = getenv("HOMEPATH"); if (homedrive != NULL && homepath != NULL) { - L(F("Home directory from HOMEDRIVE+HOMEPATH\n")); + L(FL("Home directory from HOMEDRIVE+HOMEPATH\n")); return std::string(homedrive) + std::string(homepath); } char * systemdrive = getenv("SystemDrive"); if (systemdrive != NULL) { - L(F("Home directory from SystemDrive\n")); + L(FL("Home directory from SystemDrive\n")); return std::string(systemdrive); } return std::string("C:"); @@ -146,10 +146,10 @@ MoveFileEx = reinterpret_cast (GetProcAddress(hModule, "MoveFileExA")); if (MoveFileEx) { - L(F("using MoveFileEx for renames")); + L(FL("using MoveFileEx for renames")); MoveFileExAvailable = true; } else - L(F("using DeleteFile/MoveFile fallback for renames")); + L(FL("using DeleteFile/MoveFile fallback for renames")); } if (MoveFileExAvailable) { @@ -157,7 +157,7 @@ return true; else if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { MoveFileExAvailable = false; - L(F("MoveFileEx failed with CALL_NOT_IMPLEMENTED, using fallback")); + L(FL("MoveFileEx failed with CALL_NOT_IMPLEMENTED, using fallback")); } } else { // This is not even remotely atomic, but what can you do? @@ -185,7 +185,7 @@ if (rename_clobberingly_impl(szFrom, szTo)) return; lastError = GetLastError(); - L(F("attempted rename of '%s' to '%s' failed: %d") + L(FL("attempted rename of '%s' to '%s' failed: %d") % szFrom % szTo % lastError); Sleep(sleepTime); if (sleepTime < 250) ============================================================ --- win32/process.cc 6d0e1e94d431f4fe5d724187101ec9c921355283 +++ win32/process.cc 79552c8593362854390fe3560b13ab682a31c434 @@ -117,23 +117,23 @@ realexelen = strlen(argv[0])+1+MAX_PATH; realexe = (char*)malloc(realexelen); if (realexe==NULL) return 0; - L(F("searching for exe: %s\n") % argv[0]); + L(FL("searching for exe: %s\n") % argv[0]); if (SearchPath(NULL, argv[0], ".exe", realexelen, realexe, &filepart)==0) { - L(F("SearchPath failed, err=%d\n") % GetLastError()); + L(FL("SearchPath failed, err=%d\n") % GetLastError()); free(realexe); return -1; } cmd = munge_argv_into_cmdline(argv); - L(F("spawning command: '%s' '%s'\n") % realexe % cmd); + L(FL("spawning command: '%s' '%s'\n") % realexe % cmd); memset(&si, 0, sizeof(si)); si.cb = sizeof(STARTUPINFO); /* We don't need to set any of the STARTUPINFO members */ if (CreateProcess(realexe, (char*)cmd.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)==0) { - L(F("CreateProcess failed, err=%d\n") % GetLastError()); + L(FL("CreateProcess failed, err=%d\n") % GetLastError()); free(realexe); return -1; } ============================================================ --- work.cc f3a80d9f0f9466e6bc2d6a8a78d94ec86d2c10ef +++ work.cc 5f27cea289f3b61f7f645643bf7d6b158ca031ce @@ -282,7 +282,7 @@ static void get_work_path(bookkeeping_path & w_path) { w_path = bookkeeping_root / work_file_name; - L(F("work path is %s\n") % w_path); + L(FL("work path is %s\n") % w_path); } void get_work_cset(cset & w) @@ -291,15 +291,15 @@ get_work_path(w_path); if (path_exists(w_path)) { - L(F("checking for un-committed work file %s\n") % w_path); + L(FL("checking for un-committed work file %s\n") % w_path); data w_data; read_data(w_path, w_data); read_cset(w_data, w); - L(F("read cset from %s\n") % w_path); + L(FL("read cset from %s\n") % w_path); } else { - L(F("no un-committed work file %s\n") % w_path); + L(FL("no un-committed work file %s\n") % w_path); } } @@ -336,7 +336,7 @@ static void get_revision_path(bookkeeping_path & m_path) { m_path = bookkeeping_root / revision_file_name; - L(F("revision path is %s\n") % m_path); + L(FL("revision path is %s\n") % m_path); } void get_revision_id(revision_id & c) @@ -350,7 +350,7 @@ F("working copy is corrupt: %s is a directory") % c_path); data c_data; - L(F("loading revision id from %s\n") % c_path); + L(FL("loading revision id from %s\n") % c_path); try { read_data(c_path, c_data); @@ -366,7 +366,7 @@ { bookkeeping_path c_path; get_revision_path(c_path); - L(F("writing revision id to %s\n") % c_path); + L(FL("writing revision id to %s\n") % c_path); data c_data(rev.inner()() + "\n"); write_data(c_path, c_data); } @@ -388,7 +388,7 @@ app.db.get_roster(rid, ros, mm); } - L(F("base roster has %d entries\n") % ros.all_nodes().size()); + L(FL("base roster has %d entries\n") % ros.all_nodes().size()); } void @@ -458,7 +458,7 @@ get_user_log_path(bookkeeping_path & ul_path) { ul_path = bookkeeping_root / user_log_file_name; - L(F("user log path is %s\n") % ul_path); + L(FL("user log path is %s\n") % ul_path); } void @@ -507,7 +507,7 @@ get_options_path(bookkeeping_path & o_path) { o_path = bookkeeping_root / options_file_name; - L(F("options path is %s\n") % o_path); + L(FL("options path is %s\n") % o_path); } void @@ -553,7 +553,7 @@ void get_local_dump_path(bookkeeping_path & d_path) { d_path = bookkeeping_root / local_dump_file_name; - L(F("local dump path is %s\n") % d_path); + L(FL("local dump path is %s\n") % d_path); } // inodeprint file ============================================================ --- xdelta.cc 7c8499810d4afe6687979cdccbaef6ecf65c20fe +++ xdelta.cc 623dce88e91af3d9f610b47d7596408fa4876dda @@ -258,9 +258,9 @@ I(a.size() > 0); I(b.size() > 0); - L(F("computing binary delta instructions\n")); + L(FL("computing binary delta instructions\n")); compute_delta_insns(a, b, delta_insns); - L(F("computed binary delta instructions\n")); + L(FL("computed binary delta instructions\n")); } ostringstream oss;