aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-10-05 20:58:23 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-10-05 20:58:23 +0200
commit90c90ae5dd0619f246c2379f48a4f0a7b5f5e0b7 (patch)
treec989ed5cc3672827c848b277c27e0776245f3824 /tools
parent8508eb6004ec4dd3fa032d08cf7036daf94d97e5 (diff)
Add the ability to error out of the formatter.
Diffstat (limited to 'tools')
-rw-r--r--tools/odinfmt/main.odin34
1 files changed, 4 insertions, 30 deletions
diff --git a/tools/odinfmt/main.odin b/tools/odinfmt/main.odin
index 83bccb7..a912001 100644
--- a/tools/odinfmt/main.odin
+++ b/tools/odinfmt/main.odin
@@ -43,22 +43,9 @@ print_arg_error :: proc(args: []string, error: flag.Flag_Error) {
}
-format_file :: proc(
- filepath: string,
- config: printer.Config,
- allocator := context.allocator,
-) -> (
- string,
- bool,
-) {
+format_file :: proc(filepath: string, config: printer.Config, allocator := context.allocator) -> (string, bool) {
if data, ok := os.read_entire_file(filepath, allocator); ok {
- return format.format(
- filepath,
- string(data),
- config,
- {.Optional_Semicolons},
- allocator,
- )
+ return format.format(filepath, string(data), config, {.Optional_Semicolons}, allocator)
} else {
return "", false
}
@@ -66,14 +53,7 @@ format_file :: proc(
files: [dynamic]string
-walk_files :: proc(
- info: os.File_Info,
- in_err: os.Errno,
- user_data: rawptr,
-) -> (
- err: os.Error,
- skip_dir: bool,
-) {
+walk_files :: proc(info: os.File_Info, in_err: os.Errno, user_data: rawptr) -> (err: os.Error, skip_dir: bool) {
if info.is_dir {
return nil, false
}
@@ -138,13 +118,7 @@ main :: proc() {
append(&data, ..tmp[:r])
}
- source, ok := format.format(
- "<stdin>",
- string(data[:]),
- config,
- {.Optional_Semicolons},
- arena_allocator,
- )
+ source, ok := format.format("<stdin>", string(data[:]), config, {.Optional_Semicolons}, arena_allocator)
if ok {
fmt.println(source)