<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 4, 2020 at 3:30 PM Petr Vorel <<a href="mailto:pvorel@suse.cz">pvorel@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
> --- /dev/null<br>
> +++ b/docparse/docparse.c<br>
<br>
...<br>
> +const char *next_token(FILE *f, struct data_node *doc)<br>
> +{<br>
> + size_t i = 0;<br>
> + static char buf[4096];<br>
> + int c;<br>
> + int in_str = 0;<br>
> +<br>
> + for (;;) {<br>
> + c = fgetc(f);<br>
> +<br>
> + if (c == EOF)<br>
> + goto exit;<br>
> +<br>
> + if (in_str) {<br>
> + if (c == '"') {<br>
> + if (i == 0 || buf[i-1] != '\\') {<br>
> + buf[i++] = c;<br>
> + goto exit;<br>
> + }<br>
IMHO this change (adding buf[i++] = c;), which Li suggested,<br>
is causing build failures:<br>
<a href="https://travis-ci.org/github/pevik/ltp/builds/741217630" rel="noreferrer" target="_blank">https://travis-ci.org/github/pevik/ltp/builds/741217630</a><br>
<br>
/usr/src/ltp/docparse/<a href="http://testinfo.pl" rel="noreferrer" target="_blank">testinfo.pl</a> metadata.json<br>
, or ] expected while parsing array, at character offset 340 (before "",\n "0c461cb72...") at /usr/src/ltp/docparse/<a href="http://testinfo.pl" rel="noreferrer" target="_blank">testinfo.pl</a> line 379.<br>
make[1]: *** [/usr/src/ltp/docparse/Makefile:60: txt] Error 255<br>
make[1]: Leaving directory '/usr/src/ltp-build/docparse'<br>
make: *** [/usr/src/ltp/Makefile:108: docparse-all] Error 2<br>
make: *** Waiting for unfinished jobs....<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Sorry for the error, it because of wrongly parsed tst_test struct with</div><div class="gmail_default" style="font-size:small">including <span class="gmail_default"></span>.min_kver = "2.6.32", then output into metada.json like:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"># cat metadata.json</div><div class="gmail_default" style="font-size:small">...</div><div class="gmail_default" style="font-size:small"> "cpuset01": {</div> "needs_root": "1",<br> "forks_child": "1",<br> "min_kver": "2.6.32"",<span class="gmail_default" style="font-size:small"> <====== here has two "" in the end</span><br> "fname": "testcases/kernel/mem/cpuset/cpuset01.c"<br> },<br><br></div><div><div class="gmail_default" style="font-size:small">So the "$(abs_srcdir)/<a href="http://testinfo.pl">testinfo.pl</a> metadata.json" in Makefile report failure as above.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">==========</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Another fix I can think of is just to avoid return NULL if detecting in the string("").</div><div class="gmail_default" style="font-size:small">Hope this will work for us, I will help to check it again tomorrow.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--- a/docparse/docparse.c<br>+++ b/docparse/docparse.c<br>@@ -138,10 +138,8 @@ const char *next_token(FILE *f, struct data_node *doc)<br> <br> if (in_str) {<br> if (c == '"') {<br>- if (i == 0 || buf[i-1] != '\\') {<br>- buf[i++] = c;<br>+ if (i == 0 || buf[i-1] != '\\')<br> goto exit;<br>- }<br> }<br> <br> buf[i++] = c;<br>@@ -189,7 +187,7 @@ const char *next_token(FILE *f, struct data_node *doc)<br> }<br> <br> exit:<br>- if (i == 0)<br>+ if (i == 0 && !in_str)<br> return NULL;<br> <br> buf[i] = 0;<br></div><br></div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>