-/********************************************************************
+/***********************************************************************
+ * © 2016 and later: Unicode, Inc. and others.
+ * License & terms of use: http://www.unicode.org/copyright.html#License
+ ***********************************************************************
+ ***********************************************************************
* COPYRIGHT:
- * Copyright (C) 2001-2010 IBM, Inc. All Rights Reserved.
+ * Copyright (C) 2001-2012 IBM, Inc. All Rights Reserved.
*
- ********************************************************************/
+ ***********************************************************************/
/********************************************************************************
*
* File CALLCOLL.C
int line;
int loops = 0;
int iLoop;
- int t;
int len=-1;
// Adjust loop count to compensate for file size. Should be order n
len = gFileLines[line].len;
}
for (iLoop=0; iLoop < opt_iLoopCount; iLoop++) {
- t=LCMapStringW(gWinLCID, LCMAP_SORTKEY,
+ LCMapStringW(gWinLCID, LCMAP_SORTKEY,
gFileLines[line].name, len,
- (unsigned short *)gFileLines[line].winSortKey, 5000); // TODO something with length.
+ (UChar *)gFileLines[line].winSortKey, 5000); // TODO something with length.
}
}
}
len = gFileLines[line].len;
}
for (iLoop=0; iLoop < opt_iLoopCount; iLoop++) {
- t = ucol_getSortKey(gCol, gFileLines[line].name, len, (unsigned char *)gFileLines[line].icuSortKey, 5000);
+ ucol_getSortKey(gCol, gFileLines[line].name, len, (unsigned char *)gFileLines[line].icuSortKey, 5000);
}
}
}
for (loops=0; loops<adj_loopCount; loops++) {
for (line=0; line < gNumFileLines; line++) {
for (iLoop=0; iLoop < opt_iLoopCount; iLoop++) {
- t = strxfrm(gFileLines[line].unixSortKey, gFileLines[line].unixName, 5000);
+ strxfrm(gFileLines[line].unixSortKey, gFileLines[line].unixName, 5000);
}
}
}
// Accurate timings do not depend on this being perfect. The correction is just to try to
// get total running times of about the right order, so the that user doesn't need to
// manually adjust the loop count for every different file size.
- double dLoopCount = double(opt_loopCount) * 3000. / (log10(gNumFileLines) * double(gNumFileLines));
+ double dLoopCount = double(opt_loopCount) * 3000. / (log10((double)gNumFileLines) * double(gNumFileLines));
if (opt_usekeys) dLoopCount *= 5;
int adj_loopCount = int(dLoopCount);
if (adj_loopCount < 1) adj_loopCount = 1;
Line **sortBuf = new Line *[gNumFileLines];
// Adjust loop count to compensate for file size. QSort should be n log(n)
- double dLoopCount = double(opt_loopCount) * 3000. / (log10(gNumFileLines) * double(gNumFileLines));
+ double dLoopCount = double(opt_loopCount) * 3000. / (log10((double)gNumFileLines) * double(gNumFileLines));
if (opt_usekeys) dLoopCount *= 5;
int adj_loopCount = int(dLoopCount);
if (adj_loopCount < 1) adj_loopCount = 1;
// Convert the bytes from the temp array to a Unicode char.
i = 0;
uint32_t cp;
- UTF8_NEXT_CHAR_UNSAFE(bytes, i, cp);
+ U8_NEXT_UNSAFE(bytes, i, cp);
c = (UChar)cp;
if (cp >= 0x10000) {
int bufLen = 10000;
UChar *buf = (UChar *)malloc(bufLen * sizeof(UChar));
+ UChar *tmp;
int i = 0;
for(;;) {
}
i++;
if (i >= bufLen) {
+ tmp = buf;
bufLen += 10000;
buf = (UChar *)realloc(buf, bufLen);
+ if (buf == NULL) {
+ free(tmp);
+ return 0;
+ }
}
}
buf[i] = 0;
t=LCMapStringW(gWinLCID, LCMAP_SORTKEY, gFileLines[line].name, -1, buf, sizeof(buf));
gFileLines[line].winSortKey = new char[t];
if (t > (int32_t)sizeof(buf)) {
- t = LCMapStringW(gWinLCID, LCMAP_SORTKEY, gFileLines[line].name, -1, (unsigned short *)(gFileLines[line].winSortKey), t);
+ t = LCMapStringW(gWinLCID, LCMAP_SORTKEY, gFileLines[line].name, -1, (UChar *)(gFileLines[line].winSortKey), t);
}
else
{