Exemplo n.º 1
0
static int
do_add(struct da *da, int idx, unsigned char c)
{
  int base = get_base(da, idx);
  int next = idx + base + c;
  int cur_check = get_check(da, next);
  int new_base;
  if (cur_check > 0) {
    printf("conflict(%d,%c)\n", idx, c);
    return resolve_conflict(da, idx, c);
  }
  set_check(da, next, idx);
  /**/
  new_base = 1;
  if (idx == 1) {
    new_base = 256 - next;
  }
  set_base(da, next, new_base);
  return next;
}
Exemplo n.º 2
0
	void ItemSetBuilder::fill_actions() {
		for (auto& state : m_item_sets) {
			m_sorted.emplace(state.m_id, &state);
			for (auto& item : state.m_closure) {
				auto& production = m_grammar.get_production(item.production_id());
				// for every production whose dot is at right end
				if (item.dot() == production.rhs_count()) {
					for (auto it = m_grammar.symbol_begin(); it != m_grammar.symbol_end(); it++) {
						if (item.lookaheads()[**it]) {
							if (production.id() == 0) {
								state.add_action(**it, ActionType::ACCEPT, production.id());
							}
							else {
								Action new_act {ActionType::REDUCE, production.id()};
								auto& act = state.add_action(**it, new_act.type, new_act.value);
								resolve_conflict(act, new_act, **it, state);
							}
						}
					}
				}
			}
		}
	}
Exemplo n.º 3
0
/* check if db conflicts with cap */
static
int find_db_conflicts_dbcnfl_with_cap(int indent, struct i3ctx *ictx,
                                      struct pkg *pkg, const struct capreq *cap)
{
    int i, j, ncnfl = 0;
    tn_array *dbpkgs = NULL;

    pkgdb_search(ictx->ts->db, &dbpkgs, PMTAG_CNFL, capreq_name(cap),
                 iset_packages_by_recno(ictx->unset), PKG_LDWHOLE_FLDEPDIRS);

    if (dbpkgs == NULL)
        return 0;

    for (i = 0; i < n_array_size(dbpkgs); i++) {
        struct pkg *dbpkg = n_array_nth(dbpkgs, i);
        
        msg(6, "%s (%s) <-> %s ?\n", pkg_id(pkg),
            capreq_stra(cap), pkg_id(dbpkg));
        
        for (j = 0; j < n_array_size(dbpkg->cnfls); j++) {
            struct capreq *cnfl = n_array_nth(dbpkg->cnfls, j);
            if (cap_match_req(cap, cnfl, 1)) {
                if (resolve_conflict(indent, ictx, pkg, cnfl, dbpkg))
                    continue;
                
                i3_error(ictx, pkg, I3ERR_DBCONFLICT,
                         _("%s (cap %s) conflicts with installed %s (%s)"),
                         pkg_id(pkg), capreq_stra(cap), 
                         pkg_id(dbpkg), capreq_stra(cnfl));
                ncnfl++;
            }
        }
    }
    
    n_array_free(dbpkgs);
    return ncnfl;
}
Exemplo n.º 4
0
/* check if cnfl conflicts with db */
static
int find_db_conflicts_cnfl_with_db(int indent, struct i3ctx *ictx,
                                   struct pkg *pkg, const struct capreq *cnfl)
{
    int i, ncnfl = 0;
    tn_hash *ht = NULL;
    tn_array *dbpkgs = NULL;

    pkgdb_search(ictx->ts->db, &dbpkgs, PMTAG_CAP, capreq_name(cnfl),
                 iset_packages_by_recno(ictx->unset), PKG_LDWHOLE_FLDEPDIRS);

    if (dbpkgs == NULL)
        return 0;
                
    msgn_i(4, indent, "Processing conflict %s:%s...", pkg_id(pkg),
           capreq_stra(cnfl));
    
    if (ictx->ts->getop(ictx->ts, POLDEK_OP_ALLOWDUPS) &&
        n_array_size(dbpkgs) > 1) {
        
        ht = n_hash_new(21, NULL);
        n_hash_ctl(ht, TN_HASH_NOCPKEY);
        
        for (i=0; i<n_array_size(dbpkgs); i++) {
            struct pkg *dbpkg = n_array_nth(dbpkgs, i);
            if (n_hash_exists(ht, dbpkg->name))
                continue;
            
            if (!pkg_match_req(dbpkg, cnfl, 1)) {
                msgn_i(5, indent, "%s: conflict disarmed by %s",
                       capreq_stra(cnfl), pkg_id(dbpkg));
                n_hash_insert(ht, dbpkg->name, pkg);
            }
        }
    }
    
    for (i=0; i < n_array_size(dbpkgs); i++) {
        struct pkg *dbpkg = n_array_nth(dbpkgs, i);
        
        msg_i(6, indent, "%d. %s (%s) <-> %s ?\n", i, pkg_id(pkg),
              capreq_stra(cnfl), pkg_id(dbpkg));
        
        if (ht && n_hash_exists(ht, dbpkg->name))
            continue;

        if (!pkg_is_colored_like(pkg, dbpkg))
            continue;
                
        if (pkg_match_req(dbpkg, cnfl, 1)) {
            if (!resolve_conflict(indent, ictx, pkg, cnfl, dbpkg)) {
                i3_error(ictx, pkg, I3ERR_DBCONFLICT,
                         _("%s (cnfl %s) conflicts with installed %s"),
                         pkg_id(pkg), capreq_stra(cnfl), pkg_id(dbpkg));
                
                logn(LOGERR, _("%s (cnfl %s) conflicts with installed %s"),
                     pkg_id(pkg), capreq_stra(cnfl), pkg_id(dbpkg));
                ncnfl++;
            }
        }
    }

    if (ht)
        n_hash_free(ht);

    n_array_free(dbpkgs);
    
    return ncnfl;
}