When deleting a section in the "cfg" library, the cfg_del_section
function would check each line in the configuration to see if it was
part of the section to be deleted. The way it deleted was essentially
to move all future lines "down" to replace the line to be deleted.
However, it always incremented the pointer to the next entry, which
could cause it to skip over other entries that should have been deleted.
We now only increment the pointer if we didn't delete a line.
ds_put_char(§ion, '.');
va_end(args);
- for (p = cfg.names; *p; p++) { /* XXX this is inefficient */
+ for (p = cfg.names; *p; ) { /* XXX this is inefficient */
if (!strncmp(section.string, *p, section.length)) {
+ /* Delete this matching entry in-place, so don't move on to
+ * the next entry. */
svec_del(&cfg, *p);
+ } else {
+ /* Move onto the next entry. */
+ p++;
}
}
ds_destroy(§ion);