aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2021-07-02 21:57:02 +0200
committerLibravatar Rutger Broekhoff2021-07-02 21:57:02 +0200
commit78930ad50faa446a5fbed2baad2969933bee1bd3 (patch)
treec35cd976b4a759f482a0194d59257f30d86308ce
parentca7e6b274b190ef152373ffcca8510bf50ef7e5c (diff)
downloadzig-nkeys-78930ad50faa446a5fbed2baad2969933bee1bd3.tar.gz
zig-nkeys-78930ad50faa446a5fbed2baad2969933bee1bd3.zip
Remove unused parameters and variables
-rw-r--r--src/main.zig10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig
index 3ee70cc..a299afe 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -390,7 +390,7 @@ pub fn areKeySectionContentsValid(contents: []const u8) bool {
390 return true; 390 return true;
391} 391}
392 392
393pub fn findKeySection(text: []const u8, line_it: *std.mem.SplitIterator) ?[]const u8 { 393pub fn findKeySection(line_it: *std.mem.SplitIterator) ?[]const u8 {
394 while (true) { 394 while (true) {
395 const opening_line = line_it.next() orelse return null; 395 const opening_line = line_it.next() orelse return null;
396 if (!isKeySectionBarrier(opening_line, true)) continue; 396 if (!isKeySectionBarrier(opening_line, true)) continue;
@@ -407,15 +407,14 @@ pub fn findKeySection(text: []const u8, line_it: *std.mem.SplitIterator) ?[]cons
407 407
408pub fn parseDecoratedJwt(contents: []const u8) []const u8 { 408pub fn parseDecoratedJwt(contents: []const u8) []const u8 {
409 var line_it = mem.split(contents, "\n"); 409 var line_it = mem.split(contents, "\n");
410 return findKeySection(contents, &line_it) orelse return contents; 410 return findKeySection(&line_it) orelse return contents;
411} 411}
412 412
413pub fn parseDecoratedNkey(contents: []const u8) NoNkeySeedFoundError!SeedKeyPair { 413pub fn parseDecoratedNkey(contents: []const u8) NoNkeySeedFoundError!SeedKeyPair {
414 var line_it = mem.split(contents, "\n"); 414 var line_it = mem.split(contents, "\n");
415 var current_off: usize = 0;
416 var seed: ?[]const u8 = null; 415 var seed: ?[]const u8 = null;
417 if (findKeySection(contents, &line_it) != null) 416 if (findKeySection(&line_it) != null)
418 seed = findKeySection(contents, &line_it); 417 seed = findKeySection(&line_it);
419 if (seed == null) 418 if (seed == null)
420 seed = findNkey(contents) orelse return error.NoNkeySeedFound; 419 seed = findNkey(contents) orelse return error.NoNkeySeedFound;
421 if (!isValidCredsNkey(seed.?)) 420 if (!isValidCredsNkey(seed.?))
@@ -441,7 +440,6 @@ fn isValidCredsNkey(text: []const u8) bool {
441 440
442fn findNkey(text: []const u8) ?[]const u8 { 441fn findNkey(text: []const u8) ?[]const u8 {
443 var line_it = std.mem.split(text, "\n"); 442 var line_it = std.mem.split(text, "\n");
444 var current_off: usize = 0;
445 while (line_it.next()) |line| { 443 while (line_it.next()) |line| {
446 for (line) |c, i| { 444 for (line) |c, i| {
447 if (!ascii.isSpace(c)) { 445 if (!ascii.isSpace(c)) {