summaryrefslogtreecommitdiff
path: root/src/xkbcomp
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2019-12-14 13:44:33 +0200
committerRan Benita <ran@unusedvar.com>2019-12-14 13:45:05 +0200
commita237f4f69903405dca56ba0d6b19a3f2adf62588 (patch)
tree0e18df40f0275871eb361288ab4d3e1863fb7623 /src/xkbcomp
parent1de2f174c2dceefeff6886f84c0a6b658c3665f0 (diff)
downloadxorg-lib-libxkbcommon-a237f4f69903405dca56ba0d6b19a3f2adf62588.tar.gz
parser: fix the remaining pointer chasing
Fix the TODO added in 7c42945. Signed-off-by: Ran Benita <ran@unusedvar.com>
Diffstat (limited to 'src/xkbcomp')
-rw-r--r--src/xkbcomp/parser.y43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index 9b16fc7..093151e 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -311,23 +311,27 @@ Flag : PARTIAL { $$ = MAP_IS_PARTIAL; }
DeclList : DeclList Decl
{
- /*
- * TODO: This is needed because of VModDecl, which
- * is a list and is "inlined" into the DeclList.
- * Should change to avoid the O(N)-append behavior,
- * like we do in the other lists.
- */
if ($2) {
- if (!$1.head)
- $$.head = $2;
- else
- $$.head = $1.head;
- if (!$1.last)
- $$.last = $2;
- else
- $$.last = $1.last->next = $2;
- while ($$.last->next)
- $$.last = $$.last->next;
+ if ($1.head) {
+ $$.head = $1.head; $1.last->next = $2; $$.last = $2;
+ } else {
+ $$.head = $$.last = $2;
+ }
+ }
+ }
+ /*
+ * VModDecl is "inlined" directly into DeclList, i.e.
+ * each VModDef in the VModDecl is a separate Decl in
+ * the File.
+ */
+ | DeclList OptMergeMode VModDecl
+ {
+ for (VModDef *vmod = $3.head; vmod; vmod = (VModDef *) vmod->common.next)
+ vmod->merge = $2;
+ if ($1.head) {
+ $$.head = $1.head; $1.last->next = &$3.head->common; $$.last = &$3.last->common;
+ } else {
+ $$.head = &$3.head->common; $$.last = &$3.last->common;
}
}
| { $$.head = $$.last = NULL; }
@@ -338,12 +342,7 @@ Decl : OptMergeMode VarDecl
$2->merge = $1;
$$ = (ParseCommon *) $2;
}
- | OptMergeMode VModDecl
- {
- for (VModDef *vmod = $2.head; vmod; vmod = (VModDef *) vmod->common.next)
- vmod->merge = $1;
- $$ = (ParseCommon *) $2.head;
- }
+ /* OptMergeMode VModDecl - see above. */
| OptMergeMode InterpretDecl
{
$2->merge = $1;