xref: /php-src/ext/dom/lexbor/lexbor/html/tree/error.c (revision bffab33a)
1 /*
2  * Copyright (C) 2018 Alexander Borisov
3  *
4  * Author: Alexander Borisov <borisov@lexbor.com>
5  */
6 
7 #include "lexbor/html/tree/error.h"
8 
9 
10 lxb_html_tree_error_t *
lxb_html_tree_error_add(lexbor_array_obj_t * parse_errors,lxb_html_token_t * token,lxb_html_tree_error_id_t id)11 lxb_html_tree_error_add(lexbor_array_obj_t *parse_errors,
12                         lxb_html_token_t *token, lxb_html_tree_error_id_t id)
13 {
14     if (parse_errors == NULL) {
15         return NULL;
16     }
17 
18     lxb_html_tree_error_t *entry = lexbor_array_obj_push(parse_errors);
19     if (entry == NULL) {
20         return NULL;
21     }
22 
23     entry->id = id;
24     entry->line = token->line;
25     entry->column = token->column;
26     entry->length = token->end - token->begin;
27 
28     return entry;
29 }
30