This is O(N^2) but nobody cares */
| 99 | |
| 100 | /* This is O(N^2) but nobody cares */ |
| 101 | void configvar_finalize_overrides(struct configvar **cvs) |
| 102 | { |
| 103 | /* Map to options: two different names can be the same option, |
| 104 | * given aliases! */ |
| 105 | const struct opt_table **opts; |
| 106 | |
| 107 | opts = tal_arr(tmpctx, const struct opt_table *, tal_count(cvs)); |
| 108 | for (size_t i = 0; i < tal_count(cvs); i++) { |
| 109 | opts[i] = opt_find_long(cvs[i]->optvar, NULL); |
| 110 | /* The plugin which registered this option may have |
| 111 | * disabled itself since: leave the stale configvar alone, |
| 112 | * it can still be reused if that plugin is started again. */ |
| 113 | if (!opts[i]) |
| 114 | continue; |
| 115 | /* If you're allowed multiple, they don't override... |
| 116 | * unless transient values exist, which override non-transient. */ |
| 117 | if (opts[i]->type & OPT_MULTI) { |
| 118 | if (cvs[i]->src != CONFIGVAR_SETCONFIG_TRANSIENT) |
| 119 | continue; |
| 120 | for (size_t j = 0; j < i; j++) { |
| 121 | if (opts[j] == opts[i] && |
| 122 | cvs[j]->src != CONFIGVAR_SETCONFIG_TRANSIENT) |
| 123 | cvs[j]->overridden = true; |
| 124 | } |
| 125 | continue; |
| 126 | } |
| 127 | for (size_t j = 0; j < i; j++) { |
| 128 | if (opts[j] == opts[i]) |
| 129 | cvs[j]->overridden = true; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | void configvar_remove(struct configvar ***cvs, |
| 135 | const char *name, |
no test coverage detected