summaryrefslogtreecommitdiffstats
path: root/m_property.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-22 14:54:57 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:10:32 +0200
commitd232012287fe2e6e829ce9e4c20e0d9f9dc4ed5e (patch)
tree21fcbd89ad3d1c4ecf5e0e38795b232f49b86769 /m_property.c
parent84af1733800fd78af61b2ebf5be10673192b68fe (diff)
downloadmpv-d232012287fe2e6e829ce9e4c20e0d9f9dc4ed5e.tar.bz2
mpv-d232012287fe2e6e829ce9e4c20e0d9f9dc4ed5e.tar.xz
input: handle escapes always in command parser
Previously, both the command parser and property expansion (m_properties_expand_string) handled escapes with '\'. Move all escape handling into the command parser, and remove it from the property code. This removes the need to escape strings twice for commands that use property expansion. The command parser is practically rewritten: it uses m_option for the actual parsing, and reduces hackish C-string handling.
Diffstat (limited to 'm_property.c')
-rw-r--r--m_property.c30
1 files changed, 2 insertions, 28 deletions
diff --git a/m_property.c b/m_property.c
index 25c0ef51e8..68be17c974 100644
--- a/m_property.c
+++ b/m_property.c
@@ -144,37 +144,11 @@ char *m_properties_expand_string(const m_option_t *prop_list, char *str,
void *ctx)
{
int l, fr = 0, pos = 0, size = strlen(str) + 512;
- char *p = NULL, *e, *ret = malloc(size), num_val;
+ char *p = NULL, *e, *ret = malloc(size);
int skip = 0, lvl = 0, skip_lvl = 0;
while (str[0]) {
- if (str[0] == '\\') {
- int sl = 1;
- switch (str[1]) {
- case 'e':
- p = "\x1b", l = 1; break;
- case 'n':
- p = "\n", l = 1; break;
- case 'r':
- p = "\r", l = 1; break;
- case 't':
- p = "\t", l = 1; break;
- case 'x':
- if (str[2]) {
- char num[3] = { str[2], str[3], 0 };
- char *end = num;
- num_val = strtol(num, &end, 16);
- sl = end - num + 1;
- l = 1;
- p = &num_val;
- } else
- l = 0;
- break;
- default:
- p = str + 1, l = 1;
- }
- str += 1 + sl;
- } else if (lvl > 0 && str[0] == ')') {
+ if (lvl > 0 && str[0] == ')') {
if (skip && lvl <= skip_lvl)
skip = 0;
lvl--, str++, l = 0;