mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1427023 - Remove nsCRT::strncmp. r=erahm
This commit is contained in:
parent
9baf9bb6f6
commit
8b05ff3704
@ -1253,7 +1253,7 @@ static bool
|
||||
IsSpaceStuffable(const char16_t *s)
|
||||
{
|
||||
if (s[0] == '>' || s[0] == ' ' || s[0] == kNBSP ||
|
||||
nsCRT::strncmp(s, u"From ", 5) == 0)
|
||||
NS_strncmp(s, u"From ", 5) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
@ -2731,8 +2731,8 @@ imgLoader::GetMimeTypeFromContent(const char* aContents,
|
||||
nsACString& aContentType)
|
||||
{
|
||||
/* Is it a GIF? */
|
||||
if (aLength >= 6 && (!nsCRT::strncmp(aContents, "GIF87a", 6) ||
|
||||
!nsCRT::strncmp(aContents, "GIF89a", 6))) {
|
||||
if (aLength >= 6 && (!strncmp(aContents, "GIF87a", 6) ||
|
||||
!strncmp(aContents, "GIF89a", 6))) {
|
||||
aContentType.AssignLiteral(IMAGE_GIF);
|
||||
|
||||
/* or a PNG? */
|
||||
@ -2769,7 +2769,7 @@ imgLoader::GetMimeTypeFromContent(const char* aContents,
|
||||
((unsigned char) aContents[4])==0x00 ) {
|
||||
aContentType.AssignLiteral(IMAGE_ART);
|
||||
|
||||
} else if (aLength >= 2 && !nsCRT::strncmp(aContents, "BM", 2)) {
|
||||
} else if (aLength >= 2 && !strncmp(aContents, "BM", 2)) {
|
||||
aContentType.AssignLiteral(IMAGE_BMP);
|
||||
|
||||
// ICOs always begin with a 2-byte 0 followed by a 2-byte 1.
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
static bool MatchesLanguagePrefix(const char16_t* aLang, size_t aLen,
|
||||
const char16_t (&aPrefix)[N])
|
||||
{
|
||||
return !nsCRT::strncmp(aLang, aPrefix, N - 1) &&
|
||||
return !NS_strncmp(aLang, aPrefix, N - 1) &&
|
||||
(aLen == N - 1 || aLang[N - 1] == '-');
|
||||
}
|
||||
|
||||
|
@ -2524,8 +2524,7 @@ nsStandardURL::Resolve(const nsACString &in, nsACString &out)
|
||||
if (SegmentIs(mScheme, relpath, scheme, true)) {
|
||||
// mScheme and Scheme are the same
|
||||
// but this can still be relative
|
||||
if (nsCRT::strncmp(relpath + scheme.mPos + scheme.mLen,
|
||||
"://",3) == 0) {
|
||||
if (strncmp(relpath + scheme.mPos + scheme.mLen, "://", 3) == 0) {
|
||||
// now this is really absolute
|
||||
// because a :// follows the scheme
|
||||
result = NS_strdup(relpath);
|
||||
|
@ -254,7 +254,7 @@ net_CoalesceDirs(netCoalesceFlags flags, char* path)
|
||||
to the user loging in. We remember the length of the marker */
|
||||
if (nsCRT::strncasecmp(path,"/%2F",4) == 0)
|
||||
special_ftp_len = 4;
|
||||
else if (nsCRT::strncmp(path,"//",2) == 0 )
|
||||
else if (strncmp(path, "//", 2) == 0 )
|
||||
special_ftp_len = 2;
|
||||
}
|
||||
|
||||
|
2
netwerk/cache/nsMemoryCacheDevice.cpp
vendored
2
netwerk/cache/nsMemoryCacheDevice.cpp
vendored
@ -463,7 +463,7 @@ EntryMatchesClientID(nsCacheEntry* entry, void* args)
|
||||
const char * clientID = static_cast<ClientIDArgs*>(args)->clientID;
|
||||
uint32_t prefixLength = static_cast<ClientIDArgs*>(args)->prefixLength;
|
||||
const char * key = entry->Key()->get();
|
||||
return !clientID || nsCRT::strncmp(clientID, key, prefixLength) == 0;
|
||||
return !clientID || strncmp(clientID, key, prefixLength) == 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -116,22 +116,22 @@ mozTXTToHTMLConv::UnescapeStr(const char16_t * aInString, int32_t aStartPos, int
|
||||
if (aInString[i] == '&')
|
||||
{
|
||||
subString = &aInString[i];
|
||||
if (!nsCRT::strncmp(subString, u"<", std::min(4, aLength - remainingChars)))
|
||||
if (!NS_strncmp(subString, u"<", std::min(4, aLength - remainingChars)))
|
||||
{
|
||||
aOutString.Append(char16_t('<'));
|
||||
i += 4;
|
||||
}
|
||||
else if (!nsCRT::strncmp(subString, u">", std::min(4, aLength - remainingChars)))
|
||||
else if (!NS_strncmp(subString, u">", std::min(4, aLength - remainingChars)))
|
||||
{
|
||||
aOutString.Append(char16_t('>'));
|
||||
i += 4;
|
||||
}
|
||||
else if (!nsCRT::strncmp(subString, u"&", std::min(5, aLength - remainingChars)))
|
||||
else if (!NS_strncmp(subString, u"&", std::min(5, aLength - remainingChars)))
|
||||
{
|
||||
aOutString.Append(char16_t('&'));
|
||||
i += 5;
|
||||
}
|
||||
else if (!nsCRT::strncmp(subString, u""", std::min(6, aLength - remainingChars)))
|
||||
else if (!NS_strncmp(subString, u""", std::min(6, aLength - remainingChars)))
|
||||
{
|
||||
aOutString.Append(char16_t('"'));
|
||||
i += 6;
|
||||
@ -194,7 +194,7 @@ mozTXTToHTMLConv::FindURLStart(const char16_t * aInString, int32_t aInLength,
|
||||
{ // no breaks, because end of blocks is never reached
|
||||
case RFC1738:
|
||||
{
|
||||
if (!nsCRT::strncmp(&aInString[std::max(int32_t(pos - 4), 0)], u"<URL:", 5))
|
||||
if (!NS_strncmp(&aInString[std::max(int32_t(pos - 4), 0)], u"<URL:", 5))
|
||||
{
|
||||
start = pos + 1;
|
||||
return true;
|
||||
|
@ -111,35 +111,6 @@ nsCRT::strcmp(const char16_t* aStr1, const char16_t* aStr2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare unichar string ptrs, stopping at the 1st null or nth char.
|
||||
* NOTE: If either is null, we return 0.
|
||||
* NOTE: We DO NOT terminate the search upon encountering nullptr's before N
|
||||
*
|
||||
* @update gess 11/10/99
|
||||
* @param s1 and s2 both point to unichar strings
|
||||
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
|
||||
*/
|
||||
int32_t
|
||||
nsCRT::strncmp(const char16_t* aStr1, const char16_t* aStr2, uint32_t aNum)
|
||||
{
|
||||
if (aStr1 && aStr2) {
|
||||
if (aNum != 0) {
|
||||
do {
|
||||
char16_t c1 = *aStr1++;
|
||||
char16_t c2 = *aStr2++;
|
||||
if (c1 != c2) {
|
||||
if (c1 < c2) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
} while (--aNum != 0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
nsCRT::memmem(const char* aHaystack, uint32_t aHaystackLen,
|
||||
const char* aNeedle, uint32_t aNeedleLen)
|
||||
|
@ -42,12 +42,6 @@ public:
|
||||
return int32_t(PL_strcmp(aStr1, aStr2));
|
||||
}
|
||||
|
||||
static int32_t strncmp(const char* aStr1, const char* aStr2,
|
||||
uint32_t aMaxLen)
|
||||
{
|
||||
return int32_t(PL_strncmp(aStr1, aStr2, aMaxLen));
|
||||
}
|
||||
|
||||
/// Case-insensitive string comparison.
|
||||
static int32_t strcasecmp(const char* aStr1, const char* aStr2)
|
||||
{
|
||||
@ -67,17 +61,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int32_t strncmp(const char* aStr1, const char* aStr2, int32_t aMaxLen)
|
||||
{
|
||||
// inline the first test (assumes strings are not null):
|
||||
int32_t diff =
|
||||
((const unsigned char*)aStr1)[0] - ((const unsigned char*)aStr2)[0];
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
return int32_t(PL_strncmp(aStr1, aStr2, unsigned(aMaxLen)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
How to use this fancy (thread-safe) version of strtok:
|
||||
@ -101,9 +84,6 @@ public:
|
||||
|
||||
/// Like strcmp except for ucs2 strings
|
||||
static int32_t strcmp(const char16_t* aStr1, const char16_t* aStr2);
|
||||
/// Like strcmp except for ucs2 strings
|
||||
static int32_t strncmp(const char16_t* aStr1, const char16_t* aStr2,
|
||||
uint32_t aMaxLen);
|
||||
|
||||
// The GNU libc has memmem, which is strstr except for binary data
|
||||
// This is our own implementation that uses memmem on platforms
|
||||
|
@ -1552,7 +1552,7 @@ static bool strings_equal(bool aIgnoreCase,
|
||||
const char* aS1, const char* aS2, uint32_t aLen)
|
||||
{
|
||||
return aIgnoreCase
|
||||
? !nsCRT::strncasecmp(aS1, aS2, aLen) : !nsCRT::strncmp(aS1, aS2, aLen);
|
||||
? !nsCRT::strncasecmp(aS1, aS2, aLen) : !strncmp(aS1, aS2, aLen);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -48,15 +48,9 @@ static void Check(const char* s1, const char* s2, size_t n)
|
||||
const char16_t* us2 = t2.get();
|
||||
|
||||
int u2, u2_n;
|
||||
// nsCRT::strncmp will cause buffer overrun
|
||||
// if the string buffer is shorter than |n|.
|
||||
if (!longerThanN) {
|
||||
u2 = nsCRT::strcmp(us1, us2);
|
||||
u2_n = nsCRT::strncmp(us1, us2, n);
|
||||
u2 = nsCRT::strcmp(us1, us2);
|
||||
|
||||
EXPECT_EQ(sign(clib), sign(u2));
|
||||
EXPECT_EQ(sign(clib_n), sign(u2_n));
|
||||
}
|
||||
EXPECT_EQ(sign(clib), sign(u2));
|
||||
|
||||
u2 = NS_strcmp(us1, us2);
|
||||
u2_n = NS_strncmp(us1, us2, n);
|
||||
|
Loading…
Reference in New Issue
Block a user