1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00

Change parse_sgml() to take buf+bufsize instead of DOM string

This commit is contained in:
Jonas Fonseca 2006-01-14 11:32:11 +01:00 committed by Jonas Fonseca
parent 0c866fd8ae
commit 0950996dd8
3 changed files with 8 additions and 6 deletions

View File

@ -981,7 +981,6 @@ render_dom_document(struct cache_entry *cached, struct document *document,
unsigned char *string = struri(cached->uri);
size_t length = strlen(string);
struct dom_string uri = INIT_DOM_STRING(string, length);
struct dom_string source = INIT_DOM_STRING(buffer->source, buffer->length);
enum sgml_parser_code code;
convert_table = get_convert_table(head, document->options.cp,
@ -1035,7 +1034,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
* However, it will be useful when we will be able to also
* incrementally parse new data. This will require the parser to live
* during the fetching of data. */
code = parse_sgml(parser, &source, 1);
code = parse_sgml(parser, buffer->source, buffer->length, 1);
if (parser->root) {
assert(parser->stack.depth == 1);

View File

@ -400,8 +400,10 @@ parse_sgml_plain(struct dom_stack *stack, struct dom_scanner *scanner)
}
enum sgml_parser_code
parse_sgml(struct sgml_parser *parser, struct dom_string *buffer, int complete)
parse_sgml(struct sgml_parser *parser, unsigned char *buf, size_t bufsize,
int complete)
{
struct dom_string source = INIT_DOM_STRING(buf, bufsize);
struct sgml_parsing_state *parsing;
enum sgml_parser_code code;
@ -415,7 +417,7 @@ parse_sgml(struct sgml_parser *parser, struct dom_string *buffer, int complete)
get_dom_stack_top(&parser->stack)->immutable = 1;
}
parsing = init_sgml_parsing_state(parser, buffer);
parsing = init_sgml_parsing_state(parser, &source);
if (!parsing) return SGML_PARSER_CODE_MEM_ALLOC;
code = parse_sgml_plain(&parser->stack, &parsing->scanner);

View File

@ -137,14 +137,15 @@ void done_sgml_parser(struct sgml_parser *parser);
* signals through the `complete` parameter.
*
* parser:: A parser created with ref:[init_sgml_parser].
* buffer:: A string containing the chunk to parse.
* buf:: A buffer containing the chunk to parse.
* bufsize:: The size of the buffer given in the buf parameter.
* complete:: Whether this is the last chunk to parse.
*
* The returned code is ref:[SGML_PARSER_CODE_OK] if the buffer was
* successfully parserd, else a code hinting at the error.
*/
enum sgml_parser_code
parse_sgml(struct sgml_parser *parser, struct dom_string *buffer, int complete);
parse_sgml(struct sgml_parser *parser, unsigned char *buf, size_t bufsize, int complete);
/** Get the line position in the source
*