From 31cc61b6fce0c0bb1a3cad35e9d73bd65f16f365 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 Oct 2015 20:32:51 +0100 Subject: [PATCH] Allow parsing empty strings as default color in face descs --- src/face_registry.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/face_registry.cc b/src/face_registry.cc index 2079ada3..a1a0e582 100644 --- a/src/face_registry.cc +++ b/src/face_registry.cc @@ -14,9 +14,10 @@ static Face parse_face(StringView facedesc) if (bg_it != facedesc.end() and attr_it < bg_it) throw runtime_error("invalid face description, expected [,][+]"); Face res; - res.fg = str_to_color({facedesc.begin(), std::min(attr_it, bg_it)}); + res.fg = attr_it != facedesc.begin() ? + str_to_color({facedesc.begin(), std::min(attr_it, bg_it)}) : Color::Default; if (bg_it != facedesc.end()) - res.bg = str_to_color({bg_it+1, attr_it}); + res.bg = bg_it+1 != attr_it ? str_to_color({bg_it+1, attr_it}) : Color::Default; if (attr_it != facedesc.end()) { for (++attr_it; attr_it != facedesc.end(); ++attr_it)