diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-12-19 10:21:04 -0800 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:30 +0200 |
commit | 7a1fc175980837ccc25cdd8582846a3b44838505 (patch) | |
tree | f493f37a847946025abda93109462fb448b24886 /nx-X11/lib | |
parent | c9ebd122fb9b7c28abac21b83ade9fee365a882f (diff) | |
download | nx-libs-7a1fc175980837ccc25cdd8582846a3b44838505.tar.gz nx-libs-7a1fc175980837ccc25cdd8582846a3b44838505.tar.bz2 nx-libs-7a1fc175980837ccc25cdd8582846a3b44838505.zip |
XlcDL.c: reduce code duplication
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib')
-rw-r--r-- | nx-X11/lib/X11/XlcDL.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/nx-X11/lib/X11/XlcDL.c b/nx-X11/lib/X11/XlcDL.c index 519103b86..bc71900a0 100644 --- a/nx-X11/lib/X11/XlcDL.c +++ b/nx-X11/lib/X11/XlcDL.c @@ -249,6 +249,7 @@ __lc_path(const char *dl_name, const char *lc_dir) { char *path; size_t len; + char *slash_p; /* * reject this for possible security issue @@ -264,24 +265,21 @@ __lc_path(const char *dl_name, const char *lc_dir) path = Xmalloc(len + 1); if (strchr(dl_name, '/') != NULL) { - char *slash_p; slash_p = strrchr(lc_dir, '/'); *slash_p = '\0'; + } else + slash_p = NULL; + #if defined POSTLOCALELIBDIR - snprintf(path, len + 1, "%s/%s/%s.so.2", - lc_dir, POSTLOCALELIBDIR, dl_name); + snprintf(path, len + 1, "%s/%s/%s.so.2", + lc_dir, POSTLOCALELIBDIR, dl_name); #else - snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name); + snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name); #endif + + if (slash_p != NULL) *slash_p = '/'; - } else { -#if defined POSTLOCALELIBDIR - snprintf(path, len + 1, "%s/%s/%s.so.2", - lc_dir, POSTLOCALELIBDIR, dl_name); -#else - snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name); -#endif - } + return path; } |