Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.c can not be converted to v #124

Open
trollkarlen opened this issue May 4, 2023 · 0 comments
Open

xml.c can not be converted to v #124

trollkarlen opened this issue May 4, 2023 · 0 comments
Labels
Bug Something isn't working

Comments

@trollkarlen
Copy link
Contributor

trollkarlen commented May 4, 2023

Small xml library xml.c cant be converted to v code.
Repo of C code - https://github.com/ooxi/xml.c

git clone https://github.com/ooxi/xml.c.git
# commit 2cb2dcaf2b4d6ff42346e8c58eefd28559666747 (HEAD -> master, origin/master, origin/HEAD)
cd xml.c
v run $HOME/.vmodules/c2v -d src/
C to V translator 0.3.1
"src/" is a directory, processing all C files in it recursively...

  translating ./xml.c         ... No more children
c2v_output/xml.v:476:10: error: use assignment `=` instead of declaration `:=` when modifying struct fields
  474 |             buffer = realloc(buffer, buffer_size + 2 * read_chunk)
  475 |             buffer_size += 2 * read_chunk
  476 |         }
      |          ^
  477 |         c.read := C.fread(&buffer [document_length] , sizeof(u8), read_chunk, source)
  478 |         document_length += C.read

# after that was fixed

$ v fmt src/c2v_output/xml.v 
src/c2v_output/xml.v:566:2: error: invalid expression: unexpected token `}`
  564 |         }
  565 |         current = next
  566 |         child_name = 
      |     ^
  567 |     }
  568 |     __builtin_va_end(arguments)

Internal vfmt error while formatting file: src/c2v_output/xml.v.
Encountered a total of: 1 errors.

# I think this should be "child_name = ___builtin_va_arg(arguments, &u8)"

After this fmt works.
But there is a lot of unsafe, malloc and other issues.
Should malloc be changed to v malloc/calloc ?

$ v run src/c2v_output/xml.v
src/c2v_output/xml.v:76:7: warning: pointer arithmetic is only allowed in `unsafe` blocks
   74 |     str += strcspn(str, delim)
   75 |     if *str {
   76 |         *str++ = `\x00`
      |             ~~
   77 |     }
   78 |     *nextp = str
src/c2v_output/xml.v:167:5: warning: pointer arithmetic is only allowed in `unsafe` blocks
  165 |     for *at {
  166 |         xml_attribute_free(*at)
  167 |         at++$
      |           ~~
  168 |     }
  169 |     C.free(node.attributes)
src/c2v_output/xml.v:173:5: warning: pointer arithmetic is only allowed in `unsafe` blocks
  171 |     for *it {
  172 |         xml_node_free(*it)
  173 |         it++$
      |           ~~
  174 |     }
  175 |     C.free(node.children)
