Remove old string functions.

More specifically, this removes the functions:
strcasecmp_n
strchr_n
strrchr_n

and replaces the calls with the respective C-library calls that should
be part of just about all operating systems by now.
This commit is contained in:
Johanna Amann 2016-03-04 12:02:19 -08:00
parent 611a8ab935
commit 446a44787a
7 changed files with 11 additions and 51 deletions

View file

@ -323,24 +323,6 @@ string to_upper(const std::string& s)
return t;
}
const char* strchr_n(const char* s, const char* end_of_s, char ch)
{
for ( ; s < end_of_s; ++s )
if ( *s == ch )
return s;
return 0;
}
const char* strrchr_n(const char* s, const char* end_of_s, char ch)
{
for ( --end_of_s; end_of_s >= s; --end_of_s )
if ( *end_of_s == ch )
return end_of_s;
return 0;
}
int decode_hex(char ch)
{
if ( ch >= '0' && ch <= '9' )
@ -382,27 +364,6 @@ const char* strpbrk_n(size_t len, const char* s, const char* charset)
return 0;
}
int strcasecmp_n(int b_len, const char* b, const char* t)
{
if ( ! b )
return -1;
int i;
for ( i = 0; i < b_len; ++i )
{
char c1 = islower(b[i]) ? toupper(b[i]) : b[i];
char c2 = islower(t[i]) ? toupper(t[i]) : t[i];
if ( c1 < c2 )
return -1;
if ( c1 > c2 )
return 1;
}
return t[i] != '\0';
}
#ifndef HAVE_STRCASESTR
// This code is derived from software contributed to BSD by Chris Torek.
char* strcasestr(const char* s, const char* find)
@ -421,7 +382,7 @@ char* strcasestr(const char* s, const char* find)
if ( sc == 0 )
return 0;
} while ( char(tolower((unsigned char) sc)) != c );
} while ( strcasecmp_n(len, s, find) != 0 );
} while ( strncasecmp(s, find, len) != 0 );
--s;
}