Skip to content

Commit

Permalink
windows: fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matu3ba committed Sep 8, 2024
1 parent 55d8607 commit f61510d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/cli_args.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const fs = std.fs;
const mem = std.mem;

const Mode = main.Mode;
const stdout = std.io.getStdOut();
const stderr = std.io.getStdErr();
const process = std.process;

const usage: []const u8 =
Expand Down Expand Up @@ -101,6 +99,7 @@ fn cleanup(write_file: *?fs.File) !Mode {
/// Check input arguments for correctness and stop early.
/// TODO: How to ensure process.exit is never used as return status of zig error codes?
pub fn validateArgs(args: [][:0]u8, write_file_in: *?fs.File, mode_in: Mode) !Mode {
const stdout = std.io.getStdOut();
var mode: Mode = mode_in; // default execution mode
const write_file: *?fs.File = write_file_in;
if (args.len <= 1) {
Expand Down
12 changes: 8 additions & 4 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const process = std.process;
const unicode = std.unicode;
const testing = std.testing;

const stdout = std.io.getStdOut();
const stderr = std.io.getStdErr();

const cli_args = @import("cli_args.zig");

fn fatal(comptime format: []const u8, args: anytype) noreturn {
Expand Down Expand Up @@ -126,12 +123,16 @@ fn isWordOkAsciiExtended(word: []const u8) StatusOkAsciiExt {
}

inline fn skipItIfWindows(it: *mem.TokenIterator(u8, .any)) void {
// TODO FIXME: This does not check, that we have DOS paths
const native_os = builtin.target.os.tag;
switch (native_os) {
.windows => {
if (0x61 <= it.buffer[0] and it.buffer[0] <= 0x7A // A-Z
and it.buffer[1] == ':') {
it.next();
const n = it.next();
if (n == null) {
@panic("drive path not supported, only DOS paths are supported");
}
}
},
else => {},
Expand Down Expand Up @@ -729,6 +730,9 @@ pub fn main() !u8 {

defer if (write_file != null) write_file.?.close();
mode = try cli_args.validateArgs(args, &write_file, mode);
const stdout = std.io.getStdOut();
// const stderr = std.io.getStdErr();

const ret = switch (mode) {
// only check status
Mode.CheckOnly => try checkOnly(Encoding.Utf8, arena, args),
Expand Down
3 changes: 2 additions & 1 deletion src/perfdir_gen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const log = std.log;
const mem = std.mem;
const os = std.os;
const process = std.process;
const stdout = std.io.getStdOut();

const usage: []const u8 =
\\ path
Expand Down Expand Up @@ -129,6 +128,7 @@ fn add(comptime UT: type, cust_nr: []UT, base: UT, path_buf: []u8, n_pbuf: *u64,
}

fn printCustomNr(comptime UT: type, cust_nr: []UT) !void {
const stdout = std.io.getStdOut();
try stdout.writeAll("created ");
const case = fmt.Case.lower;
digitsToChars(cust_nr, case);
Expand All @@ -138,6 +138,7 @@ fn printCustomNr(comptime UT: type, cust_nr: []UT) !void {
}

pub fn main() !void {
const stdout = std.io.getStdOut();
var path_buffer: [1000]u8 = undefined;
var n_pbuf: u64 = 0; // next free position
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
Expand Down
2 changes: 1 addition & 1 deletion src/testdir_gen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const log = std.log;
const mem = std.mem;
const os = std.os;
const process = std.process;
const stdout = std.io.getStdOut();

// 1. ensure test_directories existence
// 2. control_sequences 0x00..0x31 and 0x7F
Expand Down Expand Up @@ -56,6 +55,7 @@ fn ensureFile(path: []const u8) !void {
}

pub fn main() !void {
const stdout = std.io.getStdOut();
var path_buffer: [1000]u8 = undefined;
var n_pbuf: u64 = 0; // next free position
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
Expand Down

0 comments on commit f61510d

Please sign in to comment.