1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

const in scanner

So that render_dom_document_start() is better assured that
default_colors[] won't be modified by the CSS code.
This commit is contained in:
Kalle Olavi Niemitalo 2008-01-26 17:36:33 +02:00 committed by Kalle Olavi Niemitalo
parent f0d10c9f29
commit dae9b988f6
9 changed files with 17 additions and 19 deletions

View File

@ -629,7 +629,7 @@ css_parse_ruleset(struct css_stylesheet *css, struct scanner *scanner)
void
css_parse_stylesheet(struct css_stylesheet *css, struct uri *base_uri,
unsigned char *string, unsigned char *end)
const unsigned char *string, const unsigned char *end)
{
struct scanner scanner;

View File

@ -23,6 +23,6 @@ void css_parse_properties(LIST_OF(struct css_property) *props,
* given stylesheet @a css. If the selector is already in the stylesheet it
* properties are added to the that selector. */
void css_parse_stylesheet(struct css_stylesheet *css, struct uri *base_uri,
unsigned char *string, unsigned char *end);
const unsigned char *string, const unsigned char *end);
#endif

View File

@ -124,7 +124,7 @@ struct scanner_info css_scanner_info = {
static inline void
scan_css_token(struct scanner *scanner, struct scanner_token *token)
{
unsigned char *string = scanner->position;
const unsigned char *string = scanner->position;
unsigned char first_char = *string;
enum css_token_type type = CSS_TOKEN_GARBAGE;
int real_length = -1;
@ -169,7 +169,7 @@ scan_css_token(struct scanner *scanner, struct scanner_token *token)
scan_css(scanner, string, CSS_CHAR_IDENT);
if (*string == '(') {
unsigned char *function_end = string + 1;
const unsigned char *function_end = string + 1;
/* Make sure that we have an ending ')' */
skip_css(scanner, function_end, ')');
@ -193,8 +193,8 @@ scan_css_token(struct scanner *scanner, struct scanner_token *token)
* we should of course handle escape
* sequences .. but that will have to
* be fixed later. */
unsigned char *from = string + 1;
unsigned char *to = function_end - 1;
const unsigned char *from = string + 1;
const unsigned char *to = function_end - 1;
scan_css(scanner, from, CSS_CHAR_WHITESPACE);
scan_back_css(scanner, to, CSS_CHAR_WHITESPACE);
@ -313,7 +313,7 @@ scan_css_token(struct scanner *scanner, struct scanner_token *token)
type = CSS_TOKEN_NONE;
} else {
unsigned char *sgml = string;
const unsigned char *sgml = string;
/* Skip anything looking like SGML "<!--" and "-->"
* comments + <![CDATA[ and ]]> notations. */

View File

@ -348,13 +348,13 @@ render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *
"attribute { color: magenta } "
"comment { color: aqua } "
"cdata-section { color: orange2 } ";
unsigned char *styles = (unsigned char *) default_colors;
i_want_struct_module_for_dom = 1;
/* When someone will get here earlier than at 4am,
* this will be done in some init function, perhaps
* not overriding the user's default stylesheet. */
css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors));
css_parse_stylesheet(css, NULL, default_colors,
default_colors + sizeof(default_colors));
}
}

View File

@ -105,7 +105,7 @@ enum bencoding_token {
static inline void
scan_bencoding_token(struct scanner *scanner, struct scanner_token *token)
{
unsigned char *string = scanner->position;
const unsigned char *string = scanner->position;
unsigned char first_char = *string;
enum bencoding_token type = BENCODING_TOKEN_NONE;
int real_length = -1;
@ -136,7 +136,7 @@ scan_bencoding_token(struct scanner *scanner, struct scanner_token *token)
type = BENCODING_TOKEN_END;
} else if (is_bencoding_integer(first_char)) {
unsigned char *integer_start = string;
const unsigned char *integer_start = string;
/* Signedness. */
if (*string == '-') string++;

View File

@ -348,9 +348,7 @@ struct bittorrent_connection {
* this structure. So it is okay to make @c source point to data that
* is part of a larger buffer. Also, there is no @c magic member here. */
struct bittorrent_const_string {
/** @todo This is not yet actually const because that will
* require changes in the scanner too. */
unsigned char *source;
const unsigned char *source;
int length;
};

View File

@ -1080,7 +1080,7 @@ bittorrent_resume_writer(void *data, int fd)
uint32_t piece;
memcpy(&metafile.length, data, sizeof(metafile.length));
metafile.source = (unsigned char *) data + sizeof(metafile.length);
metafile.source = (const unsigned char *) data + sizeof(metafile.length);
if (parse_bittorrent_metafile(&meta, &metafile) != BITTORRENT_STATE_OK) {
done_bittorrent_meta(&meta);

View File

@ -157,7 +157,7 @@ init_scanner_info(struct scanner_info *scanner_info)
void
init_scanner(struct scanner *scanner, struct scanner_info *scanner_info,
unsigned char *string, unsigned char *end)
const unsigned char *string, const unsigned char *end)
{
if (!scanner_info->initialized) {
init_scanner_info(scanner_info);

View File

@ -19,7 +19,7 @@ struct scanner_token {
int precedence;
/** The start of the token string and the token length */
unsigned char *string;
const unsigned char *string;
int length;
};
@ -87,7 +87,7 @@ struct scanner_info {
/** Initializes the scanner.
* @relates scanner */
void init_scanner(struct scanner *scanner, struct scanner_info *scanner_info,
unsigned char *string, unsigned char *end);
const unsigned char *string, const unsigned char *end);
/** The number of tokens in the scanners token table:
* At best it should be big enough to contain properties with space separated
@ -101,7 +101,7 @@ struct scanner {
/** The very start of the scanned string, the position in the string
* where to scan next and the end of the string. If #position is NULL
* it means that no more tokens can be retrieved from the string. */
unsigned char *string, *position, *end;
const unsigned char *string, *position, *end;
/** The current token and number of scanned tokens in the table.
* If the number of scanned tokens is less than ::SCANNER_TOKENS