summaryrefslogtreecommitdiff
path: root/ted.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-16 15:38:59 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-16 15:38:59 -0500
commit4b8db533619ee8eef64ded0793f413faaa7609c2 (patch)
tree8b3f158897ae2ff2f3e8f78ad0712bc4b40b328f /ted.c
parent824c4ff4be5a0bf55b6644fed06fcfe2248c4301 (diff)
detecting errors in build output
Diffstat (limited to 'ted.c')
-rw-r--r--ted.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/ted.c b/ted.c
index a1cbed5..94505df 100644
--- a/ted.c
+++ b/ted.c
@@ -262,3 +262,32 @@ static bool ted_save_all(Ted *ted) {
}
return success;
}
+
+static void ted_full_path(Ted *ted, char const *relpath, char *abspath, size_t abspath_size) {
+ str_cpy(abspath, abspath_size, ted->cwd);
+
+ while (1) {
+ size_t component_len = strcspn(relpath, ALL_PATH_SEPARATORS);
+ char const *component_end = relpath + component_len;
+
+ size_t len = strlen(abspath);
+ if (abspath[len - 1] != PATH_SEPARATOR)
+ str_cat(abspath, abspath_size, PATH_SEPARATOR_STR);
+ if (component_len == 1 && relpath[0] == '.') {
+ // ., do nothing
+ } else if (component_len == 2 && relpath[0] == '.' && relpath[1] == '.') {
+ // ..
+ char *lastsep = strrchr(abspath, PATH_SEPARATOR);
+ if (lastsep == abspath)
+ lastsep[1] = '\0';
+ else
+ lastsep[0] = '\0';
+ } else {
+ strn_cat(abspath, abspath_size, relpath, component_len);
+ }
+ if (*component_end == 0)
+ break;
+ else
+ relpath = component_end + 1;
+ }
+}