Lines Matching refs:iter
116 lenient8IteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) { in lenient8IteratorGetIndex() argument
122 if(iter->index<0) { in lenient8IteratorGetIndex()
128 s=(const uint8_t *)iter->context; in lenient8IteratorGetIndex()
130 limit=iter->start; /* count up to the UTF-8 index */ in lenient8IteratorGetIndex()
140 iter->start=i; /* just in case setState() did not get us to a code point boundary */ in lenient8IteratorGetIndex()
141 if(i==iter->limit) { in lenient8IteratorGetIndex()
142 iter->length=index; /* in case it was <0 or wrong */ in lenient8IteratorGetIndex()
144 if(iter->reservedField!=0) { in lenient8IteratorGetIndex()
147 iter->index=index; in lenient8IteratorGetIndex()
149 return iter->index; in lenient8IteratorGetIndex()
152 if(iter->length<0) { in lenient8IteratorGetIndex()
157 s=(const uint8_t *)iter->context; in lenient8IteratorGetIndex()
158 if(iter->index<0) { in lenient8IteratorGetIndex()
164 limit=iter->start; in lenient8IteratorGetIndex()
177 iter->start=i; /* just in case setState() did not get us to a code point boundary */ in lenient8IteratorGetIndex()
178 iter->index= iter->reservedField!=0 ? length-1 : length; in lenient8IteratorGetIndex()
180 i=iter->start; in lenient8IteratorGetIndex()
181 length=iter->index; in lenient8IteratorGetIndex()
182 if(iter->reservedField!=0) { in lenient8IteratorGetIndex()
188 limit=iter->limit; in lenient8IteratorGetIndex()
197 iter->length=length; in lenient8IteratorGetIndex()
199 return iter->length; in lenient8IteratorGetIndex()
208 lenient8IteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) { in lenient8IteratorMove() argument
224 if(iter->index>=0) { in lenient8IteratorMove()
225 pos=iter->index+delta; in lenient8IteratorMove()
235 if(iter->length>=0) { in lenient8IteratorMove()
236 pos=iter->length+delta; in lenient8IteratorMove()
240 iter->index=-1; in lenient8IteratorMove()
241 iter->start=iter->limit; in lenient8IteratorMove()
242 iter->reservedField=0; in lenient8IteratorMove()
259 iter->index=iter->start=iter->reservedField=0; in lenient8IteratorMove()
261 } else if(iter->length>=0 && pos>=iter->length) { in lenient8IteratorMove()
262 iter->index=iter->length; in lenient8IteratorMove()
263 iter->start=iter->limit; in lenient8IteratorMove()
264 iter->reservedField=0; in lenient8IteratorMove()
265 return iter->index; in lenient8IteratorMove()
269 if(iter->index<0 || pos<iter->index/2) { in lenient8IteratorMove()
271 iter->index=iter->start=iter->reservedField=0; in lenient8IteratorMove()
272 } else if(iter->length>=0 && (iter->length-pos)<(pos-iter->index)) { in lenient8IteratorMove()
278 iter->index=iter->length; in lenient8IteratorMove()
279 iter->start=iter->limit; in lenient8IteratorMove()
280 iter->reservedField=0; in lenient8IteratorMove()
283 delta=pos-iter->index; in lenient8IteratorMove()
285 return iter->index; /* nothing to do */ in lenient8IteratorMove()
291 } else if(-delta>=iter->start) { in lenient8IteratorMove()
293 iter->index=iter->start=iter->reservedField=0; in lenient8IteratorMove()
295 } else if(delta>=(iter->limit-iter->start)) { in lenient8IteratorMove()
297 iter->index=iter->length; /* may or may not be <0 (unknown) */ in lenient8IteratorMove()
298 iter->start=iter->limit; in lenient8IteratorMove()
299 iter->reservedField=0; in lenient8IteratorMove()
300 return iter->index>=0 ? iter->index : UITER_UNKNOWN_INDEX; in lenient8IteratorMove()
307 s=(const uint8_t *)iter->context; in lenient8IteratorMove()
308 pos=iter->index; /* could be <0 (unknown) */ in lenient8IteratorMove()
309 i=iter->start; in lenient8IteratorMove()
312 int32_t limit=iter->limit; in lenient8IteratorMove()
313 if(iter->reservedField!=0) { in lenient8IteratorMove()
314 iter->reservedField=0; in lenient8IteratorMove()
328 iter->reservedField=c; in lenient8IteratorMove()
334 if(iter->length<0 && iter->index>=0) { in lenient8IteratorMove()
335 iter->length= iter->reservedField==0 ? pos : pos+1; in lenient8IteratorMove()
336 } else if(iter->index<0 && iter->length>=0) { in lenient8IteratorMove()
337 iter->index= iter->reservedField==0 ? iter->length : iter->length-1; in lenient8IteratorMove()
342 if(iter->reservedField!=0) { in lenient8IteratorMove()
343 iter->reservedField=0; in lenient8IteratorMove()
359 iter->reservedField=c; in lenient8IteratorMove()
366 iter->start=i; in lenient8IteratorMove()
367 if(iter->index>=0) { in lenient8IteratorMove()
368 return iter->index=pos; in lenient8IteratorMove()
372 return iter->index=i; /* reached the beginning */ in lenient8IteratorMove()
381 lenient8IteratorHasNext(UCharIterator *iter) { in lenient8IteratorHasNext() argument
382 return iter->reservedField!=0 || iter->start<iter->limit; in lenient8IteratorHasNext()
386 lenient8IteratorHasPrevious(UCharIterator *iter) { in lenient8IteratorHasPrevious() argument
387 return iter->start>0; in lenient8IteratorHasPrevious()
391 lenient8IteratorCurrent(UCharIterator *iter) { in lenient8IteratorCurrent() argument
392 if(iter->reservedField!=0) { in lenient8IteratorCurrent()
393 return U16_TRAIL(iter->reservedField); in lenient8IteratorCurrent()
394 } else if(iter->start<iter->limit) { in lenient8IteratorCurrent()
395 const uint8_t *s=(const uint8_t *)iter->context; in lenient8IteratorCurrent()
397 int32_t i=iter->start; in lenient8IteratorCurrent()
399 L8_NEXT(s, i, iter->limit, c); in lenient8IteratorCurrent()
413 lenient8IteratorNext(UCharIterator *iter) { in lenient8IteratorNext() argument
416 if(iter->reservedField!=0) { in lenient8IteratorNext()
417 UChar trail=U16_TRAIL(iter->reservedField); in lenient8IteratorNext()
418 iter->reservedField=0; in lenient8IteratorNext()
419 if((index=iter->index)>=0) { in lenient8IteratorNext()
420 iter->index=index+1; in lenient8IteratorNext()
423 } else if(iter->start<iter->limit) { in lenient8IteratorNext()
424 const uint8_t *s=(const uint8_t *)iter->context; in lenient8IteratorNext()
427 L8_NEXT(s, iter->start, iter->limit, c); in lenient8IteratorNext()
428 if((index=iter->index)>=0) { in lenient8IteratorNext()
429 iter->index=++index; in lenient8IteratorNext()
430 if(iter->length<0 && iter->start==iter->limit) { in lenient8IteratorNext()
431 iter->length= c<=0xffff ? index : index+1; in lenient8IteratorNext()
433 } else if(iter->start==iter->limit && iter->length>=0) { in lenient8IteratorNext()
434 iter->index= c<=0xffff ? iter->length : iter->length-1; in lenient8IteratorNext()
441 iter->reservedField=c; in lenient8IteratorNext()
450 lenient8IteratorPrevious(UCharIterator *iter) { in lenient8IteratorPrevious() argument
453 if(iter->reservedField!=0) { in lenient8IteratorPrevious()
454 UChar lead=U16_LEAD(iter->reservedField); in lenient8IteratorPrevious()
455 iter->reservedField=0; in lenient8IteratorPrevious()
456 iter->start-=4; /* we stayed behind the supplementary code point; go before it now */ in lenient8IteratorPrevious()
457 if((index=iter->index)>0) { in lenient8IteratorPrevious()
458 iter->index=index-1; in lenient8IteratorPrevious()
461 } else if(iter->start>0) { in lenient8IteratorPrevious()
462 const uint8_t *s=(const uint8_t *)iter->context; in lenient8IteratorPrevious()
465 L8_PREV(s, 0, iter->start, c); in lenient8IteratorPrevious()
466 if((index=iter->index)>0) { in lenient8IteratorPrevious()
467 iter->index=index-1; in lenient8IteratorPrevious()
468 } else if(iter->start<=1) { in lenient8IteratorPrevious()
469 iter->index= c<=0xffff ? iter->start : iter->start+1; in lenient8IteratorPrevious()
476 iter->start+=4; /* back to behind this supplementary code point for consistent state */ in lenient8IteratorPrevious()
477 iter->reservedField=c; in lenient8IteratorPrevious()
486 lenient8IteratorGetState(const UCharIterator *iter) { in lenient8IteratorGetState() argument
487 uint32_t state=(uint32_t)(iter->start<<1); in lenient8IteratorGetState()
488 if(iter->reservedField!=0) { in lenient8IteratorGetState()
495 lenient8IteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) { in lenient8IteratorSetState() argument
498 } else if(iter==NULL) { in lenient8IteratorSetState()
500 } else if(state==lenient8IteratorGetState(iter)) { in lenient8IteratorSetState()
506 if((state==0 ? index<0 : index<4) || iter->limit<index) { in lenient8IteratorSetState()
509 iter->start=index; /* restore UTF-8 byte index */ in lenient8IteratorSetState()
511 iter->index=index; in lenient8IteratorSetState()
513 iter->index=-1; /* unknown UTF-16 index */ in lenient8IteratorSetState()
516 iter->reservedField=0; in lenient8IteratorSetState()
520 L8_PREV((const uint8_t *)iter->context, 0, index, c); in lenient8IteratorSetState()
524 iter->reservedField=c; in lenient8IteratorSetState()
546 uiter_setLenient8(UCharIterator *iter, const char *s, int32_t length) { in uiter_setLenient8() argument
547 if(iter!=0) { in uiter_setLenient8()
549 *iter=lenient8Iterator; in uiter_setLenient8()
550 iter->context=s; in uiter_setLenient8()
552 iter->limit=length; in uiter_setLenient8()
554 iter->limit=strlen(s); in uiter_setLenient8()
556 iter->length= iter->limit<=1 ? iter->limit : -1; in uiter_setLenient8()
559 uiter_setString(iter, NULL, 0); in uiter_setLenient8()