ICU-2474 dont make multiple calls to ungetc

X-SVN-Rev: 10352
This commit is contained in:
Ram Viswanadha 2002-11-22 23:43:32 +00:00
parent 1a30ec126c
commit 940a3f8f1c

View File

@ -57,12 +57,12 @@ ucbuf_autodetect_fs(FileStream* in, const char** cp, UConverter** conv, int32_t*
numRead=T_FileStream_read(in, start, sizeof(start)); numRead=T_FileStream_read(in, start, sizeof(start));
*cp = ucnv_detectUnicodeSignature(start, numRead, signatureLength, error); *cp = ucnv_detectUnicodeSignature(start, numRead, signatureLength, error);
if(*cp==NULL){
/* unread the bytes already read */
while(numRead>0) {
T_FileStream_ungetc(start[--numRead], in);
}
/* unread the bytes beyond what was consumed for U+FEFF */
T_FileStream_rewind(in);
numRead = T_FileStream_read(in, start,*signatureLength);
if(*cp==NULL){
*conv =NULL; *conv =NULL;
return FALSE; return FALSE;
} }
@ -84,10 +84,7 @@ ucbuf_autodetect_fs(FileStream* in, const char** cp, UConverter** conv, int32_t*
*error=U_INTERNAL_PROGRAM_ERROR; *error=U_INTERNAL_PROGRAM_ERROR;
} }
/* unread the bytes beyond what was consumed for U+FEFF */
while(numRead>*signatureLength) {
T_FileStream_ungetc(start[--numRead], in);
}
return TRUE; return TRUE;
} }