From 96e65c105feda32599f4fb7266c08507686b99bb Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 20 Apr 2016 20:46:33 +0200 Subject: [PATCH] Explicit cast in strstr for C++ --- src/config/cmdline.c | 22 ++++++++++++---------- src/document/html/parser.c | 8 ++++---- src/intl/gettext/loadmsgcat.c | 6 +++--- src/mime/backend/mailcap.c | 8 ++++---- src/protocol/bittorrent/piececache.c | 2 +- src/protocol/ftp/ftp.c | 2 +- src/protocol/gopher/gopher.c | 2 +- src/protocol/http/http.c | 8 ++++---- src/protocol/nntp/response.c | 4 ++-- src/protocol/user.c | 2 +- src/util/error.c | 4 ++-- src/viewer/text/link.c | 2 +- src/viewer/text/search.c | 2 +- 13 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/config/cmdline.c b/src/config/cmdline.c index d01255c6..0aeb3b81 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -198,16 +198,18 @@ lookup_cmd(struct option *o, unsigned char ***argv, int *argc) #define skipback_whitespace(start, S) \ while ((start) < (S) && isspace((S)[-1])) (S)--; +enum remote_method_enum { + REMOTE_METHOD_OPENURL, + REMOTE_METHOD_PING, + REMOTE_METHOD_XFEDOCOMMAND, + REMOTE_METHOD_ADDBOOKMARK, + REMOTE_METHOD_INFOBOX, + REMOTE_METHOD_NOT_SUPPORTED, +}; + struct remote_method { unsigned char *name; - enum { - REMOTE_METHOD_OPENURL, - REMOTE_METHOD_PING, - REMOTE_METHOD_XFEDOCOMMAND, - REMOTE_METHOD_ADDBOOKMARK, - REMOTE_METHOD_INFOBOX, - REMOTE_METHOD_NOT_SUPPORTED, - } type; + enum remote_method_enum type; }; static unsigned char * @@ -336,10 +338,10 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc) if (remote_argc == 2) { unsigned char *where = remote_argv[1]; - if (strstr(where, "new-window")) { + if (strstr((const char *)where, "new-window")) { remote_session_flags |= SES_REMOTE_NEW_WINDOW; - } else if (strstr(where, "new-tab")) { + } else if (strstr((const char *)where, "new-tab")) { remote_session_flags |= SES_REMOTE_NEW_TAB; } else { diff --git a/src/document/html/parser.c b/src/document/html/parser.c index c99d6be0..d866277c 100644 --- a/src/document/html/parser.c +++ b/src/document/html/parser.c @@ -336,18 +336,18 @@ check_head_for_cache_control(struct html_context *html_context, * if we already set max age to date mentioned in Expires. * --jonas */ if ((d = parse_header(head, "Pragma", NULL))) { - if (strstr(d, "no-cache")) { + if (strstr((const char *)d, "no-cache")) { no_cache = 1; } mem_free(d); } if (!no_cache && (d = parse_header(head, "Cache-Control", NULL))) { - if (strstr(d, "no-cache") || strstr(d, "must-revalidate")) { + if (strstr((const char *)d, "no-cache") || strstr((const char *)d, "must-revalidate")) { no_cache = 1; } else { - unsigned char *pos = strstr(d, "max-age="); + unsigned char *pos = strstr((const char *)d, "max-age="); assert(!no_cache); @@ -368,7 +368,7 @@ check_head_for_cache_control(struct html_context *html_context, if (!no_cache && (d = parse_header(head, "Expires", NULL))) { /* Convert date to seconds. */ - if (strstr(d, "now")) { + if (strstr((const char *)d, "now")) { timeval_T now; timeval_now(&now); diff --git a/src/intl/gettext/loadmsgcat.c b/src/intl/gettext/loadmsgcat.c index 0eac2831..82f6f2fb 100644 --- a/src/intl/gettext/loadmsgcat.c +++ b/src/intl/gettext/loadmsgcat.c @@ -143,7 +143,7 @@ _nl_init_domain_conv(struct loaded_l10nfile *domain_file, #if HAVE_ICONV const unsigned char *charsetstr; - charsetstr = strstr(nullentry, "charset="); + charsetstr = strstr((const char *)nullentry, "charset="); if (charsetstr != NULL) { size_t len; unsigned char *charset; @@ -393,8 +393,8 @@ default: const unsigned char *plural; const unsigned char *nplurals; - plural = strstr(nullentry, "plural="); - nplurals = strstr(nullentry, "nplurals="); + plural = strstr((const char *)nullentry, "plural="); + nplurals = strstr((const char *)nullentry, "nplurals="); if (plural == NULL || nplurals == NULL) goto no_plural; else { diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index acde52b3..5abe9416 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -823,16 +823,16 @@ main(int argc, char *argv[]) handler = get_mime_handler_mailcap(arg, 0); if (!handler) continue; - if (strstr(format, "description")) + if (strstr((const char *)format, "description")) printf("description: %s\n", handler->description); - if (strstr(format, "ask")) + if (strstr((const char *)format, "ask")) printf("ask: %d\n", handler->ask); - if (strstr(format, "block")) + if (strstr((const char *)format, "block")) printf("block: %d\n", handler->block); - if (strstr(format, "program")) + if (strstr((const char *)format, "program")) printf("program: %s\n", handler->program); } else { diff --git a/src/protocol/bittorrent/piececache.c b/src/protocol/bittorrent/piececache.c index 706a5f33..9cc894a1 100644 --- a/src/protocol/bittorrent/piececache.c +++ b/src/protocol/bittorrent/piececache.c @@ -596,7 +596,7 @@ create_bittorrent_path(unsigned char *path) static void remove_bittorrent_path(struct bittorrent_meta *meta, unsigned char *path) { - unsigned char *root = strstr(path, meta->name); + unsigned char *root = strstr((const char *)path, (const char *)meta->name); int pos; assert(meta->type == BITTORRENT_MULTI_FILE); diff --git a/src/protocol/ftp/ftp.c b/src/protocol/ftp/ftp.c index eb87b984..61ecf530 100644 --- a/src/protocol/ftp/ftp.c +++ b/src/protocol/ftp/ftp.c @@ -892,7 +892,7 @@ get_filesize_from_RETR(unsigned char *data, int data_len, int *resume) double size; data[data_len - 1] = '\0'; - kbytes = strstr(data, "kbytes"); + kbytes = strstr((const char *)data, "kbytes"); data[data_len - 1] = tmp; if (!kbytes) return -1; diff --git a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c index af03d004..dcca0a66 100644 --- a/src/protocol/gopher/gopher.c +++ b/src/protocol/gopher/gopher.c @@ -387,7 +387,7 @@ encode_selector_string(struct string *buffer, unsigned char *selector) /* Rather hackishly only convert slashes if there are * two successive ones. */ - while ((slashes = strstr(selector, "//"))) { + while ((slashes = strstr((const char *)selector, "//"))) { *slashes = 0; encode_uri_string(buffer, selector, -1, 0); encode_uri_string(buffer, "//", 2, 1); diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 6ffd5862..1df90332 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -470,7 +470,7 @@ check_http_server_bugs(struct uri *uri, struct http_connection_info *http, return 0; for (s = buggy_servers; *s; s++) { - if (strstr(server, *s)) { + if (strstr((const char *)server, *s)) { add_blacklist_entry(uri, SERVER_BLACKLIST_HTTP10); break; } @@ -1602,7 +1602,7 @@ again: } if ((d = parse_header(cached->head, "Pragma", NULL))) { - if (strstr(d, "no-cache")) { + if (strstr((const char *)d, "no-cache")) { cached->cache_mode = CACHE_MODE_NEVER; cached->expire = 0; } @@ -1611,12 +1611,12 @@ again: if (cached->cache_mode != CACHE_MODE_NEVER && (d = parse_header(cached->head, "Cache-Control", NULL))) { - if (strstr(d, "no-cache") || strstr(d, "must-revalidate")) { + if (strstr((const char *)d, "no-cache") || strstr((const char *)d, "must-revalidate")) { cached->cache_mode = CACHE_MODE_NEVER; cached->expire = 0; } else { - unsigned char *pos = strstr(d, "max-age="); + unsigned char *pos = strstr((const char *)d, "max-age="); assert(cached->cache_mode != CACHE_MODE_NEVER); diff --git a/src/protocol/nntp/response.c b/src/protocol/nntp/response.c index 0cd92a6f..735374ce 100644 --- a/src/protocol/nntp/response.c +++ b/src/protocol/nntp/response.c @@ -274,7 +274,7 @@ add_header_to_string(struct string *str, unsigned char *header) { unsigned char *end; - while ((end = strstr(header, "=?")) != NULL) { + while ((end = strstr((const char *)header, "=?")) != NULL) { int encoding; unsigned char *cp, *sp; @@ -299,7 +299,7 @@ add_header_to_string(struct string *str, unsigned char *header) if (!encoding || cp[2] != '?') break; cp += 3; - end = strstr(cp + 3, "?="); + end = strstr((const char *)(cp + 3), "?="); if (!end) break; if (encoding == 'b') diff --git a/src/protocol/user.c b/src/protocol/user.c index 2dc61263..fda52704 100644 --- a/src/protocol/user.c +++ b/src/protocol/user.c @@ -203,7 +203,7 @@ get_subject_from_query(unsigned char *query) unsigned char *subject; if (strncmp(query, "subject=", 8)) { - subject = strstr(query, "&subject="); + subject = strstr((const char *)query, "&subject="); if (!subject) return NULL; subject += 9; } else { diff --git a/src/util/error.c b/src/util/error.c index f3a6f3e9..fc83d0eb 100644 --- a/src/util/error.c +++ b/src/util/error.c @@ -231,10 +231,10 @@ elinks_log(unsigned char *msg, unsigned char *file, int line, atexit(done_log); } - if (log_files && !strstr(log_files, file)) + if (log_files && !strstr((const char *)log_files, file)) return; - if (log_msg && !strstr(log_msg, msg)) + if (log_msg && !strstr((const char *)log_msg, msg)) return; va_start(params, fmt); diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 649b5d8a..b91d8fc4 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -68,7 +68,7 @@ current_link_evhook(struct document_view *doc_view, enum script_event_hook_type if (evhook->type != type) continue; ret = evhook->src; - while ((ret = strstr(ret, "return "))) + while ((ret = strstr((const char *)ret, "return "))) while (*ret != ' ') *ret++ = ' '; { struct string src = INIT_STRING(evhook->src, strlen(evhook->src)); diff --git a/src/viewer/text/search.c b/src/viewer/text/search.c index 5cc38e10..d4ca0241 100644 --- a/src/viewer/text/search.c +++ b/src/viewer/text/search.c @@ -1193,7 +1193,7 @@ match_link_text(struct link *link, unsigned char *text, int textlen, if (link_is_form(link) || textlen > strlen(match)) return -1; - matchpos = case_sensitive ? strstr(match, text) + matchpos = case_sensitive ? strstr((const char *)match, (const char *)text) : strcasestr((const char *)match, (const char *)text); if (matchpos) {