On Mon, Jan 14, 2008 at 10:09:18AM +0100, Gerfried Fuchs wrote:

> >   This is not a regression in the aptitude code; instead, it's due to
> > the fact that the debtags people decided to change the format of their
> > tags (I'm not sure when, but this is the first time I've noticed it).

Hi.  I thought I had posted about this somewhere in the aptitude bts,
but apparently I didn't.

The format has never changed, only that feature is now used more often
as more tags are added to the archive.  The curly braces hack has been
invented to work around a problem with the maximum line size supported
by apt for the packages file.  As we saw that some lines got truncated,
we had to hack together that way of compressing it.

This is the code used in libept to unpack those fields, feel free to
copy and paste it in aptitude:

std::set<std::string> parseTags(const std::string& str)
{
        if (str == string())
                return def;

        set<string> res;

        size_t pos = 0;
        while (pos < str.size())
        {
                string tag;
                size_t i = str.find(", ", pos);
                if (i == string::npos)
                        tag = str.substr(pos);
                else
                        tag = str.substr(pos, i-pos);

                // Check if we need curly brace expansion
                if (tag[tag.size() - 1] == '}')
                {
                        size_t begin = tag.find('{');
                        if (begin != string::npos)
                        {
                                string prefix(tag, 0, begin);
                                ++begin;
                                size_t end;
                                while ((end = tag.find(',', begin)) != 
string::npos)
                                {
                                        res.insert(prefix + tag.substr(begin, 
end-begin));
                                        begin = end + 1;
                                }
                                res.insert(prefix + tag.substr(begin, 
tag.size() - 1 - begin));
                        }
                } else {
                        res.insert(tag);
                }

                if (i == string::npos)
                        break;
                else
                        pos = i + 2;
        }

        return res;
}

Related to this, I'd still wish (#397652) that aptitude would read tags
from /var/lib/debtags/package-tags instead, when it's available.  This
would allow, for example, to access extra tag sources, like for example
Miriam Ruiz' OpenRating tags (http://wiki.debian.org/OpenRating) at
http://www.miriamruiz.es/tags


Ciao,

Enrico

-- 
GPG key: 1024D/797EBFAB 2000-12-05 Enrico Zini <[EMAIL PROTECTED]>

Attachment: signature.asc
Description: Digital signature

Reply via email to