On Mon, Jul 21, 2008 at 12:01 PM, Xavier <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 21, 2008 at 11:25 AM, Xavier <[EMAIL PROTECTED]> wrote:
>>
>> Apparently the static strings were a show stopper to Dan.
>> I don't have a problem with static strings, since it removes the
>> malloc/free overhead and also simplifies the code.
>> As always with dynamic strings, we have the choice between duplicating
>> all free calls, or using goto.
>>
>> But anyway, here is a new patch using strdup/free instead of static arrays.
>>
>
> This breaks sync1000, sync1003 and upgrade075 pactest, but I have not
> yet been able to figure out why.
>

Well I found a fix, which looks correct to me, but I am still highly
confused about why the old vercmp function with static strings worked
fine.
Also, my vercmp function had problems when being called from checkdeps
(which is why it broke the 3 pactests above), and probably the two
arguments of vercmp in this case are dynamic strings.
But it didn't have any problems when being called from the vercmp tool
(src/util/vercmp) which use static strings, because all tests in
pactest/vercmptest still passed fine.

Anyway, after the fix, the calls from checkdeps and vercmp tool both work fine.

diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index d0ca58a..8a36e56 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -593,12 +593,12 @@ int SYMEXPORT alpm_pkg_vercmp(const char *a,
const char *b)

        /* lose the release number */
        for(one = str1; *one && *one != '-'; one++);
-       if(one) {
+       if(*one) {
                *one = '\0';
                rel1 = ++one;
        }
        for(two = str2; *two && *two != '-'; two++);
-       if(two) {
+       if(*two) {
                *two = '\0';
                rel2 = ++two;
        }

Attachment: 0001-Revert-vercmp-code-to-the-old-version.patch
Description: application/mbox

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev

Reply via email to