src/c2v_output/xml.v:266:8: warning: casting `&u8` to `&i8` is only allowed in `unsafe` code
  264 |     attributes = C.calloc(1, sizeof(&Xml_attribute))
  265 |     attributes[0] = 0
  266 |     tmp = &i8(xml_string_clone(tag_open))
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  267 |     token = xml_strtok_r(tmp, c' ', &rest)
  268 |     if token == (unsafe { nil }) {
src/c2v_output/xml.v:269:8: warning: `goto` requires `unsafe` (consider using labelled break/continue)
  267 |     token = xml_strtok_r(tmp, c' ', &rest)
  268 |     if token == (unsafe { nil }) {
  269 |         goto cleanup
      |              ~~~~~~~
  270 |         // id: 0x7f9a979fc538
  271 |     }
src/c2v_output/xml.v:272:22: warning: function `C.strlen` must be called from an `unsafe` block
  270 |         // id: 0x7f9a979fc538
  271 |     }
  272 |     tag_open.length = C.strlen(token)
      |                         ~~~~~~~~~~~~~
  273 |     for token = xml_strtok_r((unsafe { nil }), c' ', &rest); token != (unsafe { nil }); token = xml_strtok_r((unsafe { nil }),
  274 |         c' ', &rest) {
src/c2v_output/xml.v:275:16: warning: function `C.malloc` must be called from an `unsafe` block
  273 |     for token = xml_strtok_r((unsafe { nil }), c' ', &rest); token != (unsafe { nil }); token = xml_strtok_r((unsafe { nil }),
  274 |         c' ', &rest) {
  275 |         str_name = C.malloc(C.strlen(token) + 1)
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  276 |         str_content = C.malloc(C.strlen(token) + 1)
  277 |         if C.sscanf(token, c'%[^=]="%[^"]', str_name, str_content) != 2 {
src/c2v_output/xml.v:275:25: warning: function `C.strlen` must be called from an `unsafe` block
  273 |     for token = xml_strtok_r((unsafe { nil }), c' ', &rest); token != (unsafe { nil }); token = xml_strtok_r((unsafe { nil }),
  274 |         c' ', &rest) {
  275 |         str_name = C.malloc(C.strlen(token) + 1)
      |                               ~~~~~~~~~~~~~
  276 |         str_content = C.malloc(C.strlen(token) + 1)
  277 |         if C.sscanf(token, c'%[^=]="%[^"]', str_name, str_content) != 2 {
src/c2v_output/xml.v:276:19: warning: function `C.malloc` must be called from an `unsafe` block
  274 |         c' ', &rest) {
  275 |         str_name = C.malloc(C.strlen(token) + 1)
  276 |         str_content = C.malloc(C.strlen(token) + 1)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  277 |         if C.sscanf(token, c'%[^=]="%[^"]', str_name, str_content) != 2 {
  278 |             if C.sscanf(token, c"%[^=]='%[^']", str_name, str_content) != 2 {
src/c2v_output/xml.v:276:28: warning: function `C.strlen` must be called from an `unsafe` block
  274 |         c' ', &rest) {
  275 |         str_name = C.malloc(C.strlen(token) + 1)
  276 |         str_content = C.malloc(C.strlen(token) + 1)
      |                                  ~~~~~~~~~~~~~
  277 |         if C.sscanf(token, c'%[^=]="%[^"]', str_name, str_content) != 2 {
  278 |             if C.sscanf(token, c"%[^=]='%[^']", str_name, str_content) != 2 {
src/c2v_output/xml.v:277:8: warning: function `C.sscanf` must be called from an `unsafe` block
  275 |         str_name = C.malloc(C.strlen(token) + 1)
  276 |         str_content = C.malloc(C.strlen(token) + 1)
  277 |         if C.sscanf(token, c'%[^=]="%[^"]', str_name, str_content) != 2 {
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  278 |             if C.sscanf(token, c"%[^=]='%[^']", str_name, str_content) != 2 {
  279 |                 C.free(str_name)
src/c2v_output/xml.v:278:9: warning: function `C.sscanf` must be called from an `unsafe` block
  276 |         str_content = C.malloc(C.strlen(token) + 1)
  277 |         if C.sscanf(token, c'%[^=]="%[^"]', str_name, str_content) != 2 {
  278 |             if C.sscanf(token, c"%[^=]='%[^']", str_name, str_content) != 2 {
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  279 |                 C.free(str_name)
  280 |                 C.free(str_content)
src/c2v_output/xml.v:284:14: warning: pointer arithmetic is only allowed in `unsafe` blocks
  282 |             }
  283 |         }
  284 |         position = token - tmp
      |                    ~~~~~~~~~~~
  285 |         start_name = &tag_open.buffer[position]
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
src/c2v_output/xml.v:286:49: warning: function `C.strlen` must be called from an `unsafe` block
  284 |         position = token - tmp
  285 |         start_name = &tag_open.buffer[position]
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
      |                                                       ~~~~~~~~~~~~~~~~
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
src/c2v_output/xml.v:286:49: warning: function `C.strlen` must be called from an `unsafe` block
  284 |         position = token - tmp
  285 |         start_name = &tag_open.buffer[position]
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
      |                                                       ~~~~~~~~~~~~~~~~
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
src/c2v_output/xml.v:287:21: warning: function `C.malloc` must be called from an `unsafe` block
  285 |         start_name = &tag_open.buffer[position]
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
  289 |         new_attribute.name.buffer = &u8(start_name)
src/c2v_output/xml.v:288:26: warning: function `C.malloc` must be called from an `unsafe` block
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~
  289 |         new_attribute.name.buffer = &u8(start_name)
  290 |         new_attribute.name.length = C.strlen(str_name)
src/c2v_output/xml.v:290:33: warning: function `C.strlen` must be called from an `unsafe` block
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
  289 |         new_attribute.name.buffer = &u8(start_name)
  290 |         new_attribute.name.length = C.strlen(str_name)
      |                                       ~~~~~~~~~~~~~~~~
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
  292 |         new_attribute.content.buffer = &u8(start_content)
src/c2v_output/xml.v:291:29: warning: function `C.malloc` must be called from an `unsafe` block
  289 |         new_attribute.name.buffer = &u8(start_name)
  290 |         new_attribute.name.length = C.strlen(str_name)
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~
  292 |         new_attribute.content.buffer = &u8(start_content)
  293 |         new_attribute.content.length = C.strlen(str_content)
src/c2v_output/xml.v:293:36: warning: function `C.strlen` must be called from an `unsafe` block
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
  292 |         new_attribute.content.buffer = &u8(start_content)
  293 |         new_attribute.content.length = C.strlen(str_content)
      |                                          ~~~~~~~~~~~~~~~~~~~
  294 |         old_elements = get_zero_terminated_array_attributes(attributes)
  295 |         new_elements = old_elements + 1
src/c2v_output/xml.v:329:12: warning: function `C.malloc` must be called from an `unsafe` block
  327 |     }
  328 |     xml_parser_consume(parser, 1)
  329 |     name := C.malloc(sizeof(Xml_string))
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~
  330 |     name.buffer = &parser.buffer[start]
  331 |     name.length = length
src/c2v_output/xml.v:393:15: warning: function `C.malloc` must be called from an `unsafe` block
  391 |         length--
  392 |     }
  393 |     content := C.malloc(sizeof(Xml_string))
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
  394 |     content.buffer = &parser.buffer[start]
  395 |     content.length = length
src/c2v_output/xml.v:411:11: warning: cannot assign a reference to a value (this will be an error soon) left=int false right=Xml_string true ptr=true
  409 |     children := C.calloc(1, sizeof(&Xml_node))
  410 |     children[0] = 0
  411 |     tag_open = xml_parse_tag_open(parser)
      |              ^
  412 |     if !tag_open {
  413 |         xml_parser_error(parser, Xml_parser_offset.no_character, c'xml_parse_node::tag_open')
src/c2v_output/xml.v:414:8: warning: `goto` requires `unsafe` (consider using labelled break/continue)
  412 |     if !tag_open {
  413 |         xml_parser_error(parser, Xml_parser_offset.no_character, c'xml_parse_node::tag_open')
  414 |         goto exit_failure
      |              ~~~~~~~~~~~~
  415 |         // id: 0x7f9a97a04798
  416 |     }
src/c2v_output/xml.v:420:8: warning: `goto` requires `unsafe` (consider using labelled break/continue)
  418 |     attributes = xml_find_attributes(parser, tag_open)
  419 |     if tag_open.length > 0 && `/` == tag_open.buffer[original_length - 1] {
  420 |         goto node_creation
      |              ~~~~~~~~~~~~~
  421 |         // id: 0x7f9a97a04d08
  422 |     }
src/c2v_output/xml.v:424:11: warning: cannot assign a reference to a value (this will be an error soon) left=int false right=Xml_string true ptr=true
  422 |     }
  423 |     if `<` != xml_parser_peek(parser, Xml_parser_offset.current_character) {
  424 |         content = xml_parse_content(parser)
      |                 ^
  425 |         if !content {
  426 |             xml_parser_error(parser, 0, c'xml_parse_node::content')
src/c2v_output/xml.v:427:9: warning: `goto` requires `unsafe` (consider using labelled break/continue)
  425 |         if !content {
  426 |             xml_parser_error(parser, 0, c'xml_parse_node::content')
  427 |             goto exit_failure
      |                  ~~~~~~~~~~~~
  428 |             // id: 0x7f9a97a04798
  429 |         }
src/c2v_output/xml.v:432:12: warning: cannot assign a reference to a value (this will be an error soon) left=int false right=Xml_string true ptr=true
  430 |     } else { // 3
  431 |     }
  432 |     tag_close = xml_parse_tag_close(parser)
      |               ^
  433 |     if !tag_close {
  434 |         xml_parser_error(parser, Xml_parser_offset.no_character, c'xml_parse_node::tag_close')
src/c2v_output/xml.v:435:8: warning: `goto` requires `unsafe` (consider using labelled break/continue)
  433 |     if !tag_close {
  434 |         xml_parser_error(parser, Xml_parser_offset.no_character, c'xml_parse_node::tag_close')
  435 |         goto exit_failure
      |              ~~~~~~~~~~~~
  436 |         // id: 0x7f9a97a04798
  437 |     }
src/c2v_output/xml.v:440:8: warning: `goto` requires `unsafe` (consider using labelled break/continue)
  438 |     if !xml_string_equals(tag_open, tag_close) {
  439 |         xml_parser_error(parser, Xml_parser_offset.no_character, c'xml_parse_node::tag missmatch')
  440 |         goto exit_failure
      |              ~~~~~~~~~~~~
  441 |         // id: 0x7f9a97a04798
  442 |     }
src/c2v_output/xml.v:448:12: warning: function `C.malloc` must be called from an `unsafe` block
  446 |     0
  447 |     // null
  448 |     node := C.malloc(sizeof(Xml_node))
      |               ~~~~~~~~~~~~~~~~~~~~~~~~
  449 |     node.name = tag_open
  450 |     node.content = content
src/c2v_output/xml.v:468:5: warning: pointer arithmetic is only allowed in `unsafe` blocks
  466 |     for *it {
  467 |         xml_node_free(*it)
  468 |         it++$
      |           ~~
  469 |     }
  470 |     C.free(children)
src/c2v_output/xml.v:486:16: warning: function `C.malloc` must be called from an `unsafe` block
  484 |         return 0
  485 |     }
  486 |     document := C.malloc(sizeof(Xml_document))
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  487 |     document.buffer.buffer = buffer
  488 |     document.buffer.length = length
src/c2v_output/xml.v:497:14: warning: function `C.malloc` must be called from an `unsafe` block
  495 |     document_length := 0
  496 |     buffer_size := 1
  497 |     buffer := C.malloc(buffer_size * sizeof(u8))
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  498 |     for !feof(source) {
  499 |         if buffer_size - document_length < read_chunk {
src/c2v_output/xml.v:578:11: warning: cannot assign a reference to a value (this will be an error soon) left=int false right=Xml_node true ptr=true
  576 |             if xml_string_equals(xml_node_name(child), &cn) {
  577 |                 if !next {
  578 |                     next = child
      |                          ^
  579 |                 } else {
  580 |                     __builtin_va_end(arguments)
src/c2v_output/xml.v:622:4: warning: function `C.memcpy` must be called from an `unsafe` block
  620 |     }
  621 |     length = (if length < (string_.length) { length } else { (string_.length) })
  622 |     C.memcpy(buffer, string_.buffer, length)
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  623 | }
src/c2v_output/xml.v:70:10: error: `i8` cannot be compared with `rune`
   68 |     }
   69 |     str += strspn(str, delim)
   70 |     if *str == `\x00` {
      |             ~~
   71 |         return unsafe { nil }
   72 |     }
src/c2v_output/xml.v:111:9: error: cannot use `int` as type `usize` in return argument
  109 |         elements++$
  110 |     }
  111 |     return elements
      |            ~~~~~~~~
  112 | }
  113 |
src/c2v_output/xml.v:119:9: error: cannot use `int` as type `usize` in return argument
  117 |         elements++$
  118 |     }
  119 |     return elements
      |            ~~~~~~~~
  120 | }
  121 |
src/c2v_output/xml.v:123:7: error: type `Xml_string` has no field named `length`
  121 | 
  122 | fn xml_string_equals(a &Xml_string, b &Xml_string) bool {
  123 |     if a.length != b.length {
      |          ~~~~~~
  124 |         return false
  125 |     }
src/c2v_output/xml.v:127:14: error: type `Xml_string` has no field named `length`
  125 |     }
  126 |     i := 0
  127 |     for ; i < a.length; i++ {
      |                 ~~~~~~
  128 |         if a.buffer[i] != b.buffer[i] {
  129 |             return false
src/c2v_output/xml.v:128:8: error: type `Xml_string` has no field named `buffer`
  126 |     i := 0
  127 |     for ; i < a.length; i++ {
  128 |         if a.buffer[i] != b.buffer[i] {
      |              ~~~~~~
  129 |             return false
  130 |         }
src/c2v_output/xml.v:139:22: error: type `Xml_string` has no field named `length`
  137 |         return 0
  138 |     }
  139 |     clone := C.calloc(s.length + 1, sizeof(u8))
      |                         ~~~~~~
  140 |     xml_string_copy(s, clone, s.length)
  141 |     clone[s.length] = 0
src/c2v_output/xml.v:140:30: error: type `Xml_string` has no field named `length`
  138 |     }
  139 |     clone := C.calloc(s.length + 1, sizeof(u8))
  140 |     xml_string_copy(s, clone, s.length)
      |                                 ~~~~~~
  141 |     clone[s.length] = 0
  142 |     return clone
src/c2v_output/xml.v:141:10: error: type `Xml_string` has no field named `length`
  139 |     clone := C.calloc(s.length + 1, sizeof(u8))
  140 |     xml_string_copy(s, clone, s.length)
  141 |     clone[s.length] = 0
      |             ~~~~~~
  142 |     return clone
  143 | }
src/c2v_output/xml.v:167:5: error: invalid operation: ++ (non-numeric type `&&Xml_attribute`)
  165 |     for *at {
  166 |         xml_attribute_free(*at)
  167 |         at++$
      |           ~~
  168 |     }
  169 |     C.free(node.attributes)
src/c2v_output/xml.v:173:5: error: invalid operation: ++ (non-numeric type `&&Xml_node`)
  171 |     for *it {
  172 |         xml_node_free(*it)
  173 |         it++$
      |           ~~
  174 |     }
  175 |     C.free(node.children)
src/c2v_output/xml.v:272:11: error: type `Xml_string` has no field named `length`
  270 |         // id: 0x7f9a979fc538
  271 |     }
  272 |     tag_open.length = C.strlen(token)
      |              ~~~~~~
  273 |     for token = xml_strtok_r((unsafe { nil }), c' ', &rest); token != (unsafe { nil }); token = xml_strtok_r((unsafe { nil }),
  274 |         c' ', &rest) {
src/c2v_output/xml.v:285:26: error: type `Xml_string` has no field named `buffer`
  283 |         }
  284 |         position = token - tmp
  285 |         start_name = &tag_open.buffer[position]
      |                                ~~~~~~
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
src/c2v_output/xml.v:286:29: error: type `Xml_string` has no field named `buffer`
  284 |         position = token - tmp
  285 |         start_name = &tag_open.buffer[position]
  286 |         start_content = &tag_open.buffer[position + C.strlen(str_name) + 2]
      |                                   ~~~~~~
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
src/c2v_output/xml.v:289:22: error: type `Xml_string` has no field named `buffer`
  287 |         new_attribute = C.malloc(sizeof(Xml_attribute))
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
  289 |         new_attribute.name.buffer = &u8(start_name)
      |                            ~~~~~~
  290 |         new_attribute.name.length = C.strlen(str_name)
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
src/c2v_output/xml.v:290:22: error: type `Xml_string` has no field named `length`
  288 |         new_attribute.name = C.malloc(sizeof(Xml_string))
  289 |         new_attribute.name.buffer = &u8(start_name)
  290 |         new_attribute.name.length = C.strlen(str_name)
      |                            ~~~~~~
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
  292 |         new_attribute.content.buffer = &u8(start_content)
src/c2v_output/xml.v:292:25: error: type `Xml_string` has no field named `buffer`
  290 |         new_attribute.name.length = C.strlen(str_name)
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
  292 |         new_attribute.content.buffer = &u8(start_content)
      |                               ~~~~~~
  293 |         new_attribute.content.length = C.strlen(str_content)
  294 |         old_elements = get_zero_terminated_array_attributes(attributes)
src/c2v_output/xml.v:293:25: error: type `Xml_string` has no field named `length`
  291 |         new_attribute.content = C.malloc(sizeof(Xml_string))
  292 |         new_attribute.content.buffer = &u8(start_content)
  293 |         new_attribute.content.length = C.strlen(str_content)
      |                               ~~~~~~
  294 |         old_elements = get_zero_terminated_array_attributes(attributes)
  295 |         new_elements = old_elements + 1
src/c2v_output/xml.v:296:16: error: unknown function: realloc
  294 |         old_elements = get_zero_terminated_array_attributes(attributes)
  295 |         new_elements = old_elements + 1
  296 |         attributes = realloc(attributes, (new_elements + 1) * sizeof(&Xml_attribute))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  297 |         attributes[new_elements - 1] = new_attribute
  298 |         attributes[new_elements] = 0
src/c2v_output/xml.v:330:7: error: `u8` has no property `buffer`
  328 |     xml_parser_consume(parser, 1)
  329 |     name := C.malloc(sizeof(Xml_string))
  330 |     name.buffer = &parser.buffer[start]
      |          ~~~~~~
  331 |     name.length = length
  332 |     return name
src/c2v_output/xml.v:331:7: error: `u8` has no property `length`
  329 |     name := C.malloc(sizeof(Xml_string))
  330 |     name.buffer = &parser.buffer[start]
  331 |     name.length = length
      |          ~~~~~~
  332 |     return name
  333 | }
src/c2v_output/xml.v:394:10: error: `u8` has no property `buffer`
  392 |     }
  393 |     content := C.malloc(sizeof(Xml_string))
  394 |     content.buffer = &parser.buffer[start]
      |             ~~~~~~
  395 |     content.length = length
  396 |     return content
src/c2v_output/xml.v:395:10: error: `u8` has no property `length`
  393 |     content := C.malloc(sizeof(Xml_string))
  394 |     content.buffer = &parser.buffer[start]
  395 |     content.length = length
      |             ~~~~~~
  396 |     return content
  397 | }
src/c2v_output/xml.v:417:29: error: `int` has no property `length`
  415 |         // id: 0x7f9a97a04798
  416 |     }
  417 |     original_length = tag_open.length
      |                                ~~~~~~
  418 |     attributes = xml_find_attributes(parser, tag_open)
  419 |     if tag_open.length > 0 && `/` == tag_open.buffer[original_length - 1] {
src/c2v_output/xml.v:419:14: error: `int` has no property `length`
  417 |     original_length = tag_open.length
  418 |     attributes = xml_find_attributes(parser, tag_open)
  419 |     if tag_open.length > 0 && `/` == tag_open.buffer[original_length - 1] {
      |                 ~~~~~~
  420 |         goto node_creation
  421 |         // id: 0x7f9a97a04d08
src/c2v_output/xml.v:449:7: error: `u8` has no property `name`
  447 |     // null
  448 |     node := C.malloc(sizeof(Xml_node))
  449 |     node.name = tag_open
      |          ~~~~
  450 |     node.content = content
  451 |     node.attributes = attributes
src/c2v_output/xml.v:450:7: error: `u8` has no property `content`
  448 |     node := C.malloc(sizeof(Xml_node))
  449 |     node.name = tag_open
  450 |     node.content = content
      |          ~~~~~~~
  451 |     node.attributes = attributes
  452 |     node.children = children
src/c2v_output/xml.v:451:7: error: `u8` has no property `attributes`
  449 |     node.name = tag_open
  450 |     node.content = content
  451 |     node.attributes = attributes
      |          ~~~~~~~~~~
  452 |     node.children = children
  453 |     return node
src/c2v_output/xml.v:452:7: error: `u8` has no property `children`
  450 |     node.content = content
  451 |     node.attributes = attributes
  452 |     node.children = children
      |          ~~~~~~~~
  453 |     return node
  454 |     // RRRREG exit_failure id=0x7f9a97a04798
src/c2v_output/xml.v:487:11: error: `u8` has no property `buffer`
  485 |     }
  486 |     document := C.malloc(sizeof(Xml_document))
  487 |     document.buffer.buffer = buffer
      |              ~~~~~~
  488 |     document.buffer.length = length
  489 |     document.root = root
src/c2v_output/xml.v:488:11: error: `u8` has no property `buffer`
  486 |     document := C.malloc(sizeof(Xml_document))
  487 |     document.buffer.buffer = buffer
  488 |     document.buffer.length = length
      |              ~~~~~~
  489 |     document.root = root
  490 |     return document
src/c2v_output/xml.v:489:11: error: `u8` has no property `root`
  487 |     document.buffer.buffer = buffer
  488 |     document.buffer.length = length
  489 |     document.root = root
      |              ~~~~
  490 |     return document
  491 | }
src/c2v_output/xml.v:497:21: error: `buffer_size * sizeof(u8)` (no value) used as value in argument 1 to `C.malloc`
  495 |     document_length := 0
  496 |     buffer_size := 1
  497 |     buffer := C.malloc(buffer_size * sizeof(u8))
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~
  498 |     for !feof(source) {
  499 |         if buffer_size - document_length < read_chunk {
src/c2v_output/xml.v:500:13: error: unknown function: realloc
  498 |     for !feof(source) {
  499 |         if buffer_size - document_length < read_chunk {
  500 |             buffer = realloc(buffer, buffer_size + 2 * read_chunk)
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  501 |             buffer_size += 2 * read_chunk
  502 |         }
src/c2v_output/xml.v:503:3: error: undefined ident: `c`
  501 |             buffer_size += 2 * read_chunk
  502 |         }
  503 |         c.read = C.fread(&buffer[document_length], sizeof(u8), read_chunk, source)
      |         ^
  504 |         document_length += C.read
  505 |     }
src/c2v_output/xml.v:516:25: error: type `Xml_document` has no field named `root`
  514 | 
  515 | fn xml_document_free(document &Xml_document, free_buffer bool) {
  516 |     xml_node_free(document.root)
      |                            ~~~~
  517 |     if free_buffer {
  518 |         C.free(document.buffer.buffer)
src/c2v_output/xml.v:518:19: error: type `Xml_document` has no field named `buffer`
  516 |     xml_node_free(document.root)
  517 |     if free_buffer {
  518 |         C.free(document.buffer.buffer)
      |                         ~~~~~~
  519 |     }
  520 |     C.free(document)
src/c2v_output/xml.v:524:18: error: type `Xml_document` has no field named `root`
  522 | 
  523 | fn xml_document_root(document &Xml_document) &Xml_node {
  524 |     return document.root
      |                     ~~~~
  525 | }
  526 |
src/c2v_output/xml.v:567:15: error: unknown type `Va_list`
  565 | fn xml_easy_child(node &Xml_node, child_name ...&u8) &Xml_node {
  566 |     current := node
  567 |     arguments := Va_list{}
      |                  ~~~~~~~~~
  568 |     __builtin_va_start(arguments, child_name)
  569 |     for child_name {
src/c2v_output/xml.v:568:2: error: unknown function: __builtin_va_start
  566 |     current := node
  567 |     arguments := Va_list{}
  568 |     __builtin_va_start(arguments, child_name)
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  569 |     for child_name {
  570 |         cn := Xml_string{child_name, C.strlen(child_name)}
src/c2v_output/xml.v:570:9: error: too many fields in `Xml_string` literal (expecting 0, got 2)
  568 |     __builtin_va_start(arguments, child_name)
  569 |     for child_name {
  570 |         cn := Xml_string{child_name, C.strlen(child_name)}
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  571 | 
  572 |         next := 0
src/c2v_output/xml.v:580:6: error: unknown function: __builtin_va_end
  578 |                     next = child
  579 |                 } else {
  580 |                     __builtin_va_end(arguments)
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  581 |                     return 0
  582 |                 }
src/c2v_output/xml.v:586:4: error: unknown function: __builtin_va_end
  584 |         }
  585 |         if !next {
  586 |             __builtin_va_end(arguments)
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  587 |             return 0
  588 |         }
src/c2v_output/xml.v:590:16: error: unknown function: ___builtin_va_arg
  588 |         }
  589 |         current = next
  590 |         child_name = ___builtin_va_arg(arguments, &u8)
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  591 |     }
  592 |     __builtin_va_end(arguments)
src/c2v_output/xml.v:592:2: error: unknown function: __builtin_va_end
  590 |         child_name = ___builtin_va_arg(arguments, &u8)
  591 |     }
  592 |     __builtin_va_end(arguments)
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  593 |     return current
  594 | }
src/c2v_output/xml.v:614:17: error: type `Xml_string` has no field named `length`
  612 |         return 0
  613 |     }
  614 |     return string_.length
      |                    ~~~~~~
  615 | }
  616 |
src/c2v_output/xml.v:621:33: error: type `Xml_string` has no field named `length`
  619 |         return
  620 |     }
  621 |     length = (if length < (string_.length) { length } else { (string_.length) })
      |                                    ~~~~~~
  622 |     C.memcpy(buffer, string_.buffer, length)
  623 | }
src/c2v_output/xml.v:622:27: error: type `Xml_string` has no field named `buffer`
  620 |     }
  621 |     length = (if length < (string_.length) { length } else { (string_.length) })
  622 |     C.memcpy(buffer, string_.buffer, length)
      |                              ~~~~~~
  623 | }
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
If the code of your project is in multiple files, try with `v src/c2v_output` instead of `v src/c2v_output/xml.v`
@ArtemkaKun ArtemkaKun added the Bug Something isn't working label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants