ICU-5333 Whitespace changes.

X-SVN-Rev: 20117
This commit is contained in:
George Rhoten 2006-08-19 21:27:08 +00:00
parent 07a9528f79
commit 34c5798a18
19 changed files with 1358 additions and 1359 deletions

View File

@ -2,7 +2,7 @@
//
// file: rbbiscan.cpp
//
// Copyright (C) 2002-2005, International Business Machines Corporation and others.
// Copyright (C) 2002-2006, International Business Machines Corporation and others.
// All Rights Reserved.
//
// This file contains the Rule Based Break Iterator Rule Builder functions for
@ -289,13 +289,13 @@ UBool RBBIRuleScanner::doParseActions(EParseAction action)
// Make a symbol table entry for the $variableRef node.
fSymbolTable->addEntry(varRefNode->fText, varRefNode, *fRB->fStatus);
if (U_FAILURE(*fRB->fStatus)) {
// This is a round-about way to get the parse position set
// so that duplicate symbols error messages include a line number.
UErrorCode t = *fRB->fStatus;
*fRB->fStatus = U_ZERO_ERROR;
error(t);
}
if (U_FAILURE(*fRB->fStatus)) {
// This is a round-about way to get the parse position set
// so that duplicate symbols error messages include a line number.
UErrorCode t = *fRB->fStatus;
*fRB->fStatus = U_ZERO_ERROR;
error(t);
}
// Clean up the stack.
delete startExprNode;

View File

