summaryrefslogtreecommitdiff
path: root/format.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-22 02:40:18 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-22 02:40:18 -0400
commit02168c782364a1a8641b4bed7ebf4a84cb6b3560 (patch)
treef3e31f99245871413587d3eb0ad1fa5974bf9558 /format.cc
parent5619a1d5be144877df8cce01c40ff668bbb0c96a (diff)
downloadfork-ledger-02168c782364a1a8641b4bed7ebf4a84cb6b3560.tar.gz
fork-ledger-02168c782364a1a8641b4bed7ebf4a84cb6b3560.tar.bz2
fork-ledger-02168c782364a1a8641b4bed7ebf4a84cb6b3560.zip
escape codes in format strings; can now redefine individual report formats
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;