| author | |
| committer | |
| log | cd20e0cc672249555709e1b58a415ddd50b03ad9 |
| tree | 38f017bc3a4f7adbf7c3a1463ba66d3a1ab9569f |
| parent | e5d479b06e74e04b3ef3108e6098424b2130cbe5 |
9 files changed, 27 insertions(+), 27 deletions(-)
build.zig+1-1| ... | ... | @@ -412,7 +412,7 @@ fn findAndParseConfigH(b: *Builder) !Context { |
| 412 | 412 | while (lines_it.next()) |line| { |
| 413 | 413 | inline for (mappings) |mapping| { |
| 414 | 414 | if (mem.startsWith(u8, line, mapping.prefix)) { |
| 415 | var it = mem.separate(line, "\""); | |
| 415 | var it = mem.split(line, "\""); | |
| 416 | 416 | _ = it.next().?; // skip the stuff before the quote |
| 417 | 417 | @field(ctx, mapping.field) = it.next().?; // the stuff inside the quote |
| 418 | 418 | } |
lib/std/builtin.zig+1-1| ... | ... | @@ -424,7 +424,7 @@ pub const Version = struct { |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | pub fn parse(text: []const u8) !Version { |
| 427 | var it = std.mem.separate(text, "."); | |
| 427 | var it = std.mem.split(text, "."); | |
| 428 | 428 | return Version{ |
| 429 | 429 | .major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10), |
| 430 | 430 | .minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10), |
lib/std/mem.zig+12-12| ... | ... | @@ -1141,7 +1141,7 @@ test "writeIntBig and writeIntLittle" { |
| 1141 | 1141 | /// If `buffer` is empty, the iterator will return null. |
| 1142 | 1142 | /// If `delimiter_bytes` does not exist in buffer, |
| 1143 | 1143 | /// the iterator will return `buffer`, null, in that order. |
| 1144 | /// See also the related function `separate`. | |
| 1144 | /// See also the related function `split`. | |
| 1145 | 1145 | pub fn tokenize(buffer: []const u8, delimiter_bytes: []const u8) TokenIterator { |
| 1146 | 1146 | return TokenIterator{ |
| 1147 | 1147 | .index = 0, |
| ... | ... | @@ -1196,15 +1196,13 @@ test "mem.tokenize (multibyte)" { |
| 1196 | 1196 | |
| 1197 | 1197 | /// Returns an iterator that iterates over the slices of `buffer` that |
| 1198 | 1198 | /// are separated by bytes in `delimiter`. |
| 1199 | /// separate("abc|def||ghi", "|") | |
| 1199 | /// split("abc|def||ghi", "|") | |
| 1200 | 1200 | /// will return slices for "abc", "def", "", "ghi", null, in that order. |
| 1201 | 1201 | /// If `delimiter` does not exist in buffer, |
| 1202 | 1202 | /// the iterator will return `buffer`, null, in that order. |
| 1203 | 1203 | /// The delimiter length must not be zero. |
| 1204 | 1204 | /// See also the related function `tokenize`. |
| 1205 | /// It is planned to rename this function to `split` before 1.0.0, like this: | |
| 1206 | /// pub fn split(buffer: []const u8, delimiter: []const u8) SplitIterator { | |
| 1207 | pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator { | |
| 1205 | pub fn split(buffer: []const u8, delimiter: []const u8) SplitIterator { | |
| 1208 | 1206 | assert(delimiter.len != 0); |
| 1209 | 1207 | return SplitIterator{ |
| 1210 | 1208 | .index = 0, |
| ... | ... | @@ -1213,30 +1211,32 @@ pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator { |
| 1213 | 1211 | }; |
| 1214 | 1212 | } |
| 1215 | 1213 | |
| 1216 | test "mem.separate" { | |
| 1217 | var it = separate("abc|def||ghi", "|"); | |
| 1214 | pub const separate = @compileError("deprecated: renamed to split (behavior remains unchanged)"); | |
| 1215 | ||
| 1216 | test "mem.split" { | |
| 1217 | var it = split("abc|def||ghi", "|"); | |
| 1218 | 1218 | testing.expect(eql(u8, it.next().?, "abc")); |
| 1219 | 1219 | testing.expect(eql(u8, it.next().?, "def")); |
| 1220 | 1220 | testing.expect(eql(u8, it.next().?, "")); |
| 1221 | 1221 | testing.expect(eql(u8, it.next().?, "ghi")); |
| 1222 | 1222 | testing.expect(it.next() == null); |
| 1223 | 1223 | |
| 1224 | it = separate("", "|"); | |
| 1224 | it = split("", "|"); | |
| 1225 | 1225 | testing.expect(eql(u8, it.next().?, "")); |
| 1226 | 1226 | testing.expect(it.next() == null); |
| 1227 | 1227 | |
| 1228 | it = separate("|", "|"); | |
| 1228 | it = split("|", "|"); | |
| 1229 | 1229 | testing.expect(eql(u8, it.next().?, "")); |
| 1230 | 1230 | testing.expect(eql(u8, it.next().?, "")); |
| 1231 | 1231 | testing.expect(it.next() == null); |
| 1232 | 1232 | |
| 1233 | it = separate("hello", " "); | |
| 1233 | it = split("hello", " "); | |
| 1234 | 1234 | testing.expect(eql(u8, it.next().?, "hello")); |
| 1235 | 1235 | testing.expect(it.next() == null); |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | test "mem.separate (multibyte)" { | |
| 1239 | var it = separate("a, b ,, c, d, e", ", "); | |
| 1238 | test "mem.split (multibyte)" { | |
| 1239 | var it = split("a, b ,, c, d, e", ", "); | |
| 1240 | 1240 | testing.expect(eql(u8, it.next().?, "a")); |
| 1241 | 1241 | testing.expect(eql(u8, it.next().?, "b ,")); |
| 1242 | 1242 | testing.expect(eql(u8, it.next().?, "c")); |
lib/std/net.zig+3-3| ... | ... | @@ -823,7 +823,7 @@ fn linuxLookupNameFromHosts( |
| 823 | 823 | }, |
| 824 | 824 | else => |e| return e, |
| 825 | 825 | }) |line| { |
| 826 | const no_comment_line = mem.separate(line, "#").next().?; | |
| 826 | const no_comment_line = mem.split(line, "#").next().?; | |
| 827 | 827 | |
| 828 | 828 | var line_it = mem.tokenize(no_comment_line, " \t"); |
| 829 | 829 | const ip_text = line_it.next() orelse continue; |
| ... | ... | @@ -1020,13 +1020,13 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void { |
| 1020 | 1020 | }, |
| 1021 | 1021 | else => |e| return e, |
| 1022 | 1022 | }) |line| { |
| 1023 | const no_comment_line = mem.separate(line, "#").next().?; | |
| 1023 | const no_comment_line = mem.split(line, "#").next().?; | |
| 1024 | 1024 | var line_it = mem.tokenize(no_comment_line, " \t"); |
| 1025 | 1025 | |
| 1026 | 1026 | const token = line_it.next() orelse continue; |
| 1027 | 1027 | if (mem.eql(u8, token, "options")) { |
| 1028 | 1028 | while (line_it.next()) |sub_tok| { |
| 1029 | var colon_it = mem.separate(sub_tok, ":"); | |
| 1029 | var colon_it = mem.split(sub_tok, ":"); | |
| 1030 | 1030 | const name = colon_it.next().?; |
| 1031 | 1031 | const value_txt = colon_it.next() orelse continue; |
| 1032 | 1032 | const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) { |
lib/std/process.zig+1-1| ... | ... | @@ -84,7 +84,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { |
| 84 | 84 | for (environ) |env| { |
| 85 | 85 | if (env) |ptr| { |
| 86 | 86 | const pair = mem.spanZ(ptr); |
| 87 | var parts = mem.separate(pair, "="); | |
| 87 | var parts = mem.split(pair, "="); | |
| 88 | 88 | const key = parts.next().?; |
| 89 | 89 | const value = parts.next().?; |
| 90 | 90 | try result.set(key, value); |
lib/std/zig/cross_target.zig+5-5| ... | ... | @@ -224,7 +224,7 @@ pub const CrossTarget = struct { |
| 224 | 224 | .dynamic_linker = DynamicLinker.init(args.dynamic_linker), |
| 225 | 225 | }; |
| 226 | 226 | |
| 227 | var it = mem.separate(args.arch_os_abi, "-"); | |
| 227 | var it = mem.split(args.arch_os_abi, "-"); | |
| 228 | 228 | const arch_name = it.next().?; |
| 229 | 229 | const arch_is_native = mem.eql(u8, arch_name, "native"); |
| 230 | 230 | if (!arch_is_native) { |
| ... | ... | @@ -242,7 +242,7 @@ pub const CrossTarget = struct { |
| 242 | 242 | |
| 243 | 243 | const opt_abi_text = it.next(); |
| 244 | 244 | if (opt_abi_text) |abi_text| { |
| 245 | var abi_it = mem.separate(abi_text, "."); | |
| 245 | var abi_it = mem.split(abi_text, "."); | |
| 246 | 246 | const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse |
| 247 | 247 | return error.UnknownApplicationBinaryInterface; |
| 248 | 248 | result.abi = abi; |
| ... | ... | @@ -668,7 +668,7 @@ pub const CrossTarget = struct { |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void { |
| 671 | var it = mem.separate(text, "."); | |
| 671 | var it = mem.split(text, "."); | |
| 672 | 672 | const os_name = it.next().?; |
| 673 | 673 | diags.os_name = os_name; |
| 674 | 674 | const os_is_native = mem.eql(u8, os_name, "native"); |
| ... | ... | @@ -722,7 +722,7 @@ pub const CrossTarget = struct { |
| 722 | 722 | .linux, |
| 723 | 723 | .dragonfly, |
| 724 | 724 | => { |
| 725 | var range_it = mem.separate(version_text, "..."); | |
| 725 | var range_it = mem.split(version_text, "..."); | |
| 726 | 726 | |
| 727 | 727 | const min_text = range_it.next().?; |
| 728 | 728 | const min_ver = SemVer.parse(min_text) catch |err| switch (err) { |
| ... | ... | @@ -742,7 +742,7 @@ pub const CrossTarget = struct { |
| 742 | 742 | }, |
| 743 | 743 | |
| 744 | 744 | .windows => { |
| 745 | var range_it = mem.separate(version_text, "..."); | |
| 745 | var range_it = mem.split(version_text, "..."); | |
| 746 | 746 | |
| 747 | 747 | const min_text = range_it.next().?; |
| 748 | 748 | const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse |
src-self-hosted/libc_installation.zig+1-1| ... | ... | @@ -61,7 +61,7 @@ pub const LibCInstallation = struct { |
| 61 | 61 | var it = std.mem.tokenize(contents, "\n"); |
| 62 | 62 | while (it.next()) |line| { |
| 63 | 63 | if (line.len == 0 or line[0] == '#') continue; |
| 64 | var line_it = std.mem.separate(line, "="); | |
| 64 | var line_it = std.mem.split(line, "="); | |
| 65 | 65 | const name = line_it.next() orelse { |
| 66 | 66 | try stderr.print("missing equal sign after field name\n", .{}); |
| 67 | 67 | return error.ParseError; |
src-self-hosted/main.zig+1-1| ... | ... | @@ -403,7 +403,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 403 | 403 | const root_name = if (provided_name) |n| n else blk: { |
| 404 | 404 | if (root_src_file) |file| { |
| 405 | 405 | const basename = fs.path.basename(file); |
| 406 | var it = mem.separate(basename, "."); | |
| 406 | var it = mem.split(basename, "."); | |
| 407 | 407 | break :blk it.next() orelse basename; |
| 408 | 408 | } else { |
| 409 | 409 | try stderr.writeAll("--name [name] not provided and unable to infer\n"); |
test/tests.zig+2-2| ... | ... | @@ -657,7 +657,7 @@ pub const StackTracesContext = struct { |
| 657 | 657 | var buf = ArrayList(u8).init(b.allocator); |
| 658 | 658 | defer buf.deinit(); |
| 659 | 659 | if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1]; |
| 660 | var it = mem.separate(stderr, "\n"); | |
| 660 | var it = mem.split(stderr, "\n"); | |
| 661 | 661 | process_lines: while (it.next()) |line| { |
| 662 | 662 | if (line.len == 0) continue; |
| 663 | 663 | const delims = [_][]const u8{ ":", ":", ":", " in " }; |
| ... | ... | @@ -750,7 +750,7 @@ pub const CompileErrorContext = struct { |
| 750 | 750 | const source_file = "tmp.zig"; |
| 751 | 751 | |
| 752 | 752 | fn init(input: []const u8) ErrLineIter { |
| 753 | return ErrLineIter{ .lines = mem.separate(input, "\n") }; | |
| 753 | return ErrLineIter{ .lines = mem.split(input, "\n") }; | |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | fn next(self: *ErrLineIter) ?[]const u8 { |