[gnu.utils.bug] new vpsearch fn

wsd@CS.BROWN.EDU (09/30/89)

We in the Graphics Group at Brown have adopted GNUmake as part of our
software standards.  In doing so, we made a few changes that others
might find useful:

1) . allowed in vpath (why was this explicitly excluded?)
just remove the lines

      if (len == 1 && *v == '.')
	continue;

from construct_vpath_list() in vpath.c.  This is useful in conjunction
with vpsearch.

2) vpsearch function

   This takes a bunch of filenames, finds them in the vpath, then
attaches the directory where each was found to each file.  So, if
VPATH is ../include:. and ../include contains foo and . contains bar,
then $(vpsearch foo bar) returns "../include/foo ./bar".  An example
of its use is:

wc:
	wc $(vpsearch $(src))

here's the code (for expand_function() in function.c):

    case function_vpsearch:
      text = expand_argument(text, end);
      i    = strlen(text);

      p3 = text;
      while (p = find_next_token(&p3, NULL)) {
	  p2 = p;
	  if (vpath_search(&p2)) {
	     o = variable_buffer_output(o, p2, strlen(p2));
	     o = variable_buffer_output(o, " ", 1);
	     doneany = 1;
	  }
	  else error("vpsearch couldn't find file %s", p);
      }
      if (doneany) --o;

      free(p2);
      free(text);
      break;

These contributions are from Paul Strauss, Mike Natkin, and Scott
Draves.