simplify append_yaml_to_buffer

This commit is contained in:
Aaron Gyes 2019-03-13 13:52:11 -07:00
parent b879a2650c
commit f0998fed6a

View file

@ -608,17 +608,13 @@ static void append_yaml_to_buffer(const wcstring &wcmd, time_t timestamp,
std::string cmd = wcs2string(wcmd); std::string cmd = wcs2string(wcmd);
escape_yaml(&cmd); escape_yaml(&cmd);
buffer->append("- cmd: ", cmd.c_str(), "\n"); buffer->append("- cmd: ", cmd.c_str(), "\n");
buffer->append(" when: ", std::to_string(timestamp).c_str(), "\n");
char timestamp_str[96];
snprintf(timestamp_str, sizeof timestamp_str, "%ld", (long)timestamp);
buffer->append(" when: ", timestamp_str, "\n");
if (!required_paths.empty()) { if (!required_paths.empty()) {
buffer->append(" paths:\n"); buffer->append(" paths:\n");
for (path_list_t::const_iterator iter = required_paths.begin(); for (auto const &wpath : required_paths) {
iter != required_paths.end(); ++iter) { std::string path = wcs2string(wpath);
std::string path = wcs2string(*iter);
escape_yaml(&path); escape_yaml(&path);
buffer->append(" - ", path.c_str(), "\n"); buffer->append(" - ", path.c_str(), "\n");
} }