*** bsd.port.subdir.mk Sat Jul 16 00:48:17 2005 --- bsd.port.subdir.mk.new Sat Jul 16 00:47:34 2005 *************** *** 430,432 **** --- 430,506 ---- printf("%s:\t%s\n", names[i], $$i); \ print(""); \ }' ${PORTSDIR}/${INDEXFILE} + + quicksearch: ${PORTSDIR}/${INDEXFILE} + @here=${.CURDIR}; \ + cd ${PORTSDIR}; \ + if [ -z "$$key" -a -z "$$xkey" -a \ + -z "$$name" -a -z "$$xname" -a \ + -z "$$path" -a -z "$$xpath" -a \ + -z "$$info" -a -z "$$xinfo" ]; \ + then \ + echo "The quicksearch target requires a keyword parameter or name parameter,"; \ + echo "e.g.: \"make search key=somekeyword\""; \ + echo "or \"make search name=somekeyword\""; \ + exit; \ + fi; \ + awk -F\| -v there="$$here/" -v top="$$(pwd -P)" \ + -v key="$$key" -v xkey="$$xkey" \ + -v name="$$name" -v xname="$$xname" \ + -v path="$$path" -v xpath="$$xpath" \ + -v info="$$info" -v xinfo="$$xinfo" \ + -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \ + -v keylim="$${keylim:-${PORTSEARCH_KEYLIM}}" \ + -v xkeylim="$${xkeylim:-${PORTSEARCH_XKEYLIM}}" \ + -v display="$${display:-${PORTSEARCH_DISPLAY_FIELDS}}" \ + 'BEGIN { \ + if (substr(there, 1, length(top)) == top) \ + there = "${PORTSDIR}" substr(there, 1 + length(top)); \ + therelen = length(there); \ + keylen = length(key); keylim = keylim && keylen; \ + if (!keylim && keylen) \ + parms[0] = (icase ? tolower(key) : key); \ + xkeylen = length(xkey); xkeylim = xkeylim && xkeylen; \ + if (!xkeylim && xkeylen) \ + xparms[0] = (icase ? tolower(xkey) : xkey); \ + if (icase) { \ + if (length(name)) parms[1] = tolower(name); if (length(xname)) xparms[1] = tolower(xname); \ + if (length(path)) parms[2] = tolower(path); if (length(xpath)) xparms[2] = tolower(xpath); \ + if (length(info)) parms[4] = tolower(info); if (length(xinfo)) xparms[4] = tolower(xinfo); \ + } else { \ + if (length(name)) parms[1] = name; if (length(xname)) xparms[1] = xname; \ + if (length(path)) parms[2] = path; if (length(xpath)) xparms[2] = xpath; \ + if (length(info)) parms[4] = info; if (length(xinfo)) xparms[4] = xinfo; \ + } \ + fields["name"] = 1; names[1] = "Port"; \ + fields["path"] = 2; names[2] = "Path"; \ + fields["info"] = 4; names[4] = "Info"; \ + split(display, d, /,[ \t]*/); \ + for (i in d) { \ + disp[fields[d[i]]] = 1; \ + } \ + } \ + { \ + if (substr($$2, 1, therelen) != there) \ + next; \ + for (i in parms) \ + if ((icase ? tolower($$i) : $$i) !~ parms[i]) \ + next; \ + for (i in xparms) \ + if ((icase ? tolower($$i) : $$i) ~ xparms[i]) \ + next; \ + found = 0; \ + for (i = 1; i < 11; i++) \ + if (i in disp) { \ + if (xkeylim && (icase ? tolower($$i) : $$i) ~ xkey) \ + next; \ + if (!found && keylim && (icase ? tolower($$i) : $$i) ~ key) \ + found = 1; \ + } \ + if (keylim && !found) \ + next; \ + for (i = 1; i < 11; i++) \ + if (i in disp) \ + printf("%s:\t%s\n", names[i], $$i); \ + print(""); \ + }' ${PORTSDIR}/${INDEXFILE}