mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
parser-cfg: use bstr everywhere after parsing stage
Until now it used both char[] and bstr variants in the same code, which was nasty. For example, the next commit would have additionally required using memmove() to remove the prefix from the char[] string.
This commit is contained in:
parent
8c234045fa
commit
c7dee24c8c
@ -726,10 +726,10 @@ struct m_profile *m_config_add_profile(struct m_config *config, char *name)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void m_profile_set_desc(struct m_profile *p, char *desc)
|
void m_profile_set_desc(struct m_profile *p, bstr desc)
|
||||||
{
|
{
|
||||||
talloc_free(p->desc);
|
talloc_free(p->desc);
|
||||||
p->desc = talloc_strdup(p, desc);
|
p->desc = bstrdup0(p, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_config_set_profile_option(struct m_config *config, struct m_profile *p,
|
int m_config_set_profile_option(struct m_config *config, struct m_profile *p,
|
||||||
|
@ -188,7 +188,7 @@ struct m_profile *m_config_add_profile(struct m_config *config, char *name);
|
|||||||
* \param p The profile object.
|
* \param p The profile object.
|
||||||
* \param arg The profile's name.
|
* \param arg The profile's name.
|
||||||
*/
|
*/
|
||||||
void m_profile_set_desc(struct m_profile *p, char *desc);
|
void m_profile_set_desc(struct m_profile *p, bstr desc);
|
||||||
|
|
||||||
/* Add an option to a profile.
|
/* Add an option to a profile.
|
||||||
* Used by the config file parser when defining a profile.
|
* Used by the config file parser when defining a profile.
|
||||||
|
@ -229,7 +229,7 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile,
|
|||||||
bstr bparam = bstr0(param);
|
bstr bparam = bstr0(param);
|
||||||
|
|
||||||
if (profile && bstr_equals0(bopt, "profile-desc")) {
|
if (profile && bstr_equals0(bopt, "profile-desc")) {
|
||||||
m_profile_set_desc(profile, param);
|
m_profile_set_desc(profile, bparam);
|
||||||
goto nextline;
|
goto nextline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +239,8 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile,
|
|||||||
if (tmp < 0) {
|
if (tmp < 0) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
"error parsing option %s=%s: %s\n",
|
"error parsing option %.*s=%.*s: %s\n",
|
||||||
opt, param, m_option_strerror(tmp));
|
BSTR_P(bopt), BSTR_P(bparam), m_option_strerror(tmp));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,8 @@ int m_config_parse_config_file(m_config_t *config, const char *conffile,
|
|||||||
if (tmp < 0) {
|
if (tmp < 0) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
"setting option %s='%s' failed.\n", opt, param);
|
"setting option %.*s='%.*s' failed.\n",
|
||||||
|
BSTR_P(bopt), BSTR_P(bparam));
|
||||||
continue;
|
continue;
|
||||||
/* break */
|
/* break */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user