#include "defs.h" /* * Find an item by name or proximity. * * t = command * * input = name of item or a cursor position close to one of its elements * return = item header pointer */ DL item(t) REG INT t; { REG DL p=nil(DL); STRING np; STRING cp; if(lastnam[0]) { np=lastnam; cp=commasep(lastnam); if (chkid(np)) error("bad name"); p=findname('w', np); if(p==nil(DL)) p=findname('c', np); } elif(t=='w' || t=='c') { np = noname(); cp=0; } elif(t=='@') { p=findx(); if(p==nil(DL)) error("cannot find item"); np=dln(p)->name; cp=ctype(p); } else return(p); switch(t) { case 'c': case 's': case 'o': t='c'; break; case 'z': case 'w': case 'e': case 'a': t='w'; } if(p==nil(DL)) { if(any(t, "wcL")) p = newdln(BEFORE, last(t), t, 0, np, (cp ? cp : "")); else return(p); } elif(cp) { fixname(p, np, cp); } showh(p, 0); return(p); }