aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/input.cpp
diff options
context:
space:
mode:
authorGravatar Chris Pick <chris@chrispick.com>2015-09-03 15:12:56 -0400
committerGravatar Chris Pick <chris@chrispick.com>2015-09-03 15:15:46 -0400
commit8cc154bc48f730db2303a6bfa91532775fc7ea5b (patch)
tree45f83478f84bc4d1a66c17de23add62d1d3910e9 /src/input.cpp
parentab6d9ad521dc6ad96c2a0ea1a2c55702eb5d15c9 (diff)
Fix non-zero arity functions followed by other functions
Temporarily skip any queued function code characters when reading the current function's arguments. Fixes #2357.
Diffstat (limited to 'src/input.cpp')
-rw-r--r--src/input.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/input.cpp b/src/input.cpp
index 2b556c2a..6e10074b 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -42,6 +42,7 @@
#include "output.h"
#include <vector>
#include <algorithm>
+#include <deque>
#define DEFAULT_TERM L"ansi"
#define MAX_INPUT_FUNCTION_ARGS 20
@@ -537,10 +538,23 @@ wchar_t input_function_pop_arg()
void input_function_push_args(int code)
{
int arity = input_function_arity(code);
+ std::deque<wchar_t> skipped;
+
for (int i = 0; i < arity; i++)
{
- input_function_push_arg(input_common_readch(0));
+ wchar_t arg;
+
+ // skip and queue up any function codes
+ while(((arg = input_common_readch(0)) >= R_MIN) && (arg <= R_MAX))
+ {
+ skipped.push_front(arg);
+ }
+
+ input_function_push_arg(arg);
}
+
+ // push the function codes back into the input stream
+ std::for_each(skipped.begin(), skipped.end(), input_common_next_ch);
}
/**