From cce89c1b4110abc6b316d5bb84dcd49a0e1600e6 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Tue, 27 Apr 1999 22:20:52 +0000 Subject: [PATCH] Fixed bug in strncasecmp as reported by Eric Burley ; while I was there I removed a compiler warning too --- base/src/nsCRT.cpp | 21 +++++++++++---------- xpcom/ds/nsCRT.cpp | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/base/src/nsCRT.cpp b/base/src/nsCRT.cpp index 521ceeed9922..0b9693e95070 100644 --- a/base/src/nsCRT.cpp +++ b/base/src/nsCRT.cpp @@ -134,14 +134,15 @@ static NS_DEFINE_IID(kIShutdownListenerIID, NS_ISHUTDOWNLISTENER_IID); NS_IMPL_ISUPPORTS(HandleCaseConversionShutdown, kIShutdownListenerIID); nsresult -HandleCaseConversionShutdown::OnShutdown(const nsCID& cid, nsISupports* service) +HandleCaseConversionShutdown::OnShutdown(const nsCID& cid, + nsISupports* aService) { - if (cid.Equals(kUnicharUtilCID)) { - NS_ASSERTION(service == gCaseConv, "wrong service!"); - nsrefcnt cnt = gCaseConv->Release(); - gCaseConv = NULL; - } - return NS_OK; + if (cid.Equals(kUnicharUtilCID)) { + NS_ASSERTION(aService == gCaseConv, "wrong service!"); + gCaseConv->Release(); + gCaseConv = NULL; + } + return NS_OK; } static HandleCaseConversionShutdown* gListener = NULL; @@ -351,8 +352,8 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2) PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) { if(s1 && s2) { - if(0= 0) { + if(n != 0){ + do { PRUnichar c1 = *s1++; PRUnichar c2 = *s2++; if (c1 != c2) { @@ -364,7 +365,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) } } if ((0==c1) || (0==c2)) break; - } + } while (--n != 0); } } return 0; diff --git a/xpcom/ds/nsCRT.cpp b/xpcom/ds/nsCRT.cpp index 521ceeed9922..0b9693e95070 100644 --- a/xpcom/ds/nsCRT.cpp +++ b/xpcom/ds/nsCRT.cpp @@ -134,14 +134,15 @@ static NS_DEFINE_IID(kIShutdownListenerIID, NS_ISHUTDOWNLISTENER_IID); NS_IMPL_ISUPPORTS(HandleCaseConversionShutdown, kIShutdownListenerIID); nsresult -HandleCaseConversionShutdown::OnShutdown(const nsCID& cid, nsISupports* service) +HandleCaseConversionShutdown::OnShutdown(const nsCID& cid, + nsISupports* aService) { - if (cid.Equals(kUnicharUtilCID)) { - NS_ASSERTION(service == gCaseConv, "wrong service!"); - nsrefcnt cnt = gCaseConv->Release(); - gCaseConv = NULL; - } - return NS_OK; + if (cid.Equals(kUnicharUtilCID)) { + NS_ASSERTION(aService == gCaseConv, "wrong service!"); + gCaseConv->Release(); + gCaseConv = NULL; + } + return NS_OK; } static HandleCaseConversionShutdown* gListener = NULL; @@ -351,8 +352,8 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2) PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) { if(s1 && s2) { - if(0= 0) { + if(n != 0){ + do { PRUnichar c1 = *s1++; PRUnichar c2 = *s2++; if (c1 != c2) { @@ -364,7 +365,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) } } if ((0==c1) || (0==c2)) break; - } + } while (--n != 0); } } return 0;