aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin_printf.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-07-16 13:25:42 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-07-16 13:25:42 -0700
commitd3bb2a718aa69bf58331a833a7dad07cb2e1dbcc (patch)
treecdbc4f5ca67ee47c2b10e06200f86ab022e30aa3 /builtin_printf.cpp
parentcabebd9f51449f88a492e3047cd5bc603f5c48c3 (diff)
Make printf support \e as the escape character
Diffstat (limited to 'builtin_printf.cpp')
-rw-r--r--builtin_printf.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin_printf.cpp b/builtin_printf.cpp
index e164f819..f6cef3d6 100644
--- a/builtin_printf.cpp
+++ b/builtin_printf.cpp
@@ -26,6 +26,7 @@
\a = alert (bell)
\b = backspace
\c = produce no further output
+ \e = escape
\f = form feed
\n = new line
\r = carriage return
@@ -319,6 +320,9 @@ void builtin_printf_state_t::print_esc_char(wchar_t c)
case L'c': /* Cancel the rest of the output. */
this->early_exit = true;
break;
+ case L'e': /* Escape */
+ this->append_output(L'\x1B');
+ break;
case L'f': /* Form feed. */
this->append_output(L'\f');
break;
@@ -369,8 +373,10 @@ long builtin_printf_state_t::print_esc(const wchar_t *escstart, bool octal_0)
esc_value = esc_value * 8 + octal_to_bin(*p);
this->append_format_output(L"%c", esc_value);
}
- else if (*p && wcschr(L"\"\\abcfnrtv", *p))
+ else if (*p && wcschr(L"\"\\abcefnrtv", *p))
+ {
print_esc_char(*p++);
+ }
else if (*p == L'u' || *p == L'U')
{
wchar_t esc_char = *p;