Re: [LTP] [PATCH 6/9] metaparse: Add missing blank line on the list

Petr Vorel
2024-02-23T15:04:56Z

> Hi!
> > +static inline bool item_is_str_list_member(struct data_node *self)
> > +{
> > + if (self->type != DATA_STRING)
> > + return false;
> > +
> > + return self->string.val[0] == '*' && self->string.val[1] == ' ';

> The lists in asciidoc may also start with '-' and I tend to use it
> instead of asterisk because it's easier to see inside the C style
> comments.

+1

> > +}
> > +
> > +static inline bool item_is_str_empty(struct data_node *self)
> > +{
> > + if (self->type != DATA_STRING)
> > + return false;
> > +
> > + return !strlen(self->string.val);

> This is fancy way of doing !self->string.val[0]

+2 (thanks for teaching me proper C :))

...
> > for (i = 0; i < self->array.array_used; i++) {
> > +
> > + if (i > 0 &&
> > + missing_space_for_list(self->array.array[i],
> > + self->array.array[i-1])) {
> > + fprintf(stderr,
> > + "%s:%d: WARNING: missing blank line before first list item, add it\n",
> > + __FILE__, __LINE__);
> > + data_fprintf(f, padd+1, "\"\",\n");
> > + }
> > +
> > data_to_json_(self->array.array[i], f, padd+1, 1);
> > if (i < self->array.array_used - 1)
> > fprintf(f, ",\n");

> I'm not sure if we should add the asciidoc validation into the metadata
> parser. It feels like this could have been done easier in a perl script,
> especially if we are going to add more checks.

You're right. I thought it'd be out of context in perl script, but we works with
arrays there as well, detection should be as easy as here in metadata parser.

I'll change this in v2.

Kind regards,
Petr