From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 6/9] metaparse: Add missing blank line on the list
Date: Fri, 23 Feb 2024 14:08:25 +0100 [thread overview]
Message-ID: <ZdiYya4ZvOY4j5UX@yuki> (raw)
In-Reply-To: <20240104204614.1426027-7-pvorel@suse.cz>
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.
> +}
> +
> +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]
> +}
> +
> +static inline bool missing_space_for_list(struct data_node *cur, struct
> + data_node *prev)
> +{
> + return item_is_str_list_member(cur) && !item_is_str_empty(prev) &&
> + !item_is_str_list_member(prev);
> +}
> +
> static inline void data_node_print(struct data_node *self)
> {
> printf("{\n");
> @@ -357,6 +381,16 @@ static inline void data_to_json_(struct data_node *self, FILE *f, unsigned int p
> case DATA_ARRAY:
> data_fprintf(f, do_padd ? padd : 0, "[\n");
> 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.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-02-23 13:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 20:46 [LTP] [PATCH 0/9] metadata: improvements Petr Vorel
2024-01-04 20:46 ` [LTP] [PATCH 1/9] metaparse: Print parsing file on verbose Petr Vorel
2024-01-05 12:03 ` Petr Vorel
2024-02-23 12:12 ` Cyril Hrubis
2024-02-23 13:51 ` Petr Vorel
2024-02-23 12:24 ` Cyril Hrubis
2024-01-04 20:46 ` [LTP] [PATCH 2/9] metadata: parse.sh: Allow to pass list of files Petr Vorel
2024-02-23 12:42 ` Cyril Hrubis
2024-02-23 14:11 ` Petr Vorel
2024-01-04 20:46 ` [LTP] [PATCH 3/9] metadata: parse.sh: Pass -v to metaparse on VERBOSE=1 Petr Vorel
2024-02-23 12:46 ` Cyril Hrubis
2024-02-23 14:33 ` Petr Vorel
2024-02-23 14:37 ` Petr Vorel
2024-02-23 14:40 ` Cyril Hrubis
2024-01-04 20:46 ` [LTP] [PATCH 4/9] metadata: test.sh: Print more info " Petr Vorel
2024-02-23 12:53 ` Cyril Hrubis
2024-02-23 14:54 ` Petr Vorel
2024-01-04 20:46 ` [LTP] [PATCH 5/9] metaparse: Verbose output on V=1 Petr Vorel
2024-02-23 12:50 ` Cyril Hrubis
2024-02-23 14:40 ` Petr Vorel
2024-01-04 20:46 ` [LTP] [PATCH 6/9] metaparse: Add missing blank line on the list Petr Vorel
2024-02-23 13:08 ` Cyril Hrubis [this message]
2024-02-23 14:42 ` Cyril Hrubis
2024-02-23 15:04 ` Petr Vorel
2024-01-04 20:46 ` [LTP] [PATCH 7/9] metadata: Add test for missing blank line in list Petr Vorel
2024-01-04 20:46 ` [LTP] [PATCH 8/9] ci/debian: Allow to install packages only for docparse Petr Vorel
2024-02-23 13:17 ` Cyril Hrubis
2024-02-23 13:46 ` Petr Vorel
2024-01-04 21:23 ` [LTP] [PATCH 0/9] metadata: improvements Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZdiYya4ZvOY4j5UX@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox