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.
This commit is contained in:
parent
c1d9588890
commit
20191810d1
|
@ -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
|
"prepend_first" Insert at head of list Insert at head of list
|
||||||
"append" Append after matching Append at end of list
|
"append" Append after matching Append at end of list
|
||||||
"append_last" Append at end of list 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>
|
</programlisting>
|
||||||
</para></refsect2>
|
</para></refsect2>
|
||||||
<refsect2><title><literal><int></literal>, <literal><double></literal>, <literal><string></literal>, <literal><bool></literal></title><para>
|
<refsect2><title><literal><int></literal>, <literal><double></literal>, <literal><string></literal>, <literal><bool></literal></title><para>
|
||||||
|
|
|
@ -189,7 +189,7 @@
|
||||||
<!ELEMENT edit (%expr;)*>
|
<!ELEMENT edit (%expr;)*>
|
||||||
<!ATTLIST edit
|
<!ATTLIST edit
|
||||||
name CDATA #REQUIRED
|
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">
|
binding (weak|strong|same) "weak">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
10
src/fccfg.c
10
src/fccfg.c
|
@ -1701,6 +1701,16 @@ FcConfigSubstituteWithPat (FcConfig *config,
|
||||||
case FcOpAppendLast:
|
case FcOpAppendLast:
|
||||||
FcConfigPatternAdd (p, e->object, l, FcTrue);
|
FcConfigPatternAdd (p, e->object, l, FcTrue);
|
||||||
break;
|
break;
|
||||||
|
case FcOpDelete:
|
||||||
|
if (t)
|
||||||
|
{
|
||||||
|
FcConfigDel (&st[i].elt->values, st[i].value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fall through ... */
|
||||||
|
case FcOpDeleteAll:
|
||||||
|
FcConfigPatternDel (p, e->object);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
FcValueListDestroy (l);
|
FcValueListDestroy (l);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -79,7 +79,7 @@ void
|
||||||
FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark)
|
FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark)
|
||||||
{
|
{
|
||||||
if (show_pos_mark)
|
if (show_pos_mark)
|
||||||
printf (" [insert here] ");
|
printf (" [marker] ");
|
||||||
else
|
else
|
||||||
printf (" ");
|
printf (" ");
|
||||||
_FcValuePrintFile (stdout, v);
|
_FcValuePrintFile (stdout, v);
|
||||||
|
@ -110,7 +110,7 @@ FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos)
|
||||||
FcValueBindingPrint (l);
|
FcValueBindingPrint (l);
|
||||||
}
|
}
|
||||||
if (!pos)
|
if (!pos)
|
||||||
printf (" [insert here]");
|
printf (" [marker]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -222,6 +222,8 @@ FcOpPrint (FcOp op_)
|
||||||
case FcOpPrependFirst: printf ("PrependFirst"); break;
|
case FcOpPrependFirst: printf ("PrependFirst"); break;
|
||||||
case FcOpAppend: printf ("Append"); break;
|
case FcOpAppend: printf ("Append"); break;
|
||||||
case FcOpAppendLast: printf ("AppendLast"); break;
|
case FcOpAppendLast: printf ("AppendLast"); break;
|
||||||
|
case FcOpDelete: printf ("Delete"); break;
|
||||||
|
case FcOpDeleteAll: printf ("DeleteAll"); break;
|
||||||
case FcOpQuest: printf ("Quest"); break;
|
case FcOpQuest: printf ("Quest"); break;
|
||||||
case FcOpOr: printf ("Or"); break;
|
case FcOpOr: printf ("Or"); break;
|
||||||
case FcOpAnd: printf ("And"); break;
|
case FcOpAnd: printf ("And"); break;
|
||||||
|
|
|
@ -208,6 +208,7 @@ typedef enum _FcOp {
|
||||||
FcOpField, FcOpConst,
|
FcOpField, FcOpConst,
|
||||||
FcOpAssign, FcOpAssignReplace,
|
FcOpAssign, FcOpAssignReplace,
|
||||||
FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
|
FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
|
||||||
|
FcOpDelete, FcOpDeleteAll,
|
||||||
FcOpQuest,
|
FcOpQuest,
|
||||||
FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
|
FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
|
||||||
FcOpContains, FcOpListing, FcOpNotContains,
|
FcOpContains, FcOpListing, FcOpNotContains,
|
||||||
|
|
11
src/fcxml.c
11
src/fcxml.c
|
@ -260,6 +260,8 @@ FcExprDestroy (FcExpr *e)
|
||||||
case FcOpPrependFirst:
|
case FcOpPrependFirst:
|
||||||
case FcOpAppend:
|
case FcOpAppend:
|
||||||
case FcOpAppendLast:
|
case FcOpAppendLast:
|
||||||
|
case FcOpDelete:
|
||||||
|
case FcOpDeleteAll:
|
||||||
break;
|
break;
|
||||||
case FcOpOr:
|
case FcOpOr:
|
||||||
case FcOpAnd:
|
case FcOpAnd:
|
||||||
|
@ -2321,6 +2323,8 @@ static const FcOpMap fcModeOps[] = {
|
||||||
{ "prepend_first", FcOpPrependFirst },
|
{ "prepend_first", FcOpPrependFirst },
|
||||||
{ "append", FcOpAppend },
|
{ "append", FcOpAppend },
|
||||||
{ "append_last", FcOpAppendLast },
|
{ "append_last", FcOpAppendLast },
|
||||||
|
{ "delete", FcOpDelete },
|
||||||
|
{ "delete_all", FcOpDeleteAll },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_MODE_OPS (int) (sizeof fcModeOps / sizeof fcModeOps[0])
|
#define NUM_MODE_OPS (int) (sizeof fcModeOps / sizeof fcModeOps[0])
|
||||||
|
@ -2363,6 +2367,13 @@ FcParseEdit (FcConfigParse *parse)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
expr = FcPopBinary (parse, FcOpComma);
|
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),
|
edit = FcEditCreate (parse, FcObjectFromName ((char *) name),
|
||||||
mode, expr, binding);
|
mode, expr, binding);
|
||||||
if (!edit)
|
if (!edit)
|
||||||
|
|
Loading…
Reference in New Issue