}
else {
/* We have something like bla../, so we need to copy it as is */
-
- if (slash) {
- *o ++ = '/';
- }
- if (dot && p > dot) {
+ if (o > path && dot && p > dot) {
memcpy (o, dot, p - dot);
o += p - dot;
}
o = (gchar *)slash;
}
}
+ else {
+ /* Corner case */
+ if (o == path) {
+ *o++ = '/';
+ }
+ else {
+ if (dot && p > dot) {
+ memmove (o, dot, p - dot);
+ o += p - dot;
+ }
+ }
+ }
break;
case st_got_slash:
*o++ = '/';
{"/foo/../../..", "/"},
{"/foo/../../../ton", "/ton"},
{"////../..", "/"},
+ {"./", ""},
+ {"/./", "/"},
+ {"/./././././././", "/"},
+ {"/", "/"},
+ {"/a/b", "/a/b"},
+ {"/a/b/", "/a/b/"},
+ {"..", "/"},
+ {"/../", "/"},
+ {"../", "/"},
}
for _,v in ipairs(cases) do
- print(v[1])
local buf = ffi.new("uint8_t[?]", #v[1])
local sizbuf = ffi.new("size_t[1]")
ffi.copy(buf, v[1], #v[1])