aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtins/path.c13
-rw-r--r--environment.c1
2 files changed, 9 insertions, 5 deletions
diff --git a/builtins/path.c b/builtins/path.c
index 7c9df396..caabf2ab 100644
--- a/builtins/path.c
+++ b/builtins/path.c
@@ -325,19 +325,24 @@ public Text_t Path$write_unique(Path_t path, Text_t text)
public Path_t Path$parent(Path_t path)
{
- return Text$replace(path, Pattern("{..}/{!/}{end}"), Text("@1"), Text("@"), false);
+ return Text$replace(path, Pattern("{0+..}/{!/}{end}"), Text("@1"), Text("@"), false);
}
public Text_t Path$base_name(Path_t path)
{
- return Text$replace(path, Pattern("{..}/{!/}{end}"), Text("@2"), Text("@"), false);
+ if (Text$matches(path, Pattern("/{end}")))
+ return Text$replace(path, Pattern("{0+..}/{!/}/{end}"), Text("@2"), Text("@"), false);
+ else
+ return Text$replace(path, Pattern("{0+..}/{!/}{end}"), Text("@2"), Text("@"), false);
}
public Text_t Path$extension(Path_t path, bool full)
{
Text_t base = Path$base_name(path);
- if (Text$has(base, Pattern("{!.}.{!.}")))
- return Text$replace(base, full ? Pattern("{!.}.{..}{end}") : Pattern("{..}.{!.}{end}"), Text("@2"), Text("@"), false);
+ if (Text$matches(base, Pattern(".{!.}.{..}")))
+ return Text$replace(base, full ? Pattern(".{!.}.{..}") : Pattern(".{..}.{!.}{end}"), Text("@2"), Text("@"), false);
+ else if (Text$matches(base, Pattern("{!.}.{..}")))
+ return Text$replace(base, full ? Pattern("{!.}.{..}") : Pattern("{..}.{!.}{end}"), Text("@2"), Text("@"), false);
else
return Text("");
}
diff --git a/environment.c b/environment.c
index 25a21627..d51d9aa1 100644
--- a/environment.c
+++ b/environment.c
@@ -253,7 +253,6 @@ env_t *new_compilation_unit(CORD *libname)
{"base_name", "Path$base_name", "func(path:Path)->Text"},
{"children", "Path$children", "func(path:Path, include_hidden=no)->[Path]"},
{"create_directory", "Path$create_directory", "func(path:Path, permissions=0o644_i32)"},
- {"escape_text", "Path$escape_text", "func(text:Text)->Path"},
{"exists", "Path$exists", "func(path:Path)->Bool"},
{"extension", "Path$extension", "func(path:Path, full=yes)->Text"},
{"files", "Path$children", "func(path:Path, include_hidden=no)->[Path]"},