return 0;
}
+static bool is_duplicated_item(ItemArray *existing, Item *i) {
+
+ assert(existing);
+ assert(i);
+
+ for (size_t n = 0; n < existing->n_items; n++) {
+ Item *e = existing->items + n;
+
+ if (item_compatible(e, i))
+ continue;
+
+ /* Only multiple 'w+' lines for the same path are allowed. */
+ if (e->type != WRITE_FILE || !e->append_or_force ||
+ i->type != WRITE_FILE || !i->append_or_force)
+ return true;
+ }
+
+ return false;
+}
+
static int parse_line(
const char *fname,
unsigned line,
existing = ordered_hashmap_get(h, i.path);
if (existing) {
- size_t n;
-
- for (n = 0; n < existing->n_items; n++) {
- if (!item_compatible(existing->items + n, &i) && !i.append_or_force) {
- log_syntax(NULL, LOG_NOTICE, fname, line, 0, "Duplicate line for path \"%s\", ignoring.", i.path);
- return 0;
- }
+ if (is_duplicated_item(existing, &i)) {
+ log_syntax(NULL, LOG_NOTICE, fname, line, 0,
+ "Duplicate line for path \"%s\", ignoring.", i.path);
+ return 0;
}
} else {
existing = new0(ItemArray, 1);