mirror of
https://github.com/sheumann/hush.git
synced 2025-02-28 20:31:33 +00:00
A patch from Vladimir to simplify concat_path_file() and
make it less likely to break.
This commit is contained in:
parent
c33ebc9741
commit
4ad13e5d95
@ -11,16 +11,12 @@
|
|||||||
extern char *concat_path_file(const char *path, const char *filename)
|
extern char *concat_path_file(const char *path, const char *filename)
|
||||||
{
|
{
|
||||||
char *outbuf;
|
char *outbuf;
|
||||||
int l;
|
const char *lc;
|
||||||
int flg_slash = 1;
|
|
||||||
|
lc = last_char_is((char*)path, '/');
|
||||||
l = strlen(path);
|
if (filename[0] == '/')
|
||||||
if (l>0 && path[l-1] == '/')
|
filename++;
|
||||||
flg_slash--;
|
outbuf = xmalloc(strlen(path)+strlen(filename)+1+(lc==NULL));
|
||||||
l += strlen(filename);
|
sprintf(outbuf, (lc==NULL ? "%s/%s" : "%s%s"), path, filename);
|
||||||
if (l>0 && filename[0] == '/')
|
|
||||||
flg_slash--;
|
|
||||||
outbuf = xmalloc(l+1+flg_slash);
|
|
||||||
sprintf(outbuf, (flg_slash ? "%s/%s" : "%s%s"), path, filename);
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user