From c46317c00b04cefe83101be6bb4231e3edcd2fff Mon Sep 17 00:00:00 2001 From: Daniel Gavin Date: Wed, 14 Apr 2021 02:20:05 +0200 Subject: [PATCH] fix os error --- core/odin/printer/printer.odin | 3 ++- core/os/file_windows.odin | 4 ++-- tools/odinfmt/main.odin | 10 +++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/odin/printer/printer.odin b/core/odin/printer/printer.odin index dc4cb1c1a..bc2a0a913 100644 --- a/core/odin/printer/printer.odin +++ b/core/odin/printer/printer.odin @@ -201,7 +201,8 @@ align_comments :: proc(p: ^Printer) { if .Line_Comment in line.types { - if current_info.end + 1 != line_index || current_info.depth != line.depth { + if current_info.end + 1 != line_index || current_info.depth != line.depth || + (current_info.begin == current_info.end && current_info.length == 0) { if (current_info.begin != 0 && current_info.end != 0) || current_info.length > 0 { append(&comment_infos, current_info); diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin index 4bb4c689f..8b99ee9ee 100644 --- a/core/os/file_windows.odin +++ b/core/os/file_windows.odin @@ -273,7 +273,7 @@ is_file :: proc(path: string) -> bool { attribs := win32.GetFileAttributesW(wpath); if i32(attribs) != win32.INVALID_FILE_ATTRIBUTES { - return attribs & win32.FILE_ATTRIBUTE_DIRECTORY == win32.FILE_ATTRIBUTE_DIRECTORY; + return attribs & win32.FILE_ATTRIBUTE_DIRECTORY == 0; } return false; } @@ -283,7 +283,7 @@ is_dir :: proc(path: string) -> bool { attribs := win32.GetFileAttributesW(wpath); if i32(attribs) != win32.INVALID_FILE_ATTRIBUTES { - return attribs & win32.FILE_ATTRIBUTE_DIRECTORY != win32.FILE_ATTRIBUTE_DIRECTORY; + return attribs & win32.FILE_ATTRIBUTE_DIRECTORY != 0; } return false; } diff --git a/tools/odinfmt/main.odin b/tools/odinfmt/main.odin index 78624bd94..4040fe4c2 100644 --- a/tools/odinfmt/main.odin +++ b/tools/odinfmt/main.odin @@ -5,6 +5,8 @@ import "core:odin/format" import "core:fmt" import "core:strings" import "core:path/filepath" +import "core:time" +import "core:mem" import "flag" @@ -51,6 +53,8 @@ walk_files :: proc(info: os.File_Info, in_err: os.Errno) -> (err: os.Errno, skip main :: proc() { + init_global_temporary_allocator(mem.megabytes(100)); + args: Args; if len(os.args) < 2 { @@ -65,6 +69,8 @@ main :: proc() { path := os.args[len(os.args)-1]; + tick_time := time.tick_now(); + if os.is_file(path) { if _, ok := args.write.(bool); ok { @@ -122,12 +128,14 @@ main :: proc() { } + } else { + fmt.eprintf("failed to format %v", file); } free_all(context.temp_allocator); } - fmt.printf("formatted %v files", len(files)); + fmt.printf("formatted %v files in %vms", len(files), time.duration_milliseconds(time.tick_lap_time(&tick_time))); }