diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-12-16 09:25:55 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-12-16 09:25:55 +0200 |
commit | 94d7b17c9e04c2e5ff887af916d66b7ee5194864 (patch) | |
tree | 6af3115b46da3ad6e32209588f2a555969fcbab6 /lib/fsm.c | |
parent | fe1de3869e2a13bbefa020939e5ceffbb67e616f (diff) | |
download | rpm-94d7b17c9e04c2e5ff887af916d66b7ee5194864.tar.gz rpm-94d7b17c9e04c2e5ff887af916d66b7ee5194864.tar.bz2 rpm-94d7b17c9e04c2e5ff887af916d66b7ee5194864.zip |
Simplify fsmFsPath()
Diffstat (limited to 'lib/fsm.c')
-rw-r--r-- | lib/fsm.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -111,19 +111,12 @@ static char * fsmFsPath(const FSM_t fsm, char * s = NULL; if (fsm) { - size_t nb; - char * t; - nb = strlen(fsm->dirName) + - (st && !S_ISDIR(st->st_mode) ? (subdir ? strlen(subdir) : 0) : 0) + - (st && !S_ISDIR(st->st_mode) ? (suffix ? strlen(suffix) : 0) : 0) + - strlen(fsm->baseName) + 1; - s = t = xmalloc(nb); - t = stpcpy(t, fsm->dirName); - if (st && !S_ISDIR(st->st_mode)) - if (subdir) t = stpcpy(t, subdir); - t = stpcpy(t, fsm->baseName); - if (st && !S_ISDIR(st->st_mode)) - if (suffix) t = stpcpy(t, suffix); + int isDir = (st && S_ISDIR(st->st_mode)); + s = rstrscat(NULL, fsm->dirName, + (!isDir && subdir) ? subdir : "", + fsm->baseName, + (!isDir && suffix) ? suffix : "", + NULL); } return s; } |