mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 08:38:51 +00:00
Force file copy on odin strip-semicolon
This commit is contained in:
+6
-6
@@ -868,10 +868,11 @@ enum MemoryMappedFileError {
|
||||
MemoryMappedFile_COUNT,
|
||||
};
|
||||
|
||||
MemoryMappedFileError memory_map_file_32(char const *fullpath, MemoryMappedFile *memory_mapped_file) {
|
||||
MemoryMappedFileError memory_map_file_32(char const *fullpath, MemoryMappedFile *memory_mapped_file, bool copy_file_contents) {
|
||||
MemoryMappedFileError err = MemoryMappedFile_None;
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
if (!copy_file_contents) {
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
isize w_len = 0;
|
||||
wchar_t *w_str = gb__alloc_utf8_to_ucs2(temporary_allocator(), fullpath, &w_len);
|
||||
if (w_str == nullptr) {
|
||||
@@ -917,7 +918,7 @@ MemoryMappedFileError memory_map_file_32(char const *fullpath, MemoryMappedFile
|
||||
memory_mapped_file->size = cast(i32)file_size;
|
||||
return err;
|
||||
|
||||
window_handle_file_error:;
|
||||
window_handle_file_error:;
|
||||
{
|
||||
DWORD handle_err = GetLastError();
|
||||
CloseHandle(handle);
|
||||
@@ -935,9 +936,9 @@ window_handle_file_error:;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
// TODO(bill): Memory map rather than copy contents
|
||||
gbFileContents fc = gb_file_read_contents(heap_allocator(), true, fullpath);
|
||||
|
||||
if (fc.size > I32_MAX) {
|
||||
@@ -963,7 +964,6 @@ window_handle_file_error:;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -4645,7 +4645,8 @@ ParseFileError init_ast_file(AstFile *f, String fullpath, TokenPos *err_pos) {
|
||||
zero_item(&f->tokenizer);
|
||||
f->tokenizer.curr_file_id = f->id;
|
||||
|
||||
TokenizerInitError err = init_tokenizer_from_fullpath(&f->tokenizer, f->fullpath);
|
||||
bool copy_file_contents = build_context.command_kind == Command_strip_semicolon;
|
||||
TokenizerInitError err = init_tokenizer_from_fullpath(&f->tokenizer, f->fullpath, copy_file_contents);
|
||||
if (err != TokenizerInit_None) {
|
||||
switch (err) {
|
||||
case TokenizerInit_Empty:
|
||||
|
||||
+6
-4
@@ -722,6 +722,8 @@ struct Tokenizer {
|
||||
i32 error_count;
|
||||
|
||||
bool insert_semicolon;
|
||||
|
||||
MemoryMappedFile memory_mapped_file;
|
||||
};
|
||||
|
||||
|
||||
@@ -811,17 +813,17 @@ TokenizerInitError memory_mapped_file_error_map_to_tokenizer[MemoryMappedFile_CO
|
||||
TokenizerInit_Permission, /*MemoryMappedFile_Permission*/
|
||||
};
|
||||
|
||||
TokenizerInitError init_tokenizer_from_fullpath(Tokenizer *t, String const &fullpath) {
|
||||
MemoryMappedFile memory_mapped_file = {};
|
||||
TokenizerInitError init_tokenizer_from_fullpath(Tokenizer *t, String const &fullpath, bool copy_file_contents) {
|
||||
MemoryMappedFileError mmf_err = memory_map_file_32(
|
||||
alloc_cstring(temporary_allocator(), fullpath),
|
||||
&memory_mapped_file
|
||||
&t->memory_mapped_file,
|
||||
copy_file_contents
|
||||
);
|
||||
|
||||
TokenizerInitError err = memory_mapped_file_error_map_to_tokenizer[mmf_err];
|
||||
switch (mmf_err) {
|
||||
case MemoryMappedFile_None:
|
||||
init_tokenizer_with_data(t, fullpath, memory_mapped_file.data, cast(isize)memory_mapped_file.size);
|
||||
init_tokenizer_with_data(t, fullpath, t->memory_mapped_file.data, cast(isize)t->memory_mapped_file.size);
|
||||
break;
|
||||
case MemoryMappedFile_FileTooLarge:
|
||||
case MemoryMappedFile_Empty:
|
||||
|
||||
Reference in New Issue
Block a user