Fix the behavior of intermixed tests end edits in match

to get the following recipe working:

<match>
  <test1 .../>
  <edit1 .../>
  <test2 .../>
  <edit2 .../>
</match>

as:

<match>
  <test1 .../>
  </edit1 .../>
</match>
<match>
  <test1 .../>
  <test2 .../>
  <edit2 .../>
</match>
This commit is contained in:
Akira TAGOH 2013-06-28 15:54:38 +09:00
parent 197d06c49b
commit 0907589a79
3 changed files with 53 additions and 12 deletions

View File

@ -226,20 +226,25 @@ FcSubstDestroy (FcSubst *s)
FcExpr *
FcConfigAllocExpr (FcConfig *config)
{
if (!config->expr_pool || config->expr_pool->next == config->expr_pool->end)
{
FcExprPage *new_page;
FcExpr *e;
new_page = malloc (sizeof (FcExprPage));
if (!new_page)
return 0;
if (!config->expr_pool || config->expr_pool->next == config->expr_pool->end)
{
FcExprPage *new_page;
new_page->next_page = config->expr_pool;
new_page->next = new_page->exprs;
config->expr_pool = new_page;
}
new_page = malloc (sizeof (FcExprPage));
if (!new_page)
return 0;
return config->expr_pool->next++;
new_page->next_page = config->expr_pool;
new_page->next = new_page->exprs;
config->expr_pool = new_page;
}
e = config->expr_pool->next++;
FcRefInit (&e->ref, 1);
return e;
}
FcConfig *

View File

@ -240,6 +240,7 @@ typedef struct _FcExprName {
typedef struct _FcExpr {
FcOp op;
FcRef ref;
union {
int ival;
double dval;

View File

@ -223,11 +223,24 @@ FcExprCreateOp (FcConfig *config, FcExpr *left, FcOp op, FcExpr *right)
return e;
}
static FcExpr *
FcExprReference (FcExpr *e)
{
if (e)
{
FcRefInc (&e->ref);
}
return e;
}
static void
FcExprDestroy (FcExpr *e)
{
if (!e)
return;
if (FcRefDec (&e->ref) != 1)
return;
switch (FC_OP_GET_OP (e->op)) {
case FcOpInteger:
break;
@ -727,6 +740,21 @@ FcTestCreate (FcConfigParse *parse,
return test;
}
static FcTest *
FcTestDuplicate (FcTest *test)
{
FcTest *retval = (FcTest *) malloc (sizeof (FcTest));
if (retval)
{
memcpy (retval, test, sizeof (FcTest));
retval->next = NULL;
retval->expr = FcExprReference (test->expr);
}
return retval;
}
static FcEdit *
FcEditCreate (FcConfigParse *parse,
FcObject object,
@ -2401,7 +2429,7 @@ FcParseMatch (FcConfigParse *parse)
FcVStack *vstack;
FcBool tested = FcFalse;
FcSubstStack *sstack = NULL;
int len, pos = 0;
int len, pos = 0, i;
kind_name = FcConfigGetAttribute (parse, "target");
if (!kind_name)
@ -2438,6 +2466,13 @@ FcParseMatch (FcConfigParse *parse)
test = vstack->u.test;
vstack->tag = FcVStackNone;
tested = FcTrue;
for (i = 0; i < pos; i++)
{
FcTest *t = FcTestDuplicate(test);
t->next = sstack[i].test;
sstack[i].test = t;
}
break;
case FcVStackEdit:
/* due to the reverse traversal, <edit> node appears faster than