From 53a860a3d6b6b33a9d666bb21df55d5887b62f4e Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 18 Jan 2022 20:30:48 +0100 Subject: [PATCH] [strchr] casting first parameter to const char * was not a good idea --- src/bfu/dialog.c | 2 +- src/bfu/hotkey.c | 4 ++-- src/bfu/inpfield.c | 2 +- src/bfu/menu.c | 6 +++--- src/bookmarks/backend/default.c | 8 ++++---- src/cache/cache.c | 2 +- src/config/cmdline.c | 10 +++++----- src/cookies/cookies.c | 4 ++-- src/document/html/frames.c | 2 +- src/document/html/parse-meta-refresh.c | 6 +++--- src/document/html/parser/forms.c | 4 ++-- src/document/xml/tags.c | 4 ++-- src/dom/configuration.c | 2 +- src/formhist/formhist.c | 8 ++++---- src/globhist/globhist.c | 6 +++--- src/intl/charsets.c | 12 ++++++------ src/intl/gettext/dcigettext.c | 4 ++-- src/intl/gettext/explodename.c | 2 +- src/intl/gettext/l10nflist.c | 2 +- src/intl/gettext/libintl.c | 8 ++++---- src/intl/gettext/localealias.c | 4 ++-- src/intl/libintl.c | 8 ++++---- src/main/version.c | 2 +- src/mime/backend/default.c | 2 +- src/mime/backend/mailcap.c | 6 +++--- src/mime/backend/mimetypes.c | 6 +++--- src/mime/mime.c | 2 +- src/protocol/bittorrent/peerconnect.c | 2 +- src/protocol/common.c | 2 +- src/protocol/file/cgi.c | 4 ++-- src/protocol/ftp/ftp-parser.c | 2 +- src/protocol/ftp/ftp.c | 2 +- src/protocol/gopher/gopher.c | 6 +++--- src/protocol/header.c | 2 +- src/protocol/http/http.c | 2 +- src/protocol/http/post.c | 10 +++++----- src/protocol/nntp/response.c | 8 ++++---- src/protocol/proxy.c | 6 +++--- src/protocol/rewrite/rewrite.c | 6 +++--- src/protocol/uri.c | 12 ++++++------ src/protocol/user.c | 2 +- src/scripting/ruby/core.c | 4 ++-- src/terminal/kbd.c | 2 +- src/util/file.c | 2 +- src/viewer/text/form.c | 10 +++++----- src/viewer/text/textarea.c | 2 +- 46 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index b5eeba59..988b6776 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -352,7 +352,7 @@ select_button_by_key(struct dialog_data *dlg_data) #ifdef CONFIG_UTF8 hk_char = cp_to_unicode(codepage, &hk_ptr, - strchr((const char *)hk_ptr, '\0')); + strchr(hk_ptr, '\0')); /* hk_char can be UCS_NO_CHAR only if the text of the * widget is not in the expected codepage. */ assert(hk_char != UCS_NO_CHAR); diff --git a/src/bfu/hotkey.c b/src/bfu/hotkey.c index f4a2426d..bfe4a652 100644 --- a/src/bfu/hotkey.c +++ b/src/bfu/hotkey.c @@ -25,7 +25,7 @@ static inline int find_hotkey_pos(char *text) { if (text && *text) { - char *p = strchr((const char *)text, '~'); + char *p = strchr(text, '~'); if (p) return (int) (p - text) + 1; } @@ -178,7 +178,7 @@ check_hotkeys_common(struct menu *menu, term_event_char_T hotkey, struct termina /* Compare @key to the character to which @text points. */ #ifdef CONFIG_UTF8 items_hotkey = cp_to_unicode(codepage, &text, - strchr((const char *)text, '\0')); + strchr(text, '\0')); /* items_hotkey can be UCS_NO_CHAR only if the text of * the menu item is not in the expected codepage. */ assert(items_hotkey != UCS_NO_CHAR); diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index 6645dc21..bb2c051f 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -477,7 +477,7 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data) #ifdef CONFIG_UTF8 if (term->utf8_cp) { char *next = widget_data->cdata + widget_data->info.field.cpos; - char *end = strchr((const char *)next, '\0'); + char *end = strchr(next, '\0'); utf8_to_unicode(&next, end); widget_data->info.field.cpos = (int)(next - widget_data->cdata); diff --git a/src/bfu/menu.c b/src/bfu/menu.c index d174e31e..add4b97e 100644 --- a/src/bfu/menu.c +++ b/src/bfu/menu.c @@ -456,7 +456,7 @@ draw_menu_left_text_hk(struct terminal *term, char *text, #ifdef CONFIG_UTF8 utf8: - end = strchr((const char *)text, '\0'); + end = strchr(text, '\0'); text2 = text; for (x = 0; x - !!hk_state < w && *text2; x++) { unicode_val_T data; @@ -795,11 +795,11 @@ search_menu_item(struct menu_item *item, char *buffer, text = stracpy(text); if (!text) return 0; - match = strchr((const char *)text, '~'); + match = strchr(text, '~'); if (match) memmove(match, match + 1, strlen(match)); - match = strcasestr((const char *)text, (const char *)buffer); + match = strcasestr(text, buffer); mem_free(text); return !!match; diff --git a/src/bookmarks/backend/default.c b/src/bookmarks/backend/default.c index 54e4e43d..9843e41f 100644 --- a/src/bookmarks/backend/default.c +++ b/src/bookmarks/backend/default.c @@ -47,7 +47,7 @@ read_bookmarks_default(FILE *f) /* Load URL. */ - url = strchr((const char *)in_buffer, '\t'); + url = strchr(in_buffer, '\t'); /* If separator is not found, or title is empty or too long, * skip that line. */ @@ -59,7 +59,7 @@ read_bookmarks_default(FILE *f) /* Load depth. */ - depth_str = strchr((const char *)url, '\t'); + depth_str = strchr(url, '\t'); if (depth_str && depth_str - url > MAX_STR_LEN - 1) continue; @@ -71,7 +71,7 @@ read_bookmarks_default(FILE *f) /* Load flags. */ - flags = strchr((const char *)depth_str, '\t'); + flags = strchr(depth_str, '\t'); if (flags) { *flags = '\0'; flags++; @@ -82,7 +82,7 @@ read_bookmarks_default(FILE *f) /* Load EOLN. */ - line_end = strchr((const char *)(flags ? flags : depth_str), '\n'); + line_end = strchr((flags ? flags : depth_str), '\n'); if (!line_end) continue; *line_end = '\0'; diff --git a/src/cache/cache.c b/src/cache/cache.c index 63a7e24b..12cf7788 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -754,7 +754,7 @@ redirect_cache(struct cache_entry *cached, char *location, /* To be certain we don't append post data twice in some * conditions... --Zas */ - assert(!strchr((const char *)uristring, POST_CHAR)); + assert(!strchr(uristring, POST_CHAR)); add_to_strn(&uristring, cached->uri->post - 1); } diff --git a/src/config/cmdline.c b/src/config/cmdline.c index 5c578b98..0a707712 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -75,8 +75,8 @@ parse_options_(int argc, char *argv[], struct option *opt, /* Substitute '-' by '_'. This helps * compatibility with that very wicked browser * called 'lynx'. */ - for (pos = strchr((const char *)oname, '_'); pos; - pos = strchr((const char *)pos, '_')) + for (pos = strchr(oname, '_'); pos; + pos = strchr(pos, '_')) *pos = '-'; option = get_opt_rec(opt, oname); oname--; @@ -306,7 +306,7 @@ remote_cmd(struct option *o, char ***argv, int *argc) if (*start == '"') { end = ++start; - while ((end = strchr((const char *)end, '"'))) { + while ((end = strchr(end, '"'))) { /* Treat "" inside quoted arg as ". */ if (end[1] != '"') break; @@ -334,7 +334,7 @@ remote_cmd(struct option *o, char ***argv, int *argc) *start = 0; } else { - end = strchr((const char *)start, ','); + end = strchr(start, ','); if (!end) { end = start + strlen(start); arg = end; @@ -700,7 +700,7 @@ print_short_help(void) static char * printhelp_cmd(struct option *option, char ***argv, int *argc) { - char *lineend = strchr((const char *)full_static_version, '\n'); + char *lineend = strchr(full_static_version, '\n'); if (lineend) *lineend = '\0'; diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 260b7a11..522bdc04 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -733,10 +733,10 @@ load_cookies(void) { /* First find all members. */ for (member = NAME; member < MEMBERS; member++, q = ++p) { - p = strchr((const char *)q, '\t'); + p = strchr(q, '\t'); if (!p) { if (member + 1 != MEMBERS) break; /* last field ? */ - p = strchr((const char *)q, '\n'); + p = strchr(q, '\n'); if (!p) break; } diff --git a/src/document/html/frames.c b/src/document/html/frames.c index 9cb07820..fb4d135e 100644 --- a/src/document/html/frames.c +++ b/src/document/html/frames.c @@ -435,7 +435,7 @@ extract_rows_or_cols_values(char *str, int max_value, int pixels_per_char, values[values_count++] = val; /* Check for next field if any. */ - tmp_str = strchr((const char *)str, ','); + tmp_str = strchr(str, ','); if (!tmp_str) break; /* It was the last field. */ str = tmp_str + 1; diff --git a/src/document/html/parse-meta-refresh.c b/src/document/html/parse-meta-refresh.c index 43754ec6..14511681 100644 --- a/src/document/html/parse-meta-refresh.c +++ b/src/document/html/parse-meta-refresh.c @@ -94,11 +94,11 @@ html_parse_meta_refresh(const char *content, if (*url_begin == '"' || *url_begin == '\'') { unsigned char quote = *url_begin++; - url_end = strchr((const char *)url_begin, quote); + url_end = strchr(url_begin, quote); if (url_end == NULL) - url_end = strchr((const char *)url_begin, '\0'); + url_end = strchr(url_begin, '\0'); } else { - url_end = strchr((const char *)url_begin, '\0'); + url_end = strchr(url_begin, '\0'); } /* In any case, trim all spaces from the end of the URL. */ diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index 6ad32d12..e8e99385 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -96,12 +96,12 @@ html_form(struct html_context *html_context, char *a, form->action = get_uri_string(html_context->base_href, components); /* No action URI should contain post data */ - assert(!form->action || !strchr((const char *)form->action, POST_CHAR)); + assert(!form->action || !strchr(form->action, POST_CHAR)); /* GET method URIs should not have '?'. */ assert(!form->action || form->method != FORM_METHOD_GET - || !strchr((const char *)form->action, '?')); + || !strchr(form->action, '?')); } al = get_target(html_context->options, a); diff --git a/src/document/xml/tags.c b/src/document/xml/tags.c index adf9ba86..551f1858 100644 --- a/src/document/xml/tags.c +++ b/src/document/xml/tags.c @@ -1273,12 +1273,12 @@ tags_html_form(struct source_renderer *renderer, void *node, unsigned char *a, form->action = get_uri_string(html_context->base_href, components); /* No action URI should contain post data */ - assert(!form->action || !strchr((const char *)form->action, POST_CHAR)); + assert(!form->action || !strchr(form->action, POST_CHAR)); /* GET method URIs should not have '?'. */ assert(!form->action || form->method != FORM_METHOD_GET - || !strchr((const char *)form->action, '?')); + || !strchr(form->action, '?')); } } al = NULL; diff --git a/src/dom/configuration.c b/src/dom/configuration.c index e17b5de1..dff138d7 100644 --- a/src/dom/configuration.c +++ b/src/dom/configuration.c @@ -332,7 +332,7 @@ parse_dom_config(char *flaglist, char separator) enum dom_config_flag flags = 0; while (flaglist) { - char *end = separator ? strchr((const char *)flaglist, separator) : NULL; + char *end = separator ? strchr(flaglist, separator) : NULL; int length = end ? end - flaglist : strlen(flaglist); struct dom_string name = INIT_DOM_STRING(flaglist, (unsigned int)length); diff --git a/src/formhist/formhist.c b/src/formhist/formhist.c index 64cd86d4..49ff5ae5 100644 --- a/src/formhist/formhist.c +++ b/src/formhist/formhist.c @@ -113,7 +113,7 @@ load_formhist_from_file(void) if (tmp[0] == '\n' && !tmp[1]) continue; - p = strchr((const char *)tmp, '\t'); + p = strchr(tmp, '\t'); if (p) { *p = '\0'; ++p; @@ -149,13 +149,13 @@ load_formhist_from_file(void) /* Type */ type = tmp; - p = strchr((const char *)type, '\t'); + p = strchr(type, '\t'); if (!p) goto fail; *p = '\0'; /* Name */ name = ++p; - p = strchr((const char *)name, '\t'); + p = strchr(name, '\t'); if (!p) { /* Compatibility with previous file formats. * REMOVE AT SOME TIME --Zas */ @@ -176,7 +176,7 @@ load_formhist_from_file(void) /* Value */ value = ++p; cont: - p = strchr((const char *)value, '\n'); + p = strchr(value, '\n'); if (!p) goto fail; *p = '\0'; diff --git a/src/globhist/globhist.c b/src/globhist/globhist.c index 097f604f..8af1b6c9 100644 --- a/src/globhist/globhist.c +++ b/src/globhist/globhist.c @@ -351,15 +351,15 @@ read_global_history(void) while (fgets(in_buffer, sizeof(in_buffer), f)) { char *url, *last_visit, *eol; - url = strchr((const char *)title, '\t'); + url = strchr(title, '\t'); if (!url) continue; *url++ = '\0'; /* Now url points to the character after \t. */ - last_visit = strchr((const char *)url, '\t'); + last_visit = strchr(url, '\t'); if (!last_visit) continue; *last_visit++ = '\0'; - eol = strchr((const char *)last_visit, '\n'); + eol = strchr(last_visit, '\n'); if (!eol) continue; *eol = '\0'; /* Drop ending '\n'. */ diff --git a/src/intl/charsets.c b/src/intl/charsets.c index faa6a06b..984934b7 100644 --- a/src/intl/charsets.c +++ b/src/intl/charsets.c @@ -295,7 +295,7 @@ int strlen_utf8(char **str) { char *s = *str; - char *end = strchr((const char *)s, '\0'); + char *end = strchr(s, '\0'); int x; int len; @@ -333,7 +333,7 @@ utf8_char2cells(char *utf8_char, char *end) unicode_val_T u; if (end == NULL) - end = strchr((const char *)utf8_char, '\0'); + end = strchr(utf8_char, '\0'); if(!utf8_char || !end) return -1; @@ -351,7 +351,7 @@ utf8_ptr2cells(char *string, char *end) int charlen, cell, cells = 0; if (end == NULL) - end = strchr((const char *)string, '\0'); + end = strchr(string, '\0'); if(!string || !end) return -1; @@ -379,7 +379,7 @@ utf8_ptr2chars(char *string, char *end) int charlen, chars = 0; if (end == NULL) - end = strchr((const char *)string, '\0'); + end = strchr(string, '\0'); if(!string || !end) return -1; @@ -408,7 +408,7 @@ utf8_cells2bytes(char *string, int max_cells, char *end) assert(max_cells>=0); if (end == NULL) - end = strchr((const char *)string, '\0'); + end = strchr(string, '\0'); if(!string || !end) return -1; @@ -454,7 +454,7 @@ utf8_step_forward(char *string, char *end, assert(max >= 0); if_assert_failed goto invalid_arg; if (end == NULL) - end = strchr((const char *)string, '\0'); + end = strchr(string, '\0'); switch (way) { case UTF8_STEP_CHARACTERS: diff --git a/src/intl/gettext/dcigettext.c b/src/intl/gettext/dcigettext.c index 89fbb657..a8114e3e 100644 --- a/src/intl/gettext/dcigettext.c +++ b/src/intl/gettext/dcigettext.c @@ -404,7 +404,7 @@ dcigettext__(const char *domainname, const char *msgid1, const char *msgid2, : n == 1 ? (char *) msgid1 : (char *) msgid2); } - stpcpy(stpcpy(strchr((const char *)dirname, '\0'), "/"), binding->dirname); + stpcpy(stpcpy(strchr(dirname, '\0'), "/"), binding->dirname); } /* Now determine the symbolic name of CATEGORY and its value. */ @@ -784,7 +784,7 @@ plural_lookup(struct loaded_l10nfile *domain, unsigned long int n, /* Skip INDEX strings at TRANSLATION. */ p = translation; while (indexx-- > 0) { - p = strchr((const char *)p, '\0'); + p = strchr(p, '\0'); /* And skip over the NUL byte. */ p++; diff --git a/src/intl/gettext/explodename.c b/src/intl/gettext/explodename.c index 1bf8fd58..3652c5c6 100644 --- a/src/intl/gettext/explodename.c +++ b/src/intl/gettext/explodename.c @@ -77,7 +77,7 @@ _nl_explode_name(char *name, const char **language, const char **modifier, if (*language == cp) /* This does not make sense: language has to be specified. Use this entry as it is without exploding. Perhaps it is an alias. */ - cp = strchr((const char *)*language, '\0'); + cp = strchr(*language, '\0'); else if (cp[0] == '_') { /* Next is the territory. */ cp[0] = '\0'; diff --git a/src/intl/gettext/l10nflist.c b/src/intl/gettext/l10nflist.c index 3a218934..b85c854e 100644 --- a/src/intl/gettext/l10nflist.c +++ b/src/intl/gettext/l10nflist.c @@ -119,7 +119,7 @@ argz_next__(char *argz, size_t argz_len, const char *entry) { if (entry) { if (entry < argz + argz_len) - entry = strchr((const char *)entry, '\0') + 1; + entry = strchr(entry, '\0') + 1; return entry >= argz + argz_len ? NULL : (char *) entry; } else if (argz_len > 0) diff --git a/src/intl/gettext/libintl.c b/src/intl/gettext/libintl.c index a7c6d38d..cf050cc0 100644 --- a/src/intl/gettext/libintl.c +++ b/src/intl/gettext/libintl.c @@ -82,15 +82,15 @@ iso639_to_language(char *iso639) /* The environment variable transformation. */ - p = strchr((const char *)l, '.'); + p = strchr(l, '.'); if (p) *p = '\0'; - p = strchr((const char *)l, '_'); + p = strchr(l, '_'); if (p) *p = '-'; else - p = strchr((const char *)l, '-'); + p = strchr(l, '-'); /* Exact match. */ @@ -209,7 +209,7 @@ set_language(int language) } if (LANGUAGE) { strcpy(LANGUAGE, language_to_iso639(language)); - p = strchr((const char *)LANGUAGE, '-'); + p = strchr(LANGUAGE, '-'); if (p) { *p = '_'; } diff --git a/src/intl/gettext/localealias.c b/src/intl/gettext/localealias.c index 70f05649..d86deb71 100644 --- a/src/intl/gettext/localealias.c +++ b/src/intl/gettext/localealias.c @@ -154,7 +154,7 @@ read_alias_file(const char *fname, int fname_len) /* Possibly not the whole line fits into the buffer. Ignore the rest of the line. */ - if (strchr((const char *)buf, '\n') == NULL) { + if (strchr(buf, '\n') == NULL) { char altbuf[BUFSIZ]; do @@ -162,7 +162,7 @@ read_alias_file(const char *fname, int fname_len) /* Make sure the inner loop will be left. The outer loop will exit at the `feof' test. */ break; - while (strchr((const char *)altbuf, '\n') == NULL); + while (strchr(altbuf, '\n') == NULL); } cp = buf; diff --git a/src/intl/libintl.c b/src/intl/libintl.c index 0aea765c..f4930669 100644 --- a/src/intl/libintl.c +++ b/src/intl/libintl.c @@ -82,15 +82,15 @@ iso639_to_language(char *iso639) /* The environment variable transformation. */ - p = strchr((const char *)l, '.'); + p = strchr(l, '.'); if (p) *p = '\0'; - p = strchr((const char *)l, '_'); + p = strchr(l, '_'); if (p) *p = '-'; else - p = strchr((const char *)l, '-'); + p = strchr(l, '-'); /* Exact match. */ @@ -211,7 +211,7 @@ set_language(int language) } if (LANGUAGE) { strcpy(LANGUAGE, language_to_iso639(language)); - p = strchr((const char *)LANGUAGE, '-'); + p = strchr(LANGUAGE, '-'); if (p) { *p = '_'; } diff --git a/src/main/version.c b/src/main/version.c index fd472293..98c566cc 100644 --- a/src/main/version.c +++ b/src/main/version.c @@ -90,7 +90,7 @@ wrap_string(struct string *string, int start_at, int maxlen) if (maxlen <= 0) return; pos = start_pos = &string->source[start_at]; - while ((pos = strchr((const char *)pos, ' '))) { + while ((pos = strchr(pos, ' '))) { int len = pos - start_pos; if (len < maxlen) { diff --git a/src/mime/backend/default.c b/src/mime/backend/default.c index 2583cdbc..c5fb6515 100644 --- a/src/mime/backend/default.c +++ b/src/mime/backend/default.c @@ -162,7 +162,7 @@ get_mime_type_option(char *type) if (add_optname_to_string(&name, type, strlen(type))) { /* Search for end of the base type. */ - char *pos = strchr((const char *)name.source, '/'); + char *pos = strchr(name.source, '/'); if (pos) { *pos = '.'; diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index fbb651db..967cdb6a 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -232,7 +232,7 @@ get_mailcap_field(char **next) if (*fieldend == ';') fieldend++; - fieldend = strchr((const char *)fieldend, ';'); + fieldend = strchr(fieldend, ';'); } while (fieldend && *(fieldend-1) == '\\'); if (fieldend) { @@ -360,7 +360,7 @@ parse_mailcap_file(char *filename, unsigned int priority) continue; } - basetypeend = strchr((const char *)type, '/'); + basetypeend = strchr(type, '/'); typelen = strlen(type); if (!basetypeend) { @@ -610,7 +610,7 @@ get_mailcap_entry(char *type) /* The type lookup has either failed or we need to check * the priorities so get the wild card handler */ struct mailcap_entry *wildcard = NULL; - char *wildpos = strchr((const char *)type, '/'); + char *wildpos = strchr(type, '/'); if (wildpos) { int wildlen = wildpos - type + 1; /* include '/' */ diff --git a/src/mime/backend/mimetypes.c b/src/mime/backend/mimetypes.c index d514a9ab..97296a05 100644 --- a/src/mime/backend/mimetypes.c +++ b/src/mime/backend/mimetypes.c @@ -141,7 +141,7 @@ parse_mimetypes_file(char *filename) char *token; /* Weed out any comments */ - token = strchr((const char *)line, '#'); + token = strchr(line, '#'); if (token) *token = '\0'; @@ -155,7 +155,7 @@ parse_mimetypes_file(char *filename) *token++ = '\0'; /* Check if malformed content type */ - if (!strchr((const char *)ctype, '/')) continue; + if (!strchr(ctype, '/')) continue; parse_mimetypes_extensions(token, ctype); } @@ -260,7 +260,7 @@ get_content_type_mimetypes(char *extension) } /* Try to trim the extension from the left. */ - trimmed = strchr((const char *)extension, '.'); + trimmed = strchr(extension, '.'); if (!trimmed) break; diff --git a/src/mime/mime.c b/src/mime/mime.c index b5a3daa3..94761725 100644 --- a/src/mime/mime.c +++ b/src/mime/mime.c @@ -198,7 +198,7 @@ get_cache_header_content_type(struct cache_entry *cached) ctype = parse_header(cached->head, "Content-Type", NULL); if (ctype) { - char *end = strchr((const char *)ctype, ';'); + char *end = strchr(ctype, ';'); int ctypelen; if (end) *end = '\0'; diff --git a/src/protocol/bittorrent/peerconnect.c b/src/protocol/bittorrent/peerconnect.c index a2c4bd5f..89f3d170 100644 --- a/src/protocol/bittorrent/peerconnect.c +++ b/src/protocol/bittorrent/peerconnect.c @@ -296,7 +296,7 @@ make_bittorrent_peer_connection(struct bittorrent_connection *bittorrent, if (!init_string(&uri_string)) goto out; if (!add_format_to_string(&uri_string, #ifdef CONFIG_IPV6 - strchr((const char *)peer_info->ip, ':') ? + strchr(peer_info->ip, ':') ? "bittorrent-peer://[%s]:%u/" : #endif "bittorrent-peer://%s:%u/", diff --git a/src/protocol/common.c b/src/protocol/common.c index 9471b56d..09b18533 100644 --- a/src/protocol/common.c +++ b/src/protocol/common.c @@ -122,7 +122,7 @@ init_directory_listing(struct string *page, struct uri *uri) const char *pslash = slash; const char sep = local ? CHAR_DIR_SEP : '/'; - while ((slash = strchr((const char *)slash, sep)) != NULL) { + while ((slash = strchr(slash, sep)) != NULL) { done_string(&decoded); if (!init_string(&decoded) || !add_bytes_to_string(&decoded, pslash, slash - pslash)) diff --git a/src/protocol/file/cgi.c b/src/protocol/file/cgi.c index 95c4cc02..319732df 100644 --- a/src/protocol/file/cgi.c +++ b/src/protocol/file/cgi.c @@ -120,7 +120,7 @@ send_post_data(struct connection *conn) char *postend; struct connection_state error; - postend = strchr((const char *)post, '\n'); + postend = strchr(post, '\n'); if (postend) post = postend + 1; if (!open_http_post(&http->post, post, &error)) @@ -153,7 +153,7 @@ set_vars(struct connection *conn, char *script) if (post) { struct http_connection_info *http; - char *postend = strchr((const char *)post, '\n'); + char *postend = strchr(post, '\n'); char buf[16]; struct connection_state error; diff --git a/src/protocol/ftp/ftp-parser.c b/src/protocol/ftp/ftp-parser.c index 732c79c9..07502f54 100644 --- a/src/protocol/ftp/ftp-parser.c +++ b/src/protocol/ftp/ftp-parser.c @@ -44,7 +44,7 @@ main(int argc, char *argv[]) while (*response) { char *start = response; - response = strchr((const char *)response, '\n'); + response = strchr(response, '\n'); if (!response) { response = start + strlen(start); } else { diff --git a/src/protocol/ftp/ftp.c b/src/protocol/ftp/ftp.c index b5d5335f..4915f8b1 100644 --- a/src/protocol/ftp/ftp.c +++ b/src/protocol/ftp/ftp.c @@ -831,7 +831,7 @@ static void send_it_line_by_line(struct connection *conn, struct string *cmd) { struct ftp_connection_info *ftp = conn->info; - char *nl = strchr((const char *)ftp->cmd_buffer, '\n'); + char *nl = strchr(ftp->cmd_buffer, '\n'); if (!nl) { add_to_string(cmd, ftp->cmd_buffer); diff --git a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c index 655f5fb1..f0c8b624 100644 --- a/src/protocol/gopher/gopher.c +++ b/src/protocol/gopher/gopher.c @@ -430,7 +430,7 @@ add_gopher_menu_line(struct string *buffer, char *line) } if (*name) { - selector = strchr((const char *)name, ASCII_TAB); + selector = strchr(name, ASCII_TAB); if (selector) { /* Terminate name */ *selector++ = '\0'; @@ -444,13 +444,13 @@ add_gopher_menu_line(struct string *buffer, char *line) entity = *selector; } - host = selector ? strchr((const char *)selector, ASCII_TAB) : NULL; + host = selector ? strchr(selector, ASCII_TAB) : NULL; if (host) { /* Terminate selector */ *host++ = '\0'; } - port = host ? strchr((const char *)host, ASCII_TAB) : NULL; + port = host ? strchr(host, ASCII_TAB) : NULL; if (port) { char *end; int portno; diff --git a/src/protocol/header.c b/src/protocol/header.c index bd283679..2c99f996 100644 --- a/src/protocol/header.c +++ b/src/protocol/header.c @@ -249,7 +249,7 @@ parse_header_param(char *str, char *name, char **ret, int content_disposition) if (!content_disposition) { a: - p = strchr((const char *)p, ';'); + p = strchr(p, ';'); if (!p) return HEADER_PARAM_NOT_FOUND; } while (*p && (*p == ';' || *p <= ' ')) p++; diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 7abd1c11..c85713f5 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -1006,7 +1006,7 @@ http_send_header(struct socket *socket) /* We search for first '\n' in uri->post to get content type * as set by get_form_uri(). This '\n' is dropped if any * and replaced by correct '\r\n' termination here. */ - char *postend = strchr((const char *)uri->post, '\n'); + char *postend = strchr(uri->post, '\n'); struct connection_state error; if (postend) { diff --git a/src/protocol/http/post.c b/src/protocol/http/post.c index 347d5778..c4e531e3 100644 --- a/src/protocol/http/post.c +++ b/src/protocol/http/post.c @@ -104,9 +104,9 @@ open_http_post(struct http_post *http_post, const char *post_data, struct http_post_file *new_files; char *filename; - begin = strchr((const char *)end, FILE_CHAR); + begin = strchr(end, FILE_CHAR); if (!begin) break; - end = strchr((const char *)(begin + 1), FILE_CHAR); + end = strchr((begin + 1), FILE_CHAR); if (!end) break; filename = memacpy(begin + 1, end - begin - 1); /* adds '\0' */ if (!filename) { @@ -160,14 +160,14 @@ read_http_post_inline(struct http_post *http_post, struct connection_state *error) { const char *post = http_post->post_data; - const char *end = strchr((const char *)post, FILE_CHAR); + const char *end = strchr(post, FILE_CHAR); int total = 0; assert(http_post->post_fd < 0); if_assert_failed { *error = connection_state(S_INTERNAL); return -1; } if (!end) - end = strchr((const char *)post, '\0'); + end = strchr(post, '\0'); while (post < end && total < max) { int h1, h2; @@ -189,7 +189,7 @@ read_http_post_inline(struct http_post *http_post, } http_post->file_read = 0; - end = strchr((const char *)(post + 1), FILE_CHAR); + end = strchr((post + 1), FILE_CHAR); assert(end); http_post->post_fd = open(http_post->files[http_post->file_index].name, O_RDONLY); diff --git a/src/protocol/nntp/response.c b/src/protocol/nntp/response.c index d9f07983..bcb6e8ff 100644 --- a/src/protocol/nntp/response.c +++ b/src/protocol/nntp/response.c @@ -293,7 +293,7 @@ add_header_to_string(struct string *str, char *header) * ep : "=?ISO-8859-1?Q?Foo=FCbar?= baz" */ end += 2; - cp = strchr((const char *)end, '?'); + cp = strchr(end, '?'); if (!cp) break; @@ -428,7 +428,7 @@ add_nntp_html_line(struct string *html, struct connection *conn, { char *field = line; - line = strchr((const char *)line, '\t'); + line = strchr(line, '\t'); if (!line) field = ""; else @@ -438,7 +438,7 @@ add_nntp_html_line(struct string *html, struct connection *conn, if (line) { field = line; - line = strchr((const char *)line, '\t'); + line = strchr(line, '\t'); if (line) *line++ = 0; @@ -448,7 +448,7 @@ add_nntp_html_line(struct string *html, struct connection *conn, if (line) { field = line; - line = strchr((const char *)line, '\t'); + line = strchr(line, '\t'); if (line) *line++ = 0; diff --git a/src/protocol/proxy.c b/src/protocol/proxy.c index 4b260392..bd02644c 100644 --- a/src/protocol/proxy.c +++ b/src/protocol/proxy.c @@ -27,12 +27,12 @@ static int proxy_probe_no_proxy(char *url, char *no_proxy) { - char *slash = strchr((const char *)url, '/'); + char *slash = strchr(url, '/'); if (slash) *slash = '\0'; while (no_proxy && *no_proxy) { - char *jumper = strchr((const char *)no_proxy, ','); + char *jumper = strchr(no_proxy, ','); skip_space(no_proxy); if (jumper) *jumper = '\0'; @@ -171,7 +171,7 @@ get_proxy_worker(struct uri *uri, char *proxy, if (protocol_proxy && *protocol_proxy) { char *no_proxy; - char *slash = strchr((const char *)protocol_proxy, '/'); + char *slash = strchr(protocol_proxy, '/'); if (slash) *slash = 0; diff --git a/src/protocol/rewrite/rewrite.c b/src/protocol/rewrite/rewrite.c index 3133fee5..7a5d39a3 100644 --- a/src/protocol/rewrite/rewrite.c +++ b/src/protocol/rewrite/rewrite.c @@ -313,9 +313,9 @@ goto_url_hook(va_list ap, void *data) uu = get_uri_rewrite_prefix(URI_REWRITE_DUMB, *url); if (!uu - && !strchr((const char *)*url, ':') - && !strchr((const char *)*url, '.') - && !strchr((const char *)*url, '/')) { + && !strchr(*url, ':') + && !strchr(*url, '.') + && !strchr(*url, '/')) { uu = get_opt_str("protocol.rewrite.default_template", NULL); if (uu && *uu) { arg = *url; diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 0ac9b42c..b34a30f1 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -289,9 +289,9 @@ parse_uri(struct uri *uri, char *uristring) #ifdef CONFIG_IPV6 /* Get brackets enclosing IPv6 address */ - lbracket = strchr((const char *)prefix_end, '['); + lbracket = strchr(prefix_end, '['); if (lbracket) { - rbracket = strchr((const char *)lbracket, ']'); + rbracket = strchr(lbracket, ']'); /* [address] is handled only inside of hostname part (surprisingly). */ if (rbracket && rbracket < prefix_end + strcspn(prefix_end, "/")) uri->ipv6 = 1; @@ -313,7 +313,7 @@ parse_uri(struct uri *uri, char *uristring) while (strcspn(host_end + 1, "@") < strcspn(host_end + 1, "/?")) host_end = host_end + 1 + strcspn(host_end + 1, "@"); - user_end = strchr((const char *)prefix_end, ':'); + user_end = strchr(prefix_end, ':'); if (!user_end || user_end > host_end) { uri->user = prefix_end; @@ -1034,7 +1034,7 @@ find_uri_protocol(char *newurl) ch = newurl + strcspn(newurl, ".:/@"); if (*ch == '@' - || (*ch == ':' && *newurl != '[' && strchr((const char *)newurl, '@')) + || (*ch == ':' && *newurl != '[' && strchr(newurl, '@')) || !c_strncasecmp(newurl, "ftp.", 4)) { /* Contains user/password/ftp-hostname */ return PROTOCOL_FTP; @@ -1045,8 +1045,8 @@ find_uri_protocol(char *newurl) char *bracket2, *colon2; ch++; - bracket2 = strchr((const char *)ch, ']'); - colon2 = strchr((const char *)ch, ':'); + bracket2 = strchr(ch, ']'); + colon2 = strchr(ch, ':'); if (bracket2 && colon2 && bracket2 > colon2) return PROTOCOL_HTTP; #endif diff --git a/src/protocol/user.c b/src/protocol/user.c index 776e25ef..a9ca96ae 100644 --- a/src/protocol/user.c +++ b/src/protocol/user.c @@ -234,7 +234,7 @@ save_form_data_to_file(struct uri *uri) if (!uri->post) return filename; /* Jump the content type */ - formdata = strchr((const char *)uri->post, '\n'); + formdata = strchr(uri->post, '\n'); formdata = formdata ? formdata + 1 : uri->post; len = strlen(formdata); if (len == 0) return filename; diff --git a/src/scripting/ruby/core.c b/src/scripting/ruby/core.c index f2cd3a57..e9344e78 100644 --- a/src/scripting/ruby/core.c +++ b/src/scripting/ruby/core.c @@ -92,7 +92,7 @@ erb_report_error(struct session *ses, int error) snprintf(buff, MAX_STR_LEN, "%s: %s", RSTRING_PTR(epath), RSTRING_PTR(einfo)); - p = strchr((const char *)buff, '\n'); + p = strchr(buff, '\n'); if (p) *p = '\0'; msg = buff; } @@ -121,7 +121,7 @@ erb_module_message(VALUE self, VALUE str) message = memacpy(RSTRING_PTR(str), RSTRING_LEN(str)); if (!message) return Qnil; - line_end = strchr((const char *)message, '\n'); + line_end = strchr(message, '\n'); if (line_end) *line_end = '\0'; term = get_default_terminal(); diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index d7c1a726..b6d3d393 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -493,7 +493,7 @@ resize_terminal_from_str(char *text) if_assert_failed return; for (i = 0; i < NUMBERS; i++) { - char *p = strchr((const char *)text, ','); + char *p = strchr(text, ','); if (p) { *p++ = '\0'; diff --git a/src/util/file.c b/src/util/file.c index 398e0a8f..b93fa5bb 100644 --- a/src/util/file.c +++ b/src/util/file.c @@ -195,7 +195,7 @@ file_read_line(char *line, size_t *size, FILE *file, int *lineno) } while (fgets(line + offset, *size - offset, file)) { - char *linepos = strchr((const char *)(line + offset), '\n'); + char *linepos = strchr((line + offset), '\n'); if (!linepos) { /* Test if the line buffer should be increase because diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index 957cad90..951fccda 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -613,7 +613,7 @@ drew_char: } #else text = s; - end = strchr((const char *)s, '\0'); + end = strchr(s, '\0'); len = utf8_ptr2cells(text, end); for (; i < link->npoints-2; i++) { x = link->points[i].x + dx; @@ -1290,7 +1290,7 @@ get_form_uri(struct session *ses, struct document_view *doc_view, switch (form->method) { case FORM_METHOD_GET: { - char *pos = strchr((const char *)form->action, '#'); + char *pos = strchr(form->action, '#'); if (pos) { add_bytes_to_string(&go, form->action, pos - form->action); @@ -1298,7 +1298,7 @@ get_form_uri(struct session *ses, struct document_view *doc_view, add_to_string(&go, form->action); } - if (strchr((const char *)go.source, '?')) + if (strchr(go.source, '?')) add_char_to_string(&go, '&'); else add_char_to_string(&go, '?'); @@ -1539,7 +1539,7 @@ field_op(struct session *ses, struct document_view *doc_view, } if (utf8) { char *text = fs->value + fs->state; - char *end = strchr((const char *)text, '\0'); + char *end = strchr(text, '\0'); utf8_to_unicode(&text, end); fs->state = (int)(text - fs->value); @@ -1786,7 +1786,7 @@ field_op(struct session *ses, struct document_view *doc_view, break; } - text = strchr((const char *)(fs->value + fs->state), ASCII_LF); + text = strchr((fs->value + fs->state), ASCII_LF); if (!text) { fs->value[fs->state] = '\0'; break; diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index 846edb39..2a6aefe0 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -1187,7 +1187,7 @@ do_op_right(struct form_state *fs, struct line_info *line, int current, int utf8 } text = fs->value + fs->state; - end = strchr((const char *)text, '\0'); + end = strchr(text, '\0'); old_state = fs->state; utf8_to_unicode(&text, end);