1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-07-26 16:45:12 -04:00

Explicit cast in strstr for C++

This commit is contained in:
Witold Filipczyk 2016-04-20 20:46:33 +02:00
parent 5b2efc8976
commit 96e65c105f
13 changed files with 37 additions and 35 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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 {

View File

@ -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 {

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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')

View File

@ -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 {

View File

@ -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);

View File

@ -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));

View File

@ -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) {