summaryrefslogtreecommitdiff
path: root/lib/fsm.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-12-16 09:25:55 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-12-16 09:25:55 +0200
commit94d7b17c9e04c2e5ff887af916d66b7ee5194864 (patch)
tree6af3115b46da3ad6e32209588f2a555969fcbab6 /lib/fsm.c
parentfe1de3869e2a13bbefa020939e5ceffbb67e616f (diff)
downloadrpm-94d7b17c9e04c2e5ff887af916d66b7ee5194864.tar.gz
rpm-94d7b17c9e04c2e5ff887af916d66b7ee5194864.tar.bz2
rpm-94d7b17c9e04c2e5ff887af916d66b7ee5194864.zip
Simplify fsmFsPath()
Diffstat (limited to 'lib/fsm.c')
-rw-r--r--lib/fsm.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index 071f2144b..761b12763 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -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;
}