mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
The compiler now skips UTF8 BOM.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
- Add `+++` `&&&` `|||` as replacement for `$concat`, `$and` and `$or`.
|
||||
- Add `methodsof` to type info for struct, union and bitstruct.
|
||||
- Added `@tag` `tagof` and `has_tagof` to user defined types and members.
|
||||
- The compiler now skips UTF8 BOM.
|
||||
|
||||
### Fixes
|
||||
|
||||
|
||||
@@ -243,10 +243,15 @@ char *file_read_all(const char *path, size_t *return_size)
|
||||
error_exit("Failed to read file \"%s\".\n", path);
|
||||
}
|
||||
assert(bytes_read == file_size);
|
||||
|
||||
buffer[bytes_read] = '\0';
|
||||
// Filter '\r' early.
|
||||
|
||||
size_t offset = 0;
|
||||
// Filter BOM
|
||||
if (buffer[0] == (char)0xEF && buffer[1] == (char)0xBB && buffer[2] == (char)0xBF)
|
||||
{
|
||||
offset += 3;
|
||||
}
|
||||
// Filter '\r' early.
|
||||
for (size_t i = 0; i < file_size - offset; i++)
|
||||
{
|
||||
char c = buffer[i + offset];
|
||||
|
||||
Reference in New Issue
Block a user