changeset 25501:26a839637972

Support ?(!NAME:TEXT) format for expanding string by property.
author ulion
date Wed, 26 Dec 2007 04:15:56 +0000
parents 1e8364740a86
children 605d4e3e403f
files DOCS/man/en/mplayer.1 m_property.c
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Tue Dec 25 12:22:50 2007 +0000
+++ b/DOCS/man/en/mplayer.1	Wed Dec 26 04:15:56 2007 +0000
@@ -990,6 +990,8 @@
 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
--- a/m_property.c	Tue Dec 25 12:22:50 2007 +0000
+++ b/m_property.c	Wed Dec 26 04:15:56 2007 +0000
@@ -146,11 +146,16 @@
         } 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;