Patch 8.2.0800

4 views
Skip to first unread message

Bram Moolenaar

unread,
May 19, 2020, 4:40:02 PM5/19/20
to vim...@googlegroups.com

Patch 8.2.0800
Problem: Errors from failing test are unclear.
Solution: Include text where parsing failed.
Files: src/json.c, src/testdir/test_json.vim


*** ../vim-8.2.0799/src/json.c 2020-05-13 22:44:18.142288807 +0200
--- src/json.c 2020-05-19 22:33:06.202292033 +0200
***************
*** 20,25 ****
--- 20,27 ----

static int json_encode_item(garray_T *gap, typval_T *val, int copyID, int options);

+ static char e_json_error[] = N_("E491: json decode error at '%s'");
+
/*
* Encode "val" into a JSON format string.
* The result is added to "gap"
***************
*** 740,746 ****
retval = json_decode_string(reader, cur_item, *p);
else
{
! emsg(_(e_invarg));
retval = FAIL;
}
break;
--- 742,748 ----
retval = json_decode_string(reader, cur_item, *p);
else
{
! semsg(_(e_json_error), p);
retval = FAIL;
}
break;
***************
*** 748,754 ****
case ',': // comma: empty item
if ((options & JSON_JS) == 0)
{
! emsg(_(e_invarg));
retval = FAIL;
break;
}
--- 750,756 ----
case ',': // comma: empty item
if ((options & JSON_JS) == 0)
{
! semsg(_(e_json_error), p);
retval = FAIL;
break;
}
***************
*** 778,784 ****
}
if (!VIM_ISDIGIT(*sp))
{
! emsg(_(e_invarg));
retval = FAIL;
break;
}
--- 780,786 ----
}
if (!VIM_ISDIGIT(*sp))
{
! semsg(_(e_json_error), p);
retval = FAIL;
break;
}
***************
*** 809,815 ****
&nr, NULL, 0, TRUE);
if (len == 0)
{
! emsg(_(e_invarg));
retval = FAIL;
goto theend;
}
--- 811,817 ----
&nr, NULL, 0, TRUE);
if (len == 0)
{
! semsg(_(e_json_error), p);
retval = FAIL;
goto theend;
}
***************
*** 962,968 ****
retval = MAYBE;
else
{
! emsg(_(e_invarg));
retval = FAIL;
}
goto theend;
--- 964,970 ----
retval = MAYBE;
else
{
! semsg(_(e_json_error), p);
retval = FAIL;
}
goto theend;
***************
*** 980,986 ****
retval = MAYBE;
else
{
! emsg(_(e_invarg));
retval = FAIL;
}
goto theend;
--- 982,988 ----
retval = MAYBE;
else
{
! semsg(_(e_json_error), p);
retval = FAIL;
}
goto theend;
***************
*** 1036,1042 ****
retval = MAYBE;
else
{
! emsg(_(e_invarg));
retval = FAIL;
}
goto theend;
--- 1038,1044 ----
retval = MAYBE;
else
{
! semsg(_(e_json_error), p);
retval = FAIL;
}
goto theend;
***************
*** 1055,1061 ****
res->v_type = VAR_SPECIAL;
res->vval.v_number = VVAL_NONE;
}
! emsg(_(e_invarg));

theend:
ga_clear(&stack);
--- 1057,1063 ----
res->v_type = VAR_SPECIAL;
res->vval.v_number = VVAL_NONE;
}
! semsg(_(e_json_error), p);

theend:
ga_clear(&stack);
***************
*** 1079,1085 ****
if (ret != OK)
{
if (ret == MAYBE)
! emsg(_(e_invarg));
return FAIL;
}
json_skip_white(reader);
--- 1081,1087 ----
if (ret != OK)
{
if (ret == MAYBE)
! semsg(_(e_json_error), reader->js_buf);
return FAIL;
}
json_skip_white(reader);
*** ../vim-8.2.0799/src/testdir/test_json.vim 2019-08-31 21:38:17.000000000 +0200
--- src/testdir/test_json.vim 2020-05-19 22:35:01.489763121 +0200
***************
*** 148,183 ****
call assert_fails("call json_decode('{\"\": \"ok\", \"\": \"bad\"}')", 'E938:')

call assert_equal({'n': 1}, json_decode('{"n":1,}'))
! call assert_fails("call json_decode(\"{'n':'1',}\")", 'E474:')
! call assert_fails("call json_decode(\"'n'\")", 'E474:')

! call assert_fails('call json_decode("\"")', "E474:")
! call assert_fails('call json_decode("blah")', "E474:")
call assert_fails('call json_decode("true blah")', "E488:")
! call assert_fails('call json_decode("<foobar>")', "E474:")
call assert_fails('call json_decode("{\"a\":1,\"a\":2}")', "E938:")

! call assert_fails('call json_decode("{")', "E474:")
! call assert_fails('call json_decode("{foobar}")', "E474:")
! call assert_fails('call json_decode("{\"n\",")', "E474:")
! call assert_fails('call json_decode("{\"n\":")', "E474:")
! call assert_fails('call json_decode("{\"n\":1")', "E474:")
! call assert_fails('call json_decode("{\"n\":1,")', "E474:")
! call assert_fails('call json_decode("{\"n\",1}")', "E474:")
! call assert_fails('call json_decode("{-}")', "E474:")
!
! call assert_fails('call json_decode("[foobar]")', "E474:")
! call assert_fails('call json_decode("[")', "E474:")
! call assert_fails('call json_decode("[1")', "E474:")
! call assert_fails('call json_decode("[1,")', "E474:")
! call assert_fails('call json_decode("[1 2]")', "E474:")

! call assert_fails('call json_decode("[1,,2]")', "E474:")

! call assert_fails('call json_decode("{{}:42}")', "E474:")
! call assert_fails('call json_decode("{[]:42}")', "E474:")

! call assert_fails('call json_decode("\"\\u111Z\"")', 'E474:')
call assert_equal('[😂]', json_decode('"[\uD83D\uDE02]"'))
call assert_equal('a😂b', json_decode('"a\uD83D\uDE02b"'))
endfunc
--- 148,183 ----
call assert_fails("call json_decode('{\"\": \"ok\", \"\": \"bad\"}')", 'E938:')

call assert_equal({'n': 1}, json_decode('{"n":1,}'))
! call assert_fails("call json_decode(\"{'n':'1',}\")", 'E491:')
! call assert_fails("call json_decode(\"'n'\")", 'E491:')

! call assert_fails('call json_decode("\"")', "E491:")
! call assert_fails('call json_decode("blah")', "E491:")
call assert_fails('call json_decode("true blah")', "E488:")
! call assert_fails('call json_decode("<foobar>")', "E491:")
call assert_fails('call json_decode("{\"a\":1,\"a\":2}")', "E938:")

! call assert_fails('call json_decode("{")', "E491:")
! call assert_fails('call json_decode("{foobar}")', "E491:")
! call assert_fails('call json_decode("{\"n\",")', "E491:")
! call assert_fails('call json_decode("{\"n\":")', "E491:")
! call assert_fails('call json_decode("{\"n\":1")', "E491:")
! call assert_fails('call json_decode("{\"n\":1,")', "E491:")
! call assert_fails('call json_decode("{\"n\",1}")', "E491:")
! call assert_fails('call json_decode("{-}")', "E491:")
!
! call assert_fails('call json_decode("[foobar]")', "E491:")
! call assert_fails('call json_decode("[")', "E491:")
! call assert_fails('call json_decode("[1")', "E491:")
! call assert_fails('call json_decode("[1,")', "E491:")
! call assert_fails('call json_decode("[1 2]")', "E491:")

! call assert_fails('call json_decode("[1,,2]")', "E491:")

! call assert_fails('call json_decode("{{}:42}")', "E491:")
! call assert_fails('call json_decode("{[]:42}")', "E491:")

! call assert_fails('call json_decode("\"\\u111Z\"")', 'E491:')
call assert_equal('[😂]', json_decode('"[\uD83D\uDE02]"'))
call assert_equal('a😂b', json_decode('"a\uD83D\uDE02b"'))
endfunc
*** ../vim-8.2.0799/src/version.c 2020-05-19 21:43:41.739172477 +0200
--- src/version.c 2020-05-19 22:26:35.416034247 +0200
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 800,
/**/

--
hundred-and-one symptoms of being an internet addict:
140. You'd rather catch a score on the web than watch the game as
it is being played on tv.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages