1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[strchr] casting first parameter to const char * was not a good idea

This commit is contained in:
Witold Filipczyk 2022-01-18 20:30:48 +01:00
parent aaf942d37d
commit 53a860a3d6
46 changed files with 107 additions and 107 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

2
src/cache/cache.c vendored
View File

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

View File

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

View File

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

View File

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

View File

@ -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. */

View File

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

View File

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

View File

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

View File

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

View File

@ -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'. */

View File

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

View File

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

View File

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

View File

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

View File

@ -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 = '_';
}

View File

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

View File

@ -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 = '_';
}

View File

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

View File

@ -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 = '.';

View File

@ -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 '/' */

View File

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

View File

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

View File

@ -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/",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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