mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- Fix appending to c:\ or \ #2569.
This commit is contained in:
@@ -186,13 +186,11 @@ fn bool Path.equals(self, Path p2) @operator(==)
|
||||
fn Path? Path.append(self, Allocator allocator, String filename)
|
||||
{
|
||||
if (!self.path_string.len) return new(allocator, filename, self.env)!;
|
||||
assert(!is_separator(self.path_string[^1], self.env));
|
||||
|
||||
@pool()
|
||||
{
|
||||
DString dstr = dstring::temp_with_capacity(self.path_string.len + 1 + filename.len);
|
||||
dstr.append(self.path_string);
|
||||
dstr.append(PREFERRED_SEPARATOR);
|
||||
if (!is_separator(self.path_string[^1], self.env)) dstr.append(PREFERRED_SEPARATOR);
|
||||
dstr.append(filename);
|
||||
return new(allocator, dstr.str_view(), self.env);
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
- Passing a compile time type implicitly converted to a typeid would crash instead of producing an error. #2568
|
||||
- Compiler assert with const enum based on vector #2566
|
||||
- Fix to `Path` handling `c:\foo` and `\home` parent. #2569
|
||||
- Fix appending to `c:\` or `\` #2569.
|
||||
|
||||
### Stdlib changes
|
||||
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
module std::io::path @test;
|
||||
|
||||
fn void test_append()
|
||||
{
|
||||
Path p = path::new(mem, "/", POSIX)!!;
|
||||
Path p2 = p.append(mem, "hello")!!;
|
||||
test::eq(p2.str_view(), "/hello");
|
||||
p.free();
|
||||
p2.free();
|
||||
p = path::new(mem, "c:\\", WIN32)!!;
|
||||
p2 = p.append(mem, "hello")!!;
|
||||
assert(p2.str_view() == "c:\\hello");
|
||||
p.free();
|
||||
p2.free();
|
||||
}
|
||||
fn void test_dot()
|
||||
{
|
||||
Path p = path::new(mem, ".")!!;
|
||||
|
||||
Reference in New Issue
Block a user