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
1 changed files with 15 additions and 10 deletions

View File

@ -151,20 +151,17 @@ namespace modules {
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()) {
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)};
if (data.compare(0, prefix_len, BSPWM_STATUS_PREFIX) != 0) {
m_log.err("%s: Unknown status '%s'", name(), data);
@ -204,6 +201,8 @@ namespace modules {
return false;
}
m_log.info("%s: Parsing socket data: %s", name(), data);
m_monitors.clear();
size_t workspace_n{0U};
@ -314,6 +313,12 @@ namespace modules {
default:
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)) {
@ -360,7 +365,7 @@ namespace modules {
if (m_index > 0) {
m_builder->space(m_formatter->get(DEFAULT_FORMAT)->spacing);
}
output += event_module::get_output();
output += this->event_module::get_output();
}
return output;
}