mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 04:36:24 +01:00
Support ?(!NAME:TEXT) format for expanding string by property.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25529 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
9e434fa014
commit
2b517dc714
@ -990,6 +990,8 @@ The following expansions are supported:
|
||||
Expand to the value of the property NAME.
|
||||
.IPs ?(NAME:TEXT)
|
||||
Expand TEXT only if the property NAME is available.
|
||||
.IPs ?(!NAME:TEXT)
|
||||
Expand TEXT only if the property NAME is not available.
|
||||
.RE
|
||||
.
|
||||
.TP
|
||||
|
11
m_property.c
11
m_property.c
@ -146,11 +146,16 @@ char* m_properties_expand_string(m_option_t* prop_list,char* str, void *ctx) {
|
||||
} else if(str[0] == '?' && str[1] == '(' && (e = strchr(str+2,':'))) {
|
||||
lvl++;
|
||||
if(!skip) {
|
||||
int pl = e-str-2;
|
||||
int is_not = str[2] == '!';
|
||||
int pl = e - str - (is_not ? 3 : 2);
|
||||
char pname[pl+1];
|
||||
memcpy(pname,str+2,pl);
|
||||
memcpy(pname, str + (is_not ? 3 : 2), pl);
|
||||
pname[pl] = 0;
|
||||
if(m_property_do(prop_list,pname,M_PROPERTY_GET,NULL,ctx) < 0)
|
||||
if(m_property_do(prop_list,pname,M_PROPERTY_GET,NULL,ctx) < 0) {
|
||||
if (!is_not)
|
||||
skip = 1, skip_lvl = lvl;
|
||||
}
|
||||
else if (is_not)
|
||||
skip = 1, skip_lvl = lvl;
|
||||
}
|
||||
str = e+1, l = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user