*fixed a loading bug when importing a utf8 file.
This commit is contained in:
parent
85f429353e
commit
ff7cd31fa7
3
HISTORY
3
HISTORY
@ -1,3 +1,6 @@
|
|||||||
|
Apr. 29 2016
|
||||||
|
Fixed a loading bug when importing a UTF8 file
|
||||||
|
|
||||||
Apr. 26 2016
|
Apr. 26 2016
|
||||||
Added an invalid operation usage error when met an unexpected expression
|
Added an invalid operation usage error when met an unexpected expression
|
||||||
|
|
||||||
|
@ -4279,10 +4279,19 @@ static char* _load_file(mb_interpreter_t* s, const char* f, const char* prefix)
|
|||||||
}
|
}
|
||||||
buf = (char*)mb_malloc((size_t)(l + 1));
|
buf = (char*)mb_malloc((size_t)(l + 1));
|
||||||
mb_assert(buf);
|
mb_assert(buf);
|
||||||
if(prefix) {
|
if(prefix)
|
||||||
memcpy(buf, prefix, i);
|
memcpy(buf, prefix, i);
|
||||||
}
|
|
||||||
fread(buf + i, 1, l, fp);
|
fread(buf + i, 1, l, fp);
|
||||||
|
#ifdef MB_ENABLE_UNICODE
|
||||||
|
do {
|
||||||
|
char* off = buf + i;
|
||||||
|
int b = mb_uu_getbom(&off);
|
||||||
|
if(b) {
|
||||||
|
memmove(buf + i, buf + i + b, l - b - i);
|
||||||
|
buf[l - b] = _ZERO_CHAR;
|
||||||
|
}
|
||||||
|
} while(0);
|
||||||
|
#endif /* MB_ENABLE_UNICODE */
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
buf[l] = _ZERO_CHAR;
|
buf[l] = _ZERO_CHAR;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user