[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Thu Jan 31 19:59:37 PST 2013


 doc/fontconfig-user.sgml |    2 ++
 fonts.dtd                |    2 +-
 src/fccfg.c              |   10 ++++++++++
 src/fcdbg.c              |    6 ++++--
 src/fcint.h              |    1 +
 src/fcxml.c              |   11 +++++++++++
 6 files changed, 29 insertions(+), 3 deletions(-)

New commits:
commit 20191810d1fea7c2f49b65ffee3e4d5e2bc0bac3
Author: Akira TAGOH <akira at tagoh.org>
Date:   Tue Jan 29 20:19:36 2013 +0900

    Bug 23757 - Add mode="delete" to <edit>
    
    Add two edit mode, "delete" and "delete_all".
    what values are being deleted depends on <test> as documented.
    if the target object is same to what is tested, matching value there
    will be deleted. otherwise all of values in the object will be deleted.
    so this would means both edit mode will not take any expressions.
    
    e.g.
    
    Given that the testing is always true here, the following rules:
    
      <match>
        <test name="foo" compare="eq">
          <string>bar</string>
        </test>
        <edit name="foo" mode="delete"/>
      </match>
    
    will removes "bar" string from "foo" object. and:
    
      <match>
        <test name="foo" compare="eq">
          <string>foo</string>
        </test>
        <edit name="bar" mode="delete"/>
      </match>
    
    will removes all of values in "bar" object.

diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml
index 90e246b..eeff69a 100644
--- a/doc/fontconfig-user.sgml
+++ b/doc/fontconfig-user.sgml
@@ -425,6 +425,8 @@ with "same" binding using the value from the matched pattern element.
   "prepend_first"         Insert at head of list  Insert at head of list
   "append"                Append after matching   Append at end of list
   "append_last"           Append at end of list   Append at end of list
+  "delete"                Delete matching value   Delete all values
+  "delete_all"            Delete all values       Delete all values
     </programlisting>
   </para></refsect2>
   <refsect2><title><literal><int></literal>, <literal><double></literal>, <literal><string></literal>, <literal><bool></literal></title><para>
diff --git a/fonts.dtd b/fonts.dtd
index 664467d..4c38e77 100644
--- a/fonts.dtd
+++ b/fonts.dtd
@@ -189,7 +189,7 @@
 <!ELEMENT edit (%expr;)*>
 <!ATTLIST edit
 	  name CDATA	    #REQUIRED
-	  mode (assign|assign_replace|prepend|append|prepend_first|append_last) "assign"
+	  mode (assign|assign_replace|prepend|append|prepend_first|append_last|delete|delete_all) "assign"
 	  binding (weak|strong|same) "weak">
 
 <!--
diff --git a/src/fccfg.c b/src/fccfg.c
index 12d7e1a..db878d5 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -1701,6 +1701,16 @@ FcConfigSubstituteWithPat (FcConfig    *config,
 	    case FcOpAppendLast:
 		FcConfigPatternAdd (p, e->object, l, FcTrue);
 		break;
+	    case FcOpDelete:
+		if (t)
+		{
+		    FcConfigDel (&st[i].elt->values, st[i].value);
+		    break;
+		}
+		/* fall through ... */
+	    case FcOpDeleteAll:
+		FcConfigPatternDel (p, e->object);
+		break;
 	    default:
                 FcValueListDestroy (l);
 		break;
diff --git a/src/fcdbg.c b/src/fcdbg.c
index 270d791..9d02f5a 100644
--- a/src/fcdbg.c
+++ b/src/fcdbg.c
@@ -79,7 +79,7 @@ void
 FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark)
 {
     if (show_pos_mark)
-	printf (" [insert here] ");
+	printf (" [marker] ");
     else
 	printf (" ");
     _FcValuePrintFile (stdout, v);
@@ -110,7 +110,7 @@ FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos)
 	FcValueBindingPrint (l);
     }
     if (!pos)
-	printf (" [insert here]");
+	printf (" [marker]");
 }
 
 void
@@ -222,6 +222,8 @@ FcOpPrint (FcOp op_)
     case FcOpPrependFirst: printf ("PrependFirst"); break;
     case FcOpAppend: printf ("Append"); break;
     case FcOpAppendLast: printf ("AppendLast"); break;
+    case FcOpDelete: printf ("Delete"); break;
+    case FcOpDeleteAll: printf ("DeleteAll"); break;
     case FcOpQuest: printf ("Quest"); break;
     case FcOpOr: printf ("Or"); break;
     case FcOpAnd: printf ("And"); break;
diff --git a/src/fcint.h b/src/fcint.h
index 71b7341..fceb8cc 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -208,6 +208,7 @@ typedef enum _FcOp {
     FcOpField, FcOpConst,
     FcOpAssign, FcOpAssignReplace,
     FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
+    FcOpDelete, FcOpDeleteAll,
     FcOpQuest,
     FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
     FcOpContains, FcOpListing, FcOpNotContains,
diff --git a/src/fcxml.c b/src/fcxml.c
index 5981ea9..470e44f 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -260,6 +260,8 @@ FcExprDestroy (FcExpr *e)
     case FcOpPrependFirst:
     case FcOpAppend:
     case FcOpAppendLast:
+    case FcOpDelete:
+    case FcOpDeleteAll:
 	break;
     case FcOpOr:
     case FcOpAnd:
@@ -2321,6 +2323,8 @@ static const FcOpMap fcModeOps[] = {
     { "prepend_first",	FcOpPrependFirst    },
     { "append",		FcOpAppend	    },
     { "append_last",	FcOpAppendLast	    },
+    { "delete",		FcOpDelete	    },
+    { "delete_all",	FcOpDeleteAll	    },
 };
 
 #define NUM_MODE_OPS (int) (sizeof fcModeOps / sizeof fcModeOps[0])
@@ -2363,6 +2367,13 @@ FcParseEdit (FcConfigParse *parse)
 	return;
 
     expr = FcPopBinary (parse, FcOpComma);
+    if ((mode == FcOpDelete || mode == FcOpDeleteAll) &&
+	expr != NULL)
+    {
+	FcConfigMessage (parse, FcSevereWarning, "Expression doesn't take any effects for delete and delete_all");
+	FcExprDestroy (expr);
+	expr = NULL;
+    }
     edit = FcEditCreate (parse, FcObjectFromName ((char *) name),
 			 mode, expr, binding);
     if (!edit)


More information about the Fontconfig mailing list