You are not logged in.
I have re-written db_search() so that when you type more words into a search, the results are narrowed down (AND) instead of accumulated (OR). I find this much more useful.
For example, for the current pacman I get a rather useless long list when I issue the command:
$ pacman -Ss 3d game
current/xaw3d 1.5-2
Athena widgets (libXaw) drop-in replacement
extra/3ddesktop 0.2.8-1
a 3d virtual desktop switcher (opengl/mesa)
extra/asteroids3d 0.2.2-1
Asteroids3D is a 3D, first-person game of blowing up asteroids
extra/blender 2.36-1
A fully integrated 3D graphics creation suite
extra/bzflag 1.10.8.20041007-1
BZFlag is a multiplayer 3D tank battle game.
extra/glchess 0.4.7-2
3D Chess Frontend
extra/glhack 1.2-1
a 3D port of Nethack for use with OpenGL
extra/gltron 0.70-1
A tron-like lightcycle game with a nice 3D perspective.
extra/lib3ds 1.2.0-1
Lib3ds is a free alternative to Autodesk's 3DS File Toolkit for handling 3DS
files
extra/maelstrom 3.0.6-1
Maelstrom is an excellent Asteroids-type game with sound and 3D objects
extra/mage 6.35.040409-1
Mage is a 3D vector display program which shows kinemage graphics. Used in
both teaching and research, in applications ranging from estuary ecology to
X-ray crystallography model quality assessments.
extra/neverball 1.4.0-2
3D game similar to Super Monkey Ball or Marble Madness
extra/python-vpython 3.0.3-2
A Python module that offers real-time 3D output, and is easily usable by
novice programmers
extra/qwtplot3d 0.2.4beta-1
Qt/OpenGL-based C++ programming library containing 3d-widgets
extra/tpop3d 1.5.3-1
A high-performance pop3 server with virtualhost and maildir support and
several auth method
extra/wmdots 0.2beta-1
Absolutely useless but very pretty multishape 3d rotating dots
extra/xbl 1.1.2-1
A 3D tetris/blockout game
extra/abuse 0.7.0-3
Abuse is an action game that pits you --assuming the role of Nick Vrenna,
res stance fighter -- against ruthless alien killers
extra/allegro 4.1.18-1
Allegro is a multi-platform game library
extra/apricots 0.2.6-1
A simple 2D flying/bombing game similar to basic side scrollers
extra/asteroids3d 0.2.2-1
Asteroids3D is a 3D, first-person game of blowing up asteroids
extra/black-box 1.4.1-1
A game where You can shoot in and watch, where the shot leaves the box
extra/bomberclone 0.11.5-1
A Clone of the game AtomicBomberMan
extra/bs 2.7-1
The classic game of Battleships against the computer. Ncurses.
extra/bumprace 1.45-1
BumpRace is a simple arcade game
extra/bzflag 1.10.8.20041007-1
BZFlag is a multiplayer 3D tank battle game.
extra/castle-combat 0.7.4-1
It's a clone of the old DOS game Rampart
extra/circuslinux 1.0.3-1
Circus Linux! is a clone of the Atari 2600 game Circus Atari
extra/clanlib 0.7.8-2
A multi-platform game development library
extra/crimson 0.4.6-1
Crimson Fields is a tactical war game in the tradition of Battle Isle
extra/dopewars 1.5.10-1
dopewars is a Drug dealing game set in New York
extra/dosbox 0.63-1
PC emulator with builtin DOS for running DOS Games
extra/enigma 1.04-1
Enigma is a puzzle game involving falling blocks
extra/foobillard 3.0a-1
An OpenGL billiard game for Linux
extra/fortune-mod 9708-1
The Fortune Cookie Program from BSD games
extra/freeciv 1.14.2-1
A multiuser clone of the famous Microprose game of Civilization
extra/frozen-bubble 1.0.0-5
A game in which you throw colorful bubbles and build groups to destroy the
bubbles
extra/gav 0.8.0-1
GPL Arcade Volleyball: an SDL remake of the old dos game Arcade Volleyball
extra/gfpoken 0.25-1
GFingerPoken is a black-box type game for gtk 1.2 or higher
extra/gltron 0.70-1
A tron-like lightcycle game with a nice 3D perspective.
extra/gnome-games 2.8.2-1
Some Games for GNOME
extra/gnuchess 5.07-2
Lets most modern computers play a full game of chess
extra/gnugo 3.4-1
This sofware is a program that plays the game of Go
extra/gtetrinet 0.7.6-1
A clone of the game Tetrinet for the gnome environment.
extra/gtkatlantic 0.4.1-1
Monopoly board game client for the monopd server.
extra/gweled 0.6-2
Bejewled Game (aka Diamond Mine)
extra/kdegames 3.3.2-1
Games for KDE.
extra/kobodeluxe 0.4pre8-1
kobodeluxe is an enhanced version of Akira Higuchi's game XKobo
extra/lbreakout2 2.5.2-1
A breakout game with nice effects, graphics, and sounds
extra/lexter 1.0.3-1
Lexter is a text-based word puzzle game resembling tetris
extra/lincity 1.12.1-1
LinCity is an SVGALIB (Linux only) and X based city/country simulation game
for Linux and other Unix platforms (Solaris, FreeBSD, HP_UX, AIX, SCO and
IRIX).
extra/liquidwar 5.6.2-4
Liquid War is a unique multiplayer wargame.
extra/luola 1.2.6-1
Luola is a cavern-flying game for 1-4 players
extra/maelstrom 3.0.6-1
Maelstrom is an excellent Asteroids-type game with sound and 3D objects
extra/mahjong 1.5.5-1
The classical game of Mah Jongg (not the solitare version). Includes network
play
extra/moon-buggy 0.5.53-1
Moon Buggy is a simple game for the text mode
extra/moon-lander 1.0-3
An addictive game of skill where you must land a space-ship on the moon at a
perfect speed.
extra/nethack 3.4.3-1
A single player dungeon exploration game
extra/neverball 1.4.0-2
3D game similar to Super Monkey Ball or Marble Madness
extra/pathological 1.1.3-2
A puzzle game with the same feel as frozen bubble
extra/penguin-command 1.6.6-1
This is a clone of the classic 'Missile Command' Game
extra/pente 2.2.5-1
A five in a row game that can be played with X, curses, or text.
extra/pinball 0.3.1-1
The Emilia Pinball Project strives to fulfil your needs for a great pinball
game in Linux
extra/plib 1.8.4-1
PLIB is a set of libraries to write games and other realtime interactive
applications
extra/prboom 2.3.0-1
PrBoom is a game engine - it provides a program to play Doom levels
extra/python-pygame 1.6-3
Python game library
extra/qstat 2.7-1
Qstat is a command line utility that displays the status of internet game
servers including Quake
extra/rockdodger 0.6-1
Space Rocks is a game - Dodge the space rocks, use your shields, fire your
thrusters, cross your fingers, and kiss your ship goodbye
extra/scummvm 0.7.0-1
A 'virtual machine' for several classic graphical point-and-click adventure
games.
extra/toppler 1.1.1-1
Tower Toppler (aka Nebulous) is the reimplementation of an old 'jump and
run' game.
extra/trackballs 1.0.0-1
Trackballs is a simple game similar to the classical game Marble Madness on
the Amiga in the 80's
extra/tuxmath 2001.09.07-2
'Tux of Math Command' is an educational math tutorial game for elementary
school level children
extra/tuxtype 1.0.3-5
TuxTyping is an educational typing tutorial game starring Tux
extra/vectoroids 1.1.0-2
Vectoroids is based on the X-Window PDA game 'Agendaroids,'
extra/wesnoth 0.8.11-1
A turn-based strategy game on a fantasy world
extra/xbill 2.1-3
Xbill is a game that tests you reflexes as you seek and destroy all forms of
Bill
extra/xbl 1.1.2-1
A 3D tetris/blockout game
extra/xconq 20031005-1
Xconq is a general strategy game system.
extra/xmahjongg 3.6.1-2
Mahjongg game for X-Window
extra/xrally 1.1.1-1
XRally is a clone of the Rally X arcade game
extra/xscorch 0.2.0-1
A clone of the classic DOS game Scorched Earth
extra/xskat 4.0-1
XSkat lets you play the card game Skat as defined by the official Skat Order
on any Un*x machine running X11
My modification returns these results:
$ pacman -Ss 3d game
extra/asteroids3d 0.2.2-1
Asteroids3D is a 3D, first-person game of blowing up asteroids
extra/bzflag 1.10.8.20041007-1
BZFlag is a multiplayer 3D tank battle game.
extra/gltron 0.70-1
A tron-like lightcycle game with a nice 3D perspective.
extra/maelstrom 3.0.6-1
Maelstrom is an excellent Asteroids-type game with sound and 3D objects
extra/neverball 1.4.0-2
3D game similar to Super Monkey Ball or Marble Madness
extra/xbl 1.1.2-1
A 3D tetris/blockout game
The link below is a tarball of the diff file, as well as the modified file (db.c) and the extra file (stristr.c - public domain stristr() function). The code is also shown below.
http://www.iogopro.co.uk/contrib/pacman … ch.tar.bz2
/*
* New db_search() with logical AND searching, so that when the user
* types more words the search is narrowed down, rather than expanded!
*
* Copyright (c) 2005 by Luke McCarthy <luke@iogopro.co.uk>
*/
static int in_pkg_name(pkginfo_t *pkg, const char *qry)
{
return !!stristr(pkg->name, qry);
}
static int in_pkg_desc(pkginfo_t *pkg, const char *qry)
{
return !!stristr(pkg->desc, qry);
}
static int in_pkg_provides(pacdb_t *db, pkginfo_t *pkg, const char *qry)
{
int found = 0;
pkginfo_t *info;
PMList *i;
info = db_scan(db, pkg->name, INFRQ_DESC | INFRQ_DEPENDS);
if (!info) {
return 0;
}
for (i = info->provides; i; i = i->next) {
if (stristr(i->data, qry)) {
found = 1;
break;
}
}
FREEPKG(info);
return found;
}
static int in_pkg(pacdb_t *db, pkginfo_t *pkg, const char *qry)
{
return
in_pkg_name(pkg, qry)
|| in_pkg_desc(pkg, qry)
|| in_pkg_provides(db, pkg, qry);
}
/*
The lists returned from or_search and and_search contain
references to elements belonging to pkgs, so be careful
when freeing later (i.e. set every data member to NULL
before calling list_free). Otherwise dangling pointers
will bite you.
*/
static PMList *or_search(pacdb_t *db, PMList *pkgs, PMList *qrys)
{
char *qry;
pkginfo_t *pkg;
PMList *hits = NULL, *i, *j;
for (i = pkgs; i; i = i->next) {
pkg = i->data;
if (pkg) for (j = qrys; j; j = j->next) {
qry = j->data;
if (qry && in_pkg(db, pkg, qry)) {
hits = list_add(hits, pkg);
}
}
}
return hits;
}
static PMList *and_search(pacdb_t *db, PMList *pkgs, PMList *qrys)
{
char *qry;
pkginfo_t *pkg;
PMList *hits, *frst, *i, *inxt, *j;
/* Do an OR search on the first item. */
frst = list_add(NULL, qrys->data);
hits = or_search(db, pkgs, frst);
frst->data = NULL;
FREELIST(frst);
/* Eliminate results that do not correlate to all queries. */
for (i = hits; i; i = inxt) {
inxt = NULL;
pkg = i->data;
if (pkg) for (j = qrys; j; j = j->next) {
qry = j->data;
if (qry && !in_pkg(db, pkg, qry)) {
inxt = i->next;
i->data = NULL; /* Not ours don't free it. */
hits = list_remove(hits, i);
break;
}
}
if (!inxt) {
inxt = i->next;
}
}
return hits;
}
static void print_pkg(pkginfo_t *pkg, const char *treename)
{
printf("%s/%s %sn ", treename, pkg->name, pkg->version);
indentprint(pkg->desc, 4);
putchar('n');
}
void db_search(pacdb_t *db, PMList *pkgs, const char *treename, PMList *qrys)
{
PMList *i, *hits;
pkginfo_t *pkg;
if (!qrys || !qrys->data) return;
/* and_search can be interchanged with or_search */
hits = and_search(db, pkgs, qrys);
for (i = hits; i; i = i->next) {
pkg = i->data;
if (pkg) {
print_pkg(pkg, treename);
i->data = NULL;
/* IMPORTANT: stops freeing the pkginfo! */
}
}
FREELIST(hits);
}
Offline
Sounds like a great idea to me ::thumbs up::
How about a way to specify which method you want though? Similar to phpbb's "search1 AND search2" or "search1 OR search2" (maybe defaulting to OR...)
I am a gated community.
Offline
I like the idea... you should file it as a feature request in the bug tracker.
And where were all the sportsmen who always pulled you though?
They're all resting down in Cornwall
writing up their memoirs for a paper-back edition
of the Boy Scout Manual.
Offline
Aye, sign up, submit it as a request. Link to your new version. Chances are it will be adopted.
Offline
I agree - good idea... though you should post a patch file instead of the modified file... actually you should just request using a logical and instead of a logical or for search terms - I'm sure the developers would understand...
Offline
Users should be able to decide wether they want to have a logical "or" or "and".
So, "pacman -S 3D ^ games" could be used as AND(3D,games), while "pacman -S 3D ° games" could be used as OR(3D,games). Furthermore, consider to have "pacman -S 3D ! games" as (3D,NOT(games)) ...
Frumpus ♥ addict
[mu'.krum.pus], [frum.pus]
Offline
then i would rather use || and && with !, if you encapsulate the search with quotes, then it would also work with bash.
Offline
Thanks everyone for your replies.
phrakture, I have included a patch file also. It's in the archive but you can download it directly:
http://www.iogopro.co.uk/contrib/pacman … earch.diff
Here is how to try it out (assuming the diff and pacman source archive is in the CWD):
$ tar xvzf pacman-2.9.5.tar.gz
$ cd pacman-2.9.5
$ patch -p1 -i ../pacman_and_search.diff
$ ./configure
$ make
$ ./pacman -Ss 3d game
Pink Chick, for that I would have to write a mini parser and interpreter. It's a bit beyond the scope of what I was aiming for ;-) Most of the time I don't imagine needing the full power of arbitrary expressions. It would probably be possible to add support for NOT e.g. 3d !game without too much trouble, I'll look into it.
stonecrest, I could add another command line flag. Any suggestions? Personally I wouldn't mind it replacing the default behaviour, but I'm biased :-)
I will file this as a feature request in the bug tracker as suggested.
Offline
this is a great idea
Offline
I've added it as a feature request.
Offline
I can't see anything wrong with replacing the default OR with an AND search. If you still need OR search, run two commands:
pacman -Ss 3d ; pacman -Ss games
Dusty
Offline
I can't see anything wrong with replacing the default OR with an AND search. If you still need OR search, run two commands:
pacman -Ss 3d ; pacman -Ss games
Dusty
I agree... I mean google defaults to AND... so it's obviously logical
Offline
Just as a devil's advocate, couldn't you just do this to recreate AND searching:
pacman -Ss foo | grep bar
Is this slower? It seems like either AND or OR is going to become a kludge. Maybe provide both options, or even a more complex system (||, &&, !) like someone else mentioned?
"Contrary to popular belief, penguins are not the salvation of modern technology. Neither do they throw parties for the urban proletariat."
Offline
Just as a devil's advocate, couldn't you just do this to recreate AND searching:
pacman -Ss foo | grep bar
You can't, unfortunately. Here's why:
[sweiss@raviv2 ~]$ pacman -Ss 3d | grep game
A 3D racing and car-crashing game in Python
Asteroids3D is a 3D, first-person game of blowing up asteroids
BZFlag is a multiplayer 3D tank battle game.
A tron-like lightcycle game with a nice 3D perspective.
Maelstrom is an excellent Asteroids-type game with sound and 3D objects
3D game similar to Super Monkey Ball or Marble Madness
A 3D tetris/blockout game
Some PKGBUILDs: http://members.lycos.co.uk/sweiss3
Offline