Commit 21afeb40edf27c195afe12d089d91577bf8b7898

Thomas de Grivel 2023-07-14T11:25:41

array litteral with {}

diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index df0801c..4206cdf 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -172,14 +172,14 @@ sw buf_parse_array_dimension_count (s_buf *buf, s_array *dest)
   assert(dest);
   tmp = *dest;
   buf_save_init(buf, &save);
-  if ((r = buf_read_1(buf, "[")) <= 0)
+  if ((r = buf_read_1(buf, "{")) <= 0)
     goto clean;
   result += r;
   tmp.dimension = 1;
   if ((r = buf_ignore_spaces(buf)) < 0)
     goto restore;
   result += r;
-  while ((r = buf_read_1(buf, "[")) > 0) {
+  while ((r = buf_read_1(buf, "{")) > 0) {
     result += r;
     tmp.dimension++;
     if ((r = buf_ignore_spaces(buf)) < 0)
diff --git a/test/buf_parse_test.c b/test/buf_parse_test.c
index 49bb3b2..7558caa 100644
--- a/test/buf_parse_test.c
+++ b/test/buf_parse_test.c
@@ -752,11 +752,11 @@ void buf_parse_test ()
 
 TEST_CASE(buf_parse_array)
 {
-  BUF_PARSE_TEST_ARRAY("(u8)[0]");
-  BUF_PARSE_TEST_ARRAY("(u8) [0]");
-  BUF_PARSE_TEST_ARRAY("(u8) [[0], [0]]");
-  BUF_PARSE_TEST_ARRAY("(u8) [[[0, 1], [2, 3]], [[4, 5], [6, 7]]]");
-  BUF_PARSE_TEST_ARRAY("(u8)[ [ 0 ],[ 0 ] ]");
+  BUF_PARSE_TEST_ARRAY("(u8){0}");
+  BUF_PARSE_TEST_ARRAY("(u8) {0}");
+  BUF_PARSE_TEST_ARRAY("(u8) {{0}, {0}}");
+  BUF_PARSE_TEST_ARRAY("(u8) {{{0, 1}, {2, 3}}, {{4, 5}, {6, 7}}}");
+  BUF_PARSE_TEST_ARRAY("(u8){ { 0 },{ 0 } }");
 }
 TEST_CASE_END(buf_parse_array)