[pacman-dev] vercmp discussion (was: String freeze for 3.2 release)
Xavier
shiningxc at gmail.com
Mon Jul 21 08:05:04 EDT 2008
On Mon, Jul 21, 2008 at 12:01 PM, Xavier <shiningxc at gmail.com> wrote:
> On Mon, Jul 21, 2008 at 11:25 AM, Xavier <shiningxc at gmail.com> 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Revert-vercmp-code-to-the-old-version.patch
Type: application/mbox
Size: 8722 bytes
Desc: not available
URL: <http://archlinux.org/pipermail/pacman-dev/attachments/20080721/1efe089b/attachment.bin>
More information about the pacman-dev
mailing list