On Jan 19, 2011, at 8:44 PM, Jeff Johnson wrote: > > On Jan 19, 2011, at 8:39 PM, Per Øyvind Karlsen wrote: > >>> >>>> ie. 'rpm -q foo' might return: >>>> foo-1-1-mdv2011.0.x86_64 >>>> foo-bar-1-1mdv2011.0.x86_64 >>>> >>> >>> >>> Yep. Can't tell what's what because the syntax isn't predictable. >> One workaround could be something like this: >> if(keyp[0] != '^') { >> Header h; >> while((h = rpmmiNext(mi)) { >> he->tag = RPMTAG_NAME; >> if(headerGet(h, he, 0)) >> if(strlen(keyp) < strlen(he->p.str)) >> rpmmiPrune(mi,...); >> } >> >> This would remove the matches that has a name longer than the package >> queried for. >> > > strlen isn't a strong enough hint, there's equal length strings > that parse unambiguously too. Yoy're gonna need some restrictions
s/un// (I said the opposite of what I meant to say). > on permitted characters in Disttag/Distepoch, just like Version/Release > cannot contain '-'. > And rpmmiPrune() isn't the right solution to a parsing problem either. A join might work, but there's no way that can be stabilizied on --query paths to meet luser expectations. It was hard enough figgering a means for pattern queries. I'd focus on getting a better *RE in place. You want as much of a prefix stem as possible so that DB_PARTIAL takes effect. E.g., a *RE that starts like this: ^.*... will end up reading every key because there is no prefix stem, nor is there any way I could figger to make DB_PARTIAL relative to end-of-key. Reading every key for ~4K package NVRA is _STILL_ less computational effort than loading every header, as you example above does just to find the argument to pass to rpmmiPrune(), so stay focussed on a pattern that matsches strings can be handed to a parser. hth 73 de Jeff >> Might not make immediate sense, I'll take a closer look tomorrow, >> bedtime now. :) >> > > Note I won't be back home until this weekend (and I'm still recovering > from flu last week). > > hth > > 73 de Jeff >> -- >> Regards, >> Per Øyvind >> ______________________________________________________________________ >> RPM Package Manager http://rpm5.org >> Developer Communication List rpm-devel@rpm5.org >
smime.p7s
Description: S/MIME cryptographic signature