| ... | ... | @@ -37,7 +37,7 @@ pub const Item = union(enum) { |
| 37 | 37 | kv: Key, |
| 38 | 38 | mapping: Mapping, |
| 39 | 39 | sequence: Sequence, |
| 40 | | string: string, |
| 40 | string: [:0]const u8, |
| 41 | 41 | stream: Stream, |
| 42 | 42 | |
| 43 | 43 | pub fn deinit(self: *const Item, alloc: std.mem.Allocator) void { |
| ... | ... | @@ -97,7 +97,7 @@ pub const Key = struct { |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | 99 | pub const Value = union(enum) { |
| 100 | | string: string, |
| 100 | string: [:0]const u8, |
| 101 | 101 | mapping: Mapping, |
| 102 | 102 | sequence: Sequence, |
| 103 | 103 | |
| ... | ... | @@ -367,7 +367,7 @@ fn parse_sequence(p: *Parser) Error!Sequence { |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | | fn get_event_string(event: Token, p: *const Parser) !string { |
| 370 | fn get_event_string(event: Token, p: *const Parser) ![:0]u8 { |
| 371 | 371 | const sm = event.start_mark; |
| 372 | 372 | const em = event.end_mark; |
| 373 | 373 | const lines = p.lines; |
| ... | ... | @@ -383,16 +383,16 @@ fn get_event_string(event: Token, p: *const Parser) !string { |
| 383 | 383 | try list.appendSlice(std.mem.trimLeft(u8, lines[i], " ")); |
| 384 | 384 | try list.append('\n'); |
| 385 | 385 | } |
| 386 | | return try list.toOwnedSlice(); |
| 386 | return try list.toOwnedSliceSentinel(0); |
| 387 | 387 | }, |
| 388 | 388 | else => @panic("TODO"), |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | const s = lines[sm.line][sm.column..em.column]; |
| 392 | | if (s.len < 2) return try p.alloc.dupe(u8, s); |
| 393 | | if (s[0] == '"' and s[s.len - 1] == '"') return try p.alloc.dupe(u8, std.mem.trim(u8, s, "\"")); |
| 394 | | if (s[0] == '\'' and s[s.len - 1] == '\'') return try p.alloc.dupe(u8, std.mem.trim(u8, s, "'")); |
| 395 | | return try p.alloc.dupe(u8, s); |
| 392 | if (s.len < 2) return try p.alloc.dupeZ(u8, s); |
| 393 | if (s[0] == '"' and s[s.len - 1] == '"') return try p.alloc.dupeZ(u8, std.mem.trim(u8, s, "\"")); |
| 394 | if (s[0] == '\'' and s[s.len - 1] == '\'') return try p.alloc.dupeZ(u8, std.mem.trim(u8, s, "'")); |
| 395 | return try p.alloc.dupeZ(u8, s); |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | // |