| author | |
| committer | |
| log | 271e7f758da34d2865cec4220e009bff6baccb92 |
| tree | bb5e04773efa8b1a0e379737a9a2f808e4c6a8be |
| parent | e545025a089e4512a95c147ba4a2773553817c74 |
7 files changed, 8 insertions(+), 8 deletions(-)
src/cmd/aquila/install.zig+1-1| ... | @@ -20,7 +20,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -20,7 +20,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 20 | defer f.close(); | 20 | defer f.close(); |
| 21 | const w = f.writer(); | 21 | const w = f.writer(); |
| 22 | const init = @import("../init.zig"); | 22 | const init = @import("../init.zig"); |
| 23 | try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null); | 23 | try init.writeExeManifest(w, &u.random_string(48), "zigmod_installation", null, null); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | // add to ~/zigmod.yml for later | 26 | // add to ~/zigmod.yml for later |
src/cmd/aquila/update.zig+1-1| ... | @@ -20,7 +20,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -20,7 +20,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 20 | defer f.close(); | 20 | defer f.close(); |
| 21 | const w = f.writer(); | 21 | const w = f.writer(); |
| 22 | const init = @import("../init.zig"); | 22 | const init = @import("../init.zig"); |
| 23 | try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null); | 23 | try init.writeExeManifest(w, &u.random_string(48), "zigmod_installation", null, null); |
| 24 | } | 24 | } |
| 25 | u.assert(args.len == 0, "zigmod aq update accepts no parameters", .{}); | 25 | u.assert(args.len == 0, "zigmod aq update accepts no parameters", .{}); |
| 26 | 26 |
src/cmd/init.zig+1-1| ... | @@ -26,7 +26,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { | ... | @@ -26,7 +26,7 @@ pub fn execute(self_name: []const u8, args: [][]u8) !void { |
| 26 | const stdin = std.io.getStdIn().reader(); | 26 | const stdin = std.io.getStdIn().reader(); |
| 27 | const cwd = std.fs.cwd(); | 27 | const cwd = std.fs.cwd(); |
| 28 | 28 | ||
| 29 | const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", string, "{s}", try u.random_string(gpa, 48)); | 29 | const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", string, "{s}", &u.random_string(48)); |
| 30 | 30 | ||
| 31 | const ptype = try inquirer.forEnum(stdout, stdin, "Are you making an application or a library?", gpa, enum { exe, lib }, null); | 31 | const ptype = try inquirer.forEnum(stdout, stdin, "Are you making an application or a library?", gpa, enum { exe, lib }, null); |
| 32 | 32 |
src/common.zig+1-1| ... | @@ -277,7 +277,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO | ... | @@ -277,7 +277,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 277 | dd.for_build = d.for_build; | 277 | dd.for_build = d.for_build; |
| 278 | const save = dd; | 278 | const save = dd; |
| 279 | if (d.type != .local) dd.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; | 279 | if (d.type != .local) dd.clean_path = extras.trimPrefix(modpath, cachepath)[1..]; |
| 280 | if (dd.id.len == 0) dd.id = try u.random_string(options.alloc, 48); | 280 | if (dd.id.len == 0) dd.id = &u.random_string(48); |
| 281 | if (d.name.len > 0) dd.name = d.name; | 281 | if (d.name.len > 0) dd.name = d.name; |
| 282 | if (d.main.len > 0) dd.main = d.main; | 282 | if (d.main.len > 0) dd.main = d.main; |
| 283 | if (d.c_include_dirs.len > 0) dd.c_include_dirs = d.c_include_dirs; | 283 | if (d.c_include_dirs.len > 0) dd.c_include_dirs = d.c_include_dirs; |
src/util/funcs.zig+2-2| ... | @@ -97,11 +97,11 @@ pub fn last(in: []string) !string { | ... | @@ -97,11 +97,11 @@ pub fn last(in: []string) !string { |
| 97 | 97 | ||
| 98 | const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; | 98 | const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; |
| 99 | 99 | ||
| 100 | pub fn random_string(alloc: std.mem.Allocator, len: usize) !string { | 100 | pub fn random_string(comptime len: usize) [len]u8 { |
| 101 | const now: u64 = @intCast(std.time.nanoTimestamp()); | 101 | const now: u64 = @intCast(std.time.nanoTimestamp()); |
| 102 | var rand = std.rand.DefaultPrng.init(now); | 102 | var rand = std.rand.DefaultPrng.init(now); |
| 103 | var r = rand.random(); | 103 | var r = rand.random(); |
| 104 | var buf = try alloc.alloc(u8, len); | 104 | var buf: [len]u8 = undefined; |
| 105 | var i: usize = 0; | 105 | var i: usize = 0; |
| 106 | while (i < len) : (i += 1) { | 106 | while (i < len) : (i += 1) { |
| 107 | buf[i] = alphabet[r.int(usize) % alphabet.len]; | 107 | buf[i] = alphabet[r.int(usize) % alphabet.len]; |
src/util/modfile.zig+1-1| ... | @@ -62,7 +62,7 @@ pub const ModFile = struct { | ... | @@ -62,7 +62,7 @@ pub const ModFile = struct { |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | return Self{ | 64 | return Self{ |
| 65 | .id = if (id.len == 0) try u.random_string(alloc, 48) else id, | 65 | .id = if (id.len == 0) &u.random_string(48) else id, |
| 66 | .name = name, | 66 | .name = name, |
| 67 | .main = main, | 67 | .main = main, |
| 68 | .c_include_dirs = try mapping.get_string_array(alloc, "c_include_dirs"), | 68 | .c_include_dirs = try mapping.get_string_array(alloc, "c_include_dirs"), |
src/util/module.zig+1-1| ... | @@ -40,7 +40,7 @@ pub const Module = struct { | ... | @@ -40,7 +40,7 @@ pub const Module = struct { |
| 40 | } | 40 | } |
| 41 | return Module{ | 41 | return Module{ |
| 42 | .type = dep.type, | 42 | .type = dep.type, |
| 43 | .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48), | 43 | .id = if (dep.id.len > 0) dep.id else &u.random_string(48), |
| 44 | .name = dep.name, | 44 | .name = dep.name, |
| 45 | .main = dep.main, | 45 | .main = dep.main, |
| 46 | .c_include_dirs = dep.c_include_dirs, | 46 | .c_include_dirs = dep.c_include_dirs, |