authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-02-04 23:35:22-07:00
committergravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-05-11 18:41:23-06:00
log1c874a871fe4795f71edf6e9739b72d071eb453a
tree3d829ce8be5e9e1bf48faeccdbc2d8f5d138f54b
parente65d8f82c5f98b20236f571fe4a4e40924ea8dc2

reverse some of the now unneeded changes from squeek


3 files changed, 7 insertions(+), 28 deletions(-)

lib/std/buf_map.zig+1-1
......@@ -9,7 +9,7 @@ const testing = std.testing;
99pub const BufMap = struct {
1010 hash_map: BufMapHashMap,
1111
12 pub const BufMapHashMap = StringHashMap([]const u8);
12 const BufMapHashMap = StringHashMap([]const u8);
1313
1414 /// Create a BufMap backed by a specific allocator.
1515 /// That allocator will be used for both backing allocations
lib/std/process.zig+6-4
......@@ -255,19 +255,21 @@ pub fn getEnvMap(allocator: Allocator) !EnvMap {
255255
256256 while (ptr[i] != 0 and ptr[i] != '=') : (i += 1) {}
257257 const key_w = ptr[key_start..i];
258 const key = try std.unicode.utf16leToUtf8Alloc(allocator, key_w);
259 errdefer allocator.free(key);
258260
259261 if (ptr[i] == '=') i += 1;
260262
261263 const value_start = i;
262264 while (ptr[i] != 0) : (i += 1) {}
263265 const value_w = ptr[value_start..i];
264
265 try result.storage.putUtf16NoClobber(key_w, value_w);
266 const value = try std.unicode.utf16leToUtf8Alloc(allocator, value_w);
267 errdefer allocator.free(value);
266268
267269 i += 1; // skip over null byte
268 }
269270
270 try result.storage.reallocUppercaseBuf();
271 try result.putMove(key, value);
272 }
271273 return result;
272274 } else if (builtin.os.tag == .wasi and !builtin.link_libc) {
273275 var environ_count: usize = undefined;
lib/std/unicode.zig-23
......@@ -710,29 +710,6 @@ pub fn utf8ToUtf16Le(utf16le: []u16, utf8: []const u8) !usize {
710710 return dest_i;
711711}
712712
713pub fn utf8ToUtf16LeWriter(writer: anytype, utf8: []const u8) !usize {
714 var src_i: usize = 0;
715 var bytes_written: usize = 0;
716 while (src_i < utf8.len) {
717 const n = utf8ByteSequenceLength(utf8[src_i]) catch return error.InvalidUtf8;
718 const next_src_i = src_i + n;
719 const codepoint = utf8Decode(utf8[src_i..next_src_i]) catch return error.InvalidUtf8;
720 if (codepoint < 0x10000) {
721 const short = @intCast(u16, codepoint);
722 try writer.writeIntLittle(u16, short);
723 bytes_written += 2;
724 } else {
725 const high = @intCast(u16, (codepoint - 0x10000) >> 10) + 0xD800;
726 const low = @intCast(u16, codepoint & 0x3FF) + 0xDC00;
727 try writer.writeIntLittle(u16, high);
728 try writer.writeIntLittle(u16, low);
729 bytes_written += 4;
730 }
731 src_i = next_src_i;
732 }
733 return bytes_written;
734}
735
736713test "utf8ToUtf16Le" {
737714 var utf16le: [2]u16 = [_]u16{0} ** 2;
738715 {