fix(bspwm): Handle single char prefix clash

This commit is contained in:
Michael Carlberg 2016-12-22 02:16:24 +01:00
parent e9d88d3173
commit d9de16e888

View File

@ -151,20 +151,17 @@ namespace modules {
return false; return false;
} }
string data{string_util::replace_all(m_subscriber->receive(BUFSIZ), "\n", "")}; string data{m_subscriber->receive(BUFSIZ)};
size_t pos;
if ((pos = data.find('\n')) != string::npos) {
data.erase(pos);
}
if (data.empty()) { if (data.empty()) {
return false; return false;
} }
size_t pos;
// If there were more than 1 row available in the channel
// we'll strip out the old updates
if ((pos = data.find_last_of(BSPWM_STATUS_PREFIX)) > 0) {
data.erase(0, pos);
}
size_t prefix_len{strlen(BSPWM_STATUS_PREFIX)}; size_t prefix_len{strlen(BSPWM_STATUS_PREFIX)};
if (data.compare(0, prefix_len, BSPWM_STATUS_PREFIX) != 0) { if (data.compare(0, prefix_len, BSPWM_STATUS_PREFIX) != 0) {
m_log.err("%s: Unknown status '%s'", name(), data); m_log.err("%s: Unknown status '%s'", name(), data);
@ -204,6 +201,8 @@ namespace modules {
return false; return false;
} }
m_log.info("%s: Parsing socket data: %s", name(), data);
m_monitors.clear(); m_monitors.clear();
size_t workspace_n{0U}; size_t workspace_n{0U};
@ -314,6 +313,12 @@ namespace modules {
default: default:
m_log.warn("%s: Undefined tag => '%s'", name(), tag.substr(0, 1)); m_log.warn("%s: Undefined tag => '%s'", name(), tag.substr(0, 1));
continue;
}
if (!m_monitors.back()) {
m_log.warn("%s: No monitor created", name());
continue;
} }
if (workspace_mask && m_formatter->has(TAG_LABEL_STATE)) { if (workspace_mask && m_formatter->has(TAG_LABEL_STATE)) {
@ -360,7 +365,7 @@ namespace modules {
if (m_index > 0) { if (m_index > 0) {
m_builder->space(m_formatter->get(DEFAULT_FORMAT)->spacing); m_builder->space(m_formatter->get(DEFAULT_FORMAT)->spacing);
} }
output += event_module::get_output(); output += this->event_module::get_output();
} }
return output; return output;
} }