Home | History | Annotate | Download | only in uciter8

Lines Matching refs:iter

110 lenient8IteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
116 if(iter->index<0) {
122 s=(const uint8_t *)iter->context;
124 limit=iter->start; /* count up to the UTF-8 index */
134 iter->start=i; /* just in case setState() did not get us to a code point boundary */
135 if(i==iter->limit) {
136 iter->length=index; /* in case it was <0 or wrong */
138 if(iter->reservedField!=0) {
141 iter->index=index;
143 return iter->index;
146 if(iter->length<0) {
151 s=(const uint8_t *)iter->context;
152 if(iter->index<0) {
158 limit=iter->start;
170 /* assume i==limit==iter->start, set the UTF-16 index */
171 iter->start=i; /* just in case setState() did not get us to a code point boundary */
172 iter->index= iter->reservedField!=0 ? length-1 : length;
174 i=iter->start;
175 length=iter->index;
176 if(iter->reservedField!=0) {
182 limit=iter->limit;
191 iter->length=length;
193 return iter->length;
202 lenient8IteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
215 /* iter->index<0 (unknown) is possible */
218 if(iter->index>=0) {
219 pos=iter->index+delta;
229 if(iter->length>=0) {
230 pos=iter->length+delta;
234 iter->index=-1;
235 iter->start=iter->limit;
236 iter->reservedField=0;
253 iter->index=iter->start=iter->reservedField=0;
255 } else if(iter->length>=0 && pos>=iter->length) {
256 iter->index=iter->length;
257 iter->start=iter->limit;
258 iter->reservedField=0;
259 return iter->index;
263 if(iter->index<0 || pos<iter->index/2) {
265 iter->index=iter->start=iter->reservedField=0;
266 } else if(iter->length>=0 && (iter->length-pos)<(pos-iter->index)) {
272 iter->index=iter->length;
273 iter->start=iter->limit;
274 iter->reservedField=0;
277 delta=pos-iter->index;
279 return iter->index; /* nothing to do */
285 } else if(-delta>=iter->start) {
287 iter->index=iter->start=iter->reservedField=0;
289 } else if(delta>=(iter->limit-iter->start)) {
291 iter->index=iter->length; /* may or may not be <0 (unknown) */
292 iter->start=iter->limit;
293 iter->reservedField=0;
294 return iter->index>=0 ? iter->index : UITER_UNKNOWN_INDEX;
301 s=(const uint8_t *)iter->context;
302 pos=iter->index; /* could be <0 (unknown) */
303 i=iter->start;
306 int32_t limit=iter->limit;
307 if(iter->reservedField!=0) {
308 iter->reservedField=0;
322 iter->reservedField=c;
328 if(iter->length<0 && iter->index>=0) {
329 iter->length= iter->reservedField==0 ? pos : pos+1;
330 } else if(iter->index<0 && iter->length>=0) {
331 iter->index= iter->reservedField==0 ? iter->length : iter->length-1;
336 if(iter->reservedField!=0) {
337 iter->reservedField=0;
353 iter->reservedField=c;
360 iter->start=i;
361 if(iter->index>=0) {
362 return iter->index=pos;
366 return iter->index=i; /* reached the beginning */
375 lenient8IteratorHasNext(UCharIterator *iter) {
376 return iter->reservedField!=0 || iter->start<iter->limit;
380 lenient8IteratorHasPrevious(UCharIterator *iter) {
381 return iter->start>0;
385 lenient8IteratorCurrent(UCharIterator *iter) {
386 if(iter->reservedField!=0) {
387 return U16_TRAIL(iter->reservedField);
388 } else if(iter->start<iter->limit) {
389 const uint8_t *s=(const uint8_t *)iter->context;
391 int32_t i=iter->start;
393 L8_NEXT(s, i, iter->limit, c);
407 lenient8IteratorNext(UCharIterator *iter) {
410 if(iter->reservedField!=0) {
411 UChar trail=U16_TRAIL(iter->reservedField);
412 iter->reservedField=0;
413 if((index=iter->index)>=0) {
414 iter->index=index+1;
417 } else if(iter->start<iter->limit) {
418 const uint8_t *s=(const uint8_t *)iter->context;
421 L8_NEXT(s, iter->start, iter->limit, c);
422 if((index=iter->index)>=0) {
423 iter->index=++index;
424 if(iter->length<0 && iter->start==iter->limit) {
425 iter->length= c<=0xffff ? index : index+1;
427 } else if(iter->start==iter->limit && iter->length>=0) {
428 iter->index= c<=0xffff ? iter->length : iter->length-1;
435 iter->reservedField=c;
444 lenient8IteratorPrevious(UCharIterator *iter) {
447 if(iter->reservedField!=0) {
448 UChar lead=U16_LEAD(iter->reservedField);
449 iter->reservedField=0;
450 iter->start-=4; /* we stayed behind the supplementary code point; go before it now */
451 if((index=iter->index)>0) {
452 iter->index=index-1;
455 } else if(iter->start>0) {
456 const uint8_t *s=(const uint8_t *)iter->context;
459 L8_PREV(s, 0, iter->start, c);
460 if((index=iter->index)>0) {
461 iter->index=index-1;
462 } else if(iter->start<=1) {
463 iter->index= c<=0xffff ? iter->start : iter->start+1;
470 iter->start+=4; /* back to behind this supplementary code point for consistent state */
471 iter->reservedField=c;
480 lenient8IteratorGetState(const UCharIterator *iter) {
481 uint32_t state=(uint32_t)(iter->start<<1);
482 if(iter->reservedField!=0) {
489 lenient8IteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
492 } else if(iter==NULL) {
494 } else if(state==lenient8IteratorGetState(iter)) {
500 if((state==0 ? index<0 : index<4) || iter->limit<index) {
503 iter->start=index; /* restore UTF-8 byte index */
505 iter->index=index;
507 iter->index=-1; /* unknown UTF-16 index */
510 iter->reservedField=0;
514 L8_PREV((const uint8_t *)iter->context, 0, index, c);
518 iter->reservedField=c;
540 uiter_setLenient8(UCharIterator *iter, const char *s, int32_t length) {
541 if(iter!=0) {
543 *iter=lenient8Iterator;
544 iter->context=s;
546 iter->limit=length;
548 iter->limit=strlen(s);
550 iter->length= iter->limit<=1 ? iter->limit : -1;
553 uiter_setString(iter, NULL, 0);