diff options
author | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2010-12-05 03:23:29 +0000 |
---|---|---|
committer | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2010-12-05 03:23:29 +0000 |
commit | 7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71 (patch) | |
tree | 83af5f1db544ea2d196d505a7ea2dd1a8c2ab747 | |
parent | 5627fc47a5ba19725d70bb04f7bd05cb9f96294a (diff) | |
download | perl-URPM-7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71.tar perl-URPM-7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71.tar.gz perl-URPM-7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71.tar.bz2 perl-URPM-7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71.tar.xz perl-URPM-7a28b9810611fbe1e8e9b07c1be5b6eae3e42b71.zip |
clean up return_files() & update_provided_files() to only use RPMTAG_FILEPATHS (thx to jbj suggestion)
-rw-r--r-- | URPM.xs | 126 |
1 files changed, 22 insertions, 104 deletions
@@ -761,81 +761,34 @@ void return_files(Header header, int filter_mode) { dSP; if (header) { - char buff[4096]; - char *p; const char *s; STRLEN len; + const char **list = NULL; + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); rpmsenseFlags *flags = NULL; - uint16_t *fmodes = NULL; if (filter_mode) { - HE_t he_flags = memset(alloca(sizeof(*he_flags)), 0, sizeof(*he_flags)); - HE_t he_fmodes = memset(alloca(sizeof(*he_fmodes)), 0, sizeof(*he_fmodes)); + he->tag = RPMTAG_FILEFLAGS; + if(headerGet(header, he, 0)) + flags = (rpmsenseFlags*)he->p.ui32p; - he_flags->tag = RPMTAG_FILEFLAGS; - if(headerGet(header, he_flags, 0)) - flags = (rpmsenseFlags*)he_flags->p.ui32p; - - he_fmodes->tag = RPMTAG_FILEMODES; - if(headerGet(header, he_fmodes, 0)) - fmodes = he_fmodes->p.ui16p; } - const char **baseNames = NULL; - const char **dirNames = NULL; - uint32_t *dirIndexes = NULL; - const char **list = NULL; - - HE_t he_baseNames = memset(alloca(sizeof(*he_baseNames)), 0, sizeof(*he_baseNames)); - HE_t he_dirIndexes = memset(alloca(sizeof(*he_dirIndexes)), 0, sizeof(*he_dirIndexes)); - HE_t he_dirNames = memset(alloca(sizeof(*he_dirNames)), 0, sizeof(*he_dirNames)); - - he_baseNames->tag = RPMTAG_BASENAMES; - if(headerGet(header, he_baseNames, 0)) - baseNames = he_baseNames->p.argv; - - he_dirIndexes->tag = RPMTAG_DIRINDEXES; - if(headerGet(header, he_dirIndexes, 0)) - dirIndexes = he_dirIndexes->p.ui32p; - - he_dirNames->tag = RPMTAG_DIRNAMES; - if(headerGet(header, he_dirNames, 0)) - dirNames = he_dirNames->p.argv; - - - if (!baseNames || !dirNames || !dirIndexes) { - HE_t he_list = memset(alloca(sizeof(*he_list)), 0, sizeof(*he_list)); - - he_list->tag = RPMTAG_OLDFILENAMES; - if (!headerGet(header, he_list, 0)) return; - list = he_list->p.argv; - } + he->tag = RPMTAG_FILEPATHS; + if (!headerGet(header, he, 0)) return; + list = he->p.argv; - for(he_baseNames->ix = 0; he_baseNames->ix < (int)he_baseNames->c; he_baseNames->ix++) { - if (list) { - s = list[he_baseNames->ix]; - len = strlen(list[he_baseNames->ix]); - } else { - len = strlen(dirNames[dirIndexes[he_baseNames->ix]]); - if (len >= sizeof(buff)) continue; - memcpy(p = buff, dirNames[dirIndexes[he_baseNames->ix]], len + 1); p += len; - len = strlen(baseNames[he_baseNames->ix]); - if (p - buff + len >= sizeof(buff)) continue; - memcpy(p, baseNames[he_baseNames->ix], len + 1); p += len; - s = buff; - len = p-buff; - } + for(he->ix = 0; he->ix < (int)he->c; he->ix++) { + s = list[he->ix]; + len = strlen(list[he->ix]); if (filter_mode) { - if ((filter_mode & FILTER_MODE_CONF_FILES) && flags && (flags[he_baseNames->ix] & RPMFILE_CONFIG) == 0) continue; + if ((filter_mode & FILTER_MODE_CONF_FILES) && flags && (flags[he->ix] & RPMFILE_CONFIG) == 0) continue; } XPUSHs(sv_2mortal(newSVpv(s, len))); } - - baseNames = _free(baseNames); - dirIndexes = _free(dirIndexes); - dirNames = _free(dirNames); + flags = _free(flags); list = _free(list); } PUTBACK; @@ -1120,53 +1073,18 @@ update_provides_files(URPM__Package pkg, HV *provides) { if (pkg->h) { STRLEN len; const char **list = NULL; - HE_t he_baseNames = memset(alloca(sizeof(*he_baseNames)), 0, sizeof(*he_baseNames)); - HE_t he_dirIndexes = memset(alloca(sizeof(*he_dirIndexes)), 0, sizeof(*he_dirIndexes)); - HE_t he_dirNames = memset(alloca(sizeof(*he_dirNames)), 0, sizeof(*he_dirNames)); - - he_baseNames->tag = RPMTAG_BASENAMES; - he_dirIndexes->tag = RPMTAG_DIRINDEXES; - he_dirNames->tag = RPMTAG_DIRNAMES; - - if (headerGet(pkg->h, he_baseNames, 0) && - headerGet(pkg->h, he_dirIndexes, 0) && - headerGet(pkg->h, he_dirNames, 0)) { - - const char **baseNames = he_baseNames->p.argv; - const char **dirNames = he_dirNames->p.argv; - uint32_t *dirIndexes = he_dirIndexes->p.ui32p; - - char buff[4096]; - char *p; - - for(he_baseNames->ix = 0; he_baseNames->ix < (int)he_baseNames->c; he_baseNames->ix++) { - len = strlen(dirNames[dirIndexes[he_baseNames->ix]]); - if (len >= sizeof(buff)) continue; - memcpy(p = buff, dirNames[dirIndexes[he_baseNames->ix]], len + 1); p += len; - len = strlen(baseNames[he_baseNames->ix]); - if (p - buff + len >= sizeof(buff)) continue; - memcpy(p, baseNames[he_baseNames->ix], len + 1); p += len; - - update_provide_entry(buff, p-buff, 0, 0, pkg, provides); - } - - baseNames = _free(baseNames); - dirNames = _free(dirNames); - dirIndexes = _free(dirIndexes); - } else { - HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); - - he->tag = RPMTAG_OLDFILENAMES; - if(headerGet(pkg->h, he, 0)) { - list = he->p.argv; - for (he->ix = 0; he->ix < (int)he->c; he->ix++) { - len = strlen(list[he->ix]); + HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); - update_provide_entry(list[he->ix], len, 0, 0, pkg, provides); - } + he->tag = RPMTAG_FILEPATHS; + if(headerGet(pkg->h, he, 0)) { + list = he->p.argv; + for (he->ix = 0; he->ix < (int)he->c; he->ix++) { + len = strlen(list[he->ix]); - list = _free(list); + update_provide_entry(list[he->ix], len, 0, 0, pkg, provides); } + + list = _free(list); } } } |