- node->inserted = true; /* inserted into tree */
- return node;
-
-#else
- TREE_NODE *sibling, *last_sibling = NULL;
- uint16_t fname_len = strlen(fname);
- int cmp;
-
- /* Is it already a sibling? */
- foreach_child(sibling, parent) {
- Dmsg2(000, "sibling->fname=%s fname=%s\n", sibling->fname, fname);
- if (fname[0] > sibling->fname[0] || (cmp=strcmp(fname, sibling->fname)) > 0) {
- last_sibling = sibling;
- continue;
- }
- if (cmp < 0) {
- /* Insert before current sibling */
- if (!node) {
- node = new_tree_node(root);
- }
- node->sibling_ = sibling;
- if (sibling == first_child(parent)) { /* if sibling was at head of list */
- parent->child_ = NULL; /* force parent to be updated below */
- }
- Dmsg2(000, "insert before sibling->fname=%s fname=%s\n", sibling->fname, fname);
- break;
- }
- /* Found it */
- sibling->inserted = false; /* already in tree */
- return sibling;
- }
-
-
- /*
- * At this point, the fname is not found. We must add it
- */
- if (!node) {
- node = new_tree_node(root);
- }
- Dmsg1(000, "append_tree_node: %s\n", fname);
- node->fname_len = fname_len;
- node->fname = tree_alloc(root, node->fname_len + 1);
- strcpy(node->fname, fname);
- node->parent = parent;
- node->type = type;
- if (!tree_node_has_child(parent)) {
- parent->child_ = node;
- } else {
- last_sibling->sibling_ = node;
- }
-
- /* Maintain a linear chain of nodes */
- if (!root->first) {
- root->first = node;
- root->last = node;
- } else {
- root->last->next = node;
- root->last = node;
- }
- node->inserted = true; /* inserted into tree */