From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] docparse: Replace \t with space
Date: Thu, 21 Jan 2021 14:47:57 +0000 [thread overview]
Message-ID: <87mtx29wiq.fsf@suse.de> (raw)
In-Reply-To: <20210121130033.20764-1-pvorel@suse.cz>
Hello,
Petr Vorel <pvorel@suse.cz> writes:
> to avoid constant failures because tabs are forbidden in JSON.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
>
> Currently required for "Convert CAN tests to new LTP API" patchset
> https://patchwork.ozlabs.org/project/ltp/patch/20210120143723.26483-5-rpalethorpe@suse.com/
> https://patchwork.ozlabs.org/project/ltp/patch/20210120143723.26483-6-rpalethorpe@suse.com/
>
> Kind regards,
> Petr
>
> docparse/data_storage.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/docparse/data_storage.h b/docparse/data_storage.h
> index ef420c08f..99c2514b7 100644
> --- a/docparse/data_storage.h
> +++ b/docparse/data_storage.h
> @@ -54,6 +54,7 @@ static inline struct data_node *data_node_string(const char *string)
> {
> size_t size = sizeof(struct data_node_string) + strlen(string) + 1;
> struct data_node *node = malloc(size);
> + char *ix = node->string.val;
>
> if (!node)
> return NULL;
> @@ -61,6 +62,9 @@ static inline struct data_node *data_node_string(const char *string)
> node->type = DATA_STRING;
> strcpy(node->string.val, string);
>
> + while ((ix = strchr(ix, '\t')))
> + *ix++ = ' ';
JQ says "control characters from U+0000 through U+001F must be
escaped". So I expect it is only a matter of time until some other
control character is used.
Perhaps we should escape all control characters into the \uXXXX
hexidecimal form?
http://www.json.org/json-en.html
> +
> return node;
> }
--
Thank you,
Richard.
next prev parent reply other threads:[~2021-01-21 14:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-21 13:00 [LTP] [PATCH 1/2] docparse: Replace \t with space Petr Vorel
2021-01-21 13:00 ` [LTP] [PATCH 2/2] testinfo.pl: Optimize imports Petr Vorel
2021-01-28 14:53 ` Petr Vorel
2021-01-21 13:05 ` [LTP] [PATCH 1/2] docparse: Replace \t with space Petr Vorel
2021-01-21 14:47 ` Richard Palethorpe [this message]
2021-01-21 14:50 ` Cyril Hrubis
2021-01-21 15:43 ` Petr Vorel
2021-01-21 15:59 ` Richard Palethorpe
2021-01-21 16:20 ` Petr Vorel
2021-01-21 16:28 ` Cyril Hrubis
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=87mtx29wiq.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=ltp@lists.linux.it \
/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