landing patch for bug 262218 "libxpcom.so should only export frozen symbols" r=bsmedberg sr=bryner

git-svn-id: svn://10.0.0.236/trunk@164375 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2004-10-25 19:34:45 +00:00
parent 94cd40c1ae
commit 3f701b6803
69 changed files with 1055 additions and 233 deletions

View File

@@ -294,6 +294,55 @@ static PRBool test_replace()
return PR_TRUE;
}
static const char* kWhitespace="\b\t\r\n ";
static void
CompressWhitespace(nsACString &str)
{
const char *p;
PRInt32 i, len = (PRInt32) NS_CStringGetData(str, &p);
// trim leading whitespace
for (i=0; i<len; ++i)
{
if (!strchr(kWhitespace, (char) p[i]))
break;
}
if (i>0)
{
NS_CStringCutData(str, 0, i);
len = (PRInt32) NS_CStringGetData(str, &p);
}
// trim trailing whitespace
for (i=len-1; i>=0; --i)
{
if (!strchr(kWhitespace, (char) p[i]))
break;
}
if (++i < len)
NS_CStringCutData(str, i, len - i);
}
static PRBool test_compress_ws()
{
nsCStringContainer s;
NS_CStringContainerInit(s);
NS_CStringSetData(s, " \thello world\r \n");
CompressWhitespace(s);
const char *d;
NS_CStringGetData(s, &d);
PRBool rv = !strcmp(d, "hello world");
if (!rv)
printf("=> \"%s\"\n", d);
NS_CStringContainerFinish(s);
return rv;
}
//----
typedef PRBool (*TestFunc)();
@@ -310,6 +359,7 @@ tests[] =
{ "test_convert", test_convert },
{ "test_append", test_append },
{ "test_replace", test_replace },
{ "test_compress_ws", test_compress_ws },
{ nsnull, nsnull }
};