示例#1
0
文件: put.c 项目: d11/MCECTL
static void regexp_match_error(struct state *state, struct lens *lens,
                               int count, struct split *split) {
    // FIXME: Split the regexp and encoding back
    // into something resembling a tree level
    char *text = NULL;
    char *pat = NULL;

    lns_format_atype(lens, &pat);
    text = enc_format(split->enc + split->start, split->end - split->start);

    if (count == -1) {
        put_error(state, lens,
                  "Failed to match \n    %s\n  with tree\n   %s",
                  pat, text);
    } else if (count == -2) {
        put_error(state, lens,
                  "Internal error matching\n    %s\n  with tree\n   %s",
                  pat, text);
    } else if (count == -3) {
        /* Should have been caught by the typechecker */
        put_error(state, lens, "Syntax error in tree schema\n    %s", pat);
    }
    free(pat);
    free(text);
}
示例#2
0
/* V_LENS -> V_STRING */
static struct value *lns_fmt_atype(struct info *info, struct value *l) {
    struct value *result = NULL;
    char *s = NULL;
    int r;

    r = lns_format_atype(l->lens, &s);
    if (r < 0)
        return exn_error();
    result = make_value(V_STRING, ref(info));
    result->string = make_string(s);
    return result;
}