diff --git a/src/document/css/parser.c b/src/document/css/parser.c index a133149db..ee2bfe721 100644 --- a/src/document/css/parser.c +++ b/src/document/css/parser.c @@ -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; diff --git a/src/document/css/parser.h b/src/document/css/parser.h index 645d0525e..67d00e215 100644 --- a/src/document/css/parser.h +++ b/src/document/css/parser.h @@ -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 diff --git a/src/document/css/scanner.c b/src/document/css/scanner.c index 361b1a411..767c66431 100644 --- a/src/document/css/scanner.c +++ b/src/document/css/scanner.c @@ -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 "" * comments + notations. */ diff --git a/src/document/dom/source.c b/src/document/dom/source.c index 5faf1d35e..f195a8242 100644 --- a/src/document/dom/source.c +++ b/src/document/dom/source.c @@ -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)); } } diff --git a/src/protocol/bittorrent/bencoding.c b/src/protocol/bittorrent/bencoding.c index 80dc5d67f..4765e9d5d 100644 --- a/src/protocol/bittorrent/bencoding.c +++ b/src/protocol/bittorrent/bencoding.c @@ -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++; diff --git a/src/protocol/bittorrent/common.h b/src/protocol/bittorrent/common.h index 3726844a1..263072f20 100644 --- a/src/protocol/bittorrent/common.h +++ b/src/protocol/bittorrent/common.h @@ -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; }; diff --git a/src/protocol/bittorrent/piececache.c b/src/protocol/bittorrent/piececache.c index 8db5bb375..16fa5499f 100644 --- a/src/protocol/bittorrent/piececache.c +++ b/src/protocol/bittorrent/piececache.c @@ -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); diff --git a/src/util/scanner.c b/src/util/scanner.c index 1545745f5..949d6016e 100644 --- a/src/util/scanner.c +++ b/src/util/scanner.c @@ -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); diff --git a/src/util/scanner.h b/src/util/scanner.h index a88462583..615142ebc 100644 --- a/src/util/scanner.h +++ b/src/util/scanner.h @@ -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