1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Store struct dom_scan_table_info data in a dom_string

This commit is contained in:
Jonas Fonseca 2005-12-28 15:51:31 +01:00 committed by Jonas Fonseca
parent 73785bee02
commit 62d981c551
2 changed files with 11 additions and 13 deletions

View File

@ -128,21 +128,21 @@ init_dom_scanner_info(struct dom_scanner_info *scanner_info)
if (!info) return;
for (i = 0; info[i].type != DOM_SCAN_END; i++) {
const union scan_table_data *data = &info[i].data;
const struct dom_string *data = &info[i].data;
if (info[i].type == DOM_SCAN_RANGE) {
int index = *data->range.start;
int index = *data->string;
assert(index > 0);
assert(data->range.end < DOM_SCAN_TABLE_SIZE);
assert(index <= data->range.end);
assert(data->length < DOM_SCAN_TABLE_SIZE);
assert(index <= data->length);
for (; index <= data->range.end; index++)
for (; index <= data->length; index++)
scan_table[index] |= info[i].bits;
} else {
unsigned char *string = info[i].data.string.source;
int pos = info[i].data.string.length - 1;
unsigned char *string = info[i].data.string;
int pos = info[i].data.length - 1;
assert(info[i].type == DOM_SCAN_STRING && pos >= 0);

View File

@ -1,6 +1,7 @@
#ifndef EL_DOM_SCANNER_H
#define EL_DOM_SCANNER_H
#include "dom/string.h"
#include "util/error.h"
/* Define if you want a talking scanner */
@ -39,17 +40,14 @@ struct dom_scanner_token {
struct dom_scan_table_info {
enum { DOM_SCAN_RANGE, DOM_SCAN_STRING, DOM_SCAN_END } type;
union scan_table_data {
struct { unsigned char *source; long length; } string;
struct { unsigned char *start; long end; } range;
} data;
struct dom_string data;
int bits;
};
#define DOM_SCAN_TABLE_SIZE 256
#define DOM_SCAN_TABLE_INFO(type, data1, data2, bits) \
{ (type), { { (data1), (data2) } }, (bits) }
{ (type), INIT_DOM_STRING((data1), (data2)), (bits) }
#define DOM_SCAN_TABLE_RANGE(from, to, bits) \
DOM_SCAN_TABLE_INFO(DOM_SCAN_RANGE, from, to, bits)
@ -58,7 +56,7 @@ struct dom_scan_table_info {
DOM_SCAN_TABLE_INFO(DOM_SCAN_STRING, str, sizeof(str) - 1, bits)
#define DOM_SCAN_TABLE_END \
DOM_SCAN_TABLE_INFO(DOM_SCAN_END, 0, 0, 0)
DOM_SCAN_TABLE_INFO(DOM_SCAN_END, NULL, 0, 0)
struct dom_scanner_string_mapping {
unsigned char *name;