From e873d703e956d3e2e68b9e18562983b029b5c7a8 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 28 Jul 2011 11:07:47 +0300 Subject: options: change option parsing to use bstr Using bstr allows simpler parsing code, especially because it avoids the need to modify or copy strings just to terminate extracted substrings. --- m_struct.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'm_struct.c') diff --git a/m_struct.c b/m_struct.c index ca7c967ff2..764f616a89 100644 --- a/m_struct.c +++ b/m_struct.c @@ -67,8 +67,9 @@ m_struct_alloc(const m_struct_t* st) { return r; } -int -m_struct_set(const m_struct_t* st, void* obj, const char* field, const char* param) { +int m_struct_set(const m_struct_t *st, void *obj, const char *field, + struct bstr param) +{ const m_option_t* f = m_struct_get_field(st,field); if(!f) { @@ -77,9 +78,9 @@ m_struct_set(const m_struct_t* st, void* obj, const char* field, const char* par return 0; } - if(f->type->parse(f, field, param, false, M_ST_MB_P(obj,f->p)) < 0) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s, field %s parsing error: %s\n", - st->name,field,param); + if(f->type->parse(f, bstr(field), param, false, M_ST_MB_P(obj,f->p)) < 0) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Struct %s, field %s parsing error: %.*s\n", + st->name, field, BSTR_P(param)); return 0; } -- cgit v1.2.3