authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-05-06 21:47:56-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-05-13 13:45:05-07:00
log104f4053a2c3c6a1a2bf801ca5bf88ce4fee7a2a
tree32685a5d9a662b5ff8849c9b768256b18940f789
parent2129f28953b72da2f1bb58ff063a044d737c59c4

std.mem: Rename splitFull/tokenizeFull to splitSequence/tokenizeSequence

I think this makes the name less ambiguous and more obvious that the suffix applies to the `delimiter`.

4 files changed, 62 insertions(+), 62 deletions(-)

lib/std/mem.zig+57-57
...@@ -1910,7 +1910,7 @@ test "byteSwapAllFields" {...@@ -1910,7 +1910,7 @@ test "byteSwapAllFields" {
1910 }, s);1910 }, s);
1911}1911}
19121912
1913/// Deprecated: use `tokenizeAny`, `tokenizeFull`, or `tokenizeScalar`1913/// Deprecated: use `tokenizeAny`, `tokenizeSequence`, or `tokenizeScalar`
1914pub const tokenize = tokenizeAny;1914pub const tokenize = tokenizeAny;
19151915
1916/// Returns an iterator that iterates over the slices of `buffer` that are not1916/// Returns an iterator that iterates over the slices of `buffer` that are not
...@@ -1923,9 +1923,9 @@ pub const tokenize = tokenizeAny;...@@ -1923,9 +1923,9 @@ pub const tokenize = tokenizeAny;
1923/// If none of `delimiters` exist in buffer,1923/// If none of `delimiters` exist in buffer,
1924/// the iterator will return `buffer`, null, in that order.1924/// the iterator will return `buffer`, null, in that order.
1925///1925///
1926/// See also: `tokenizeFull`, `tokenizeScalar`,1926/// See also: `tokenizeSequence`, `tokenizeScalar`,
1927/// `splitFull`,`splitAny`, `splitScalar`,1927/// `splitSequence`,`splitAny`, `splitScalar`,
1928/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`1928/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
1929pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any) {1929pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any) {
1930 return .{1930 return .{
1931 .index = 0,1931 .index = 0,
...@@ -1937,7 +1937,7 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T...@@ -1937,7 +1937,7 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T
1937/// Returns an iterator that iterates over the slices of `buffer` that are not1937/// Returns an iterator that iterates over the slices of `buffer` that are not
1938/// the sequence in `delimiter`.1938/// the sequence in `delimiter`.
1939///1939///
1940/// `tokenizeFull(u8, "<>abc><def<><>ghi", "<>")` will return slices1940/// `tokenizeSequence(u8, "<>abc><def<><>ghi", "<>")` will return slices
1941/// for "abc><def", "ghi", null, in that order.1941/// for "abc><def", "ghi", null, in that order.
1942///1942///
1943/// If `buffer` is empty, the iterator will return null.1943/// If `buffer` is empty, the iterator will return null.
...@@ -1946,9 +1946,9 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T...@@ -1946,9 +1946,9 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T
1946/// The delimiter length must not be zero.1946/// The delimiter length must not be zero.
1947///1947///
1948/// See also: `tokenizeAny`, `tokenizeScalar`,1948/// See also: `tokenizeAny`, `tokenizeScalar`,
1949/// `splitFull`,`splitAny`, and `splitScalar`1949/// `splitSequence`,`splitAny`, and `splitScalar`
1950/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`1950/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
1951pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .full) {1951pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence) {
1952 assert(delimiter.len != 0);1952 assert(delimiter.len != 0);
1953 return .{1953 return .{
1954 .index = 0,1954 .index = 0,
...@@ -1967,9 +1967,9 @@ pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) T...@@ -1967,9 +1967,9 @@ pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) T
1967/// If `delimiter` does not exist in buffer,1967/// If `delimiter` does not exist in buffer,
1968/// the iterator will return `buffer`, null, in that order.1968/// the iterator will return `buffer`, null, in that order.
1969///1969///
1970/// See also: `tokenizeAny`, `tokenizeFull`,1970/// See also: `tokenizeAny`, `tokenizeSequence`,
1971/// `splitFull`,`splitAny`, and `splitScalar`1971/// `splitSequence`,`splitAny`, and `splitScalar`
1972/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`1972/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
1973pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar) {1973pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar) {
1974 return .{1974 return .{
1975 .index = 0,1975 .index = 0,
...@@ -2019,7 +2019,7 @@ test "tokenizeScalar" {...@@ -2019,7 +2019,7 @@ test "tokenizeScalar" {
2019 try testing.expect(it16.next() == null);2019 try testing.expect(it16.next() == null);
2020}2020}
20212021
2022test "tokenizeAny (multibyte)" {2022test "tokenizeAny" {
2023 var it = tokenizeAny(u8, "a|b,c/d e", " /,|");2023 var it = tokenizeAny(u8, "a|b,c/d e", " /,|");
2024 try testing.expect(eql(u8, it.next().?, "a"));2024 try testing.expect(eql(u8, it.next().?, "a"));
2025 try testing.expect(eql(u8, it.peek().?, "b"));2025 try testing.expect(eql(u8, it.peek().?, "b"));
...@@ -2047,8 +2047,8 @@ test "tokenizeAny (multibyte)" {...@@ -2047,8 +2047,8 @@ test "tokenizeAny (multibyte)" {
2047 try testing.expect(it16.next() == null);2047 try testing.expect(it16.next() == null);
2048}2048}
20492049
2050test "tokenizeFull" {2050test "tokenizeSequence" {
2051 var it = tokenizeFull(u8, "a<>b<><>c><>d><", "<>");2051 var it = tokenizeSequence(u8, "a<>b<><>c><>d><", "<>");
2052 try testing.expectEqualStrings("a", it.next().?);2052 try testing.expectEqualStrings("a", it.next().?);
2053 try testing.expectEqualStrings("b", it.peek().?);2053 try testing.expectEqualStrings("b", it.peek().?);
2054 try testing.expectEqualStrings("b", it.next().?);2054 try testing.expectEqualStrings("b", it.next().?);
...@@ -2057,7 +2057,7 @@ test "tokenizeFull" {...@@ -2057,7 +2057,7 @@ test "tokenizeFull" {
2057 try testing.expect(it.next() == null);2057 try testing.expect(it.next() == null);
2058 try testing.expect(it.peek() == null);2058 try testing.expect(it.peek() == null);
20592059
2060 var it16 = tokenizeFull(2060 var it16 = tokenizeSequence(
2061 u16,2061 u16,
2062 std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"),2062 std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"),
2063 std.unicode.utf8ToUtf16LeStringLiteral("<>"),2063 std.unicode.utf8ToUtf16LeStringLiteral("<>"),
...@@ -2084,7 +2084,7 @@ test "tokenize (reset)" {...@@ -2084,7 +2084,7 @@ test "tokenize (reset)" {
2084 try testing.expect(it.next() == null);2084 try testing.expect(it.next() == null);
2085 }2085 }
2086 {2086 {
2087 var it = tokenizeFull(u8, "<><>abc<>def<><>ghi<>", "<>");2087 var it = tokenizeSequence(u8, "<><>abc<>def<><>ghi<>", "<>");
2088 try testing.expect(eql(u8, it.next().?, "abc"));2088 try testing.expect(eql(u8, it.next().?, "abc"));
2089 try testing.expect(eql(u8, it.next().?, "def"));2089 try testing.expect(eql(u8, it.next().?, "def"));
2090 try testing.expect(eql(u8, it.next().?, "ghi"));2090 try testing.expect(eql(u8, it.next().?, "ghi"));
...@@ -2111,23 +2111,23 @@ test "tokenize (reset)" {...@@ -2111,23 +2111,23 @@ test "tokenize (reset)" {
2111 }2111 }
2112}2112}
21132113
2114/// Deprecated: use `splitFull`, `splitAny`, or `splitScalar`2114/// Deprecated: use `splitSequence`, `splitAny`, or `splitScalar`
2115pub const split = splitFull;2115pub const split = splitSequence;
21162116
2117/// Returns an iterator that iterates over the slices of `buffer` that2117/// Returns an iterator that iterates over the slices of `buffer` that
2118/// are separated by the byte sequence in `delimiter`.2118/// are separated by the byte sequence in `delimiter`.
2119///2119///
2120/// `splitFull(u8, "abc||def||||ghi", "||")` will return slices2120/// `splitSequence(u8, "abc||def||||ghi", "||")` will return slices
2121/// for "abc", "def", "", "ghi", null, in that order.2121/// for "abc", "def", "", "ghi", null, in that order.
2122///2122///
2123/// If `delimiter` does not exist in buffer,2123/// If `delimiter` does not exist in buffer,
2124/// the iterator will return `buffer`, null, in that order.2124/// the iterator will return `buffer`, null, in that order.
2125/// The delimiter length must not be zero.2125/// The delimiter length must not be zero.
2126///2126///
2127/// See also: `splitAny`, `splitScalar`, `splitBackwardsFull`,2127/// See also: `splitAny`, `splitScalar`, `splitBackwardsSequence`,
2128/// `splitBackwardsAny`,`splitBackwardsScalar`,2128/// `splitBackwardsAny`,`splitBackwardsScalar`,
2129/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.2129/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2130pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .full) {2130pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence) {
2131 assert(delimiter.len != 0);2131 assert(delimiter.len != 0);
2132 return .{2132 return .{
2133 .index = 0,2133 .index = 0,
...@@ -2145,9 +2145,9 @@ pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) Spli...@@ -2145,9 +2145,9 @@ pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) Spli
2145/// If none of `delimiters` exist in buffer,2145/// If none of `delimiters` exist in buffer,
2146/// the iterator will return `buffer`, null, in that order.2146/// the iterator will return `buffer`, null, in that order.
2147///2147///
2148/// See also: `splitFull`, `splitScalar`, `splitBackwardsFull`,2148/// See also: `splitSequence`, `splitScalar`, `splitBackwardsSequence`,
2149/// `splitBackwardsAny`,`splitBackwardsScalar`,2149/// `splitBackwardsAny`,`splitBackwardsScalar`,
2150/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.2150/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2151pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any) {2151pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any) {
2152 return .{2152 return .{
2153 .index = 0,2153 .index = 0,
...@@ -2165,9 +2165,9 @@ pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) Spli...@@ -2165,9 +2165,9 @@ pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) Spli
2165/// If `delimiter` does not exist in buffer,2165/// If `delimiter` does not exist in buffer,
2166/// the iterator will return `buffer`, null, in that order.2166/// the iterator will return `buffer`, null, in that order.
2167///2167///
2168/// See also: `splitFull`, `splitAny`, `splitBackwardsFull`,2168/// See also: `splitSequence`, `splitAny`, `splitBackwardsSequence`,
2169/// `splitBackwardsAny`,`splitBackwardsScalar`,2169/// `splitBackwardsAny`,`splitBackwardsScalar`,
2170/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.2170/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2171pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar) {2171pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar) {
2172 return .{2172 return .{
2173 .index = 0,2173 .index = 0,
...@@ -2215,8 +2215,8 @@ test "splitScalar" {...@@ -2215,8 +2215,8 @@ test "splitScalar" {
2215 try testing.expect(it16.next() == null);2215 try testing.expect(it16.next() == null);
2216}2216}
22172217
2218test "splitFull (multibyte)" {2218test "splitSequence" {
2219 var it = splitFull(u8, "a, b ,, c, d, e", ", ");2219 var it = splitSequence(u8, "a, b ,, c, d, e", ", ");
2220 try testing.expectEqualSlices(u8, it.first(), "a");2220 try testing.expectEqualSlices(u8, it.first(), "a");
2221 try testing.expectEqualSlices(u8, it.rest(), "b ,, c, d, e");2221 try testing.expectEqualSlices(u8, it.rest(), "b ,, c, d, e");
2222 try testing.expectEqualSlices(u8, it.next().?, "b ,");2222 try testing.expectEqualSlices(u8, it.next().?, "b ,");
...@@ -2225,7 +2225,7 @@ test "splitFull (multibyte)" {...@@ -2225,7 +2225,7 @@ test "splitFull (multibyte)" {
2225 try testing.expectEqualSlices(u8, it.next().?, "e");2225 try testing.expectEqualSlices(u8, it.next().?, "e");
2226 try testing.expect(it.next() == null);2226 try testing.expect(it.next() == null);
22272227
2228 var it16 = splitFull(2228 var it16 = splitSequence(
2229 u16,2229 u16,
2230 std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),2230 std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),
2231 std.unicode.utf8ToUtf16LeStringLiteral(", "),2231 std.unicode.utf8ToUtf16LeStringLiteral(", "),
...@@ -2269,7 +2269,7 @@ test "splitAny" {...@@ -2269,7 +2269,7 @@ test "splitAny" {
22692269
2270test "split (reset)" {2270test "split (reset)" {
2271 {2271 {
2272 var it = splitFull(u8, "abc def ghi", " ");2272 var it = splitSequence(u8, "abc def ghi", " ");
2273 try testing.expect(eql(u8, it.first(), "abc"));2273 try testing.expect(eql(u8, it.first(), "abc"));
2274 try testing.expect(eql(u8, it.next().?, "def"));2274 try testing.expect(eql(u8, it.next().?, "def"));
2275 try testing.expect(eql(u8, it.next().?, "ghi"));2275 try testing.expect(eql(u8, it.next().?, "ghi"));
...@@ -2309,13 +2309,13 @@ test "split (reset)" {...@@ -2309,13 +2309,13 @@ test "split (reset)" {
2309 }2309 }
2310}2310}
23112311
2312/// Deprecated: use `splitBackwardsFull`, `splitBackwardsAny`, or `splitBackwardsScalar`2312/// Deprecated: use `splitBackwardsSequence`, `splitBackwardsAny`, or `splitBackwardsScalar`
2313pub const splitBackwards = splitBackwardsFull;2313pub const splitBackwards = splitBackwardsSequence;
23142314
2315/// Returns an iterator that iterates backwards over the slices of `buffer` that2315/// Returns an iterator that iterates backwards over the slices of `buffer` that
2316/// are separated by the sequence in `delimiter`.2316/// are separated by the sequence in `delimiter`.
2317///2317///
2318/// `splitBackwardsFull(u8, "abc||def||||ghi", "||")` will return slices2318/// `splitBackwardsSequence(u8, "abc||def||||ghi", "||")` will return slices
2319/// for "ghi", "", "def", "abc", null, in that order.2319/// for "ghi", "", "def", "abc", null, in that order.
2320///2320///
2321/// If `delimiter` does not exist in buffer,2321/// If `delimiter` does not exist in buffer,
...@@ -2323,9 +2323,9 @@ pub const splitBackwards = splitBackwardsFull;...@@ -2323,9 +2323,9 @@ pub const splitBackwards = splitBackwardsFull;
2323/// The delimiter length must not be zero.2323/// The delimiter length must not be zero.
2324///2324///
2325/// See also: `splitBackwardsAny`, `splitBackwardsScalar`,2325/// See also: `splitBackwardsAny`, `splitBackwardsScalar`,
2326/// `splitFull`, `splitAny`,`splitScalar`,2326/// `splitSequence`, `splitAny`,`splitScalar`,
2327/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.2327/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2328pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .full) {2328pub fn splitBackwardsSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .sequence) {
2329 assert(delimiter.len != 0);2329 assert(delimiter.len != 0);
2330 return .{2330 return .{
2331 .index = buffer.len,2331 .index = buffer.len,
...@@ -2343,9 +2343,9 @@ pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []cons...@@ -2343,9 +2343,9 @@ pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []cons
2343/// If none of `delimiters` exist in buffer,2343/// If none of `delimiters` exist in buffer,
2344/// the iterator will return `buffer`, null, in that order.2344/// the iterator will return `buffer`, null, in that order.
2345///2345///
2346/// See also: `splitBackwardsFull`, `splitBackwardsScalar`,2346/// See also: `splitBackwardsSequence`, `splitBackwardsScalar`,
2347/// `splitFull`, `splitAny`,`splitScalar`,2347/// `splitSequence`, `splitAny`,`splitScalar`,
2348/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.2348/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2349pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any) {2349pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any) {
2350 return .{2350 return .{
2351 .index = buffer.len,2351 .index = buffer.len,
...@@ -2363,9 +2363,9 @@ pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []cons...@@ -2363,9 +2363,9 @@ pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []cons
2363/// If `delimiter` does not exist in buffer,2363/// If `delimiter` does not exist in buffer,
2364/// the iterator will return `buffer`, null, in that order.2364/// the iterator will return `buffer`, null, in that order.
2365///2365///
2366/// See also: `splitBackwardsFull`, `splitBackwardsAny`,2366/// See also: `splitBackwardsSequence`, `splitBackwardsAny`,
2367/// `splitFull`, `splitAny`,`splitScalar`,2367/// `splitSequence`, `splitAny`,`splitScalar`,
2368/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.2368/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2369pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar) {2369pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar) {
2370 return .{2370 return .{
2371 .index = buffer.len,2371 .index = buffer.len,
...@@ -2413,8 +2413,8 @@ test "splitBackwardsScalar" {...@@ -2413,8 +2413,8 @@ test "splitBackwardsScalar" {
2413 try testing.expect(it16.next() == null);2413 try testing.expect(it16.next() == null);
2414}2414}
24152415
2416test "splitBackwardsFull (multibyte)" {2416test "splitBackwardsSequence" {
2417 var it = splitBackwardsFull(u8, "a, b ,, c, d, e", ", ");2417 var it = splitBackwardsSequence(u8, "a, b ,, c, d, e", ", ");
2418 try testing.expectEqualSlices(u8, it.rest(), "a, b ,, c, d, e");2418 try testing.expectEqualSlices(u8, it.rest(), "a, b ,, c, d, e");
2419 try testing.expectEqualSlices(u8, it.first(), "e");2419 try testing.expectEqualSlices(u8, it.first(), "e");
24202420
...@@ -2433,7 +2433,7 @@ test "splitBackwardsFull (multibyte)" {...@@ -2433,7 +2433,7 @@ test "splitBackwardsFull (multibyte)" {
2433 try testing.expectEqualSlices(u8, it.rest(), "");2433 try testing.expectEqualSlices(u8, it.rest(), "");
2434 try testing.expect(it.next() == null);2434 try testing.expect(it.next() == null);
24352435
2436 var it16 = splitBackwardsFull(2436 var it16 = splitBackwardsSequence(
2437 u16,2437 u16,
2438 std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),2438 std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),
2439 std.unicode.utf8ToUtf16LeStringLiteral(", "),2439 std.unicode.utf8ToUtf16LeStringLiteral(", "),
...@@ -2485,7 +2485,7 @@ test "splitBackwardsAny" {...@@ -2485,7 +2485,7 @@ test "splitBackwardsAny" {
24852485
2486test "splitBackwards (reset)" {2486test "splitBackwards (reset)" {
2487 {2487 {
2488 var it = splitBackwardsFull(u8, "abc def ghi", " ");2488 var it = splitBackwardsSequence(u8, "abc def ghi", " ");
2489 try testing.expect(eql(u8, it.first(), "ghi"));2489 try testing.expect(eql(u8, it.first(), "ghi"));
2490 try testing.expect(eql(u8, it.next().?, "def"));2490 try testing.expect(eql(u8, it.next().?, "def"));
2491 try testing.expect(eql(u8, it.next().?, "abc"));2491 try testing.expect(eql(u8, it.next().?, "abc"));
...@@ -2693,13 +2693,13 @@ test "endsWith" {...@@ -2693,13 +2693,13 @@ test "endsWith" {
2693 try testing.expect(!endsWith(u8, "Bob", "Bo"));2693 try testing.expect(!endsWith(u8, "Bob", "Bo"));
2694}2694}
26952695
2696pub const DelimiterType = enum { full, any, scalar };2696pub const DelimiterType = enum { sequence, any, scalar };
26972697
2698pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) type {2698pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) type {
2699 return struct {2699 return struct {
2700 buffer: []const T,2700 buffer: []const T,
2701 delimiter: switch (delimiter_type) {2701 delimiter: switch (delimiter_type) {
2702 .full, .any => []const T,2702 .sequence, .any => []const T,
2703 .scalar => T,2703 .scalar => T,
2704 },2704 },
2705 index: usize,2705 index: usize,
...@@ -2719,7 +2719,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -2719,7 +2719,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
2719 pub fn peek(self: *Self) ?[]const T {2719 pub fn peek(self: *Self) ?[]const T {
2720 // move to beginning of token2720 // move to beginning of token
2721 while (self.index < self.buffer.len and self.isDelimiter(self.index)) : (self.index += switch (delimiter_type) {2721 while (self.index < self.buffer.len and self.isDelimiter(self.index)) : (self.index += switch (delimiter_type) {
2722 .full => self.delimiter.len,2722 .sequence => self.delimiter.len,
2723 .any, .scalar => 1,2723 .any, .scalar => 1,
2724 }) {}2724 }) {}
2725 const start = self.index;2725 const start = self.index;
...@@ -2739,7 +2739,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -2739,7 +2739,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
2739 // move to beginning of token2739 // move to beginning of token
2740 var index: usize = self.index;2740 var index: usize = self.index;
2741 while (index < self.buffer.len and self.isDelimiter(index)) : (index += switch (delimiter_type) {2741 while (index < self.buffer.len and self.isDelimiter(index)) : (index += switch (delimiter_type) {
2742 .full => self.delimiter.len,2742 .sequence => self.delimiter.len,
2743 .any, .scalar => 1,2743 .any, .scalar => 1,
2744 }) {}2744 }) {}
2745 return self.buffer[index..];2745 return self.buffer[index..];
...@@ -2752,7 +2752,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -2752,7 +2752,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27522752
2753 fn isDelimiter(self: Self, index: usize) bool {2753 fn isDelimiter(self: Self, index: usize) bool {
2754 switch (delimiter_type) {2754 switch (delimiter_type) {
2755 .full => return startsWith(T, self.buffer[index..], self.delimiter),2755 .sequence => return startsWith(T, self.buffer[index..], self.delimiter),
2756 .any => {2756 .any => {
2757 const item = self.buffer[index];2757 const item = self.buffer[index];
2758 for (self.delimiter) |delimiter_item| {2758 for (self.delimiter) |delimiter_item| {
...@@ -2773,7 +2773,7 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -2773,7 +2773,7 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
2773 buffer: []const T,2773 buffer: []const T,
2774 index: ?usize,2774 index: ?usize,
2775 delimiter: switch (delimiter_type) {2775 delimiter: switch (delimiter_type) {
2776 .full, .any => []const T,2776 .sequence, .any => []const T,
2777 .scalar => T,2777 .scalar => T,
2778 },2778 },
27792779
...@@ -2790,12 +2790,12 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t...@@ -2790,12 +2790,12 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
2790 pub fn next(self: *Self) ?[]const T {2790 pub fn next(self: *Self) ?[]const T {
2791 const start = self.index orelse return null;2791 const start = self.index orelse return null;
2792 const end = if (switch (delimiter_type) {2792 const end = if (switch (delimiter_type) {
2793 .full => indexOfPos(T, self.buffer, start, self.delimiter),2793 .sequence => indexOfPos(T, self.buffer, start, self.delimiter),
2794 .any => indexOfAnyPos(T, self.buffer, start, self.delimiter),2794 .any => indexOfAnyPos(T, self.buffer, start, self.delimiter),
2795 .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),2795 .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),
2796 }) |delim_start| blk: {2796 }) |delim_start| blk: {
2797 self.index = delim_start + switch (delimiter_type) {2797 self.index = delim_start + switch (delimiter_type) {
2798 .full => self.delimiter.len,2798 .sequence => self.delimiter.len,
2799 .any, .scalar => 1,2799 .any, .scalar => 1,
2800 };2800 };
2801 break :blk delim_start;2801 break :blk delim_start;
...@@ -2825,7 +2825,7 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit...@@ -2825,7 +2825,7 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
2825 buffer: []const T,2825 buffer: []const T,
2826 index: ?usize,2826 index: ?usize,
2827 delimiter: switch (delimiter_type) {2827 delimiter: switch (delimiter_type) {
2828 .full, .any => []const T,2828 .sequence, .any => []const T,
2829 .scalar => T,2829 .scalar => T,
2830 },2830 },
28312831
...@@ -2842,13 +2842,13 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit...@@ -2842,13 +2842,13 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
2842 pub fn next(self: *Self) ?[]const T {2842 pub fn next(self: *Self) ?[]const T {
2843 const end = self.index orelse return null;2843 const end = self.index orelse return null;
2844 const start = if (switch (delimiter_type) {2844 const start = if (switch (delimiter_type) {
2845 .full => lastIndexOf(T, self.buffer[0..end], self.delimiter),2845 .sequence => lastIndexOf(T, self.buffer[0..end], self.delimiter),
2846 .any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter),2846 .any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter),
2847 .scalar => lastIndexOfScalar(T, self.buffer[0..end], self.delimiter),2847 .scalar => lastIndexOfScalar(T, self.buffer[0..end], self.delimiter),
2848 }) |delim_start| blk: {2848 }) |delim_start| blk: {
2849 self.index = delim_start;2849 self.index = delim_start;
2850 break :blk delim_start + switch (delimiter_type) {2850 break :blk delim_start + switch (delimiter_type) {
2851 .full => self.delimiter.len,2851 .sequence => self.delimiter.len,
2852 .any, .scalar => 1,2852 .any, .scalar => 1,
2853 };2853 };
2854 } else blk: {2854 } else blk: {
lib/std/zig/CrossTarget.zig+2-2
...@@ -706,7 +706,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const...@@ -706,7 +706,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
706 .linux,706 .linux,
707 .dragonfly,707 .dragonfly,
708 => {708 => {
709 var range_it = mem.splitFull(u8, version_text, "...");709 var range_it = mem.splitSequence(u8, version_text, "...");
710710
711 const min_text = range_it.next().?;711 const min_text = range_it.next().?;
712 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {712 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {
...@@ -726,7 +726,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const...@@ -726,7 +726,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
726 },726 },
727727
728 .windows => {728 .windows => {
729 var range_it = mem.splitFull(u8, version_text, "...");729 var range_it = mem.splitSequence(u8, version_text, "...");
730730
731 const min_text = range_it.first();731 const min_text = range_it.first();
732 const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse732 const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse
src/Compilation.zig+2-2
...@@ -5016,14 +5016,14 @@ fn parseLldStderr(comp: *Compilation, comptime prefix: []const u8, stderr: []con...@@ -5016,14 +5016,14 @@ fn parseLldStderr(comp: *Compilation, comptime prefix: []const u8, stderr: []con
5016 defer context_lines.deinit();5016 defer context_lines.deinit();
50175017
5018 var current_err: ?*LldError = null;5018 var current_err: ?*LldError = null;
5019 var lines = mem.splitFull(u8, stderr, std.cstr.line_sep);5019 var lines = mem.splitSequence(u8, stderr, std.cstr.line_sep);
5020 while (lines.next()) |line| {5020 while (lines.next()) |line| {
5021 if (mem.startsWith(u8, line, prefix ++ ":")) {5021 if (mem.startsWith(u8, line, prefix ++ ":")) {
5022 if (current_err) |err| {5022 if (current_err) |err| {
5023 err.context_lines = try context_lines.toOwnedSlice();5023 err.context_lines = try context_lines.toOwnedSlice();
5024 }5024 }
50255025
5026 var split = std.mem.splitFull(u8, line, "error: ");5026 var split = std.mem.splitSequence(u8, line, "error: ");
5027 _ = split.first();5027 _ = split.first();
50285028
5029 const duped_msg = try std.fmt.allocPrint(comp.gpa, "{s}: {s}", .{ prefix, split.rest() });5029 const duped_msg = try std.fmt.allocPrint(comp.gpa, "{s}: {s}", .{ prefix, split.rest() });
tools/update_crc_catalog.zig+1-1
...@@ -78,7 +78,7 @@ pub fn main() anyerror!void {...@@ -78,7 +78,7 @@ pub fn main() anyerror!void {
78 var residue: []const u8 = undefined;78 var residue: []const u8 = undefined;
79 var name: []const u8 = undefined;79 var name: []const u8 = undefined;
8080
81 var it = mem.splitFull(u8, line, " ");81 var it = mem.splitSequence(u8, line, " ");
82 while (it.next()) |property| {82 while (it.next()) |property| {
83 const i = mem.indexOf(u8, property, "=").?;83 const i = mem.indexOf(u8, property, "=").?;
84 const key = property[0..i];84 const key = property[0..i];