Replace uses of sindex() with constant accept strings with strpbrk() / strchr()

sindex(), where neither argument is NULL and the accept string does not start with ^, is exactly equivalent
to the standard function strpbrk().

Further, strpbrk() where the accept string is only one character long, is exactly equivalent to strchr().
This commit is contained in:
Kevin Easton
2017-11-17 16:23:39 +11:00
parent eb6ffc7395
commit 8c7d9334dd
4 changed files with 26 additions and 30 deletions

View File

@@ -194,8 +194,8 @@ void add_to_history(char *line)
{
while (line && *line)
{
if ((ptr = sindex(line, "\n\r")) != NULL)
*(ptr++) = '\0';
if ((ptr = strpbrk(line, "\r\n")) != NULL)
*ptr++ = '\0';
add_to_history_list(hist_count, line);
last_dir = PREV;
hist_count++;