# # # patch "HACKING" # from [15344dd3cc9c94d75f7d6da521d44357ea3c2bdb] # to [b6ac9bddef14c7b4b04e04100ad4ed40f5e9a913] # # patch "annotate.cc" # from [27e0f14d529224e51282f455b80a804585aa697b] # to [ca0a82901ab666554fca69edd1cdb7776d77e3a7] # # patch "automate.cc" # from [2d83f22200a3999fe8416b301f0bbbca0d90723c] # to [8ec9608c841b8b1f966039bd12f06af1b96ab032] # # patch "cmd_automate.cc" # from [9e4980ad281f610de4303c3afe6749c41b090060] # to [4b0adb50546986e09c334e1da05e7c48bcba330d] # # patch "cmd_db.cc" # from [c647b4d7745e3daa2bdb12fc13a23405f272dbd2] # to [590012d40b93eac9677904fde3bb2c3717ba565d] # # patch "cmd_diff_log.cc" # from [8daa52e0f47b4462b4f393e24d04bd98dd98e4b9] # to [6020c9e5cbc3ed6eb910d5916365db364b6b7f65] # # patch "cmd_files.cc" # from [112a24126bea86d32a5e563a9207296bf5cba97c] # to [4e72e60135d0b3771e0cd71f594b77a060214e1c] # # patch "cmd_key_cert.cc" # from [2dc4128b1f916d2fdaa990f3e8d324774f52d1b3] # to [3e80a3c990efceced0f46d845dba8d8d4dae50f5] # # patch "cmd_list.cc" # from [1f78175c59f892f6389f046b3e732d00085553a0] # to [0a7d7a729f6a69eafcb274fc669afdb2b1918190] # # patch "cmd_merging.cc" # from [9ab60698531667923015ebaa59b536c18de3350f] # to [5ce276748daf5e39207f2688526d45cb4afd1e53] # # patch "cmd_netsync.cc" # from [f0a73af0909b03372b8c96bad5647e3bddff17ac] # to [e027393bafb3487042dd155f84efb88ed5b041b6] # # patch "cmd_ws_commit.cc" # from [a81d478bf4c7ef569dd8ae9ccc4d745772005eae] # to [575f7684d42ae851eb4565051c7bc000354ed023] # # patch "commands.cc" # from [ccae8a0a37eb7eceab3cd4586e22e3660ddef9ee] # to [15a40992593942e0a8610be9edd311422903fae4] # # patch "contrib/usher.cc" # from [a85a96788684cdf4761de0c268444c31cca161d2] # to [6ebc1e6b5d4b44e048dc3a9b3ec788d522b43b62] # # patch "database.cc" # from [3e65a0b3f6e71edd464d6dc18e8ac46652a44cb1] # to [c2569141900f0620bef8e7b85965e9ffcffbf018] # # patch "diff_patch.cc" # from [05abac4db33a6942b39833e2f75c3dacb3222250] # to [06a1fcb53473c9cf684b41e162a3774f72668ac0] # # patch "keys.cc" # from [0da3d3d300eb96edc50758f49b8383fc8fb18f8d] # to [6acd8d3bff1299cb4b96e227f448fc0bfe29d7ba] # # patch "monotone.cc" # from [78453eea6f4d8796e0c0a181d6a8a91f1e0b8248] # to [160073e2d0ac102d57db3e761f89ff10b5bfac5d] # # patch "mt_version.cc" # from [ef1f68f30cba797cca4116a3f7e0a564ece59501] # to [a146b93aa0550b024bf41bbb4f0fcd1b8378a57d] # # patch "packet.cc" # from [878c9142ecd2955dc1fd5c4a7fca4baff910db85] # to [1dd3e1b56ecdb676fc5bff8b948d3ccf79ad5900] # # patch "paths.cc" # from [0dc1996f499253e7f5663c528da8ce8e7e8c7d70] # to [e0558b714b4a46a0206d1d2c1c0266a950a29415] # # patch "rcs_file.cc" # from [b6331f4c720ee5894b90f599df7d1e8be2502cda] # to [03010605b87bfa54cd3a78996c7e0750d2a9fe81] # # patch "revision.cc" # from [f22703d784fb1f7fab53662f2337e5b85d76c95b] # to [f2c7dfa91c547a2da942f863a7bb8f51bb5ee0f0] # # patch "roster.cc" # from [c43672f75a5b86fc334bf008b9a99db6db8bbfbf] # to [f62b03b41fa5286a94947a3bebc17ac9b83774cb] # # patch "sanity.cc" # from [9fd3709f9f2dd5417339d9fb966577618ad63123] # to [8c2cb1ec66d4342731bb79f536f50fec2a9c9eca] # # patch "simplestring_xform.cc" # from [97d9d76e5a162bafbe2dd9517e1fbbb17cf562e2] # to [4d9df66d29c1e2b1ec4ef1717b271de71fd3d941] # # patch "tests/diff_against_empty_file/expected.diff" # from [07a262d6f3b512e3c40c6c3f012b1218c753ba72] # to [4bd7f5ef4ef0e7ef33ee6995cb9b37e14385c918] # # patch "txt2c.cc" # from [d951820558e77aa3f2ea48ebf7cbfa18728436aa] # to [b53f05ddac34b55e53343efc612c572d9e861b37] # # patch "ui.cc" # from [f1bb749951aa4f9b75298f15d70b28ca98b217fd] # to [21bba61b39d2178a31aa97437d0b60688003ff42] # # patch "unit_tests.cc" # from [430d859a43e8c858d85b962dd50a2acac80abee4] # to [479c8975ba1b505e2f0d8d83a3ed54cd6bdfb126] # # patch "unix/read_password.cc" # from [1400281952dcc743e0b1a047958aa6fe368bfdff] # to [800251ef5cdc0a0786e39c37e254dcc830fea6ba] # # patch "win32/read_password.cc" # from [2c7195f1b01fa1176ae2342761af3e8baac031ce] # to [7d985a945f4b6fa3ba0cfc50bb4492ab457a4149] # ============================================================ --- HACKING 15344dd3cc9c94d75f7d6da521d44357ea3c2bdb +++ HACKING b6ac9bddef14c7b4b04e04100ad4ed40f5e9a913 @@ -130,6 +130,16 @@ continued to adhere to the dialect we wr one of the standard streams (cin, cout, cerr, clog). use , , , , etc instead, as appropriate. + - it is almost always a mistake to use std::endl instead of '\n'. + std::endl writes a newline to the stream *and flushes it*. + in monotone this is basically only appropriate when one needs to + resynchronize clog and cout (ui.cc:clear_line()), or recover from + disabling terminal echo (read_password()). note that it is never + necessary to use endl with cerr, as cerr is unbuffered. + + - prefer character constants ('x') to single-character strings ("x") in + formatted output sequences. + - return type and function qualifiers should be placed on the line above the function name, so that the function name sits flush with the first column. this makes grepping for function definitions easier. ============================================================ --- annotate.cc 27e0f14d529224e51282f455b80a804585aa697b +++ annotate.cc ca0a82901ab666554fca69edd1cdb7776d77e3a7 @@ -34,7 +34,6 @@ using std::cout; using std::back_insert_iterator; using std::back_inserter; using std::cout; -using std::endl; using std::map; using std::min; using std::set; @@ -446,15 +445,15 @@ annotate_context::dump(app_state & app, { if (lastid == annotations[i]) cout << empty_note << ": " - << file_lines[i] << endl; + << file_lines[i] << '\n'; else cout << revs_to_notations[annotations[i]] - << file_lines[i] << endl; + << file_lines[i] << '\n'; lastid = annotations[i]; } else cout << annotations[i] << ": " - << file_lines[i] << endl; + << file_lines[i] << '\n'; } } ============================================================ --- automate.cc 2d83f22200a3999fe8416b301f0bbbca0d90723c +++ automate.cc 8ec9608c841b8b1f966039bd12f06af1b96ab032 @@ -73,7 +73,7 @@ AUTOMATE(heads, N_("[BRANCH]"), options: set heads; app.get_project().get_branch_heads(app.opts.branchname, heads); for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: ancestors @@ -119,7 +119,7 @@ AUTOMATE(ancestors, N_("REV1 [REV2 [REV3 for (set::const_iterator i = ancestors.begin(); i != ancestors.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } @@ -163,7 +163,7 @@ AUTOMATE(descendents, N_("REV1 [REV2 [RE } for (set::const_iterator i = descendents.begin(); i != descendents.end(); ++i) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } @@ -191,7 +191,7 @@ AUTOMATE(erase_ancestors, N_("[REV1 [REV } erase_ancestors(revs, app); for (set::const_iterator i = revs.begin(); i != revs.end(); ++i) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: attributes @@ -339,7 +339,7 @@ AUTOMATE(toposort, N_("[REV1 [REV2 [REV3 toposort(revs, sorted, app); for (vector::const_iterator i = sorted.begin(); i != sorted.end(); ++i) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: ancestry_difference @@ -381,7 +381,7 @@ AUTOMATE(ancestry_difference, N_("NEW_RE toposort(ancestors, sorted, app); for (vector::const_iterator i = sorted.begin(); i != sorted.end(); ++i) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: leaves @@ -412,7 +412,7 @@ AUTOMATE(leaves, "", options::opts::none leaves.erase(i->first); for (set::const_iterator i = leaves.begin(); i != leaves.end(); ++i) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: parents @@ -437,7 +437,7 @@ AUTOMATE(parents, N_("REV"), options::op for (set::const_iterator i = parents.begin(); i != parents.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: children @@ -462,7 +462,7 @@ AUTOMATE(children, N_("REV"), options::o for (set::const_iterator i = children.begin(); i != children.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: graph @@ -515,8 +515,8 @@ AUTOMATE(graph, "", options::opts::none) output << (i->first).inner()(); for (set::const_iterator j = i->second.begin(); j != i->second.end(); ++j) - output << " " << (*j).inner()(); - output << "\n"; + output << ' ' << (*j).inner()(); + output << '\n'; } } @@ -543,7 +543,7 @@ AUTOMATE(select, N_("SELECTOR"), options for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) - output << *i << "\n"; + output << *i << '\n'; } // consider a changeset with the following @@ -803,17 +803,17 @@ AUTOMATE(inventory, "", options::opts::n switch (i->second.pre_state) { - case inventory_item::UNCHANGED_PATH: output << " "; break; - case inventory_item::DROPPED_PATH: output << "D"; break; - case inventory_item::RENAMED_PATH: output << "R"; break; + case inventory_item::UNCHANGED_PATH: output << ' '; break; + case inventory_item::DROPPED_PATH: output << 'D'; break; + case inventory_item::RENAMED_PATH: output << 'R'; break; default: I(false); // invalid pre_state } switch (i->second.post_state) { - case inventory_item::UNCHANGED_PATH: output << " "; break; - case inventory_item::RENAMED_PATH: output << "R"; break; - case inventory_item::ADDED_PATH: output << "A"; break; + case inventory_item::UNCHANGED_PATH: output << ' '; break; + case inventory_item::RENAMED_PATH: output << 'R'; break; + case inventory_item::ADDED_PATH: output << 'A'; break; default: I(false); // invalid post_state } @@ -821,20 +821,20 @@ AUTOMATE(inventory, "", options::opts::n { case inventory_item::UNCHANGED_NODE: if (i->second.post_state == inventory_item::ADDED_PATH) - output << "P"; + output << 'P'; else - output << " "; + output << ' '; break; - case inventory_item::PATCHED_NODE: output << "P"; break; - case inventory_item::UNKNOWN_NODE: output << "U"; break; - case inventory_item::IGNORED_NODE: output << "I"; break; - case inventory_item::MISSING_NODE: output << "M"; break; + case inventory_item::PATCHED_NODE: output << 'P'; break; + case inventory_item::UNKNOWN_NODE: output << 'U'; break; + case inventory_item::IGNORED_NODE: output << 'I'; break; + case inventory_item::MISSING_NODE: output << 'M'; break; default: I(false); // invalid node_state } - output << " " << i->second.pre_id - << " " << i->second.post_id - << " " << i->first; + output << ' ' << i->second.pre_id + << ' ' << i->second.post_id + << ' ' << i->first; // FIXME: it's possible that a directory was deleted and a file // was added in it's place (or vice-versa) so we need something @@ -843,7 +843,7 @@ AUTOMATE(inventory, "", options::opts::n output << path_suffix; - output << "\n"; + output << '\n'; } } @@ -965,7 +965,7 @@ AUTOMATE(get_base_revision_id, "", optio N(parents.size() == 1, F("this command can only be used in a single-parent workspace")); - output << parent_id(parents.begin()) << "\n"; + output << parent_id(parents.begin()) << '\n'; } // Name: get_current_revision_id @@ -999,7 +999,7 @@ AUTOMATE(get_current_revision_id, "", op calculate_ident(rev, new_revision_id); - output << new_revision_id << "\n"; + output << new_revision_id << '\n'; } // Name: get_manifest_of @@ -1248,7 +1248,7 @@ AUTOMATE(common_ancestors, N_("REV1 [REV for (set::const_iterator i = common_ancestors.begin(); i != common_ancestors.end(); ++i) if (!null_id(*i)) - output << (*i).inner()() << "\n"; + output << (*i).inner()() << '\n'; } // Name: branches @@ -1276,7 +1276,7 @@ AUTOMATE(branches, "", options::opts::no i != names.end(); ++i) { if (!app.lua.hook_ignore_branch(*i)) - output << (*i) << "\n"; + output << (*i) << '\n'; } } @@ -1479,13 +1479,13 @@ AUTOMATE(get_option, N_("OPTION"), optio string opt = args[0](); if (opt == "database") - output << database_option << "\n"; + output << database_option << '\n'; else if (opt == "branch") - output << branch_option << "\n"; + output << branch_option << '\n'; else if (opt == "key") - output << key_option << "\n"; + output << key_option << '\n'; else if (opt == "keydir") - output << keydir_option << "\n"; + output << keydir_option << '\n'; else N(false, F("'%s' is not a recognized workspace option") % opt); } ============================================================ --- cmd_automate.cc 9e4980ad281f610de4303c3afe6749c41b090060 +++ cmd_automate.cc 4b0adb50546986e09c334e1da05e7c48bcba330d @@ -76,7 +76,7 @@ AUTOMATE(interface_version, "", options: N(args.size() == 0, F("no arguments needed")); - output << interface_version << "\n"; + output << interface_version << '\n'; } // Name: stdio @@ -284,10 +284,10 @@ public: int num = pptr() - pbase(); if (num || end) { - (*out) << cmdnum << ":" - << err << ":" - << (end?'l':'m') << ":" - << num << ":" << std::string(pbase(), num); + (*out) << cmdnum << ':' + << err << ':' + << (end?'l':'m') << ':' + << num << ':' << std::string(pbase(), num); setp(pbase(), pbase() + _bufsize); out->flush(); } ============================================================ --- cmd_db.cc c647b4d7745e3daa2bdb12fc13a23405f272dbd2 +++ cmd_db.cc 590012d40b93eac9677904fde3bb2c3717ba565d @@ -170,8 +170,8 @@ CMD(complete, N_("informative"), N_("(re for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) { - if (!verbose) cout << i->inner()() << "\n"; - else cout << describe_revision(app, *i) << "\n"; + if (!verbose) cout << i->inner()() << '\n'; + else cout << describe_revision(app, *i) << '\n'; } } else if (idx(args, 0)() == "file") @@ -180,7 +180,7 @@ CMD(complete, N_("informative"), N_("(re app.db.complete(idx(args, 1)(), completions); for (set::const_iterator i = completions.begin(); i != completions.end(); ++i) - cout << i->inner()() << "\n"; + cout << i->inner()() << '\n'; } else if (idx(args, 0)() == "key") { @@ -191,8 +191,8 @@ CMD(complete, N_("informative"), N_("(re i != completions.end(); ++i) { cout << i->first.inner()(); - if (verbose) cout << " " << i->second(); - cout << "\n"; + if (verbose) cout << ' ' << i->second(); + cout << '\n'; } } else ============================================================ --- cmd_diff_log.cc 8daa52e0f47b4462b4f393e24d04bd98dd98e4b9 +++ cmd_diff_log.cc 6020c9e5cbc3ed6eb910d5916365db364b6b7f65 @@ -102,12 +102,12 @@ print_indented_set(ostream & os, if (cols > 8 && cols + str.size() + 1 >= max_cols) { cols = 8; - os << "\n" << " "; + os << "\n "; } - os << " " << str; + os << ' ' << str; cols += str.size() + 1; } - os << "\n"; + os << '\n'; } void @@ -116,18 +116,18 @@ changes_summary::print(ostream & os, siz if (! cs.nodes_deleted.empty()) { - os << _("Deleted entries:") << "\n"; + os << _("Deleted entries:") << '\n'; print_indented_set(os, cs.nodes_deleted, max_cols); } if (! cs.nodes_renamed.empty()) { - os << _("Renamed entries:") << "\n"; + os << _("Renamed entries:") << '\n'; for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); i++) os << " " << file_path(i->first) - << " to " << file_path(i->second) << "\n"; + << " to " << file_path(i->second) << '\n'; } if (! cs.files_added.empty()) @@ -137,13 +137,13 @@ changes_summary::print(ostream & os, siz i = cs.files_added.begin(); i != cs.files_added.end(); ++i) tmp.insert(i->first); - os << _("Added files:") << "\n"; + os << _("Added files:") << '\n'; print_indented_set(os, tmp, max_cols); } if (! cs.dirs_added.empty()) { - os << _("Added directories:") << "\n"; + os << _("Added directories:") << '\n'; print_indented_set(os, cs.dirs_added, max_cols); } @@ -154,7 +154,7 @@ changes_summary::print(ostream & os, siz i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) tmp.insert(i->first); - os << _("Modified files:") << "\n"; + os << _("Modified files:") << '\n'; print_indented_set(os, tmp, max_cols); } @@ -171,7 +171,7 @@ changes_summary::print(ostream & os, siz i != cs.attrs_set.end(); ++i) tmp.insert(i->first.first); - os << _("Modified attrs:") << "\n"; + os << _("Modified attrs:") << '\n'; print_indented_set(os, tmp, max_cols); } } @@ -237,7 +237,7 @@ dump_diffs(cset const & cs, if (limit_paths && paths.find(i->first) == paths.end()) continue; - output << patch_sep << "\n"; + output << patch_sep << '\n'; data unpacked; vector lines; @@ -284,7 +284,7 @@ dump_diffs(cset const & cs, file_data f_old; data data_old, data_new; - output << patch_sep << "\n"; + output << patch_sep << '\n'; app.db.get_file_version(delta_entry_src(i), f_old); data_old = f_old.inner(); @@ -382,7 +382,7 @@ prepare_diff(cset & included, check_restricted_cset(old_roster, included); new_is_archived = false; - header << "# old_revision [" << old_rid << "]" << "\n"; + header << "# old_revision [" << old_rid << "]\n"; } else if (app.opts.revision_selectors.size() == 1) { @@ -407,7 +407,7 @@ prepare_diff(cset & included, check_restricted_cset(old_roster, included); new_is_archived = false; - header << "# old_revision [" << r_old_id << "]" << "\n"; + header << "# old_revision [" << r_old_id << "]\n"; } else if (app.opts.revision_selectors.size() == 2) { @@ -490,19 +490,19 @@ CMD(diff, N_("informative"), N_("[PATH]. vector lines; split_into_lines(summary(), lines); - cout << "# " << "\n"; + cout << "#\n"; if (summary().size() > 0) { - cout << revs << "# " << "\n"; + cout << revs << "#\n"; for (vector::iterator i = lines.begin(); i != lines.end(); ++i) - cout << "# " << *i << "\n"; + cout << "# " << *i << '\n'; } else { - cout << "# " << _("no changes") << "\n"; + cout << "# " << _("no changes") << '\n'; } - cout << "# " << "\n"; + cout << "#\n"; if (app.opts.diff_format == external_diff) { do_external_diff(included, app, new_is_archived); @@ -560,7 +560,7 @@ log_certs(ostream & os, app_state & app, os << "\n\n"; os << tv; if (newline) - os << "\n"; + os << '\n'; first = false; } @@ -855,8 +855,8 @@ CMD(log, N_("informative"), N_("[FILE] . } else { - out << string(65, '-') << "\n"; - out << "Revision: " << rid << "\n"; + out << string(65, '-') << '\n'; + out << "Revision: " << rid << '\n'; changes_summary csum; @@ -871,7 +871,7 @@ CMD(log, N_("informative"), N_("[FILE] . for (set::const_iterator anc = ancestors.begin(); anc != ancestors.end(); ++anc) - out << "Ancestor: " << *anc << "\n"; + out << "Ancestor: " << *anc << '\n'; log_certs(out, app, rid, author_name, "Author: ", false); log_certs(out, app, rid, date_name, "Date: ", false); @@ -880,9 +880,9 @@ CMD(log, N_("informative"), N_("[FILE] . if (!app.opts.no_files && !csum.cs.empty()) { - out << "\n"; + out << '\n'; csum.print(out, 70); - out << "\n"; + out << '\n'; } log_certs(out, app, rid, changelog_name, "ChangeLog: ", true); ============================================================ --- cmd_files.cc 112a24126bea86d32a5e563a9207296bf5cba97c +++ cmd_files.cc 4e72e60135d0b3771e0cd71f594b77a060214e1c @@ -198,7 +198,7 @@ CMD(identify, N_("debug"), N_("[PATH]"), hexenc ident; calculate_ident(dat, ident); - cout << ident << "\n"; + cout << ident << '\n'; } static void ============================================================ --- cmd_key_cert.cc 2dc4128b1f916d2fdaa990f3e8d324774f52d1b3 +++ cmd_key_cert.cc 3e80a3c990efceced0f46d845dba8d8d4dae50f5 @@ -182,7 +182,7 @@ CMD(trusted, N_("key and cert"), % value % all_signers.str() % (trusted ? _("trusted") : _("UNtrusted"))) - << "\n"; // final newline is kept out of the translation + << '\n'; // final newline is kept out of the translation } CMD(tag, N_("review"), N_("REVISION TAGNAME"), ============================================================ --- cmd_list.cc 1f78175c59f892f6389f046b3e732d00085553a0 +++ cmd_list.cc 0a7d7a729f6a69eafcb274fc669afdb2b1918190 @@ -28,7 +28,6 @@ using std::cout; #include "vocab_cast.hh" using std::cout; -using std::endl; using std::make_pair; using std::map; using std::ostream_iterator; @@ -134,7 +133,7 @@ ls_certs(string const & name, app_state } if (certs.size() > 0) - cout << "\n"; + cout << '\n'; guard.commit(); } @@ -178,7 +177,7 @@ ls_keys(string const & name, app_state & if (pubkeys.size() > 0) { - cout << "\n" << "[public keys]" << "\n"; + cout << "\n[public keys]\n"; for (map::iterator i = pubkeys.begin(); i != pubkeys.end(); i++) { @@ -197,19 +196,19 @@ ls_keys(string const & name, app_state & } key_hash_code(keyid, pub_encoded, hash_code); if (indb) - cout << hash_code << " " << keyid << "\n"; + cout << hash_code << ' ' << keyid << '\n'; else - cout << hash_code << " " << keyid << " (*)" << "\n"; + cout << hash_code << ' ' << keyid << " (*)\n"; } if (!all_in_db) cout << (F("(*) - only in %s/") - % app.keys.get_key_dir()) << "\n"; - cout << "\n"; + % app.keys.get_key_dir()) << '\n'; + cout << '\n'; } if (privkeys.size() > 0) { - cout << "\n" << "[private keys]" << "\n"; + cout << "\n[private keys]\n"; for (vector::iterator i = privkeys.begin(); i != privkeys.end(); i++) { @@ -217,9 +216,9 @@ ls_keys(string const & name, app_state & hexenc hash_code; app.keys.get_key_pair(*i, kp); key_hash_code(*i, kp.priv, hash_code); - cout << hash_code << " " << *i << "\n"; + cout << hash_code << ' ' << *i << '\n'; } - cout << "\n"; + cout << '\n'; } if (pubkeys.size() == 0 && @@ -253,7 +252,7 @@ ls_branches(string name, app_state & app { if (match((*i)()) && !app.lua.hook_ignore_branch(*i)) { - cout << *i << "\n"; + cout << *i << '\n'; } } } @@ -270,7 +269,7 @@ ls_epochs(string name, app_state & app, i = epochs.begin(); i != epochs.end(); ++i) { - cout << i->second << " " << i->first << "\n"; + cout << i->second << ' ' << i->first << '\n'; } } else @@ -281,7 +280,7 @@ ls_epochs(string name, app_state & app, { map::const_iterator j = epochs.find(branch_name((*i)())); N(j != epochs.end(), F("no epoch for branch %s") % *i); - cout << j->second << " " << j->first << "\n"; + cout << j->second << ' ' << j->first << '\n'; } } } @@ -294,9 +293,9 @@ ls_tags(string name, app_state & app, ve for (set::const_iterator i = tags.begin(); i != tags.end(); ++i) { - cout << i->name << " " - << i->ident << " " - << i->key << "\n"; + cout << i->name << ' ' + << i->ident << ' ' + << i->key << '\n'; } } @@ -327,8 +326,8 @@ ls_vars(string name, app_state & app, ve external ext_domain, ext_name; externalize_var_domain(i->first.first, ext_domain); cout << ext_domain << ": " - << i->first.second << " " - << i->second << "\n"; + << i->first.second << ' ' + << i->second << '\n'; } } @@ -368,7 +367,7 @@ ls_known(app_state & app, vector c for (vector::const_iterator sp = print_paths.begin(); sp != print_paths.end(); sp++) { - cout << *sp << "\n"; + cout << *sp << '\n'; } } @@ -392,11 +391,11 @@ ls_unknown_or_ignored(app_state & app, b if (want_ignored) for (path_set::const_iterator i = ignored.begin(); i != ignored.end(); ++i) - cout << file_path(*i) << "\n"; + cout << file_path(*i) << '\n'; else for (path_set::const_iterator i = unknown.begin(); i != unknown.end(); ++i) - cout << file_path(*i) << "\n"; + cout << file_path(*i) << '\n'; } static void @@ -416,7 +415,7 @@ ls_missing(app_state & app, vector for (path_set::const_iterator i = missing.begin(); i != missing.end(); ++i) { - cout << file_path(*i) << "\n"; + cout << file_path(*i) << '\n'; } } @@ -470,7 +469,7 @@ ls_changed(app_state & app, vector for (set::const_iterator sp = print_paths.begin(); sp != print_paths.end(); sp++) { - cout << *sp << endl; + cout << *sp << '\n'; } } ============================================================ --- cmd_merging.cc 9ab60698531667923015ebaa59b536c18de3350f +++ cmd_merging.cc 5ce276748daf5e39207f2688526d45cb4afd1e53 @@ -948,7 +948,7 @@ CMD(heads, N_("tree"), "", N_("show unme for (set::const_iterator i = heads.begin(); i != heads.end(); ++i) - cout << describe_revision(app, *i) << "\n"; + cout << describe_revision(app, *i) << '\n'; } CMD(get_roster, N_("debug"), N_("[REVID]"), ============================================================ --- cmd_netsync.cc f0a73af0909b03372b8c96bad5647e3bddff17ac +++ cmd_netsync.cc e027393bafb3487042dd155f84efb88ed5b041b6 @@ -169,7 +169,7 @@ struct pid_file require_path_is_nonexistent(path, F("pid file '%s' already exists") % path); file.open(path.as_external().c_str()); E(file.is_open(), F("failed to create pid file '%s'") % path); - file << get_process_id() << "\n"; + file << get_process_id() << '\n'; file.flush(); } ============================================================ --- cmd_ws_commit.cc a81d478bf4c7ef569dd8ae9ccc4d745772005eae +++ cmd_ws_commit.cc 575f7684d42ae851eb4565051c7bc000354ed023 @@ -435,40 +435,40 @@ CMD(status, N_("informative"), N_("[PATH // We intentionally do not collapse the final \n into the format // strings here, for consistency with newline conventions used by most // other format strings. - cout << (F("Current branch: %s") % app.opts.branchname).str() << "\n"; + cout << (F("Current branch: %s") % app.opts.branchname).str() << '\n'; for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); ++i) { revision_id parent = edge_old_revision(*i); // A colon at the end of this string looked nicer, but it made // double-click copying from terminals annoying. - cout << (F("Changes against parent %s") % parent).str() << "\n"; + cout << (F("Changes against parent %s") % parent).str() << '\n'; cset const & cs = edge_changes(*i); if (cs.empty()) - cout << F(" no changes").str() << "\n"; + cout << F(" no changes").str() << '\n'; for (path_set::const_iterator i = cs.nodes_deleted.begin(); i != cs.nodes_deleted.end(); ++i) - cout << (F(" dropped %s") % *i).str() << "\n"; + cout << (F(" dropped %s") % *i).str() << '\n'; for (map::const_iterator i = cs.nodes_renamed.begin(); i != cs.nodes_renamed.end(); ++i) cout << (F(" renamed %s\n" - " to %s") % i->first % i->second).str() << "\n"; + " to %s") % i->first % i->second).str() << '\n'; for (path_set::const_iterator i = cs.dirs_added.begin(); i != cs.dirs_added.end(); ++i) - cout << (F(" added %s") % *i).str() << "\n"; + cout << (F(" added %s") % *i).str() << '\n'; for (map::const_iterator i = cs.files_added.begin(); i != cs.files_added.end(); ++i) - cout << (F(" added %s") % i->first).str() << "\n"; + cout << (F(" added %s") % i->first).str() << '\n'; for (map >::const_iterator i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i) - cout << (F(" patched %s") % (i->first)).str() << "\n"; + cout << (F(" patched %s") % (i->first)).str() << '\n'; } } @@ -653,12 +653,12 @@ CMD(attr, N_("workspace"), N_("set PATH if (i->second.first) { cout << path << " : " - << i->first << "=" - << i->second.second << "\n"; + << i->first << '=' + << i->second.second << '\n'; has_any_live_attrs = true; } if (!has_any_live_attrs) - cout << F("No attributes for '%s'") % path << "\n"; + cout << F("No attributes for '%s'") % path << '\n'; } else if (args.size() == 3) { @@ -666,11 +666,11 @@ CMD(attr, N_("workspace"), N_("set PATH full_attr_map_t::const_iterator i = node->attrs.find(a_key); if (i != node->attrs.end() && i->second.first) cout << path << " : " - << i->first << "=" - << i->second.second << "\n"; + << i->first << '=' + << i->second.second << '\n'; else cout << (F("No attribute '%s' on path '%s'") - % a_key % path) << "\n"; + % a_key % path) << '\n'; } else throw usage(name); ============================================================ --- commands.cc ccae8a0a37eb7eceab3cd4586e22e3660ddef9ee +++ commands.cc 15a40992593942e0a8610be9edd311422903fae4 @@ -104,7 +104,6 @@ namespace commands namespace commands { - using std::endl; using std::greater; using std::ostream; @@ -171,17 +170,17 @@ namespace commands split_into_lines(params, lines); for (vector::const_iterator j = lines.begin(); j != lines.end(); ++j) - out << " " << i->second->name << " " << *j << endl; + out << " " << i->second->name << ' ' << *j << '\n'; split_into_lines(i->second->desc(), lines); for (vector::const_iterator j = lines.begin(); j != lines.end(); ++j) - out << " " << *j << endl; - out << endl; + out << " " << *j << '\n'; + out << '\n'; return; } vector sorted; - out << _("commands:") << endl; + out << _("commands:") << '\n'; for (i = (*cmds).begin(); i != (*cmds).end(); ++i) { if (i->second->cmdgroup != hidden_group()) @@ -204,23 +203,23 @@ namespace commands if (idx(sorted, i)->cmdgroup != curr_group) { curr_group = idx(sorted, i)->cmdgroup; - out << endl; + out << '\n'; out << " " << safe_gettext(idx(sorted, i)->cmdgroup.c_str()); col = display_width(utf8(safe_gettext(idx(sorted, i)->cmdgroup.c_str()))) + 2; while (col++ < (col2 + 3)) out << ' '; } - out << " " << idx(sorted, i)->name; + out << ' ' << idx(sorted, i)->name; col += idx(sorted, i)->name.size() + 1; if (col >= 70) { - out << endl; + out << '\n'; col = 0; while (col++ < (col2 + 3)) out << ' '; } } - out << endl << endl; + out << "\n\n"; } int process(app_state & app, string const & cmd, vector const & args) ============================================================ --- contrib/usher.cc a85a96788684cdf4761de0c268444c31cca161d2 +++ contrib/usher.cc 6ebc1e6b5d4b44e048dc3a9b3ec788d522b43b62 @@ -715,8 +715,7 @@ struct server for (vector::const_iterator i = h.begin(); i != h.end(); ++i) { c = servers_by_host.find(*i); if (c != servers_by_host.end()) { - cerr << "Removing duplicate for hostname " << *i << " in:" << std::endl - << " "; + cerr << "Removing duplicate for hostname " << *i << " in:\n " list >::iterator>::iterator j; bool first = true; for (j = c->second->by_host.begin(); j != c->second->by_host.end();) @@ -732,8 +731,7 @@ struct server c->second->by_host.erase(j_saved); } } - cerr << std::endl - << " ... because it appeared in " << by_name->first << std::endl; + cerr << "\n ... because it appeared in " << by_name->first << '\n'; } c = servers_by_host.insert(make_pair(*i, me)).first; by_host.push_back(c); @@ -750,8 +748,7 @@ struct server for (vector::const_iterator i = p.begin(); i != p.end(); ++i) { c = servers_by_pattern.find(*i); if (c != servers_by_pattern.end()) { - cerr << "Removing duplicate for pattern " << *i << " in: " << std::endl - << " "; + cerr << "Removing duplicate for pattern " << *i << " in:\n "; list >::iterator>::iterator j; bool first = true; for (j = c->second->by_pat.begin(); j != c->second->by_pat.end(); ++j) @@ -767,8 +764,7 @@ struct server c->second->by_pat.erase(j_saved); } } - cerr << std::endl - << " ... because it appeared in " << by_name->first << std::endl; + cerr << "\n ... because it appeared in " << by_name->first << '\n'; } c = servers_by_pattern.insert(make_pair(*i, me)).first; by_pat.push_back(c); @@ -908,8 +904,7 @@ string read_server_record(std::istream & else if (cmd == "pattern") patterns.push_back(arg); else - cerr << "Unrecognised directive " << cmd << ", skipping line..." - << std::endl; + cerr << "Unrecognised directive " << cmd << ", skipping line...\n"; line = getline(in); } @@ -1209,8 +1204,7 @@ void reload_conffile(string const & file logdir = b; } else - cerr << "Unrecognised directive " << a << ", skipping line..." - << std::endl; + cerr << "Unrecognised directive " << a << ", skipping line...\n"; line = getline(cf); } ============================================================ --- database.cc 3e65a0b3f6e71edd464d6dc18e8ac46652a44cb1 +++ database.cc c2569141900f0620bef8e7b85965e9ffcffbf018 @@ -54,7 +54,6 @@ using std::deque; // see file schema.sql for the text of the schema. using std::deque; -using std::endl; using std::istream; using std::ifstream; using std::make_pair; @@ -291,7 +290,7 @@ dump_row(ostream &out, sqlite3_stmt *stm const char *val = (const char*) sqlite3_column_blob(stmt, i); int bytes = sqlite3_column_bytes(stmt, i); out << encode_hexenc(string(val,val+bytes)); - out << "'"; + out << '\''; } else { @@ -300,7 +299,7 @@ dump_row(ostream &out, sqlite3_stmt *stm out << "NULL"; else { - out << "'"; + out << '\''; for (const unsigned char *cp = val; *cp; ++cp) { if (*cp == '\'') @@ -308,7 +307,7 @@ dump_row(ostream &out, sqlite3_stmt *stm else out << *cp; } - out << "'"; + out << '\''; } } } @@ -448,7 +447,7 @@ database::debug(string const & sql, ostr results res; fetch(res, any_cols, any_rows, query(sql)); - out << "'" << sql << "' -> " << res.size() << " rows\n" << endl; + out << '\'' << sql << "' -> " << res.size() << " rows\n\n"; for (size_t i = 0; i < res.size(); ++i) { for (size_t j = 0; j < res[i].size(); ++j) @@ -457,7 +456,7 @@ database::debug(string const & sql, ostr out << " | "; out << res[i][j]; } - out << endl; + out << '\n'; } } @@ -656,7 +655,7 @@ database::info(ostream & out) form = form % page_size(); form = form % cache_size(); - out << form.str() << "\n"; // final newline is kept out of the translation + out << form.str() << '\n'; // final newline is kept out of the translation } void @@ -664,7 +663,7 @@ database::version(ostream & out) { ensure_open_for_maintenance(); out << (F("database schema version: %s") % describe_sql_schema(__sql)).str() - << "\n"; + << '\n'; } void ============================================================ --- diff_patch.cc 05abac4db33a6942b39833e2f75c3dacb3222250 +++ diff_patch.cc 06a1fcb53473c9cf684b41e162a3774f72668ac0 @@ -32,7 +32,6 @@ #include "constants.hh" #include "file_io.hh" -using std::endl; using std::make_pair; using std::map; using std::min; @@ -378,7 +377,7 @@ void merge_via_edit_scripts(vector 1) - ost << "," << a_len; + ost << ',' << a_len; } if (b_len == 0) @@ -960,7 +959,7 @@ void unidiff_hunk_writer::flush_hunk(siz { ost << " +" << b_begin+1; if (b_len > 1) - ost << "," << b_len; + ost << ',' << b_len; } { @@ -975,7 +974,7 @@ void unidiff_hunk_writer::flush_hunk(siz } find_encloser(a_begin + first_mod, encloser); - ost << " @@" << encloser << endl; + ost << " @@" << encloser << '\n'; } copy(hunk.begin(), hunk.end(), ostream_iterator(ost, "\n")); } @@ -1111,14 +1110,14 @@ void cxtdiff_hunk_writer::flush_hunk(siz find_encloser(a_begin + min(first_insert, first_delete), encloser); - ost << "***************" << encloser << endl; + ost << "***************" << encloser << '\n'; } - ost << "*** " << (a_begin + 1) << "," << (a_begin + a_len) << " ****" << endl; + ost << "*** " << (a_begin + 1) << ',' << (a_begin + a_len) << " ****\n"; if (have_deletions) copy(from_file.begin(), from_file.end(), ostream_iterator(ost, "\n")); - ost << "--- " << (b_begin + 1) << "," << (b_begin + b_len) << " ----" << endl; + ost << "--- " << (b_begin + 1) << ',' << (b_begin + b_len) << " ----\n"; if (have_insertions) copy(to_file.begin(), to_file.end(), ostream_iterator(ost, "\n")); } @@ -1317,8 +1316,8 @@ make_diff(string const & filename1, { case unified_diff: { - ost << "--- " << filename1 << "\t" << id1 << endl; - ost << "+++ " << filename2 << "\t" << id2 << endl; + ost << "--- " << filename1 << '\t' << id1 << '\n'; + ost << "+++ " << filename2 << '\t' << id2 << '\n'; unidiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern); walk_hunk_consumer(lcs, left_interned, right_interned, hunks); @@ -1326,8 +1325,8 @@ make_diff(string const & filename1, } case context_diff: { - ost << "*** " << filename1 << "\t" << id1 << endl; - ost << "--- " << filename2 << "\t" << id2 << endl; + ost << "*** " << filename1 << '\t' << id1 << '\n'; + ost << "--- " << filename2 << '\t' << id2 << '\n'; cxtdiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern); walk_hunk_consumer(lcs, left_interned, right_interned, hunks); @@ -1366,16 +1365,16 @@ static void dump_incorrect_merge(vector< cerr << "bad merge: " << i << " [" << prefix << "]\t"; if (i < expected.size()) - cerr << "[" << expected[i] << "]\t"; + cerr << '[' << expected[i] << "]\t"; else cerr << "[--nil--]\t"; if (i < got.size()) - cerr << "[" << got[i] << "]\t"; + cerr << '[' << got[i] << "]\t"; else cerr << "[--nil--]\t"; - cerr << endl; + cerr << '\n'; } } ============================================================ --- keys.cc 0da3d3d300eb96edc50758f49b8383fc8fb18f8d +++ keys.cc 6acd8d3bff1299cb4b96e227f448fc0bfe29d7ba @@ -35,7 +35,6 @@ using std::cout; #include "charset.hh" using std::cout; -using std::endl; using std::make_pair; using std::map; using std::string; @@ -112,7 +111,6 @@ get_passphrase(lua_hooks & lua, ui.ensure_clean_line(); read_password(prompt_beginning + " for key ID [" + keyid() + "]: ", pass1, constants::maxpasswd); - cout << endl; if (strlen(pass1) == 0) { P(F("empty passphrase not allowed")); @@ -124,7 +122,6 @@ get_passphrase(lua_hooks & lua, ui.ensure_clean_line(); read_password((F("confirm passphrase for key ID [%s]: ") % keyid()).str(), pass2, constants::maxpasswd); - cout << endl; if (strlen(pass1) == 0 || strlen(pass2) == 0) { P(F("empty passphrases not allowed, try again")); ============================================================ --- monotone.cc 78453eea6f4d8796e0c0a181d6a8a91f1e0b8248 +++ monotone.cc 160073e2d0ac102d57db3e761f89ff10b5bfac5d @@ -39,7 +39,6 @@ using std::cerr; using std::cout; using std::cerr; -using std::endl; using std::string; using std::ios_base; using std::ostringstream; @@ -271,7 +270,7 @@ cpp_main(int argc, char ** argv) std::ostream & usage_stream = (app.opts.help ? cout : cerr); usage_stream << F("Usage: %s [OPTION...] command [ARG...]") % ui.prog_name << "\n\n"; - usage_stream << options::opts::globals().instantiate(&app.opts).get_usage_str() << "\n"; + usage_stream << options::opts::globals().instantiate(&app.opts).get_usage_str() << '\n'; // Make sure to hide documentation that's not part of // the current command. @@ -279,7 +278,7 @@ cpp_main(int argc, char ** argv) if (!cmd_options.empty()) { usage_stream << F("Options specific to '%s %s':") % ui.prog_name % u.which << "\n\n"; - usage_stream << cmd_options.instantiate(&app.opts).get_usage_str() << "\n"; + usage_stream << cmd_options.instantiate(&app.opts).get_usage_str() << '\n'; } commands::explain_usage(u.which, usage_stream); ============================================================ --- mt_version.cc ef1f68f30cba797cca4116a3f7e0a564ece59501 +++ mt_version.cc a146b93aa0550b024bf41bbb4f0fcd1b8378a57d @@ -26,7 +26,6 @@ using std::cout; #include "sanity.hh" using std::cout; -using std::endl; using std::ostringstream; using std::string; @@ -42,7 +41,7 @@ print_version() { string s; get_version(s); - cout << s << endl; + cout << s << '\n'; } void @@ -51,7 +50,7 @@ get_full_version(string & out) ostringstream oss; string s; get_version(s); - oss << s << "\n"; + oss << s << '\n'; get_system_flavour(s); oss << F("Running on : %s\n" "C++ compiler : %s\n" @@ -72,7 +71,7 @@ print_full_version() { string s; get_full_version(s); - cout << s << endl; + cout << s << '\n'; } // Local Variables: ============================================================ --- packet.cc 878c9142ecd2955dc1fd5c4a7fca4baff910db85 +++ packet.cc 1dd3e1b56ecdb676fc5bff8b948d3ccf79ad5900 @@ -23,7 +23,6 @@ #include "keys.hh" #include "cert.hh" -using std::endl; using std::istream; using std::make_pair; using std::map; @@ -264,9 +263,9 @@ packet_writer::consume_file_data(file_id { base64 > packed; pack(dat.inner(), packed); - ost << "[fdata " << ident.inner()() << "]" << endl - << trim_ws(packed()) << endl - << "[end]" << endl; + ost << "[fdata " << ident.inner()() << "]\n" + << trim_ws(packed()) << '\n' + << "[end]\n"; } void @@ -276,10 +275,10 @@ packet_writer::consume_file_delta(file_i { base64 > packed; pack(del.inner(), packed); - ost << "[fdelta " << old_id.inner()() << endl - << " " << new_id.inner()() << "]" << endl - << trim_ws(packed()) << endl - << "[end]" << endl; + ost << "[fdelta " << old_id.inner()() << '\n' + << " " << new_id.inner()() << "]\n" + << trim_ws(packed()) << '\n' + << "[end]\n"; } void @@ -288,38 +287,38 @@ packet_writer::consume_revision_data(rev { base64 > packed; pack(dat.inner(), packed); - ost << "[rdata " << ident.inner()() << "]" << endl - << trim_ws(packed()) << endl - << "[end]" << endl; + ost << "[rdata " << ident.inner()() << "]\n" + << trim_ws(packed()) << '\n' + << "[end]\n"; } void packet_writer::consume_revision_cert(revision const & t) { - ost << "[rcert " << t.inner().ident() << endl - << " " << t.inner().name() << endl - << " " << t.inner().key() << endl - << " " << trim_ws(t.inner().value()) << "]" << endl - << trim_ws(t.inner().sig()) << endl - << "[end]" << endl; + ost << "[rcert " << t.inner().ident() << '\n' + << " " << t.inner().name() << '\n' + << " " << t.inner().key() << '\n' + << " " << trim_ws(t.inner().value()) << "]\n" + << trim_ws(t.inner().sig()) << '\n' + << "[end]\n"; } void packet_writer::consume_public_key(rsa_keypair_id const & ident, base64< rsa_pub_key > const & k) { - ost << "[pubkey " << ident() << "]" << endl - << trim_ws(k()) << endl - << "[end]" << endl; + ost << "[pubkey " << ident() << "]\n" + << trim_ws(k()) << '\n' + << "[end]\n"; } void packet_writer::consume_key_pair(rsa_keypair_id const & ident, keypair const & kp) { - ost << "[keypair " << ident() << "]" << endl - << trim_ws(kp.pub()) <<"#\n" <first << "\n"; + oss << "roster: " << i->first << '\n'; string roster_str, indented_roster_str; dump(*i->second.first, roster_str); prefix_lines_with(" ", roster_str, indented_roster_str); ============================================================ --- roster.cc c43672f75a5b86fc334bf008b9a99db6db8bbfbf +++ roster.cc f62b03b41fa5286a94947a3bebc17ac9b83774cb @@ -53,7 +53,7 @@ dump(full_attr_map_t const & val, string ostringstream oss; for (full_attr_map_t::const_iterator i = val.begin(); i != val.end(); ++i) oss << "attr key: '" << i->first << "'\n" - << " status: " << (i->second.first ? "live" : "dead") << "\n" + << " status: " << (i->second.first ? "live" : "dead") << '\n' << " value: '" << i->second.second << "'\n"; out = oss.str(); } @@ -78,17 +78,17 @@ dump(marking_t const & marking, string & { ostringstream oss; string tmp; - oss << "birth_revision: " << marking.birth_revision << "\n"; + oss << "birth_revision: " << marking.birth_revision << '\n'; dump(marking.parent_name, tmp); - oss << "parent_name: " << tmp << "\n"; + oss << "parent_name: " << tmp << '\n'; dump(marking.file_content, tmp); - oss << "file_content: " << tmp << "\n"; + oss << "file_content: " << tmp << '\n'; oss << "attrs (number: " << marking.attrs.size() << "):\n"; for (map >::const_iterator i = marking.attrs.begin(); i != marking.attrs.end(); ++i) { dump(i->second, tmp); - oss << " " << i->first << ": " << tmp << "\n"; + oss << " " << i->first << ": " << tmp << '\n'; } out = oss.str(); } @@ -105,7 +105,7 @@ dump(marking_map const & markings, strin string marking_str, indented_marking_str; dump(i->second, marking_str); prefix_lines_with(" ", marking_str, indented_marking_str); - oss << indented_marking_str << "\n"; + oss << indented_marking_str << '\n'; } out = oss.str(); } @@ -253,25 +253,25 @@ dump(node_t const & n, string & out) string name; dump(n->name, name); oss << "address: " << n << " (uses: " << n.use_count() << ")\n" - << "self: " << n->self << "\n" - << "parent: " << n->parent << "\n" - << "name: " << name << "\n"; + << "self: " << n->self << '\n' + << "parent: " << n->parent << '\n' + << "name: " << name << '\n'; string attr_map_s; dump(n->attrs, attr_map_s); oss << "attrs:\n" << attr_map_s; oss << "type: "; if (is_file_t(n)) oss << "file\n" - << "content: " << downcast_to_file_t(n)->content << "\n"; + << "content: " << downcast_to_file_t(n)->content << '\n'; else { oss << "dir\n"; dir_map const & c = downcast_to_dir_t(n)->children; - oss << "children: " << c.size() << "\n"; + oss << "children: " << c.size() << '\n'; for (dir_map::const_iterator i = c.begin(); i != c.end(); ++i) { dump(i->first, name); - oss << " " << name << " -> " << i->second << "\n"; + oss << " " << name << " -> " << i->second << '\n'; } } out = oss.str(); @@ -900,13 +900,13 @@ dump(roster_t const & val, string & out) { ostringstream oss; if (val.root_dir) - oss << "Root node: " << val.root_dir->self << "\n" - << " at " << val.root_dir << ", uses: " << val.root_dir.use_count() << "\n"; + oss << "Root node: " << val.root_dir->self << '\n' + << " at " << val.root_dir << ", uses: " << val.root_dir.use_count() << '\n'; else oss << "root dir is NULL\n"; for (node_map::const_iterator i = val.nodes.begin(); i != val.nodes.end(); ++i) { - oss << "\nNode " << i->first << "\n"; + oss << "\nNode " << i->first << '\n'; string node_s; dump(i->second, node_s); oss << node_s; @@ -3462,9 +3462,9 @@ namespace virtual void dump(string & out) const { ostringstream oss; - oss << "type: " << my_type() << "\n" - << "root_nid: " << root_nid << "\n" - << "obj_under_test_nid: " << obj_under_test_nid << "\n"; + oss << "type: " << my_type() << '\n' + << "root_nid: " << root_nid << '\n' + << "obj_under_test_nid: " << obj_under_test_nid << '\n'; out = oss.str(); } }; ============================================================ --- sanity.cc 9fd3709f9f2dd5417339d9fb966577618ad63123 +++ sanity.cc 8c2cb1ec66d4342731bb79f536f50fec2a9c9eca @@ -64,7 +64,7 @@ sanity::initialize(int argc, char ** arg { if (i) cmdline_ss << ", "; - cmdline_ss << "'" << argv[i] << "'"; + cmdline_ss << '\'' << argv[i] << '\''; } cmdline_string = cmdline_ss.str(); } @@ -271,7 +271,7 @@ sanity::gasp() L(FL("saving current work set: %i items") % musings.size()); ostringstream out; out << (F("Current work set: %i items") % musings.size()) - << "\n"; // final newline is kept out of the translation + << '\n'; // final newline is kept out of the translation for (vector::const_iterator i = musings.begin(); i != musings.end(); ++i) { @@ -332,9 +332,8 @@ print_var(std::string const & value, cha std::cout << (FL("----- begin '%s' (in %s, at %s:%d)\n") % var % func % file % line) << value - << (FL("\n----- end '%s' (in %s, at %s:%d)\n") - % var % func % file % line) - << std::endl; + << (FL("\n----- end '%s' (in %s, at %s:%d)\n\n") + % var % func % file % line); } void MusingBase::gasp_head(string & out) const ============================================================ --- simplestring_xform.cc 97d9d76e5a162bafbe2dd9517e1fbbb17cf562e2 +++ simplestring_xform.cc 4d9df66d29c1e2b1ec4ef1717b271de71fd3d941 @@ -134,7 +134,7 @@ prefix_lines_with(string const & prefix, oss << prefix << *i; i++; if (i != msgs.end()) - oss << "\n"; + oss << '\n'; } out = oss.str(); ============================================================ --- tests/diff_against_empty_file/expected.diff 07a262d6f3b512e3c40c6c3f012b1218c753ba72 +++ tests/diff_against_empty_file/expected.diff 4bd7f5ef4ef0e7ef33ee6995cb9b37e14385c918 @@ -1,10 +1,10 @@ -# +# # old_revision [010297e01bc32090e5a7de8f5bd1c4c69d72f532] -# +# # patch "foo" # from [83f5a5c359f3dc8317519240e32f1f51f68bc051] # to [da39a3ee5e6b4b0d3255bfef95601890afd80709] -# +# ============================================================ --- foo 83f5a5c359f3dc8317519240e32f1f51f68bc051 +++ foo da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- txt2c.cc d951820558e77aa3f2ea48ebf7cbfa18728436aa +++ txt2c.cc b53f05ddac34b55e53343efc612c572d9e861b37 @@ -1,25 +1,26 @@ #include #include #include +#include +#include using std::cerr; using std::cout; -using std::endl; using std::ifstream; using std::string; -using std::exit; +using std::strerror; int main(int argc, char **argv) { if (argc < 3 || argc > 5) { - cerr << "usage: " << argv[0] << " [--strip-trailing] [--no-static] " << endl; - exit(1); + cerr << "usage: " << argv[0] + << " [--strip-trailing] [--no-static] \n"; + return 1; } bool do_strip_trailing = false; - bool do_static = false; - string static_decl("static "); + char const * static_decl = "static "; int i = 1; if (string(argv[i]) == "--strip-trailing") { @@ -28,17 +29,19 @@ int main(int argc, char **argv) } if (string(argv[i]) == "--no-static") { - do_static = true; static_decl = ""; i++; } - ifstream fin(argv[i++]); - string arr(argv[i++]); - + char const * fname = argv[i++]; + char const * arr = argv[i++]; + + ifstream fin(fname); if (!fin) { - cerr << "could not open " << argv[1] << " for reading" << endl; - exit(1); + int e = errno; + cerr << "could not open " << fname << " for reading: " + << strerror(e) << '\n'; + return 1; } char c; @@ -53,7 +56,7 @@ int main(int argc, char **argv) } cout << "// DO NOT EDIT\n" - << "// this file is automatically generated from " << argv[1 + do_strip_trailing + do_static] << ",\n" + << "// this file is automatically generated from " << fname << ",\n" << "// any changes you make will be destroyed when it is regenerated\n" << "\n\n" << static_decl @@ -61,8 +64,8 @@ int main(int argc, char **argv) for (unsigned int i = 0; i < dat.size(); ++i) { - if (i == 0) cout << "\t"; - else if (i % 20 == 0) cout << "\n\t"; + if (i == 0) cout << '\t'; + else if (i % 14 == 0) cout << "\n\t"; cout << static_cast(dat[i]) << ", "; } cout << "0\n};\n"; ============================================================ --- ui.cc f1bb749951aa4f9b75298f15d70b28ca98b217fd +++ ui.cc 21bba61b39d2178a31aa97437d0b60688003ff42 @@ -295,7 +295,7 @@ void tick_write_count::write_ticks() if(write_tickline1) { if (ui.last_write_was_a_tick) - clog << "\n"; + clog << '\n'; if (tw && display_width(utf8(tickline1)) > tw) { @@ -303,7 +303,7 @@ void tick_write_count::write_ticks() // bytes, not by characters) tickline1.resize(tw); } - clog << tickline1 << "\n"; + clog << tickline1 << '\n'; } if (tw && display_width(utf8(tickline2)) > tw) { @@ -311,7 +311,7 @@ void tick_write_count::write_ticks() // bytes, not by characters) tickline2.resize(tw); } - clog << "\r" << tickline2; + clog << '\r' << tickline2; clog.flush(); } @@ -588,8 +588,7 @@ user_interface::inform(string const & li string prefixedLine; prefix_lines_with(output_prefix(), line, prefixedLine); ensure_clean_line(); - clog << sanitize(prefixedLine) << endl; - clog.flush(); + clog << sanitize(prefixedLine) << endl; // flushes } unsigned int ============================================================ --- unit_tests.cc 430d859a43e8c858d85b962dd50a2acac80abee4 +++ unit_tests.cc 479c8975ba1b505e2f0d8d83a3ed54cd6bdfb126 @@ -35,7 +35,6 @@ using std::clog; using std::cout; using std::cerr; using std::clog; -using std::endl; using std::exit; using std::atexit; using boost::unit_test::test_suite; @@ -67,7 +66,7 @@ static void notifier(string const & grou // per-test-group level. static void notifier(string const & group) { - cerr << group << "..." << endl; + cerr << group << "...\n"; } // A teebuf implements the basic_streambuf interface and forwards all @@ -172,21 +171,20 @@ test_suite * init_unit_test_suite(int ar if (help) { cout << (FL("Usage: %s [options] [tests]\nOptions") % argv[0]) - << os.get_usage_str() << endl; + << os.get_usage_str() << '\n'; exit(0); } } catch (option::option_error const & e) { - cerr << argv[0] << ": " << e.what() << endl; + cerr << argv[0] << ": " << e.what() << '\n'; exit(2); } if (list_groups && list_tests) { cerr << argv[0] - << ": only one of --list-groups and --list-tests at a time" - << endl; + << ": only one of --list-groups and --list-tests at a time\n"; exit(2); } @@ -198,7 +196,7 @@ test_suite * init_unit_test_suite(int ar i++) if (last != (*i).first) { - cout << (*i).first << "\n"; + cout << (*i).first << '\n'; last = (*i).first; } exit(0); @@ -209,7 +207,7 @@ test_suite * init_unit_test_suite(int ar for (unit_test_list_t::const_iterator i = unit_tests->begin(); i != unit_tests->end(); i++) - cout << (*i).first << ':' << (*i).second->p_name.get() << "\n"; + cout << (*i).first << ':' << (*i).second->p_name.get() << '\n'; exit(0); } @@ -259,7 +257,8 @@ test_suite * init_unit_test_suite(int ar if (range.first == range.second) { unrecognized = true; - cerr << argv[0] << ": unrecognized test group: " << group << endl; + cerr << argv[0] << ": unrecognized test group: " + << group << '\n'; continue; } @@ -279,7 +278,7 @@ test_suite * init_unit_test_suite(int ar { unrecognized = true; cerr << argv[0] << ": unrecognized test: " - << group << ':' << test << endl; + << group << ':' << test << '\n'; } } @@ -308,7 +307,7 @@ test_suite * init_unit_test_suite(int ar { char const * syserr = std::strerror(errno); cerr << argv[0] << ": failed to open " << logname - << ": " << syserr << endl; + << ": " << syserr << '\n'; exit(1); } clog.rdbuf(logbuf); @@ -324,8 +323,7 @@ test_suite * init_unit_test_suite(int ar if (!log.empty()) { cerr << argv[0] - << ": only one of --debug and --log at a time" - << endl; + << ": only one of --debug and --log at a time\n"; exit(2); } ============================================================ --- unix/read_password.cc 1400281952dcc743e0b1a047958aa6fe368bfdff +++ unix/read_password.cc 800251ef5cdc0a0786e39c37e254dcc830fea6ba @@ -37,6 +37,7 @@ read_password(std::string const & prompt std::cout.flush(); echo_off(save_term); std::cin.getline(buf, bufsz, '\n'); + std::cout << std::endl; echo_on(save_term); } ============================================================ --- win32/read_password.cc 2c7195f1b01fa1176ae2342761af3e8baac031ce +++ win32/read_password.cc 7d985a945f4b6fa3ba0cfc50bb4492ab457a4149 @@ -43,6 +43,7 @@ read_password(std::string const & prompt { I(SetConsoleMode(mt_stdin, pwmode) != 0); std::cin.getline(buf, bufsz, '\n'); + std::cout << std::endl; I(SetConsoleMode(mt_stdin, origmode) != 0); } else @@ -50,7 +51,7 @@ read_password(std::string const & prompt std::cout << "\x1B\x37\x1B[30;40m"; std::cout.flush(); fgets(buf, bufsz, stdin); /* Sorry, but cin.getline just doesn't work under MinGW's rxvt */ - std::cout << "\x1B[0m\x1B\x38"; + std::cout << "\x1B[0m\x1B\x38\n"; std::cout.flush(); /* ...and fgets gives us an LF we don't want */