Lines Matching refs:buf

161 ucbuf_fillucbuf( UCHARBUF* buf,UErrorCode* error){  in ucbuf_fillucbuf()  argument
172 pTarget = buf->buffer; in ucbuf_fillucbuf()
174 if(buf->currentPos<buf->bufLimit){ in ucbuf_fillucbuf()
175 offset = (int32_t)(buf->bufLimit-buf->currentPos); in ucbuf_fillucbuf()
176 memmove(buf->buffer,buf->currentPos,offset* sizeof(UChar)); in ucbuf_fillucbuf()
182 if(buf->isBuffered){ in ucbuf_fillucbuf()
185 inputRead=T_FileStream_read(buf->in,cbuf,cbufSize-offset); in ucbuf_fillucbuf()
186 buf->remaining-=inputRead; in ucbuf_fillucbuf()
189 cbufSize = T_FileStream_size(buf->in); in ucbuf_fillucbuf()
195 inputRead= T_FileStream_read(buf->in,cbuf,cbufSize); in ucbuf_fillucbuf()
196 buf->remaining-=inputRead; in ucbuf_fillucbuf()
201 buf->remaining = 0; in ucbuf_fillucbuf()
205 if(buf->conv){ in ucbuf_fillucbuf()
210 ucnv_setToUCallBack(buf->conv, in ucbuf_fillucbuf()
220 ucnv_toUnicode(buf->conv,&target,target+(buf->bufCapacity-offset), in ucbuf_fillucbuf()
222 (UBool)(buf->remaining==0),error); in ucbuf_fillucbuf()
235 if( buf->showWarning==TRUE){ in ucbuf_fillucbuf()
243 ucnv_getInvalidChars(buf->conv,context,&len,&error1); in ucbuf_fillucbuf()
264 if(buf->showWarning ==TRUE){ in ucbuf_fillucbuf()
272 ucnv_reset(buf->conv); in ucbuf_fillucbuf()
277 ucnv_setToUCallBack(buf->conv, in ucbuf_fillucbuf()
289 ucnv_toUnicode(buf->conv,&target,target+(buf->bufCapacity-offset), in ucbuf_fillucbuf()
291 (UBool)(buf->remaining==0),&error1); in ucbuf_fillucbuf()
308 outputWritten=((buf->remaining>cbufSize)? cbufSize:inputRead+offset); in ucbuf_fillucbuf()
310 buf->currentPos = pTarget; in ucbuf_fillucbuf()
311 buf->bufLimit=pTarget+outputWritten; in ucbuf_fillucbuf()
312 *buf->bufLimit=0; /*NUL terminate*/ in ucbuf_fillucbuf()
316 return buf; in ucbuf_fillucbuf()
323 ucbuf_getc(UCHARBUF* buf,UErrorCode* error){ in ucbuf_getc() argument
327 if(buf->currentPos>=buf->bufLimit){ in ucbuf_getc()
328 if(buf->remaining==0){ in ucbuf_getc()
331 buf=ucbuf_fillucbuf(buf,error); in ucbuf_getc()
337 return *(buf->currentPos++); in ucbuf_getc()
342 ucbuf_getc32(UCHARBUF* buf,UErrorCode* error){ in ucbuf_getc32() argument
347 if(buf->currentPos+1>=buf->bufLimit){ in ucbuf_getc32()
348 if(buf->remaining==0){ in ucbuf_getc32()
351 buf=ucbuf_fillucbuf(buf,error); in ucbuf_getc32()
356 if(U16_IS_LEAD(*(buf->currentPos))){ in ucbuf_getc32()
357 retVal=U16_GET_SUPPLEMENTARY(buf->currentPos[0],buf->currentPos[1]); in ucbuf_getc32()
358 buf->currentPos+=2; in ucbuf_getc32()
360 retVal = *(buf->currentPos++); in ucbuf_getc32()
373 ucbuf_getcx32(UCHARBUF* buf,UErrorCode* error) { in ucbuf_getcx32() argument
381 if (buf->currentPos >=buf->bufLimit-2) { in ucbuf_getcx32()
382 ucbuf_fillucbuf(buf,error); in ucbuf_getcx32()
386 if (buf->currentPos < buf->bufLimit) { in ucbuf_getcx32()
387 c1 = *(buf->currentPos)++; in ucbuf_getcx32()
392 c2 = *(buf->currentPos); in ucbuf_getcx32()
400 length = (int32_t)(buf->bufLimit - buf->currentPos); in ucbuf_getcx32()
407 ucbuf_fillucbuf(buf,error); in ucbuf_getcx32()
408 length = (int32_t)(buf->bufLimit - buf->buffer); in ucbuf_getcx32()
413 c32 = u_unescapeAt(_charAt, &offset, length, (void*)buf); in ucbuf_getcx32()
419 if(buf->showWarning) { in ucbuf_getcx32()
426 u_UCharsToChars( buf->currentPos, context, len); in ucbuf_getcx32()
433 buf->currentPos += offset; in ucbuf_getcx32()
467 UCHARBUF* buf =(UCHARBUF*) uprv_malloc(sizeof(UCHARBUF)); in ucbuf_open() local
469 if(buf == NULL){ in ucbuf_open()
474 buf->in=in; in ucbuf_open()
475 buf->conv=NULL; in ucbuf_open()
476 buf->showWarning = showWarning; in ucbuf_open()
477 buf->isBuffered = buffered; in ucbuf_open()
478 buf->signatureLength=0; in ucbuf_open()
481 ucbuf_autodetect_fs(in,cp,&buf->conv,&buf->signatureLength,error); in ucbuf_open()
484 ucbuf_autodetect_fs(in,&knownCp,&buf->conv,&buf->signatureLength,error); in ucbuf_open()
486 if(U_SUCCESS(*error) && buf->conv==NULL) { in ucbuf_open()
487 buf->conv=ucnv_open(*cp,error); in ucbuf_open()
490 ucnv_close(buf->conv); in ucbuf_open()
491 uprv_free(buf); in ucbuf_open()
496 if((buf->conv==NULL) && (buf->showWarning==TRUE)){ in ucbuf_open()
499 buf->remaining=fileSize-buf->signatureLength; in ucbuf_open()
500 if(buf->isBuffered){ in ucbuf_open()
501 buf->bufCapacity=MAX_U_BUF; in ucbuf_open()
503buf->bufCapacity=buf->remaining+buf->signatureLength+1/*for terminating nul*/; in ucbuf_open()
505 buf->buffer=(UChar*) uprv_malloc(U_SIZEOF_UCHAR * buf->bufCapacity ); in ucbuf_open()
506 if (buf->buffer == NULL) { in ucbuf_open()
508 ucbuf_close(buf); in ucbuf_open()
511 buf->currentPos=buf->buffer; in ucbuf_open()
512 buf->bufLimit=buf->buffer; in ucbuf_open()
515 ucbuf_close(buf); in ucbuf_open()
518 ucbuf_fillucbuf(buf,error); in ucbuf_open()
520 ucbuf_close(buf); in ucbuf_open()
523 return buf; in ucbuf_open()
537 ucbuf_ungetc(int32_t c,UCHARBUF* buf){ in ucbuf_ungetc() argument
541 if(buf->currentPos!=buf->buffer){ in ucbuf_ungetc()
542 if(*(buf->currentPos-1)==c){ in ucbuf_ungetc()
543 buf->currentPos--; in ucbuf_ungetc()
554 ucbuf_closebuf(UCHARBUF* buf){ in ucbuf_closebuf() argument
555 uprv_free(buf->buffer); in ucbuf_closebuf()
556 buf->buffer = NULL; in ucbuf_closebuf()
561 ucbuf_close(UCHARBUF* buf){ in ucbuf_close() argument
562 if(buf!=NULL){ in ucbuf_close()
563 if(buf->conv){ in ucbuf_close()
564 ucnv_close(buf->conv); in ucbuf_close()
566 T_FileStream_close(buf->in); in ucbuf_close()
567 ucbuf_closebuf(buf); in ucbuf_close()
568 uprv_free(buf); in ucbuf_close()
574 ucbuf_rewind(UCHARBUF* buf,UErrorCode* error){ in ucbuf_rewind() argument
578 if(buf){ in ucbuf_rewind()
579 buf->currentPos=buf->buffer; in ucbuf_rewind()
580 buf->bufLimit=buf->buffer; in ucbuf_rewind()
581 T_FileStream_rewind(buf->in); in ucbuf_rewind()
582 buf->remaining=T_FileStream_size(buf->in)-buf->signatureLength; in ucbuf_rewind()
584 ucnv_resetToUnicode(buf->conv); in ucbuf_rewind()
585 if(buf->signatureLength>0) { in ucbuf_rewind()
593 numRead=T_FileStream_read(buf->in, start, buf->signatureLength); in ucbuf_rewind()
598 … ucnv_toUnicode(buf->conv, &pTarget, target+1, &pStart, start+numRead, NULL, FALSE, error); in ucbuf_rewind()
604 …if(U_SUCCESS(*error) && (numRead!=buf->signatureLength || pTarget!=(target+1) || target[0]!=0xfeff… in ucbuf_rewind()
613 ucbuf_size(UCHARBUF* buf){ in ucbuf_size() argument
614 if(buf){ in ucbuf_size()
615 if(buf->isBuffered){ in ucbuf_size()
616 return (T_FileStream_size(buf->in)-buf->signatureLength)/ucnv_getMinCharSize(buf->conv); in ucbuf_size()
618 return (int32_t)(buf->bufLimit - buf->buffer); in ucbuf_size()
625 ucbuf_getBuffer(UCHARBUF* buf,int32_t* len,UErrorCode* error){ in ucbuf_getBuffer() argument
629 if(buf==NULL || len==NULL){ in ucbuf_getBuffer()
633 *len = (int32_t)(buf->bufLimit - buf->buffer); in ucbuf_getBuffer()
634 return buf->buffer; in ucbuf_getBuffer()
714 ucbuf_readline(UCHARBUF* buf,int32_t* len,UErrorCode* err){ in ucbuf_readline() argument
715 UChar* temp = buf->currentPos; in ucbuf_readline()
718 if(buf->isBuffered){ in ucbuf_readline()
724 if(buf->remaining==0){ in ucbuf_readline()
727 if(temp>=buf->bufLimit && buf->currentPos == buf->buffer){ in ucbuf_readline()
731 ucbuf_fillucbuf(buf,err); in ucbuf_readline()
741 if(c ==0x0d && temp <= buf->bufLimit && *temp == 0x0a ){ in ucbuf_readline()
742 *len = (int32_t)(temp++ - buf->currentPos); in ucbuf_readline()
743 savePos = buf->currentPos; in ucbuf_readline()
744 buf->currentPos = temp; in ucbuf_readline()
749 … if (temp>=buf->bufLimit|| ucbuf_isCharNewLine(c)){ /* Unipad inserts 2028 line separators! */ in ucbuf_readline()
750 *len = (int32_t)(temp - buf->currentPos); in ucbuf_readline()
751 savePos = buf->currentPos; in ucbuf_readline()
752 buf->currentPos = temp; in ucbuf_readline()
763 if(buf->currentPos==buf->bufLimit){ in ucbuf_readline()
767 if(c ==0x0d && temp <= buf->bufLimit && *temp == 0x0a ){ in ucbuf_readline()
768 *len = (int32_t)(temp++ - buf->currentPos); in ucbuf_readline()
769 savePos = buf->currentPos; in ucbuf_readline()
770 buf->currentPos = temp; in ucbuf_readline()
774 … if (temp>=buf->bufLimit|| ucbuf_isCharNewLine(c)) { /* Unipad inserts 2028 line separators! */ in ucbuf_readline()
775 *len = (int32_t)(temp - buf->currentPos); in ucbuf_readline()
776 savePos = buf->currentPos; in ucbuf_readline()
777 buf->currentPos = temp; in ucbuf_readline()