RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Ralf S. Engelschall Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 14-Dec-2007 12:22:08 Branch: HEAD Handle: 2007121411220800 Modified files: rpm VENDOR rpm/build parsePreamble.c rpm/rpmio argv.c argv.h Log: Apply another OpenPKG-specific change which is another candicate for being used for stock RPM, too: Allow wildcards in %{_arbitrary_tags} in order to support e.g. "%_arbitrary_tags My*" for custom but clearly distinguishable user headers, the matching of tagnames is done via a slower but more flexible linear search based on fnmatch(3) instead of a binary search based on strcasecmp(3). Summary: Revision Changes Path 2.9 +10 -0 rpm/VENDOR 2.158 +4 -0 rpm/build/parsePreamble.c 1.10 +37 -0 rpm/rpmio/argv.c 1.7 +34 -0 rpm/rpmio/argv.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/VENDOR ============================================================================ $ cvs diff -u -r2.8 -r2.9 VENDOR --- rpm/VENDOR 13 Dec 2007 19:08:16 -0000 2.8 +++ rpm/VENDOR 14 Dec 2007 11:22:08 -0000 2.9 @@ -272,4 +272,14 @@ Reason: This is a macro-frontend to realpath(3) and allows one to resolve a (relative) path into an absolute path. + ________________________________________________________________________ + + Change: wildcard-matching-arbitrary-tagnames + Purpose: Allow wildcards in %{_arbitrary_tags} + Reason: In order to support e.g. "%_arbitrary_tags My*" + for custom but clearly distinguishable user + headers, the matching of tagnames is done via a + slower but more flexible linear search based on + fnmatch(3) instead of a binary search based on + strcasecmp(3). @@ . patch -p0 <<'@@ .' Index: rpm/build/parsePreamble.c ============================================================================ $ cvs diff -u -r2.157 -r2.158 parsePreamble.c --- rpm/build/parsePreamble.c 13 Dec 2007 19:08:16 -0000 2.157 +++ rpm/build/parsePreamble.c 14 Dec 2007 11:22:08 -0000 2.158 @@ -928,7 +928,11 @@ if (aTags != NULL && aTags[0] != NULL) { ARGV_t av; s = tagCanonicalize(spec->line); +#if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ + av = argvSearchLinear(aTags, s, argvFnmatchCasefold); +#else av = argvSearch(aTags, s, argvStrcasecmp); +#endif if (av != NULL) { *tagp = tagGenerate(s); rc = 0; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/argv.c ============================================================================ $ cvs diff -u -r1.9 -r1.10 argv.c --- rpm/rpmio/argv.c 2 Dec 2007 23:06:02 -0000 1.9 +++ rpm/rpmio/argv.c 14 Dec 2007 11:22:08 -0000 1.10 @@ -93,6 +93,22 @@ return xstrcasecmp(astr, bstr); } +#if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ +int argvFnmatch(const void * a, const void * b) +{ + ARGstr_t astr = *(ARGV_t)a; + ARGstr_t bstr = *(ARGV_t)b; + return (fnmatch(astr, bstr, 0) == 0 ? 0 : 1); +} + +int argvFnmatchCasefold(const void * a, const void * b) +{ + ARGstr_t astr = *(ARGV_t)a; + ARGstr_t bstr = *(ARGV_t)b; + return (fnmatch(astr, bstr, FNM_CASEFOLD) == 0 ? 0 : 1); +} +#endif + int argvSort(ARGV_t argv, int (*compar)(const void *, const void *)) { if (compar == NULL) @@ -111,6 +127,27 @@ return bsearch(&val, argv, argvCount(argv), sizeof(*argv), compar); } +#if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ +ARGV_t argvSearchLinear(ARGV_t argv, ARGstr_t val, + int (*compar)(const void *, const void *)) +{ + ARGV_t result; + ARGV_t av; + if (argv == NULL) + return NULL; + if (compar == NULL) + compar = argvCmp; + result = NULL; + for (av = argv; *av != NULL; av++) { + if (compar(av, &val) == 0) { + result = av; + break; + } + } + return result; +} +#endif + int argiAdd(/[EMAIL PROTECTED]@*/ ARGI_t * argip, int ix, int val) { ARGI_t argi; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/argv.h ============================================================================ $ cvs diff -u -r1.6 -r1.7 argv.h --- rpm/rpmio/argv.h 2 Dec 2007 23:06:02 -0000 1.6 +++ rpm/rpmio/argv.h 14 Dec 2007 11:22:08 -0000 1.7 @@ -102,6 +102,26 @@ int argvStrcasecmp(const void * a, const void * b) /[EMAIL PROTECTED]/; +#if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ +/** + * Wildcard-match argv arrays using fnmatch. + * @param a 1st instance address + * @param b 2nd instance address + * @return result of comparison + */ +int argvFnmatch(const void * a, const void * b) + /[EMAIL PROTECTED]/; + +/** + * Wildcard-match argv arrays using fnmatch (case-insensitive). + * @param a 1st instance address + * @param b 2nd instance address + * @return result of comparison + */ +int argvFnmatchCasefold(const void * a, const void * b) + /[EMAIL PROTECTED]/; +#endif + /** * Sort an argv array. * @param argv argv array @@ -123,6 +143,20 @@ int (*compar)(const void *, const void *)) /[EMAIL PROTECTED]/; +#if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ +/** + * Find an element in an argv array (via linear searching and just match/no-match comparison). + * @param argv argv array + * @param val string to find + * @param compar strcmp-like comparison function, or NULL for argvCmp() + * @return found string (NULL on failure) + */ +/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ +ARGV_t argvSearchLinear(ARGV_t argv, ARGstr_t val, + int (*compar)(const void *, const void *)) + /[EMAIL PROTECTED]/; +#endif + /** * Add an int to an argi array. * @retval *argip argi array @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org