@ -666,27 +666,27 @@ void RBBITableBuilder::flagAcceptingStates() {
// If no other value was specified, force it to -1.
if (sd->fAccepting==0) {
// State hasn't been marked as accepting yet. Do it now.
// State hasn't been marked as accepting yet. Do it now.
sd->fAccepting = endMarker->fVal;
if (sd->fAccepting == 0) {
sd->fAccepting = -1;
}
}
}
if (sd->fAccepting==-1 && endMarker->fVal != 0) {
// Both lookahead and non-lookahead accepting for this state.
// Favor the look-ahead. Expedient for line break.
// TODO: need a more elegant resolution for conflicting rules.
sd->fAccepting = endMarker->fVal;
}
// implicit else:
// if sd->fAccepting already had a value other than 0 or -1, leave it be.
// Both lookahead and non-lookahead accepting for this state.
// Favor the look-ahead. Expedient for line break.
// TODO: need a more elegant resolution for conflicting rules.
sd->fAccepting = endMarker->fVal;
}
// implicit else:
// if sd->fAccepting already had a value other than 0 or -1, leave it be.
// If the end marker node is from a look-ahead rule, set
// the fLookAhead field or this state also.
if (endMarker->fLookAheadEnd) {
// TODO: don't change value if already set?
// TODO: allow for more than one active look-ahead rule in engine.
// Make value here an index to a side array in engine?
// TODO: don't change value if already set?
// TODO: allow for more than one active look-ahead rule in engine.
// Make value here an index to a side array in engine?
sd->fLookAhead = sd->fAccepting;
}
}

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 2000-2005, International Business Machines
* Copyright (C) 2000-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: ucnv_lmb.cpp
@ -1045,7 +1045,7 @@ _LMBCSGetNextUCharWorker(UConverterToUnicodeArgs* args,
|| CurByte == ULMBCS_HT || CurByte == ULMBCS_CR
|| CurByte == ULMBCS_LF || CurByte == ULMBCS_123SYSTEMRANGE)
{
uniChar = CurByte;
uniChar = CurByte;
}
else
{

View File

@ -520,7 +520,7 @@ umtx_atomic_inc(int32_t *p) {
#if defined (U_WINDOWS) && ICU_USE_THREADS == 1
retVal = InterlockedIncrement((LONG*)p);
#elif defined(USE_MAC_OS_ATOMIC_INCREMENT)
retVal = OSAtomicIncrement32Barrier(p);
retVal = OSAtomicIncrement32Barrier(p);
#elif defined (POSIX) && ICU_USE_THREADS == 1
umtx_lock(&gIncDecMutex);
retVal = ++(*p);
@ -542,7 +542,7 @@ umtx_atomic_dec(int32_t *p) {
#if defined (U_WINDOWS) && ICU_USE_THREADS == 1
retVal = InterlockedDecrement((LONG*)p);
#elif defined(USE_MAC_OS_ATOMIC_INCREMENT)
retVal = OSAtomicDecrement32Barrier(p);
retVal = OSAtomicDecrement32Barrier(p);
#elif defined (POSIX) && ICU_USE_THREADS == 1
umtx_lock(&gIncDecMutex);
retVal = --(*p);

View File

@ -685,14 +685,14 @@ Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& succ
else
#endif
{
UErrorCode feErr;
UErrorCode feErr;
char calLocaleType[ULOC_FULLNAME_CAPACITY];
calLocaleType[0] = 0; // NULL terminate
int32_t keywordCapacity = aLocale.getKeywordValue("calendar", calLocaleType, sizeof(calLocaleType)-1, success);
if (keywordCapacity == 0) {
char funcEquiv[ULOC_FULLNAME_CAPACITY];
feErr = success;
feErr = success;
// fetch default calendar id
ures_getFunctionalEquivalent(funcEquiv, sizeof(funcEquiv)-1,
@ -701,7 +701,7 @@ Calendar::createInstance(TimeZone* zone, const Locale& aLocale, UErrorCode& succ
NULL, FALSE, &feErr);
keywordCapacity = uloc_getKeywordValue(funcEquiv, "calendar", calLocaleType,
sizeof(calLocaleType)-1, &feErr); // This can fail if there is no data.
// Don't want to stop calendar construction just because we couldn't get this type.
// Don't want to stop calendar construction just because we couldn't get this type.
if (keywordCapacity == 0 || U_FAILURE(feErr)) {
// no calendar type. Default to nothing.
calLocaleType[0] = 0;

View File

@ -23,71 +23,71 @@ const int32_t commonChars_sjis [] = {
// TODO: This set of data comes from the character frequency-
// of-occurence analysis tool. The data needs to be moved
// into a resource and loaded from there.
0x8140, 0x8141, 0x8142, 0x8145, 0x815b, 0x8169, 0x816a, 0x8175, 0x8176, 0x82a0,
0x82a2, 0x82a4, 0x82a9, 0x82aa, 0x82ab, 0x82ad, 0x82af, 0x82b1, 0x82b3, 0x82b5,
0x82b7, 0x82bd, 0x82be, 0x82c1, 0x82c4, 0x82c5, 0x82c6, 0x82c8, 0x82c9, 0x82cc,
0x82cd, 0x82dc, 0x82e0, 0x82e7, 0x82e8, 0x82e9, 0x82ea, 0x82f0, 0x82f1, 0x8341,
0x8343, 0x834e, 0x834f, 0x8358, 0x835e, 0x8362, 0x8367, 0x8375, 0x8376, 0x8389,
0x8140, 0x8141, 0x8142, 0x8145, 0x815b, 0x8169, 0x816a, 0x8175, 0x8176, 0x82a0,
0x82a2, 0x82a4, 0x82a9, 0x82aa, 0x82ab, 0x82ad, 0x82af, 0x82b1, 0x82b3, 0x82b5,
0x82b7, 0x82bd, 0x82be, 0x82c1, 0x82c4, 0x82c5, 0x82c6, 0x82c8, 0x82c9, 0x82cc,
0x82cd, 0x82dc, 0x82e0, 0x82e7, 0x82e8, 0x82e9, 0x82ea, 0x82f0, 0x82f1, 0x8341,
0x8343, 0x834e, 0x834f, 0x8358, 0x835e, 0x8362, 0x8367, 0x8375, 0x8376, 0x8389,
0x838a, 0x838b, 0x838d, 0x8393, 0x8e96, 0x93fa, 0x95aa};
const int32_t commonChars_euc_jp[] = {
// TODO: This set of data comes from the character frequency-
// of-occurence analysis tool. The data needs to be moved
// into a resource and loaded from there.
0xa1a1, 0xa1a2, 0xa1a3, 0xa1a6, 0xa1bc, 0xa1ca, 0xa1cb, 0xa1d6, 0xa1d7, 0xa4a2,
0xa4a4, 0xa4a6, 0xa4a8, 0xa4aa, 0xa4ab, 0xa4ac, 0xa4ad, 0xa4af, 0xa4b1, 0xa4b3,
0xa4b5, 0xa4b7, 0xa4b9, 0xa4bb, 0xa4bd, 0xa4bf, 0xa4c0, 0xa4c1, 0xa4c3, 0xa4c4,
0xa4c6, 0xa4c7, 0xa4c8, 0xa4c9, 0xa4ca, 0xa4cb, 0xa4ce, 0xa4cf, 0xa4d0, 0xa4de,
0xa4df, 0xa4e1, 0xa4e2, 0xa4e4, 0xa4e8, 0xa4e9, 0xa4ea, 0xa4eb, 0xa4ec, 0xa4ef,
0xa4f2, 0xa4f3, 0xa5a2, 0xa5a3, 0xa5a4, 0xa5a6, 0xa5a7, 0xa5aa, 0xa5ad, 0xa5af,
0xa5b0, 0xa5b3, 0xa5b5, 0xa5b7, 0xa5b8, 0xa5b9, 0xa5bf, 0xa5c3, 0xa5c6, 0xa5c7,
0xa5c8, 0xa5c9, 0xa5cb, 0xa5d0, 0xa5d5, 0xa5d6, 0xa5d7, 0xa5de, 0xa5e0, 0xa5e1,
0xa5e5, 0xa5e9, 0xa5ea, 0xa5eb, 0xa5ec, 0xa5ed, 0xa5f3, 0xb8a9, 0xb9d4, 0xbaee,
0xa1a1, 0xa1a2, 0xa1a3, 0xa1a6, 0xa1bc, 0xa1ca, 0xa1cb, 0xa1d6, 0xa1d7, 0xa4a2,
0xa4a4, 0xa4a6, 0xa4a8, 0xa4aa, 0xa4ab, 0xa4ac, 0xa4ad, 0xa4af, 0xa4b1, 0xa4b3,
0xa4b5, 0xa4b7, 0xa4b9, 0xa4bb, 0xa4bd, 0xa4bf, 0xa4c0, 0xa4c1, 0xa4c3, 0xa4c4,
0xa4c6, 0xa4c7, 0xa4c8, 0xa4c9, 0xa4ca, 0xa4cb, 0xa4ce, 0xa4cf, 0xa4d0, 0xa4de,
0xa4df, 0xa4e1, 0xa4e2, 0xa4e4, 0xa4e8, 0xa4e9, 0xa4ea, 0xa4eb, 0xa4ec, 0xa4ef,
0xa4f2, 0xa4f3, 0xa5a2, 0xa5a3, 0xa5a4, 0xa5a6, 0xa5a7, 0xa5aa, 0xa5ad, 0xa5af,
0xa5b0, 0xa5b3, 0xa5b5, 0xa5b7, 0xa5b8, 0xa5b9, 0xa5bf, 0xa5c3, 0xa5c6, 0xa5c7,
0xa5c8, 0xa5c9, 0xa5cb, 0xa5d0, 0xa5d5, 0xa5d6, 0xa5d7, 0xa5de, 0xa5e0, 0xa5e1,
0xa5e5, 0xa5e9, 0xa5ea, 0xa5eb, 0xa5ec, 0xa5ed, 0xa5f3, 0xb8a9, 0xb9d4, 0xbaee,
0xbbc8, 0xbef0, 0xbfb7, 0xc4ea, 0xc6fc, 0xc7bd, 0xcab8, 0xcaf3, 0xcbdc, 0xcdd1};
const int32_t commonChars_euc_kr[] = {
// TODO: This set of data comes from the character frequency-
// of-occurence analysis tool. The data needs to be moved
// into a resource and loaded from there.
0xb0a1, 0xb0b3, 0xb0c5, 0xb0cd, 0xb0d4, 0xb0e6, 0xb0ed, 0xb0f8, 0xb0fa, 0xb0fc,
0xb1b8, 0xb1b9, 0xb1c7, 0xb1d7, 0xb1e2, 0xb3aa, 0xb3bb, 0xb4c2, 0xb4cf, 0xb4d9,
0xb4eb, 0xb5a5, 0xb5b5, 0xb5bf, 0xb5c7, 0xb5e9, 0xb6f3, 0xb7af, 0xb7c2, 0xb7ce,
0xb8a6, 0xb8ae, 0xb8b6, 0xb8b8, 0xb8bb, 0xb8e9, 0xb9ab, 0xb9ae, 0xb9cc, 0xb9ce,
0xb9fd, 0xbab8, 0xbace, 0xbad0, 0xbaf1, 0xbbe7, 0xbbf3, 0xbbfd, 0xbcad, 0xbcba,
0xbcd2, 0xbcf6, 0xbdba, 0xbdc0, 0xbdc3, 0xbdc5, 0xbec6, 0xbec8, 0xbedf, 0xbeee,
0xbef8, 0xbefa, 0xbfa1, 0xbfa9, 0xbfc0, 0xbfe4, 0xbfeb, 0xbfec, 0xbff8, 0xc0a7,
0xc0af, 0xc0b8, 0xc0ba, 0xc0bb, 0xc0bd, 0xc0c7, 0xc0cc, 0xc0ce, 0xc0cf, 0xc0d6,
0xc0da, 0xc0e5, 0xc0fb, 0xc0fc, 0xc1a4, 0xc1a6, 0xc1b6, 0xc1d6, 0xc1df, 0xc1f6,
0xb0a1, 0xb0b3, 0xb0c5, 0xb0cd, 0xb0d4, 0xb0e6, 0xb0ed, 0xb0f8, 0xb0fa, 0xb0fc,
0xb1b8, 0xb1b9, 0xb1c7, 0xb1d7, 0xb1e2, 0xb3aa, 0xb3bb, 0xb4c2, 0xb4cf, 0xb4d9,
0xb4eb, 0xb5a5, 0xb5b5, 0xb5bf, 0xb5c7, 0xb5e9, 0xb6f3, 0xb7af, 0xb7c2, 0xb7ce,
0xb8a6, 0xb8ae, 0xb8b6, 0xb8b8, 0xb8bb, 0xb8e9, 0xb9ab, 0xb9ae, 0xb9cc, 0xb9ce,
0xb9fd, 0xbab8, 0xbace, 0xbad0, 0xbaf1, 0xbbe7, 0xbbf3, 0xbbfd, 0xbcad, 0xbcba,
0xbcd2, 0xbcf6, 0xbdba, 0xbdc0, 0xbdc3, 0xbdc5, 0xbec6, 0xbec8, 0xbedf, 0xbeee,
0xbef8, 0xbefa, 0xbfa1, 0xbfa9, 0xbfc0, 0xbfe4, 0xbfeb, 0xbfec, 0xbff8, 0xc0a7,
0xc0af, 0xc0b8, 0xc0ba, 0xc0bb, 0xc0bd, 0xc0c7, 0xc0cc, 0xc0ce, 0xc0cf, 0xc0d6,
0xc0da, 0xc0e5, 0xc0fb, 0xc0fc, 0xc1a4, 0xc1a6, 0xc1b6, 0xc1d6, 0xc1df, 0xc1f6,
0xc1f8, 0xc4a1, 0xc5cd, 0xc6ae, 0xc7cf, 0xc7d1, 0xc7d2, 0xc7d8, 0xc7e5, 0xc8ad};
const int32_t commonChars_big5[] = {
// TODO: This set of data comes from the character frequency-
// of-occurence analysis tool. The data needs to be moved
// into a resource and loaded from there.
0xa140, 0xa141, 0xa142, 0xa143, 0xa147, 0xa149, 0xa175, 0xa176, 0xa440, 0xa446,
0xa447, 0xa448, 0xa451, 0xa454, 0xa457, 0xa464, 0xa46a, 0xa46c, 0xa477, 0xa4a3,
0xa4a4, 0xa4a7, 0xa4c1, 0xa4ce, 0xa4d1, 0xa4df, 0xa4e8, 0xa4fd, 0xa540, 0xa548,
0xa558, 0xa569, 0xa5cd, 0xa5e7, 0xa657, 0xa661, 0xa662, 0xa668, 0xa670, 0xa6a8,
0xa6b3, 0xa6b9, 0xa6d3, 0xa6db, 0xa6e6, 0xa6f2, 0xa740, 0xa751, 0xa759, 0xa7da,
0xa8a3, 0xa8a5, 0xa8ad, 0xa8d1, 0xa8d3, 0xa8e4, 0xa8fc, 0xa9c0, 0xa9d2, 0xa9f3,
0xaa6b, 0xaaba, 0xaabe, 0xaacc, 0xaafc, 0xac47, 0xac4f, 0xacb0, 0xacd2, 0xad59,
0xaec9, 0xafe0, 0xb0ea, 0xb16f, 0xb2b3, 0xb2c4, 0xb36f, 0xb44c, 0xb44e, 0xb54c,
0xb5a5, 0xb5bd, 0xb5d0, 0xb5d8, 0xb671, 0xb7ed, 0xb867, 0xb944, 0xbad8, 0xbb44,
0xa140, 0xa141, 0xa142, 0xa143, 0xa147, 0xa149, 0xa175, 0xa176, 0xa440, 0xa446,
0xa447, 0xa448, 0xa451, 0xa454, 0xa457, 0xa464, 0xa46a, 0xa46c, 0xa477, 0xa4a3,
0xa4a4, 0xa4a7, 0xa4c1, 0xa4ce, 0xa4d1, 0xa4df, 0xa4e8, 0xa4fd, 0xa540, 0xa548,
0xa558, 0xa569, 0xa5cd, 0xa5e7, 0xa657, 0xa661, 0xa662, 0xa668, 0xa670, 0xa6a8,
0xa6b3, 0xa6b9, 0xa6d3, 0xa6db, 0xa6e6, 0xa6f2, 0xa740, 0xa751, 0xa759, 0xa7da,
0xa8a3, 0xa8a5, 0xa8ad, 0xa8d1, 0xa8d3, 0xa8e4, 0xa8fc, 0xa9c0, 0xa9d2, 0xa9f3,
0xaa6b, 0xaaba, 0xaabe, 0xaacc, 0xaafc, 0xac47, 0xac4f, 0xacb0, 0xacd2, 0xad59,
0xaec9, 0xafe0, 0xb0ea, 0xb16f, 0xb2b3, 0xb2c4, 0xb36f, 0xb44c, 0xb44e, 0xb54c,
0xb5a5, 0xb5bd, 0xb5d0, 0xb5d8, 0xb671, 0xb7ed, 0xb867, 0xb944, 0xbad8, 0xbb44,
0xbba1, 0xbdd1, 0xc2c4, 0xc3b9, 0xc440, 0xc45f};
const int32_t commonChars_gb_18030[] = {
// TODO: This set of data comes from the character frequency-
// of-occurence analysis tool. The data needs to be moved
// into a resource and loaded from there.
0xa1a1, 0xa1a2, 0xa1a3, 0xa1a4, 0xa1b0, 0xa1b1, 0xa1f1, 0xa1f3, 0xa3a1, 0xa3ac,
0xa3ba, 0xb1a8, 0xb1b8, 0xb1be, 0xb2bb, 0xb3c9, 0xb3f6, 0xb4f3, 0xb5bd, 0xb5c4,
0xb5e3, 0xb6af, 0xb6d4, 0xb6e0, 0xb7a2, 0xb7a8, 0xb7bd, 0xb7d6, 0xb7dd, 0xb8b4,
0xb8df, 0xb8f6, 0xb9ab, 0xb9c9, 0xb9d8, 0xb9fa, 0xb9fd, 0xbacd, 0xbba7, 0xbbd6,
0xbbe1, 0xbbfa, 0xbcbc, 0xbcdb, 0xbcfe, 0xbdcc, 0xbecd, 0xbedd, 0xbfb4, 0xbfc6,
0xbfc9, 0xc0b4, 0xc0ed, 0xc1cb, 0xc2db, 0xc3c7, 0xc4dc, 0xc4ea, 0xc5cc, 0xc6f7,
0xc7f8, 0xc8ab, 0xc8cb, 0xc8d5, 0xc8e7, 0xc9cf, 0xc9fa, 0xcab1, 0xcab5, 0xcac7,
0xcad0, 0xcad6, 0xcaf5, 0xcafd, 0xccec, 0xcdf8, 0xceaa, 0xcec4, 0xced2, 0xcee5,
0xcfb5, 0xcfc2, 0xcfd6, 0xd0c2, 0xd0c5, 0xd0d0, 0xd0d4, 0xd1a7, 0xd2aa, 0xd2b2,
0xa1a1, 0xa1a2, 0xa1a3, 0xa1a4, 0xa1b0, 0xa1b1, 0xa1f1, 0xa1f3, 0xa3a1, 0xa3ac,
0xa3ba, 0xb1a8, 0xb1b8, 0xb1be, 0xb2bb, 0xb3c9, 0xb3f6, 0xb4f3, 0xb5bd, 0xb5c4,
0xb5e3, 0xb6af, 0xb6d4, 0xb6e0, 0xb7a2, 0xb7a8, 0xb7bd, 0xb7d6, 0xb7dd, 0xb8b4,
0xb8df, 0xb8f6, 0xb9ab, 0xb9c9, 0xb9d8, 0xb9fa, 0xb9fd, 0xbacd, 0xbba7, 0xbbd6,
0xbbe1, 0xbbfa, 0xbcbc, 0xbcdb, 0xbcfe, 0xbdcc, 0xbecd, 0xbedd, 0xbfb4, 0xbfc6,
0xbfc9, 0xc0b4, 0xc0ed, 0xc1cb, 0xc2db, 0xc3c7, 0xc4dc, 0xc4ea, 0xc5cc, 0xc6f7,
0xc7f8, 0xc8ab, 0xc8cb, 0xc8d5, 0xc8e7, 0xc9cf, 0xc9fa, 0xcab1, 0xcab5, 0xcac7,
0xcad0, 0xcad6, 0xcaf5, 0xcafd, 0xccec, 0xcdf8, 0xceaa, 0xcec4, 0xced2, 0xcee5,
0xcfb5, 0xcfc2, 0xcfd6, 0xd0c2, 0xd0c5, 0xd0d0, 0xd0d4, 0xd1a7, 0xd2aa, 0xd2b2,
0xd2b5, 0xd2bb, 0xd2d4, 0xd3c3, 0xd3d0, 0xd3fd, 0xd4c2, 0xd4da, 0xd5e2, 0xd6d0};
static int32_t binarySearch(const int32_t *array, int32_t len, int32_t value)
@ -126,7 +126,7 @@ void IteratedChar::reset()
done = FALSE;
}
int32_t IteratedChar::nextByte(InputText *det)
int32_t IteratedChar::nextByte(InputText *det)
{
if (nextIndex >= det->fRawLength) {
done = TRUE;
@ -135,7 +135,7 @@ int32_t IteratedChar::nextByte(InputText *det)
}
return det->fRawInput[nextIndex++];
}
}
CharsetRecog_mbcs::~CharsetRecog_mbcs()
{
@ -156,7 +156,7 @@ int32_t CharsetRecog_mbcs::match_mbcs(InputText *det, const int32_t commonChars[
totalCharCount += 1;
if (iter->error) {
badCharCount += 1;
badCharCount += 1;
} else {
if (iter->charValue <= 0xFF) {
singleByteCharCount += 1;
@ -174,7 +174,7 @@ int32_t CharsetRecog_mbcs::match_mbcs(InputText *det, const int32_t commonChars[
if (badCharCount >= 2 && badCharCount*5 >= doubleByteCharCount) {
// Bail out early if the byte data is not matching the encoding scheme.
// break detectBlock;
// break detectBlock;
delete iter;
return confidence;
}
@ -251,7 +251,7 @@ UBool CharsetRecog_sjis::nextChar(IteratedChar* it, InputText* det) {
int32_t secondByte = it->nextByte(det);
if (secondByte < 0) {
return FALSE;
return FALSE;
}
it->charValue = (firstByte << 8) | secondByte;
if (! ((secondByte >= 0x40 && secondByte <= 0x7F) || (secondByte >= 0x80 && secondByte <= 0xFE))) {
@ -286,11 +286,11 @@ UBool CharsetRecog_euc::nextChar(IteratedChar* it, InputText* det) {
int32_t firstByte = 0;
int32_t secondByte = 0;
int32_t thirdByte = 0;
// int32_t fourthByte = 0;
// int32_t fourthByte = 0;
it->index = it->nextIndex;
it->error = FALSE;
firstByte = it->charValue = it->nextByte(det);
firstByte = it->charValue = it->nextByte(det);
if (firstByte < 0) {
// Ran off the end of the input data
@ -322,7 +322,7 @@ UBool CharsetRecog_euc::nextChar(IteratedChar* it, InputText* det) {
// In EUC-TW, total char size is 4 bytes, three bytes contribute to char value.
// We don't know which we've got.
// Treat it like EUC-JP. If the data really was EUC-TW, the following two
// bytes will look like a well formed 2 byte char.
// bytes will look like a well formed 2 byte char.
if (secondByte < 0xA1) {
it->error = TRUE;
}
@ -401,16 +401,16 @@ UBool CharsetRecog_big5::nextChar(IteratedChar* it, InputText* det)
if (firstByte < 0) {
return FALSE;
}
if (firstByte <= 0x7F || firstByte == 0xFF) {
// single byte character.
return TRUE;
}
int32_t secondByte = it->nextByte(det);
if (secondByte < 0) {
return FALSE;
return FALSE;
}
it->charValue = (it->charValue << 8) | secondByte;
@ -452,7 +452,7 @@ UBool CharsetRecog_gb_18030::nextChar(IteratedChar* it, InputText* det) {
it->index = it->nextIndex;
it->error = FALSE;
firstByte = it->charValue = it->nextByte(det);
firstByte = it->charValue = it->nextByte(det);
if (firstByte < 0) {
// Ran off the end of the input data

View File

@ -38,18 +38,18 @@ public:
public:
IteratedChar();
void reset();
int32_t nextByte(InputText* det);
void reset();
int32_t nextByte(InputText* det);
};
class CharsetRecog_mbcs : public CharsetRecognizer {
protected:
protected:
/**
* Test the match of this charset with the input text data
* which is obtained via the CharsetDetector object.
*
*
* @param det The CharsetDetector, which contains the input text
* to be checked for being in this charset.
* @return Two values packed into one int (Damn java, anyhow)
@ -60,9 +60,9 @@ protected:
*/
int32_t match_mbcs(InputText* det, const int32_t commonChars[], int32_t commonCharsLen);
public:
public:
virtual ~CharsetRecog_mbcs();
virtual ~CharsetRecog_mbcs();
/**
* Get the IANA name of this charset.
@ -77,7 +77,7 @@ public:
* Get the next character (however many bytes it is) from the input data
* Subclasses for specific charset encodings must implement this function
* to get characters according to the rules of their encoding scheme.
*
*
* This function is not a method of class IteratedChar only because
* that would require a lot of extra derived classes, which is awkward.
* @param it The IteratedChar "struct" into which the returned char is placed.
@ -87,11 +87,11 @@ public:
*/
virtual UBool nextChar(IteratedChar *it, InputText *textIn) = 0;
};
};
/**
* Shift-JIS charset recognizer.
* Shift-JIS charset recognizer.
*
*/
class CharsetRecog_sjis : public CharsetRecog_mbcs {
@ -111,10 +111,10 @@ public:
/**
* EUC charset recognizers. One abstract class that provides the common function
* for getting the next character according to the EUC encoding scheme,
* and nested derived classes for EUC_KR, EUC_JP, EUC_CN.
* and nested derived classes for EUC_KR, EUC_JP, EUC_CN.
*
*/
class CharsetRecog_euc : public CharsetRecog_mbcs
class CharsetRecog_euc : public CharsetRecog_mbcs
{
public:
virtual ~CharsetRecog_euc();
@ -130,7 +130,7 @@ public:
* packed into an int.
*/
UBool nextChar(IteratedChar *it, InputText *det);
};
};
/**
* The charset recognize for EUC-JP. A singleton instance of this class
@ -138,7 +138,7 @@ public:
*/
class CharsetRecog_euc_jp : public CharsetRecog_euc
{
public:
public:
virtual ~CharsetRecog_euc_jp();
const char *getName() const;
@ -163,11 +163,11 @@ public:
};
/**
*
*
* Big5 charset recognizer.
*
*/
class CharsetRecog_big5 : public CharsetRecog_mbcs
class CharsetRecog_big5 : public CharsetRecog_mbcs
{
public:
virtual ~CharsetRecog_big5();
@ -182,11 +182,11 @@ public:
/**
*
* GB-18030 recognizer. Uses simplified Chinese statistics.
*
* GB-18030 recognizer. Uses simplified Chinese statistics.
*
*/
class CharsetRecog_gb_18030 : public CharsetRecog_mbcs
class CharsetRecog_gb_18030 : public CharsetRecog_mbcs
{
public:
virtual ~CharsetRecog_gb_18030();

View File

@ -21,12 +21,12 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringSearch)
// public constructors and destructors -----------------------------------
StringSearch::StringSearch(const UnicodeString &pattern,
StringSearch::StringSearch(const UnicodeString &pattern,
const UnicodeString &text,
const Locale &locale,
const Locale &locale,
BreakIterator *breakiter,
UErrorCode &status) :
SearchIterator(text, breakiter),
SearchIterator(text, breakiter),
m_collator_(),
m_pattern_(pattern)
{
@ -35,9 +35,9 @@ StringSearch::StringSearch(const UnicodeString &pattern,
return;
}
m_strsrch_ = usearch_open(m_pattern_.getBuffer(), m_pattern_.length(),
m_text_.getBuffer(), m_text_.length(),
locale.getName(), (UBreakIterator *)breakiter,
m_strsrch_ = usearch_open(m_pattern_.getBuffer(), m_pattern_.length(),
m_text_.getBuffer(), m_text_.length(),
locale.getName(), (UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
m_search_ = NULL;
@ -46,26 +46,26 @@ StringSearch::StringSearch(const UnicodeString &pattern,
// wrapper around the internal collator and rules, which (here) are
// owned by this stringsearch object. this means 1) it's destructor
// _should not_ delete the ucollator or rules, and 2) changes made
// to the exposed collator (setStrength etc) _should_ modify the
// to the exposed collator (setStrength etc) _should_ modify the
// ucollator. thus the collator is not a copy-on-write alias, and it
// needs to distinguish itself not merely from 'stand alone' colators
// but also from copy-on-write ones. it needs additional state, which
// setUCollator should set.
if (U_SUCCESS(status)) {
// Alias the collator
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
// m_search_ has been created by the base SearchIterator class
m_search_ = m_strsrch_->search;
}
}
StringSearch::StringSearch(const UnicodeString &pattern,
StringSearch::StringSearch(const UnicodeString &pattern,
const UnicodeString &text,
RuleBasedCollator *coll,
RuleBasedCollator *coll,
BreakIterator *breakiter,
UErrorCode &status) :
SearchIterator(text, breakiter),
SearchIterator(text, breakiter),
m_collator_(),
m_pattern_(pattern)
{
@ -78,45 +78,17 @@ StringSearch::StringSearch(const UnicodeString &pattern,
m_strsrch_ = NULL;
return;
}
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(), coll->ucollator,
(UBreakIterator *)breakiter,
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(), coll->ucollator,
(UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
m_search_ = NULL;
if (U_SUCCESS(status)) {
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
// m_search_ has been created by the base SearchIterator class
m_search_ = m_strsrch_->search;
}
}
StringSearch::StringSearch(const UnicodeString &pattern,
CharacterIterator &text,
const Locale &locale,
BreakIterator *breakiter,
UErrorCode &status) :
SearchIterator(text, breakiter),
m_collator_(),
m_pattern_(pattern)
{
if (U_FAILURE(status)) {
m_strsrch_ = NULL;
return;
}
m_strsrch_ = usearch_open(m_pattern_.getBuffer(), m_pattern_.length(),
m_text_.getBuffer(), m_text_.length(),
locale.getName(), (UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
m_search_ = NULL;
if (U_SUCCESS(status)) {
// Alias the collator
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
// m_search_ has been created by the base SearchIterator class
m_search_ = m_strsrch_->search;
@ -125,10 +97,38 @@ StringSearch::StringSearch(const UnicodeString &pattern,
StringSearch::StringSearch(const UnicodeString &pattern,
CharacterIterator &text,
RuleBasedCollator *coll,
const Locale &locale,
BreakIterator *breakiter,
UErrorCode &status) :
SearchIterator(text, breakiter),
SearchIterator(text, breakiter),
m_collator_(),
m_pattern_(pattern)
{
if (U_FAILURE(status)) {
m_strsrch_ = NULL;
return;
}
m_strsrch_ = usearch_open(m_pattern_.getBuffer(), m_pattern_.length(),
m_text_.getBuffer(), m_text_.length(),
locale.getName(), (UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
m_search_ = NULL;
if (U_SUCCESS(status)) {
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
// m_search_ has been created by the base SearchIterator class
m_search_ = m_strsrch_->search;
}
}
StringSearch::StringSearch(const UnicodeString &pattern,
CharacterIterator &text,
RuleBasedCollator *coll,
BreakIterator *breakiter,
UErrorCode &status) :
SearchIterator(text, breakiter),
m_collator_(),
m_pattern_(pattern)
{
@ -141,17 +141,17 @@ StringSearch::StringSearch(const UnicodeString &pattern,
m_strsrch_ = NULL;
return;
}
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(), coll->ucollator,
(UBreakIterator *)breakiter,
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(), coll->ucollator,
(UBreakIterator *)breakiter,
&status);
uprv_free(m_search_);
m_search_ = NULL;
if (U_SUCCESS(status)) {
// Alias the collator
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
// m_search_ has been created by the base SearchIterator class
m_search_ = m_strsrch_->search;
@ -175,15 +175,15 @@ StringSearch::StringSearch(const StringSearch &that) :
}
else {
// Make a deep copy
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(),
that.m_strsrch_->collator,
(UBreakIterator *)that.m_breakiterator_,
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(),
that.m_strsrch_->collator,
(UBreakIterator *)that.m_breakiterator_,
&status);
if (U_SUCCESS(status)) {
// Alias the collator
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
// m_search_ has been created by the base SearchIterator class
m_search_ = m_strsrch_->search;
@ -214,13 +214,13 @@ StringSearch & StringSearch::operator=(const StringSearch &that)
m_pattern_ = that.m_pattern_;
// all m_search_ in the parent class is linked up with m_strsrch_
usearch_close(m_strsrch_);
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(),
that.m_strsrch_->collator,
m_strsrch_ = usearch_openFromCollator(m_pattern_.getBuffer(),
m_pattern_.length(),
m_text_.getBuffer(),
m_text_.length(),
that.m_strsrch_->collator,
NULL, &status);
// Alias the collator
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
m_search_ = m_strsrch_->search;
}
@ -260,7 +260,7 @@ void StringSearch::setText(const UnicodeString &text, UErrorCode &status)
usearch_setText(m_strsrch_, text.getBuffer(), text.length(), &status);
}
}
void StringSearch::setText(CharacterIterator &text, UErrorCode &status)
{
if (U_SUCCESS(status)) {
@ -273,17 +273,17 @@ RuleBasedCollator * StringSearch::getCollator() const
{
return (RuleBasedCollator *)&m_collator_;
}
void StringSearch::setCollator(RuleBasedCollator *coll, UErrorCode &status)
{
if (U_SUCCESS(status)) {
usearch_setCollator(m_strsrch_, coll->getUCollator(), &status);
// Alias the collator
// Alias the collator
m_collator_.setUCollator((UCollator *)m_strsrch_->collator);
}
}
void StringSearch::setPattern(const UnicodeString &pattern,
void StringSearch::setPattern(const UnicodeString &pattern,
UErrorCode &status)
{
if (U_SUCCESS(status)) {
@ -292,7 +292,7 @@ void StringSearch::setPattern(const UnicodeString &pattern,
&status);
}
}
const UnicodeString & StringSearch::getPattern() const
{
return m_pattern_;
@ -308,8 +308,8 @@ void StringSearch::reset()
SearchIterator * StringSearch::safeClone(void) const
{
UErrorCode status = U_ZERO_ERROR;
StringSearch *result = new StringSearch(m_pattern_, m_text_,
(RuleBasedCollator *)&m_collator_,
StringSearch *result = new StringSearch(m_pattern_, m_text_,
(RuleBasedCollator *)&m_collator_,
m_breakiterator_,
status);
/* test for NULL */
@ -325,7 +325,7 @@ SearchIterator * StringSearch::safeClone(void) const
}
return result;
}
// protected method -------------------------------------------------
int32_t StringSearch::handleNext(int32_t position, UErrorCode &status)
@ -333,27 +333,27 @@ int32_t StringSearch::handleNext(int32_t position, UErrorCode &status)
// values passed here are already in the pre-shift position
if (U_SUCCESS(status)) {
if (m_strsrch_->pattern.CELength == 0) {
m_search_->matchedIndex =
m_search_->matchedIndex == USEARCH_DONE ?
m_search_->matchedIndex =
m_search_->matchedIndex == USEARCH_DONE ?
getOffset() : m_search_->matchedIndex + 1;
m_search_->matchedLength = 0;
ucol_setOffset(m_strsrch_->textIter, m_search_->matchedIndex,
ucol_setOffset(m_strsrch_->textIter, m_search_->matchedIndex,
&status);
if (m_search_->matchedIndex == m_search_->textLength) {
m_search_->matchedIndex = USEARCH_DONE;
}
}
else {
// looking at usearch.cpp, this part is shifted out to
// looking at usearch.cpp, this part is shifted out to
// StringSearch instead of SearchIterator because m_strsrch_ is
// not accessible in SearchIterator
if (position + m_strsrch_->pattern.defaultShiftSize
if (position + m_strsrch_->pattern.defaultShiftSize
> m_search_->textLength) {
setMatchNotFound();
return USEARCH_DONE;
}
if (m_search_->matchedLength <= 0) {
// the flipping direction issue has already been handled
// the flipping direction issue has already been handled
// in next()
// for boundary check purposes. this will ensure that the
// next match will not preceed the current offset
@ -376,19 +376,19 @@ int32_t StringSearch::handleNext(int32_t position, UErrorCode &status)
}
if (m_breakiterator_ == NULL
#if !UCONFIG_NO_BREAK_ITERATION
||
||
m_search_->matchedIndex == USEARCH_DONE ||
(m_breakiterator_->isBoundary(m_search_->matchedIndex) &&
m_breakiterator_->isBoundary(m_search_->matchedIndex +
m_breakiterator_->isBoundary(m_search_->matchedIndex +
m_search_->matchedLength))
#endif
) {
if (m_search_->matchedIndex == USEARCH_DONE) {
ucol_setOffset(m_strsrch_->textIter,
ucol_setOffset(m_strsrch_->textIter,
m_search_->textLength, &status);
}
else {
ucol_setOffset(m_strsrch_->textIter,
ucol_setOffset(m_strsrch_->textIter,
m_search_->matchedIndex, &status);
}
return m_search_->matchedIndex;
@ -404,24 +404,24 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status)
// values passed here are already in the pre-shift position
if (U_SUCCESS(status)) {
if (m_strsrch_->pattern.CELength == 0) {
m_search_->matchedIndex =
(m_search_->matchedIndex == USEARCH_DONE ? getOffset() :
m_search_->matchedIndex =
(m_search_->matchedIndex == USEARCH_DONE ? getOffset() :
m_search_->matchedIndex);
if (m_search_->matchedIndex == 0) {
setMatchNotFound();
}
else {
m_search_->matchedIndex --;
ucol_setOffset(m_strsrch_->textIter, m_search_->matchedIndex,
ucol_setOffset(m_strsrch_->textIter, m_search_->matchedIndex,
&status);
m_search_->matchedLength = 0;
}
}
else {
// looking at usearch.cpp, this part is shifted out to
// looking at usearch.cpp, this part is shifted out to
// StringSearch instead of SearchIterator because m_strsrch_ is
// not accessible in SearchIterator
if (!m_search_->isOverlap &&
if (!m_search_->isOverlap &&
position - m_strsrch_->pattern.defaultShiftSize < 0) {
setMatchNotFound();
return USEARCH_DONE;
@ -439,10 +439,10 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status)
}
if (m_breakiterator_ == NULL
#if !UCONFIG_NO_BREAK_ITERATION
||
||
m_search_->matchedIndex == USEARCH_DONE ||
(m_breakiterator_->isBoundary(m_search_->matchedIndex) &&
m_breakiterator_->isBoundary(m_search_->matchedIndex +
m_breakiterator_->isBoundary(m_search_->matchedIndex +
m_search_->matchedLength))
#endif
) {
@ -450,7 +450,7 @@ int32_t StringSearch::handlePrev(int32_t position, UErrorCode &status)
}
}
}
return m_search_->matchedIndex;
}
return USEARCH_DONE;

View File

@ -1087,7 +1087,7 @@ TimeZone::getDisplayName(UBool daylight, EDisplayType style, UnicodeString& resu
int32_t
TimeZone::getDSTSavings()const {
if (useDaylightTime()) {
return 3600000;
return 3600000;
}
return 0;
}

View File

@ -1245,7 +1245,7 @@ void Transliterator::_registerInstance(Transliterator* adoptedPrototype) {
}
void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID,
const UnicodeString& realID) {
const UnicodeString& realID) {
umtx_init(&registryMutex);
Mutex lock(&registryMutex);
if (HAVE_REGISTRY) {
@ -1254,8 +1254,8 @@ void U_EXPORT2 Transliterator::registerAlias(const UnicodeString& aliasID,
}
void Transliterator::_registerAlias(const UnicodeString& aliasID,
const UnicodeString& realID) {
registry->put(aliasID, realID, FALSE, TRUE);
const UnicodeString& realID) {
registry->put(aliasID, realID, FALSE, TRUE);
}
/**

View File

@ -164,7 +164,7 @@ ucsdet_detectAll(UCharsetDetector *ucsd,
// ucsdet_getDetectableCharsetName(const UCharsetDetector *csd, int32_t index, UErrorCode *status)
// {
// if(U_FAILURE(*status)) {
// return 0;
// return 0;
// }
// return csd->getCharsetName(index,*status);
// }
@ -173,7 +173,7 @@ ucsdet_detectAll(UCharsetDetector *ucsd,
// ucsdet_getDetectableCharsetsCount(const UCharsetDetector *csd, UErrorCode *status)
// {
// if(U_FAILURE(*status)) {
// return -1;
// return -1;
// }
// return UCharsetDetector::getDetectableCount();
// }

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2005, International Business Machines
* Copyright (C) 1999-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -614,93 +614,93 @@ umsg_vparse(const UMessageFormat *fmt,
#define MAppend(c) if (len < destCapacity) dest[len++] = c; else len++
int32_t umsg_autoQuoteApostrophe(const UChar* pattern,
int32_t patternLength,
UChar* dest,
int32_t destCapacity,
UErrorCode* ec)
int32_t patternLength,
UChar* dest,
int32_t destCapacity,
UErrorCode* ec)
{
int32_t state = STATE_INITIAL;
int32_t braceCount = 0;
int32_t len = 0;
int32_t state = STATE_INITIAL;
int32_t braceCount = 0;
int32_t len = 0;
if (ec == NULL || U_FAILURE(*ec)) {
return -1;
}
if (pattern == NULL || patternLength < -1 || (dest == NULL && destCapacity > 0)) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
if (patternLength == -1) {
patternLength = u_strlen(pattern);
}
for (int i = 0; i < patternLength; ++i) {
UChar c = pattern[i];
switch (state) {
case STATE_INITIAL:
switch (c) {
case SINGLE_QUOTE:
state = STATE_SINGLE_QUOTE;
break;
case CURLY_BRACE_LEFT:
state = STATE_MSG_ELEMENT;
++braceCount;
break;
}
break;
case STATE_SINGLE_QUOTE:
switch (c) {
case SINGLE_QUOTE:
state = STATE_INITIAL;
break;
case CURLY_BRACE_LEFT:
case CURLY_BRACE_RIGHT:
state = STATE_IN_QUOTE;
break;
default:
MAppend(SINGLE_QUOTE);
state = STATE_INITIAL;
break;
}
break;
case STATE_IN_QUOTE:
switch (c) {
case SINGLE_QUOTE:
state = STATE_INITIAL;
break;
}
break;
case STATE_MSG_ELEMENT:
switch (c) {
case CURLY_BRACE_LEFT:
++braceCount;
break;
case CURLY_BRACE_RIGHT:
if (--braceCount == 0) {
state = STATE_INITIAL;
}
break;
}
break;
default: // Never happens.
break;
if (ec == NULL || U_FAILURE(*ec)) {
return -1;
}
MAppend(c);
}
if (pattern == NULL || patternLength < -1 || (dest == NULL && destCapacity > 0)) {
*ec = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
// End of scan
if (state == STATE_SINGLE_QUOTE || state == STATE_IN_QUOTE) {
MAppend(SINGLE_QUOTE);
}
if (patternLength == -1) {
patternLength = u_strlen(pattern);
}
return u_terminateUChars(dest, destCapacity, len, ec);
for (int i = 0; i < patternLength; ++i) {
UChar c = pattern[i];
switch (state) {
case STATE_INITIAL:
switch (c) {
case SINGLE_QUOTE:
state = STATE_SINGLE_QUOTE;
break;
case CURLY_BRACE_LEFT:
state = STATE_MSG_ELEMENT;
++braceCount;
break;
}
break;
case STATE_SINGLE_QUOTE:
switch (c) {
case SINGLE_QUOTE:
state = STATE_INITIAL;
break;
case CURLY_BRACE_LEFT:
case CURLY_BRACE_RIGHT:
state = STATE_IN_QUOTE;
break;
default:
MAppend(SINGLE_QUOTE);
state = STATE_INITIAL;
break;
}
break;
case STATE_IN_QUOTE:
switch (c) {
case SINGLE_QUOTE:
state = STATE_INITIAL;
break;
}
break;
case STATE_MSG_ELEMENT:
switch (c) {
case CURLY_BRACE_LEFT:
++braceCount;
break;
case CURLY_BRACE_RIGHT:
if (--braceCount == 0) {
state = STATE_INITIAL;
}
break;
}
break;
default: // Never happens.
break;
}
MAppend(c);
}
// End of scan
if (state == STATE_SINGLE_QUOTE || state == STATE_IN_QUOTE) {
MAppend(SINGLE_QUOTE);
}
return u_terminateUChars(dest, destCapacity, len, ec);
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View File

@ -64,9 +64,9 @@ u_finit(FILE *f,
if (0 <= result->fFileno && result->fFileno <= 2) {
/* stdin, stdout and stderr need to be special cased for Windows 98 */
#if _MSC_VER >= 1400
result->fFile = &__iob_func()[_fileno(f)];
result->fFile = &__iob_func()[_fileno(f)];
#else
result->fFile = &_iob[_fileno(f)];
result->fFile = &_iob[_fileno(f)];
#endif
}
else

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (C) 2002-2003 IBM, Inc. All Rights Reserved.
* Copyright (C) 2002-2006 IBM, Inc. All Rights Reserved.
*
********************************************************************/
/*****************************************************************************
@ -23,9 +23,9 @@
#include "uoptions.h"
UOption options[] = {
UOPTION_DEF("min", 'n', UOPT_REQUIRES_ARG),
UOPTION_DEF("min", 'x', UOPT_REQUIRES_ARG),
};
UOPTION_DEF("min", 'n', UOPT_REQUIRES_ARG),
UOPTION_DEF("min", 'x', UOPT_REQUIRES_ARG),
};
int MIN_OPTION_ = 0;
int MAX_OPTION_ = 1;
@ -33,41 +33,41 @@ int main(int argc, const char *argv[])
{
UErrorCode status = U_ZERO_ERROR;
CharPerformanceTest test(argc, argv, status);
if (U_FAILURE(status)){
if (U_FAILURE(status)){
return status;
}
if (test.run() == FALSE){
fprintf(stderr, "FAILED: Tests could not be run please check the "
"arguments.\n");
"arguments.\n");
return -1;
}
return 0;
}
CharPerformanceTest::CharPerformanceTest(int32_t argc, const char *argv[],
UErrorCode &status)
: UPerfTest(argc, argv, status)
UErrorCode &status)
: UPerfTest(argc, argv, status)
{
if (status== U_ILLEGAL_ARGUMENT_ERROR){
fprintf(stderr,gUsageString, "charperf");
return;
if (status== U_ILLEGAL_ARGUMENT_ERROR){
fprintf(stderr,gUsageString, "charperf");
return;
}
if (U_FAILURE(status)){
fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n",
u_errorName(status));
u_errorName(status));
return;
}
if (_remainingArgc < 0) {
// that means there are some -names not matched in the super class
// first tag is always skipped in u_parseArgs
int size = - _remainingArgc;
argv += argc - size;
argc = size;
_remainingArgc = u_parseArgs(argc, (char**)argv,
(int32_t)(sizeof(options)/sizeof(options[0])), options);
}
MIN_ = 0;
if (_remainingArgc < 0) {
// that means there are some -names not matched in the super class
// first tag is always skipped in u_parseArgs
int size = - _remainingArgc;
argv += argc - size;
argc = size;
_remainingArgc = u_parseArgs(argc, (char**)argv,
(int32_t)(sizeof(options)/sizeof(options[0])), options);
}
MIN_ = 0;
if (sizeof(wchar_t) > 2) {
// for stdlibs like glibc that supports 32 bits wchar
// we test for the whole unicode character set by default
@ -77,12 +77,12 @@ CharPerformanceTest::CharPerformanceTest(int32_t argc, const char *argv[],
MAX_ = 0xffff;
}
printf("MAX_ size will be 0x%x\n", MAX_);
if (options[MIN_OPTION_].doesOccur) {
MIN_ = atoi(options[MIN_OPTION_].value);
}
if (options[MAX_OPTION_].doesOccur) {
MAX_ = atoi(options[MAX_OPTION_].value);
}
if (options[MIN_OPTION_].doesOccur) {
MIN_ = atoi(options[MIN_OPTION_].value);
}
if (options[MAX_OPTION_].doesOccur) {
MAX_ = atoi(options[MAX_OPTION_].value);
}
}
CharPerformanceTest::~CharPerformanceTest()
@ -90,32 +90,32 @@ CharPerformanceTest::~CharPerformanceTest()
}
UPerfFunction* CharPerformanceTest::runIndexedTest(int32_t index, UBool exec,
const char *&name,
char* par)
const char *&name,
char* par)
{
switch (index) {
TESTCASE(0, TestIsAlpha);
TESTCASE(1, TestIsUpper);
TESTCASE(2, TestIsLower);
TESTCASE(3, TestIsDigit);
TESTCASE(4, TestIsSpace);
TESTCASE(5, TestIsAlphaNumeric);
TESTCASE(6, TestIsPrint);
TESTCASE(7, TestIsControl);
TESTCASE(8, TestToLower);
TESTCASE(9, TestToUpper);
TESTCASE(10, TestIsWhiteSpace);
TESTCASE(11, TestStdLibIsAlpha);
TESTCASE(12, TestStdLibIsUpper);
TESTCASE(13, TestStdLibIsLower);
TESTCASE(14, TestStdLibIsDigit);
TESTCASE(15, TestStdLibIsSpace);
TESTCASE(16, TestStdLibIsAlphaNumeric);
TESTCASE(17, TestStdLibIsPrint);
TESTCASE(18, TestStdLibIsControl);
TESTCASE(19, TestStdLibToLower);
TESTCASE(20, TestStdLibToUpper);
TESTCASE(21, TestStdLibIsWhiteSpace);
TESTCASE(1, TestIsUpper);
TESTCASE(2, TestIsLower);
TESTCASE(3, TestIsDigit);
TESTCASE(4, TestIsSpace);
TESTCASE(5, TestIsAlphaNumeric);
TESTCASE(6, TestIsPrint);
TESTCASE(7, TestIsControl);
TESTCASE(8, TestToLower);
TESTCASE(9, TestToUpper);
TESTCASE(10, TestIsWhiteSpace);
TESTCASE(11, TestStdLibIsAlpha);
TESTCASE(12, TestStdLibIsUpper);
TESTCASE(13, TestStdLibIsLower);
TESTCASE(14, TestStdLibIsDigit);
TESTCASE(15, TestStdLibIsSpace);
TESTCASE(16, TestStdLibIsAlphaNumeric);
TESTCASE(17, TestStdLibIsPrint);
TESTCASE(18, TestStdLibIsControl);
TESTCASE(19, TestStdLibToLower);
TESTCASE(20, TestStdLibToUpper);
TESTCASE(21, TestStdLibIsWhiteSpace);
default:
name = "";
return NULL;
@ -125,131 +125,131 @@ UPerfFunction* CharPerformanceTest::runIndexedTest(int32_t index, UBool exec,
UPerfFunction* CharPerformanceTest::TestIsAlpha()
{
return new CharPerfFunction(isAlpha, MIN_, MAX_);
return new CharPerfFunction(isAlpha, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsUpper()
{
return new CharPerfFunction(isUpper, MIN_, MAX_);
return new CharPerfFunction(isUpper, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsLower()
{
return new CharPerfFunction(isLower, MIN_, MAX_);
return new CharPerfFunction(isLower, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsDigit()
{
return new CharPerfFunction(isDigit, MIN_, MAX_);
return new CharPerfFunction(isDigit, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsSpace()
{
return new CharPerfFunction(isSpace, MIN_, MAX_);
return new CharPerfFunction(isSpace, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsAlphaNumeric()
{
return new CharPerfFunction(isAlphaNumeric, MIN_, MAX_);
return new CharPerfFunction(isAlphaNumeric, MIN_, MAX_);
}
/**
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
UPerfFunction* CharPerformanceTest::TestIsPrint()
{
return new CharPerfFunction(isPrint, MIN_, MAX_);
return new CharPerfFunction(isPrint, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsControl()
{
return new CharPerfFunction(isControl, MIN_, MAX_);
return new CharPerfFunction(isControl, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestToLower()
{
return new CharPerfFunction(toLower, MIN_, MAX_);
return new CharPerfFunction(toLower, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestToUpper()
{
return new CharPerfFunction(toUpper, MIN_, MAX_);
return new CharPerfFunction(toUpper, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestIsWhiteSpace()
{
return new CharPerfFunction(isWhiteSpace, MIN_, MAX_);
return new CharPerfFunction(isWhiteSpace, MIN_, MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsAlpha()
{
return new StdLibCharPerfFunction(StdLibIsAlpha, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsAlpha, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsUpper()
{
return new StdLibCharPerfFunction(StdLibIsUpper, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsUpper, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsLower()
{
return new StdLibCharPerfFunction(StdLibIsLower, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsLower, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsDigit()
{
return new StdLibCharPerfFunction(StdLibIsDigit, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsDigit, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsSpace()
{
return new StdLibCharPerfFunction(StdLibIsSpace, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsSpace, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsAlphaNumeric()
{
return new StdLibCharPerfFunction(StdLibIsAlphaNumeric, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsAlphaNumeric, (wchar_t)MIN_,
(wchar_t)MAX_);
}
/**
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
UPerfFunction* CharPerformanceTest::TestStdLibIsPrint()
{
return new StdLibCharPerfFunction(StdLibIsPrint, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsPrint, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsControl()
{
return new StdLibCharPerfFunction(StdLibIsControl, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsControl, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibToLower()
{
return new StdLibCharPerfFunction(StdLibToLower, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibToLower, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibToUpper()
{
return new StdLibCharPerfFunction(StdLibToUpper, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibToUpper, (wchar_t)MIN_,
(wchar_t)MAX_);
}
UPerfFunction* CharPerformanceTest::TestStdLibIsWhiteSpace()
{
return new StdLibCharPerfFunction(StdLibIsWhiteSpace, (wchar_t)MIN_,
(wchar_t)MAX_);
return new StdLibCharPerfFunction(StdLibIsWhiteSpace, (wchar_t)MIN_,
(wchar_t)MAX_);
}

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2002-2005, International Business Machines
* Copyright (c) 2002-2006, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
**********************************************************************
@ -22,98 +22,98 @@ typedef void (*StdLibCharPerfFn)(wchar_t ch);
class CharPerfFunction : public UPerfFunction
{
public:
virtual void call(UErrorCode* status)
{
for (UChar32 i = MIN_; i < MAX_; i ++) {
(*m_fn_)(i);
}
}
virtual void call(UErrorCode* status)
{
for (UChar32 i = MIN_; i < MAX_; i ++) {
(*m_fn_)(i);
}
}
virtual long getOperationsPerIteration()
{
return MAX_ - MIN_;
}
CharPerfFunction(CharPerfFn func, UChar32 min, UChar32 max)
{
m_fn_ = func;
MIN_ = min;
MAX_ = max;
}
virtual long getOperationsPerIteration()
{
return MAX_ - MIN_;
}
CharPerfFunction(CharPerfFn func, UChar32 min, UChar32 max)
{
m_fn_ = func;
MIN_ = min;
MAX_ = max;
}
private:
CharPerfFn m_fn_;
UChar32 MIN_;
UChar32 MAX_;
CharPerfFn m_fn_;
UChar32 MIN_;
UChar32 MAX_;
};
class StdLibCharPerfFunction : public UPerfFunction
{
public:
virtual void call(UErrorCode* status)
{
// note wchar_t is unsigned, it will revert to 0 once it reaches
// 65535
for (wchar_t i = MIN_; i < MAX_; i ++) {
(*m_fn_)(i);
}
}
virtual void call(UErrorCode* status)
{
// note wchar_t is unsigned, it will revert to 0 once it reaches
// 65535
for (wchar_t i = MIN_; i < MAX_; i ++) {
(*m_fn_)(i);
}
}
virtual long getOperationsPerIteration()
{
return MAX_ - MIN_;
}
virtual long getOperationsPerIteration()
{
return MAX_ - MIN_;
}
StdLibCharPerfFunction(StdLibCharPerfFn func, wchar_t min, wchar_t max)
{
m_fn_ = func;
MIN_ = min;
MAX_ = max;
}
StdLibCharPerfFunction(StdLibCharPerfFn func, wchar_t min, wchar_t max)
{
m_fn_ = func;
MIN_ = min;
MAX_ = max;
}
~StdLibCharPerfFunction()
{
}
~StdLibCharPerfFunction()
{
}
private:
StdLibCharPerfFn m_fn_;
wchar_t MIN_;
wchar_t MAX_;
StdLibCharPerfFn m_fn_;
wchar_t MIN_;
wchar_t MAX_;
};
class CharPerformanceTest : public UPerfTest
{
public:
CharPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
~CharPerformanceTest();
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
const char *&name,
char *par = NULL);
UPerfFunction* TestIsAlpha();
UPerfFunction* TestIsUpper();
UPerfFunction* TestIsLower();
UPerfFunction* TestIsDigit();
UPerfFunction* TestIsSpace();
UPerfFunction* TestIsAlphaNumeric();
UPerfFunction* TestIsPrint();
UPerfFunction* TestIsControl();
UPerfFunction* TestToLower();
UPerfFunction* TestToUpper();
UPerfFunction* TestIsWhiteSpace();
UPerfFunction* TestStdLibIsAlpha();
UPerfFunction* TestStdLibIsUpper();
UPerfFunction* TestStdLibIsLower();
UPerfFunction* TestStdLibIsDigit();
UPerfFunction* TestStdLibIsSpace();
UPerfFunction* TestStdLibIsAlphaNumeric();
UPerfFunction* TestStdLibIsPrint();
UPerfFunction* TestStdLibIsControl();
UPerfFunction* TestStdLibToLower();
UPerfFunction* TestStdLibToUpper();
UPerfFunction* TestStdLibIsWhiteSpace();
CharPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
~CharPerformanceTest();
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
const char *&name,
char *par = NULL);
UPerfFunction* TestIsAlpha();
UPerfFunction* TestIsUpper();
UPerfFunction* TestIsLower();
UPerfFunction* TestIsDigit();
UPerfFunction* TestIsSpace();
UPerfFunction* TestIsAlphaNumeric();
UPerfFunction* TestIsPrint();
UPerfFunction* TestIsControl();
UPerfFunction* TestToLower();
UPerfFunction* TestToUpper();
UPerfFunction* TestIsWhiteSpace();
UPerfFunction* TestStdLibIsAlpha();
UPerfFunction* TestStdLibIsUpper();
UPerfFunction* TestStdLibIsLower();
UPerfFunction* TestStdLibIsDigit();
UPerfFunction* TestStdLibIsSpace();
UPerfFunction* TestStdLibIsAlphaNumeric();
UPerfFunction* TestStdLibIsPrint();
UPerfFunction* TestStdLibIsControl();
UPerfFunction* TestStdLibToLower();
UPerfFunction* TestStdLibToUpper();
UPerfFunction* TestStdLibIsWhiteSpace();
private:
UChar32 MIN_;
UChar32 MAX_;
UChar32 MIN_;
UChar32 MAX_;
};
inline void isAlpha(UChar32 ch)
@ -123,117 +123,117 @@ inline void isAlpha(UChar32 ch)
inline void isUpper(UChar32 ch)
{
u_isupper(ch);
u_isupper(ch);
}
inline void isLower(UChar32 ch)
{
u_islower(ch);
u_islower(ch);
}
inline void isDigit(UChar32 ch)
{
u_isdigit(ch);
u_isdigit(ch);
}
inline void isSpace(UChar32 ch)
{
u_isspace(ch);
u_isspace(ch);
}
inline void isAlphaNumeric(UChar32 ch)
{
u_isalnum(ch);
u_isalnum(ch);
}
/**
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
inline void isPrint(UChar32 ch)
{
u_isprint(ch);
u_isprint(ch);
}
inline void isControl(UChar32 ch)
{
u_iscntrl(ch);
u_iscntrl(ch);
}
inline void toLower(UChar32 ch)
{
u_tolower(ch);
u_tolower(ch);
}
inline void toUpper(UChar32 ch)
{
u_toupper(ch);
u_toupper(ch);
}
inline void isWhiteSpace(UChar32 ch)
{
u_isWhitespace(ch);
u_isWhitespace(ch);
}
inline void StdLibIsAlpha(wchar_t ch)
{
iswalpha(ch);
iswalpha(ch);
}
inline void StdLibIsUpper(wchar_t ch)
{
iswupper(ch);
iswupper(ch);
}
inline void StdLibIsLower(wchar_t ch)
{
iswlower(ch);
iswlower(ch);
}
inline void StdLibIsDigit(wchar_t ch)
{
iswdigit(ch);
iswdigit(ch);
}
inline void StdLibIsSpace(wchar_t ch)
{
iswspace(ch);
iswspace(ch);
}
inline void StdLibIsAlphaNumeric(wchar_t ch)
{
iswalnum(ch);
iswalnum(ch);
}
/**
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
* This test may be different since c lib has a type PUNCT and it is printable.
* iswgraph is not used for testing since it is a subset of iswprint with the
* exception of returning true for white spaces. no match found in icu4c.
*/
inline void StdLibIsPrint(wchar_t ch)
{
iswprint(ch);
iswprint(ch);
}
inline void StdLibIsControl(wchar_t ch)
{
iswcntrl(ch);
iswcntrl(ch);
}
inline void StdLibToLower(wchar_t ch)
{
towlower(ch);
towlower(ch);
}
inline void StdLibToUpper(wchar_t ch)
{
towupper(ch);
towupper(ch);
}
inline void StdLibIsWhiteSpace(wchar_t ch)
{
iswspace(ch);
iswspace(ch);
}
#endif // CHARPERF_H

File diff suppressed because it is too large Load Diff

View File

@ -102,7 +102,7 @@ private:
ULine* lines;
int32_t numLines;
UChar dest[DEST_BUFFER_CAPACITY];
UChar* pDest;
UChar* pDest;
int32_t destLen;
NormFn fn;
int32_t retVal;
@ -149,7 +149,7 @@ public:
numLines = srcNumLines;
uselen = _uselen;
destLen = DEST_BUFFER_CAPACITY;
pDest = dest;
pDest = dest;
src = NULL;
srcLen = 0;
line_mode = TRUE;
@ -160,16 +160,16 @@ public:
numLines = 0;
uselen = _uselen;
destLen = sourceLen*3;
pDest = (UChar*) malloc(destLen * U_SIZEOF_UCHAR);
pDest = (UChar*) malloc(destLen * U_SIZEOF_UCHAR);
src = source;
srcLen = sourceLen;
line_mode = FALSE;
}
~NormPerfFunction(){
if(dest != pDest){
free(pDest);
}
}
~NormPerfFunction(){
if(dest != pDest){
free(pDest);
}
}
};

View File

@ -9,7 +9,7 @@
*
* Modification History:
* Name Description
* Doug Wang Second version
* Doug Wang Second version
* Doug Wang First Version
******************************************************************************
*/
@ -28,55 +28,55 @@ int main(int argc, const char *argv[])
{
UErrorCode status = U_ZERO_ERROR;
bCatenatePrealloc=TRUE;
bCatenatePrealloc=TRUE;
StringPerformanceTest test(argc, argv, status);
if (U_FAILURE(status)){
if (U_FAILURE(status)){
return status;
}
int loops = LOOPS;
if (bCatenatePrealloc) {
int to_alloc = loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN);
catICU = new UnicodeString(to_alloc,'a',0);
//catICU = new UnicodeString();
catStd = new stlstring();
catStd -> reserve(loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN));
//catStd -> reserve(110000000);
} else {
catICU = new UnicodeString();
catStd = new stlstring();
}
int loops = LOOPS;
if (bCatenatePrealloc) {
int to_alloc = loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN);
catICU = new UnicodeString(to_alloc,'a',0);
//catICU = new UnicodeString();
catStd = new stlstring();
catStd -> reserve(loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN));
//catStd -> reserve(110000000);
} else {
catICU = new UnicodeString();
catStd = new stlstring();
}
if (test.run() == FALSE){
fprintf(stderr, "FAILED: Tests could not be run please check the "
"arguments.\n");
"arguments.\n");
return -1;
}
delete catICU;
delete catStd;
delete catICU;
delete catStd;
return 0;
}
StringPerformanceTest::StringPerformanceTest(int32_t argc, const char *argv[],
UErrorCode &status)
: UPerfTest(argc, argv, status)
UErrorCode &status)
: UPerfTest(argc, argv, status)
{
filelines_=NULL;
StrBuffer=NULL;
StrBufferLen=0;
filelines_=NULL;
StrBuffer=NULL;
StrBufferLen=0;
int32_t len =0;
int32_t len =0;
if (status== U_ILLEGAL_ARGUMENT_ERROR){
//fprintf(stderr,gUsageString, "stringperf");
return;
if (status== U_ILLEGAL_ARGUMENT_ERROR){
//fprintf(stderr,gUsageString, "stringperf");
return;
}
if (U_FAILURE(status)){
fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n",
u_errorName(status));
u_errorName(status));
return;
}
@ -87,15 +87,15 @@ StringPerformanceTest::StringPerformanceTest(int32_t argc, const char *argv[],
fprintf(stderr, "FAILED to read lines from file and create UPerfTest object. Error: %s\n", u_errorName(status));
return;
}
filelines_ = new ULine[numLines];
for (int i =0; i < numLines; i++) {
len = filelines[i].len;
filelines_[i].name = new UChar[len];
filelines_ = new ULine[numLines];
for (int i =0; i < numLines; i++) {
len = filelines[i].len;
filelines_[i].name = new UChar[len];
filelines_[i].len = len;
memcpy(filelines_[i].name, filelines[i].name, len * U_SIZEOF_UCHAR);
}
memcpy(filelines_[i].name, filelines[i].name, len * U_SIZEOF_UCHAR);
}
}else if(bulk_mode){
int32_t srcLen = 0;
const UChar* src = getBuffer(srcLen,status);
@ -103,50 +103,50 @@ StringPerformanceTest::StringPerformanceTest(int32_t argc, const char *argv[],
fprintf(stderr, "FAILED to read buffer from file and create UPerfTest object. Error: %s\n", u_errorName(status));
return;
}
StrBuffer = new UChar[srcLen];
StrBufferLen = srcLen;
memcpy(StrBuffer, src, srcLen * U_SIZEOF_UCHAR);
StrBuffer = new UChar[srcLen];
StrBufferLen = srcLen;
memcpy(StrBuffer, src, srcLen * U_SIZEOF_UCHAR);
}
}
StringPerformanceTest::~StringPerformanceTest()
{
delete[] filelines_;
delete[] StrBuffer;
delete[] filelines_;
delete[] StrBuffer;
}
UPerfFunction* StringPerformanceTest::runIndexedTest(int32_t index, UBool exec,
const char *&name,
char* par)
const char *&name,
char* par)
{
switch (index) {
TESTCASE(0, TestCtor);
TESTCASE(1, TestCtor1);
TESTCASE(2, TestCtor2);
TESTCASE(3, TestCtor3);
TESTCASE(4, TestAssign);
TESTCASE(5, TestAssign1);
TESTCASE(6, TestAssign2);
TESTCASE(7, TestGetch);
TESTCASE(8, TestCatenate);
TESTCASE(9, TestScan);
TESTCASE(10, TestScan1);
TESTCASE(11, TestScan2);
TESTCASE(1, TestCtor1);
TESTCASE(2, TestCtor2);
TESTCASE(3, TestCtor3);
TESTCASE(4, TestAssign);
TESTCASE(5, TestAssign1);
TESTCASE(6, TestAssign2);
TESTCASE(7, TestGetch);
TESTCASE(8, TestCatenate);
TESTCASE(9, TestScan);
TESTCASE(10, TestScan1);
TESTCASE(11, TestScan2);
TESTCASE(12, TestStdLibCtor);
TESTCASE(13, TestStdLibCtor1);
TESTCASE(14, TestStdLibCtor2);
TESTCASE(15, TestStdLibCtor3);
TESTCASE(16, TestStdLibAssign);
TESTCASE(17, TestStdLibAssign1);
TESTCASE(18, TestStdLibAssign2);
TESTCASE(19, TestStdLibGetch);
TESTCASE(20, TestStdLibCatenate);
TESTCASE(21, TestStdLibScan);
TESTCASE(22, TestStdLibScan1);
TESTCASE(23, TestStdLibScan2);
TESTCASE(12, TestStdLibCtor);
TESTCASE(13, TestStdLibCtor1);
TESTCASE(14, TestStdLibCtor2);
TESTCASE(15, TestStdLibCtor3);
TESTCASE(16, TestStdLibAssign);
TESTCASE(17, TestStdLibAssign1);
TESTCASE(18, TestStdLibAssign2);
TESTCASE(19, TestStdLibGetch);
TESTCASE(20, TestStdLibCatenate);
TESTCASE(21, TestStdLibScan);
TESTCASE(22, TestStdLibScan1);
TESTCASE(23, TestStdLibScan2);
default:
name = "";
@ -157,221 +157,221 @@ UPerfFunction* StringPerformanceTest::runIndexedTest(int32_t index, UBool exec,
UPerfFunction* StringPerformanceTest::TestCtor()
{
if (line_mode) {
return new StringPerfFunction(ctor, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(ctor, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestCtor1()
{
if (line_mode) {
return new StringPerfFunction(ctor1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor1, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(ctor1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor1, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestCtor2()
{
if (line_mode) {
return new StringPerfFunction(ctor2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor2, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(ctor2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor2, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestCtor3()
{
if (line_mode) {
return new StringPerfFunction(ctor3, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor3, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(ctor3, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(ctor3, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestAssign()
{
if (line_mode) {
return new StringPerfFunction(assign, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(assign, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(assign, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(assign, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestAssign1()
{
if (line_mode) {
return new StringPerfFunction(assign1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(assign1, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(assign1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(assign1, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestAssign2()
{
if (line_mode) {
return new StringPerfFunction(assign2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(assign2, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(assign2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(assign2, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestGetch()
{
if (line_mode) {
return new StringPerfFunction(getch, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(getch, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(getch, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(getch, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestCatenate()
{
if (line_mode) {
return new StringPerfFunction(catenate, filelines_, numLines, uselen);
} else {
//return new StringPerfFunction(catenate, buffer, bufferLen, uselen);
return new StringPerfFunction(catenate, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(catenate, filelines_, numLines, uselen);
} else {
//return new StringPerfFunction(catenate, buffer, bufferLen, uselen);
return new StringPerfFunction(catenate, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestScan()
{
if (line_mode) {
return new StringPerfFunction(scan, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(scan, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(scan, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(scan, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestScan1()
{
if (line_mode) {
return new StringPerfFunction(scan1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(scan1, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(scan1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(scan1, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestScan2()
{
if (line_mode) {
return new StringPerfFunction(scan2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(scan2, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(scan2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(scan2, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibCtor()
{
if (line_mode) {
return new StringPerfFunction(StdLibCtor, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibCtor, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibCtor1()
{
if (line_mode) {
return new StringPerfFunction(StdLibCtor1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor1, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibCtor1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor1, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibCtor2()
{
if (line_mode) {
return new StringPerfFunction(StdLibCtor2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor2, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibCtor2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor2, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibCtor3()
{
if (line_mode) {
return new StringPerfFunction(StdLibCtor3, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor3, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibCtor3, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibCtor3, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibAssign()
{
if (line_mode) {
return new StringPerfFunction(StdLibAssign, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibAssign, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibAssign, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibAssign, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibAssign1()
{
if (line_mode) {
return new StringPerfFunction(StdLibAssign1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibAssign1, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibAssign1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibAssign1, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibAssign2()
{
if (line_mode) {
return new StringPerfFunction(StdLibAssign2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibAssign2, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibAssign2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibAssign2, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibGetch()
{
if (line_mode) {
return new StringPerfFunction(StdLibGetch, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibGetch, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibGetch, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibGetch, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibCatenate()
{
if (line_mode) {
return new StringPerfFunction(StdLibCatenate, filelines_, numLines, uselen);
} else {
//return new StringPerfFunction(StdLibCatenate, buffer, bufferLen, uselen);
return new StringPerfFunction(StdLibCatenate, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibCatenate, filelines_, numLines, uselen);
} else {
//return new StringPerfFunction(StdLibCatenate, buffer, bufferLen, uselen);
return new StringPerfFunction(StdLibCatenate, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibScan()
{
if (line_mode) {
return new StringPerfFunction(StdLibScan, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibScan, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibScan, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibScan, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibScan1()
{
if (line_mode) {
return new StringPerfFunction(StdLibScan1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibScan1, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibScan1, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibScan1, StrBuffer, StrBufferLen, uselen);
}
}
UPerfFunction* StringPerformanceTest::TestStdLibScan2()
{
if (line_mode) {
return new StringPerfFunction(StdLibScan2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibScan2, StrBuffer, StrBufferLen, uselen);
}
if (line_mode) {
return new StringPerfFunction(StdLibScan2, filelines_, numLines, uselen);
} else {
return new StringPerfFunction(StdLibScan2, StrBuffer, StrBufferLen, uselen);
}
}

View File

@ -19,7 +19,7 @@ typedef std::wstring stlstring;
/* Define all constants for test case operations */
#define MAXNUMLINES 40000 //Max number of lines in a test data file
#define MAXSRCLEN 20 //Max length of one line. maybe a larger number, but it need more mem
#define LOOPS 100 //Iterations
#define LOOPS 100 //Iterations
//#define LOOPS 10
#define catenate_STRLEN 2
@ -61,385 +61,385 @@ class StringPerfFunction : public UPerfFunction
{
public:
virtual long getEventsPerIteration(){
int loops = LOOPS;
if (catICU) { delete catICU;}
if (catStd) { delete catStd;}
virtual long getEventsPerIteration(){
int loops = LOOPS;
if (catICU) { delete catICU;}
if (catStd) { delete catStd;}
if (bCatenatePrealloc) {
int to_alloc = loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN);
catICU = new UnicodeString(to_alloc,'a',0);
//catICU = new UnicodeString();
if (bCatenatePrealloc) {
catStd = new stlstring();
//catStd -> reserve(loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN));
catStd -> reserve(110000000);
} else {
catICU = new UnicodeString();
catStd = new stlstring();
}
int to_alloc = loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN);
catICU = new UnicodeString(to_alloc,'a',0);
//catICU = new UnicodeString();
return -1;
catStd = new stlstring();
//catStd -> reserve(loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN));
catStd -> reserve(110000000);
} else {
catICU = new UnicodeString();
catStd = new stlstring();
}
return -1;
}
virtual void call(UErrorCode* status)
{
virtual void call(UErrorCode* status)
{
if(line_mode_==TRUE){
if(uselen_){
for(int32_t i = 0; i< numLines_; i++){
if (fnType_==Fn_ICU) {
(*fn1_)(lines_[i].name,lines_[i].len,uS0_[i]);
} else {
(*fn2_)(wlines_[i].name,wlines_[i].len,sS0_[i]);
}
if (fnType_==Fn_ICU) {
(*fn1_)(lines_[i].name,lines_[i].len,uS0_[i]);
} else {
(*fn2_)(wlines_[i].name,wlines_[i].len,sS0_[i]);
}
}
}else{
for(int32_t i = 0; i< numLines_; i++){
if (fnType_==Fn_ICU) {
(*fn1_)(lines_[i].name,-1,uS0_[i]);
} else {
(*fn2_)(wlines_[i].name,-1,sS0_[i]);
}
(*fn1_)(lines_[i].name,-1,uS0_[i]);
} else {
(*fn2_)(wlines_[i].name,-1,sS0_[i]);
}
}
}
}else{
if(uselen_){
if (fnType_==Fn_ICU) {
(*fn1_)(src_,srcLen_,*ubulk_);
} else {
(*fn2_)(wsrc_,wsrcLen_,*sbulk_);
}
if (fnType_==Fn_ICU) {
(*fn1_)(src_,srcLen_,*ubulk_);
} else {
(*fn2_)(wsrc_,wsrcLen_,*sbulk_);
}
}else{
if (fnType_==Fn_ICU) {
(*fn1_)(src_,-1,*ubulk_);
} else {
(*fn2_)(wsrc_,-1,*sbulk_);
}
if (fnType_==Fn_ICU) {
(*fn1_)(src_,-1,*ubulk_);
} else {
(*fn2_)(wsrc_,-1,*sbulk_);
}
}
}
}
}
virtual long getOperationsPerIteration()
{
virtual long getOperationsPerIteration()
{
if(line_mode_==TRUE){
return numLines_;
}else{
return 1;
}
}
}
StringPerfFunction(ICUStringPerfFn func, ULine* srcLines, int32_t srcNumLines, UBool uselen)
{
fn1_ = func;
lines_=srcLines;
wlines_=NULL;
numLines_=srcNumLines;
uselen_=uselen;
line_mode_=TRUE;
StringPerfFunction(ICUStringPerfFn func, ULine* srcLines, int32_t srcNumLines, UBool uselen)
{
fn1_ = func;
lines_=srcLines;
wlines_=NULL;
numLines_=srcNumLines;
uselen_=uselen;
line_mode_=TRUE;
src_ = NULL;
srcLen_ = 0;
wsrc_ = NULL;
wsrcLen_ = 0;
fnType_ = Fn_ICU;
uS0_=new UnicodeString[numLines_];
for(int32_t i=0; i<numLines_; i++) {
uS0_[i]=UnicodeString(lines_[i].name, lines_[i].len);
}
sS0_=NULL;
ubulk_=NULL;
sbulk_=NULL;
}
wsrc_ = NULL;
wsrcLen_ = 0;
fnType_ = Fn_ICU;
StringPerfFunction(StdStringPerfFn func, ULine* srcLines, int32_t srcNumLines, UBool uselen)
{
fn2_ = func;
lines_=srcLines;
wlines_=NULL;
numLines_=srcNumLines;
uselen_=uselen;
line_mode_=TRUE;
uS0_=new UnicodeString[numLines_];
for(int32_t i=0; i<numLines_; i++) {
uS0_[i]=UnicodeString(lines_[i].name, lines_[i].len);
}
sS0_=NULL;
ubulk_=NULL;
sbulk_=NULL;
}
StringPerfFunction(StdStringPerfFn func, ULine* srcLines, int32_t srcNumLines, UBool uselen)
{
fn2_ = func;
lines_=srcLines;
wlines_=NULL;
numLines_=srcNumLines;
uselen_=uselen;
line_mode_=TRUE;
src_ = NULL;
srcLen_ = 0;
wsrc_ = NULL;
wsrcLen_ = 0;
fnType_ = Fn_STD;
wsrc_ = NULL;
wsrcLen_ = 0;
fnType_ = Fn_STD;
uS0_=NULL;
ubulk_=NULL;
sbulk_=NULL;
//fillin wlines_[], sS0_[]
prepareLinesForStd();
}
uS0_=NULL;
ubulk_=NULL;
sbulk_=NULL;
StringPerfFunction(ICUStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
{
fn1_ = func;
lines_=NULL;
wlines_=NULL;
numLines_=0;
uselen_=uselen;
line_mode_=FALSE;
src_ = new UChar[sourceLen];
memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
//fillin wlines_[], sS0_[]
prepareLinesForStd();
}
StringPerfFunction(ICUStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
{
fn1_ = func;
lines_=NULL;
wlines_=NULL;
numLines_=0;
uselen_=uselen;
line_mode_=FALSE;
src_ = new UChar[sourceLen];
memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
srcLen_ = sourceLen;
wsrc_ = NULL;
wsrcLen_ = 0;
fnType_ = Fn_ICU;
wsrc_ = NULL;
wsrcLen_ = 0;
fnType_ = Fn_ICU;
uS0_=NULL;
sS0_=NULL;
ubulk_=new UnicodeString(src_,srcLen_);
sbulk_=NULL;
}
uS0_=NULL;
sS0_=NULL;
ubulk_=new UnicodeString(src_,srcLen_);
sbulk_=NULL;
}
StringPerfFunction(StdStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
{
fn2_ = func;
lines_=NULL;
wlines_=NULL;
numLines_=0;
uselen_=uselen;
line_mode_=FALSE;
src_ = new UChar[sourceLen];
memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
StringPerfFunction(StdStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
{
fn2_ = func;
lines_=NULL;
wlines_=NULL;
numLines_=0;
uselen_=uselen;
line_mode_=FALSE;
src_ = new UChar[sourceLen];
memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
srcLen_ = sourceLen;
fnType_ = Fn_STD;
fnType_ = Fn_STD;
uS0_=NULL;
sS0_=NULL;
ubulk_=NULL;
uS0_=NULL;
sS0_=NULL;
ubulk_=NULL;
//fillin wsrc_, sbulk_
prepareBulkForStd();
}
//fillin wsrc_, sbulk_
prepareBulkForStd();
~StringPerfFunction()
{
//free(src_);
free(wsrc_);
delete[] src_;
delete ubulk_;
delete sbulk_;
delete[] uS0_;
delete[] sS0_;
delete[] wlines_;
}
}
~StringPerfFunction()
{
//free(src_);
free(wsrc_);
delete[] src_;
delete ubulk_;
delete sbulk_;
delete[] uS0_;
delete[] sS0_;
delete[] wlines_;
}
private:
void prepareLinesForStd(void)
{
UErrorCode err=U_ZERO_ERROR;
wlines_=new WLine[numLines_];
void prepareLinesForStd(void)
{
UErrorCode err=U_ZERO_ERROR;
wlines_=new WLine[numLines_];
wchar_t ws[100];
int32_t wcap = sizeof(ws) / sizeof(*ws);
int32_t wl;
wchar_t* wcs;
sS0_=new stlstring[numLines_];
for(int32_t i=0; i<numLines_; i++) {
if(uselen_) {
wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len, &err);
memcpy(wlines_[i].name, wcs, wl * sizeof(wchar_t));
wlines_[i].len = wl;
sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len);
} else {
wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len-1, &err);
memcpy(wlines_[i].name, wcs, wl*sizeof(wchar_t));
wlines_[i].len = wl;
sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len+1);
}
wchar_t* wcs;
if (U_FAILURE(err)) {
return;
}
}
sS0_=new stlstring[numLines_];
for(int32_t i=0; i<numLines_; i++) {
if(uselen_) {
wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len, &err);
memcpy(wlines_[i].name, wcs, wl * sizeof(wchar_t));
wlines_[i].len = wl;
sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len);
} else {
wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len-1, &err);
memcpy(wlines_[i].name, wcs, wl*sizeof(wchar_t));
wlines_[i].len = wl;
sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len+1);
}
}
if (U_FAILURE(err)) {
return;
}
}
void prepareBulkForStd(void)
{
UErrorCode err=U_ZERO_ERROR;
}
const UChar* uSrc = src_;
int32_t uSrcLen = srcLen_;
wchar_t* wDest = NULL;
int32_t wDestLen = 0;
int32_t reqLen= 0 ;
void prepareBulkForStd(void)
{
UErrorCode err=U_ZERO_ERROR;
if(uselen_) {
/* pre-flight*/
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
const UChar* uSrc = src_;
int32_t uSrcLen = srcLen_;
wchar_t* wDest = NULL;
int32_t wDestLen = 0;
int32_t reqLen= 0 ;
if(err == U_BUFFER_OVERFLOW_ERROR){
err=U_ZERO_ERROR;
wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen));
wDestLen = reqLen;
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
}
if(uselen_) {
/* pre-flight*/
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
if (U_SUCCESS(err)) {
wsrc_ = wDest;
wsrcLen_ = wDestLen;
sbulk_=new stlstring(wsrc_,wsrcLen_);
}
if(err == U_BUFFER_OVERFLOW_ERROR){
err=U_ZERO_ERROR;
wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen));
wDestLen = reqLen;
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
}
} else {
/* pre-flight*/
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
if (U_SUCCESS(err)) {
wsrc_ = wDest;
wsrcLen_ = wDestLen;
sbulk_=new stlstring(wsrc_,wsrcLen_);
}
if(err == U_BUFFER_OVERFLOW_ERROR){
err=U_ZERO_ERROR;
wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen+1));
wDestLen = reqLen+1;
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
}
} else {
/* pre-flight*/
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
if (U_SUCCESS(err)) {
wsrc_ = wDest;
wsrcLen_ = wDestLen;
sbulk_=new stlstring(wsrc_);
}
}
if(err == U_BUFFER_OVERFLOW_ERROR){
err=U_ZERO_ERROR;
wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen+1));
wDestLen = reqLen+1;
u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
}
//free(wDest);
}
if (U_SUCCESS(err)) {
wsrc_ = wDest;
wsrcLen_ = wDestLen;
sbulk_=new stlstring(wsrc_);
}
}
//free(wDest);
}
private:
ICUStringPerfFn fn1_;
StdStringPerfFn fn2_;
ICUStringPerfFn fn1_;
StdStringPerfFn fn2_;
ULine* lines_;
WLine* wlines_;
int32_t numLines_;
ULine* lines_;
WLine* wlines_;
int32_t numLines_;
UBool uselen_;
UChar* src_;
int32_t srcLen_;
wchar_t* wsrc_;
int32_t wsrcLen_;
UBool uselen_;
UChar* src_;
int32_t srcLen_;
wchar_t* wsrc_;
int32_t wsrcLen_;
UBool line_mode_;
//added for preparing testing data
UnicodeString* uS0_;
stlstring* sS0_;
UnicodeString* ubulk_;
stlstring* sbulk_;
FnType fnType_;
};
//added for preparing testing data
UnicodeString* uS0_;
stlstring* sS0_;
UnicodeString* ubulk_;
stlstring* sbulk_;
FnType fnType_;
};
class StringPerformanceTest : public UPerfTest
{
public:
StringPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
~StringPerformanceTest();
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
const char *&name,
char *par = NULL);
UPerfFunction* TestCtor();
UPerfFunction* TestCtor1();
UPerfFunction* TestCtor2();
UPerfFunction* TestCtor3();
UPerfFunction* TestAssign();
UPerfFunction* TestAssign1();
UPerfFunction* TestAssign2();
UPerfFunction* TestGetch();
UPerfFunction* TestCatenate();
UPerfFunction* TestScan();
UPerfFunction* TestScan1();
UPerfFunction* TestScan2();
StringPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
~StringPerformanceTest();
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
const char *&name,
char *par = NULL);
UPerfFunction* TestCtor();
UPerfFunction* TestCtor1();
UPerfFunction* TestCtor2();
UPerfFunction* TestCtor3();
UPerfFunction* TestAssign();
UPerfFunction* TestAssign1();
UPerfFunction* TestAssign2();
UPerfFunction* TestGetch();
UPerfFunction* TestCatenate();
UPerfFunction* TestScan();
UPerfFunction* TestScan1();
UPerfFunction* TestScan2();
UPerfFunction* TestStdLibCtor();
UPerfFunction* TestStdLibCtor1();
UPerfFunction* TestStdLibCtor2();
UPerfFunction* TestStdLibCtor3();
UPerfFunction* TestStdLibAssign();
UPerfFunction* TestStdLibAssign1();
UPerfFunction* TestStdLibAssign2();
UPerfFunction* TestStdLibGetch();
UPerfFunction* TestStdLibCatenate();
UPerfFunction* TestStdLibScan();
UPerfFunction* TestStdLibScan1();
UPerfFunction* TestStdLibScan2();
UPerfFunction* TestStdLibCtor();
UPerfFunction* TestStdLibCtor1();
UPerfFunction* TestStdLibCtor2();
UPerfFunction* TestStdLibCtor3();
UPerfFunction* TestStdLibAssign();
UPerfFunction* TestStdLibAssign1();
UPerfFunction* TestStdLibAssign2();
UPerfFunction* TestStdLibGetch();
UPerfFunction* TestStdLibCatenate();
UPerfFunction* TestStdLibScan();
UPerfFunction* TestStdLibScan1();
UPerfFunction* TestStdLibScan2();
private:
long COUNT_;
ULine* filelines_;
UChar* StrBuffer;
int32_t StrBufferLen;
long COUNT_;
ULine* filelines_;
UChar* StrBuffer;
int32_t StrBufferLen;
};
inline void ctor(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void ctor(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString a;
UnicodeString a;
}
inline void ctor1(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void ctor1(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString b(uTESTCHAR1);
UnicodeString b(uTESTCHAR1);
}
inline void ctor2(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void ctor2(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString c(uEMPTY);
UnicodeString c(uEMPTY);
}
inline void ctor3(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void ctor3(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UnicodeString d(src,srcLen);
UnicodeString d(src,srcLen);
}
inline UnicodeString icu_assign_helper(const UChar* src,int32_t srcLen)
{
if (srcLen==-1) { return src;}
else { return UnicodeString(src, srcLen);}
if (srcLen==-1) { return src;}
else { return UnicodeString(src, srcLen);}
}
inline void assign(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void assign(const UChar* src,int32_t srcLen, UnicodeString s0)
{
unistr = icu_assign_helper(src,srcLen);
unistr = icu_assign_helper(src,srcLen);
}
inline void assign1(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void assign1(const UChar* src,int32_t srcLen, UnicodeString s0)
{
unistr.setTo(src, srcLen);
unistr.setTo(src, srcLen);
}
inline void assign2(const UChar* src,int32_t srcLen, UnicodeString s0)
inline void assign2(const UChar* src,int32_t srcLen, UnicodeString s0)
{
unistr = s0;
unistr = s0;
}
inline void getch(const UChar* src,int32_t srcLen, UnicodeString s0)
{
s0.charAt(0);
s0.charAt(0);
}
inline void catenate(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UTimer mystart, mystop;
utimer_getTime(&mystart);
*catICU += s0;
utimer_getTime(&mystop);
double mytime = utimer_getDeltaSeconds(&mystart,&mystop);
printf("\nmytime=%f \n", mytime);
UTimer mystart, mystop;
utimer_getTime(&mystart);
*catICU += uCatenate_STR;
*catICU += s0;
utimer_getTime(&mystop);
double mytime = utimer_getDeltaSeconds(&mystart,&mystop);
printf("\nmytime=%f \n", mytime);
*catICU += uCatenate_STR;
}
volatile int scan_idx;
@ -447,103 +447,102 @@ U_STRING_DECL(SCAN1, "123", 3);
inline void scan(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UChar c='.';
scan_idx = uScan_STRING.indexOf(c);
UChar c='.';
scan_idx = uScan_STRING.indexOf(c);
}
inline void scan1(const UChar* src,int32_t srcLen, UnicodeString s0)
{
scan_idx = uScan_STRING.indexOf(SCAN1,3);
scan_idx = uScan_STRING.indexOf(SCAN1,3);
}
inline void scan2(const UChar* src,int32_t srcLen, UnicodeString s0)
{
UChar c1='s';
UChar c2='m';
scan_idx = uScan_STRING.indexOf(c1);
scan_idx = uScan_STRING.indexOf(c2);
UChar c1='s';
UChar c2='m';
scan_idx = uScan_STRING.indexOf(c1);
scan_idx = uScan_STRING.indexOf(c2);
}
inline void StdLibCtor(const wchar_t* src,int32_t srcLen, stlstring s0)
{
stlstring a;
stlstring a;
}
inline void StdLibCtor1(const wchar_t* src,int32_t srcLen, stlstring s0)
{
stlstring b(simulate);
stlstring b(simulate);
}
inline void StdLibCtor2(const wchar_t* src,int32_t srcLen, stlstring s0)
{
stlstring c(sEMPTY);
stlstring c(sEMPTY);
}
inline void StdLibCtor3(const wchar_t* src,int32_t srcLen, stlstring s0)
{
if (srcLen==-1) {
stlstring d(src);
}else {
stlstring d(src, srcLen);
}
if (srcLen==-1) {
stlstring d(src);
}else {
stlstring d(src, srcLen);
}
}
inline stlstring stl_assign_helper(const wchar_t* src,int32_t srcLen)
{
if (srcLen==-1) { return src;}
else { return stlstring(src, srcLen);}
if (srcLen==-1) { return src;}
else { return stlstring(src, srcLen);}
}
inline void StdLibAssign(const wchar_t* src,int32_t srcLen, stlstring s0)
inline void StdLibAssign(const wchar_t* src,int32_t srcLen, stlstring s0)
{
stlstr = stl_assign_helper(src,srcLen);
stlstr = stl_assign_helper(src,srcLen);
}
inline void StdLibAssign1(const wchar_t* src,int32_t srcLen, stlstring s0)
inline void StdLibAssign1(const wchar_t* src,int32_t srcLen, stlstring s0)
{
if (srcLen==-1) { stlstr=src;}
else { stlstr.assign(src, srcLen);}
if (srcLen==-1) { stlstr=src;}
else { stlstr.assign(src, srcLen);}
}
inline void StdLibAssign2(const wchar_t* src,int32_t srcLen, stlstring s0)
inline void StdLibAssign2(const wchar_t* src,int32_t srcLen, stlstring s0)
{
stlstr=s0;
stlstr=s0;
}
inline void StdLibGetch(const wchar_t* src,int32_t srcLen, stlstring s0)
{
s0.at(0);
s0.at(0);
}
inline void StdLibCatenate(const wchar_t* src,int32_t srcLen, stlstring s0)
{
UTimer mystart, mystop;
utimer_getTime(&mystart);
UTimer mystart, mystop;
utimer_getTime(&mystart);
*catStd += s0;
*catStd += sCatenate_STR;
*catStd += sCatenate_STR;
utimer_getTime(&mystop);
utimer_getTime(&mystop);
double mytime = utimer_getDeltaSeconds(&mystart,&mystop);
printf("\nmytime=%f \n", mytime);
printf("\nmytime=%f \n", mytime);
}
inline void StdLibScan(const wchar_t* src,int32_t srcLen, stlstring s0)
{
scan_idx = (int) sScan_STRING.find('.');
scan_idx = (int) sScan_STRING.find('.');
}
inline void StdLibScan1(const wchar_t* src,int32_t srcLen, stlstring s0)
{
scan_idx = (int) sScan_STRING.find(L"123");
scan_idx = (int) sScan_STRING.find(L"123");
}
inline void StdLibScan2(const wchar_t* src,int32_t srcLen, stlstring s0)
{
scan_idx = (int) sScan_STRING.find_first_of(L"sm");
scan_idx = (int) sScan_STRING.find_first_of(L"sm");
}
#endif // STRINGPERF_H