diff options
author | Guillem Jover <guillem@debian.org> | 2014-02-24 06:00:01 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-04-21 17:00:27 +0200 |
commit | 97ffe228c96b815a2dc3a689b70b6827d0cb255b (patch) | |
tree | 6b46083956b31335de1cac4b089b338d2ff6fe9a /dpkg-split | |
parent | 9933a758c0a8c40dc7977e3d0c101c70d511aee3 (diff) | |
download | dpkg-97ffe228c96b815a2dc3a689b70b6827d0cb255b.tar.gz |
dpkg-split, dpkg: Use new str_match_end() function instead of ad-hoc code
Diffstat (limited to 'dpkg-split')
-rw-r--r-- | dpkg-split/split.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/dpkg-split/split.c b/dpkg-split/split.c index c41286f69..b886f2a51 100644 --- a/dpkg-split/split.c +++ b/dpkg-split/split.c @@ -41,6 +41,7 @@ #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> #include <dpkg/path.h> +#include <dpkg/string.h> #include <dpkg/subproc.h> #include <dpkg/buffer.h> #include <dpkg/ar.h> @@ -255,17 +256,12 @@ do_split(const char *const *argv) if (prefix && *argv) badusage(_("--split takes at most a source filename and destination prefix")); if (!prefix) { - char *palloc; - int l; - - l = strlen(sourcefile); - palloc = nfmalloc(l + 1); - strcpy(palloc, sourcefile); - if (strcmp(palloc + l - (sizeof(DEBEXT) - 1), DEBEXT) == 0) { - l -= (sizeof(DEBEXT) - 1); - palloc[l] = '\0'; - } - prefix = palloc; + size_t sourcefile_len = strlen(sourcefile); + + if (str_match_end(sourcefile, DEBEXT)) + sourcefile_len -= strlen(DEBEXT); + + prefix = nfstrnsave(sourcefile, sourcefile_len); } mksplit(sourcefile, prefix, opt_maxpartsize, opt_msdos); |