Implement longer defines

This commit is contained in:
bʰedoh₂ swé 2024-06-11 16:14:18 +05:00
parent 5cc866637e
commit 1c9de73b91
3 changed files with 18 additions and 1 deletions

View File

@ -10,9 +10,14 @@ bool replace(tSyntaxElement* tree, tProcessingData* pd) {
free(tree->content.none);
tSyntaxElement* clone = se_clone_no_next(pd->data.replace.replacewiththis, tree);
tSyntaxElement* clone = se_clone(pd->data.replace.replacewiththis, tree);
tree->content = clone->content;
tree->type = clone->type;
if (clone->next != NULL) {
tSyntaxElement* tmp = se_find_last(clone);
tmp->next = tree->next;
tree->next = clone->next;
}
free(clone);

View File

@ -142,3 +142,13 @@ tSyntaxElement* se_clone_no_next(tSyntaxElement* syntaxelement, tSyntaxElement*
return clone;
}
tSyntaxElement* se_find_last(tSyntaxElement* syntaxelement) {
tSyntaxElement* i = syntaxelement;
while (1)
if (i->next == NULL)
return i;
else
i = i->next;
}

View File

@ -47,4 +47,6 @@ tSyntaxElement* se_clone(tSyntaxElement*, tSyntaxElement*);
tSyntaxElement* se_clone_no_next(tSyntaxElement*, tSyntaxElement*);
tSyntaxElement* se_find_last(tSyntaxElement*);
#endif