summaryrefslogtreecommitdiff
path: root/format.cc
diff options
context:
space:
mode:
Diffstat (limited to 'format.cc')
-rw-r--r--format.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/format.cc b/format.cc
index a26ce631..90fbf388 100644
--- a/format.cc
+++ b/format.cc
@@ -53,7 +53,7 @@ element_t * format_t::parse_elements(const std::string& fmt)
char * q = buf;
for (const char * p = fmt.c_str(); *p; p++) {
- if (*p != '%') {
+ if (*p != '%' && *p != '\\') {
*q++ = *p;
continue;
}
@@ -75,6 +75,20 @@ element_t * format_t::parse_elements(const std::string& fmt)
current = current->next;
}
+ if (*p == '\\') {
+ p++;
+ current->type = element_t::STRING;
+ switch (*p) {
+ case 'b': current->chars = "\b"; break;
+ case 'f': current->chars = "\f"; break;
+ case 'n': current->chars = "\n"; break;
+ case 'r': current->chars = "\r"; break;
+ case 't': current->chars = "\t"; break;
+ case 'v': current->chars = "\v"; break;
+ }
+ continue;
+ }
+
++p;
if (*p == '-') {
current->align_left = true;