diff options
| author | skytrias <skytrias@protonmail.com> | 2021-10-23 00:12:32 +0200 |
|---|---|---|
| committer | skytrias <skytrias@protonmail.com> | 2021-10-23 00:12:32 +0200 |
| commit | 6399f2b0146c4d91b948b09c2b180b42996fdb88 (patch) | |
| tree | 9b365ca0a15dd2d1cf9598056835072fdbb5568e /src/main.cpp | |
| parent | 7218a68e894d765a6b30ed48f64d91740ce2b23e (diff) | |
fix strip-semicolon using original file handle size
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index cdc6468ab..21496b80f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2141,8 +2141,8 @@ int strip_semicolons(Parser *parser) { generated_count += 1; i64 written = 0; - defer (gb_file_truncate(&f, written)); - + defer (err = gb_file_truncate(&f, written)); + debugf("Write file with stripped tokens: %s\n", filename); err = write_file_with_stripped_tokens(&f, file->file, &written); if (err) { @@ -2178,6 +2178,7 @@ int strip_semicolons(Parser *parser) { } debugf("Copy '%s' to '%s'\n", new_fullpath, old_fullpath); + if (!gb_file_copy(new_fullpath, old_fullpath, false)) { gb_printf_err("failed to copy '%s' to '%s'\n", old_fullpath, new_fullpath); debugf("Copy '%s' to '%s'\n", old_fullpath_backup, old_fullpath); @@ -2187,7 +2188,7 @@ int strip_semicolons(Parser *parser) { failed = true; break; } - + debugf("Remove '%s'\n", old_fullpath_backup); if (!gb_file_remove(old_fullpath_backup)) { gb_printf_err("failed to remove '%s'\n", old_fullpath_backup); |