MCPcopy Create free account
hub / github.com/git/git / postorder

Function postorder

compat/regex/regcomp.c:1222–1252  ·  view source on GitHub ↗

Our parse trees are very unbalanced, so we cannot use a stack to implement parse tree visits. Instead, we use parent pointers and some hairy code in these two functions. */

Source from the content-addressed store, hash-verified

1220 ret = calc_inveclosure (dfa);
1221 }
1222
1223 return ret;
1224}
1225
1226/* Our parse trees are very unbalanced, so we cannot use a stack to
1227 implement parse tree visits. Instead, we use parent pointers and
1228 some hairy code in these two functions. */
1229static reg_errcode_t
1230postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1231 void *extra)
1232{
1233 bin_tree_t *node, *prev;
1234
1235 for (node = root; ; )
1236 {
1237 /* Descend down the tree, preferably to the left (or to the right
1238 if that's the only child). */
1239 while (node->left || node->right)
1240 if (node->left)
1241 node = node->left;
1242 else
1243 node = node->right;
1244
1245 do
1246 {
1247 reg_errcode_t err = fn (extra, node);
1248 if (BE (err != REG_NOERROR, 0))
1249 return err;
1250 if (node->parent == NULL)
1251 return REG_NOERROR;
1252 prev = node;
1253 node = node->parent;
1254 }
1255 /* Go up while we have a node that is reached from the right. */

Callers 2

analyzeFunction · 0.85
parse_dup_opFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected