Skip to content

Commit

Permalink
simplify isabspath from init.c and use it in dlopen instead of duplic…
Browse files Browse the repository at this point in the history
…ating
  • Loading branch information
stevengj committed Aug 18, 2016
1 parent 7cd85c2 commit 1c15629
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,7 @@ static void *jl_load_dynamic_library_(const char *modname, unsigned flags, int t
goto done;
}

#ifdef _OS_WINDOWS_
abspath = modname[0] == '/' || modname[0] == '\\' ||
(modname[0] && modname[1] == ':' && (modname[2] == '\\' || modname[2] == '/'));
#else
abspath = modname[0] == '/';
#endif
abspath = isabspath(modname);

/*
this branch permutes all base paths in DL_LOAD_PATH with all extensions
Expand Down
10 changes: 3 additions & 7 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,9 @@ int isabspath(const char *in)
if (c0 == '/' || c0 == '\\') {
return 1; // absolute path relative to %CD% (current drive), or UNC
}
else {
int s = strlen(in);
if (s > 2) {
char c1 = in[1];
char c2 = in[2];
if (c1 == ':' && (c2 == '/' || c2 == '\\')) return 1; // absolute path
}
else if (c0 && in[1] == ':') {
char c2 = in[2];
return c2 == '/' || c2 == '\\'; // absolute path with drive name
}
#else
if (in[0] == '/') return 1; // absolute path
Expand Down
2 changes: 2 additions & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ STATIC_INLINE void *jl_get_frame_addr(void)

JL_DLLEXPORT jl_array_t *jl_array_cconvert_cstring(jl_array_t *a);

int isabspath(const char *in);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 1c15629

Please sign in to comment.