Changeset 34132 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- May 26, 2008, 5:29:11 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h
r33485 r34132 189 189 const UChar *s = src; 190 190 UChar *r = result; 191 UChar *re = result + resultLength;191 uint rindex = 0; 192 192 193 193 // this avoids one out of bounds check in the loop 194 if (QChar(*s).isLowSurrogate()) 195 *r++ = *s++; 194 if (s < e && QChar(*s).isLowSurrogate()) { 195 if (r) 196 r[rindex] = *s++; 197 ++rindex; 198 } 196 199 197 200 int needed = 0; 198 while (s < e && r < re) {201 while (s < e && (rindex < resultLength || !r)) { 199 202 uint c = *s; 200 203 if (QChar(c).isLowSurrogate() && QChar(*(s - 1)).isHighSurrogate()) … … 211 214 qstring = qstring.toLower(); 212 215 for (int i = 0; i < qstring.length(); ++i) { 213 if (r == re) {216 if (rindex >= resultLength) { 214 217 needed += qstring.length() - i; 215 218 break; 216 219 } 217 *r = qstring.at(i).unicode(); 218 ++r; 220 if (r) 221 r[rindex] = qstring.at(i).unicode(); 222 ++rindex; 219 223 } 220 224 } else { 221 *r = *s + prop->lowerCaseDiff; 222 ++r; 225 if (r) 226 r[rindex] = *s + prop->lowerCaseDiff; 227 ++rindex; 223 228 } 224 229 ++s; … … 227 232 needed += e - s; 228 233 *error = (needed != 0); 229 if (r < re)230 *r= 0;231 return (r - result)+ needed;234 if (rindex < resultLength) 235 r[rindex] = 0; 236 return rindex + needed; 232 237 } 233 238 … … 242 247 const UChar *s = src; 243 248 UChar *r = result; 244 UChar *re = result + resultLength;249 int rindex = 0; 245 250 246 251 // this avoids one out of bounds check in the loop 247 if (QChar(*s).isLowSurrogate()) 248 *r++ = *s++; 252 if (s < e && QChar(*s).isLowSurrogate()) { 253 if (r) 254 r[rindex] = *s++; 255 ++rindex; 256 } 249 257 250 258 int needed = 0; 251 while (s < e && r < re) {259 while (s < e && (rindex < resultLength || !r)) { 252 260 uint c = *s; 253 261 if (QChar(c).isLowSurrogate() && QChar(*(s - 1)).isHighSurrogate()) … … 264 272 qstring = qstring.toUpper(); 265 273 for (int i = 0; i < qstring.length(); ++i) { 266 if (r == re) {274 if (rindex >= resultLength) { 267 275 needed += qstring.length() - i; 268 276 break; 269 277 } 270 *r = qstring.at(i).unicode(); 271 ++r; 278 if (r) 279 r[rindex] = qstring.at(i).unicode(); 280 ++rindex; 272 281 } 273 282 } else { 274 *r = *s + prop->upperCaseDiff; 275 ++r; 283 if (r) 284 r[rindex] = *s + prop->upperCaseDiff; 285 ++rindex; 276 286 } 277 287 ++s; … … 280 290 needed += e - s; 281 291 *error = (needed != 0); 282 if (r < re)283 *r= 0;284 return (r - result)+ needed;292 if (rindex < resultLength) 293 r[rindex] = 0; 294 return rindex + needed; 285 295 } 286 296
Note:
See TracChangeset
for help on using the changeset viewer.