summaryrefslogtreecommitdiffhomepage
path: root/src/logic/slbt_exec_ctx.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/logic/slbt_exec_ctx.c')
-rw-r--r--src/logic/slbt_exec_ctx.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c
index f1b6b75..6b66f12 100644
--- a/src/logic/slbt_exec_ctx.c
+++ b/src/logic/slbt_exec_ctx.c
@@ -147,6 +147,7 @@ int slbt_get_exec_ctx(
char ** parg;
char * ch;
char * mark;
+ const char * dmark;
char * slash;
const char * arprefix;
const char * dsoprefix;
@@ -172,6 +173,28 @@ int slbt_get_exec_ctx(
: ictx->ctx.csrc;
if (ref && !ictx->ctx.csrc && (mark = strrchr(ref,'/'))) {
+ if (!(strncmp(ref,"../",3)))
+ dmark = 0;
+ else if (!(strncmp(ref,"./",2)))
+ dmark = &ref[1];
+ else
+ dmark = strchr(ref,'/');
+
+ for (; dmark; ) {
+ if (!(strncmp(dmark,"/./",3))) {
+ dmark = strchr(&dmark[2],'/');
+ } else if (!(strncmp(dmark,"/../",4))) {
+ ictx->ctx.ldirdepth = -1;
+ dmark = 0;
+ } else {
+ for (; *dmark=='/'; )
+ dmark++;
+
+ ictx->ctx.ldirdepth++;
+ dmark = strchr(dmark,'/');
+ }
+ }
+
ictx->ctx.ldirname = ch;
strcpy(ch,ref);
ch += mark - ref;