Josh Steadmon <steadmon@xxxxxxxxxx> writes: > +static void start_event(struct config_source *cs, enum config_event_t type, > + struct parse_event_data *data) > +{ > + data->previous_type = type; > + data->previous_offset = get_corrected_offset(cs, type); > +} It's a pity that get_corrected_offset() has to be called twice (once here and once below) but I think that's the best we can do given how the code is laid out (and I can't think of a better code layout either). > +static int flush_event(struct config_source *cs, enum config_event_t type, > + struct parse_event_data *data) One thing confusing here is that the "type" is not what's being flushed, but used to change details about how we flush. Technically all we need is is_whitespace_type and is_eof_type, but that's clumsier to code. I think the best we can do is add some documentation to this function, maybe 'Flush the event started by a prior start_event(), if one exists. The type of the event being flushed is not "type" but the type that was passed to the prior start_event(); "type" here may merely change how the flush is performed' or something like that. > +{ > + if (!data->opts || !data->opts->event_fn) > + return 0; > + > + if (type == CONFIG_EVENT_WHITESPACE && > + data->previous_type == type) > + return 0; > > if (data->previous_type != CONFIG_EVENT_EOF && > data->opts->event_fn(data->previous_type, data->previous_offset, > - offset, cs, data->opts->event_fn_data) < 0) > + get_corrected_offset(cs, type), cs, > + data->opts->event_fn_data) < 0) > return -1; Another confusing point here is how EOF is used both to mean "start_event() was never called" and a true EOF. I think for now it's best to just document this where we define CONFIG_EVENT_EOF.