Пример #1
0
/* V_STRING -> V_TREE -> V_TREE */
static struct value *tree_rm_glue(struct info *info,
                                  struct value *path,
                                  struct value *tree) {
    // FIXME: This only works if TREE is not referenced more than once;
    // otherwise we'll have some pretty weird semantics, and would really
    // need to copy TREE first
    assert(path->tag == V_STRING);
    assert(tree->tag == V_TREE);

    struct pathx *p = NULL;
    struct value *result = NULL;

    if (pathx_parse(tree->origin, NULL, path->string->str, true, NULL, &p)
        != PATHX_NOERROR) {
        result = make_pathx_exn(ref(info), p);
        goto done;
    }

    if (tree_rm(p) == -1) {
        result = make_exn_value(ref(info), "Tree rm of %s failed",
                                path->string->str);
        goto done;
    }
    result = ref(tree);
 done:
    free_pathx(p);
    return result;
}
Пример #2
0
/*
 * remove a pattern previously set by _setoverride().
 * returns 1 if pattern was found and successfully deleted or 0 if there
 * was no pattern
 */
int elog_rmoverride(char *re_pattern	/* regular expression pattern */ )
{
     struct elog_overridedat *over;

     elog_checkinit();

     if ((over = tree_find(elog_override, re_pattern)) != TREE_NOVAL) {
	  regfree(&over->pattern);
	  nfree(over);
	  nfree(tree_getkey(elog_override));
	  tree_rm(elog_override);

	  return 1;
     }

     return 0;
}