2 * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
4 * This file is part of Jam - see jam.c for Copyright information.
7 * search.c - find a target along $(SEARCH) or $(LOCATE)
9 * 11/04/02 (seiwald) - const-ing for string literals
14 #include "timestamp.h"
20 const char *search (const char *target
, time_t *time
) {
25 /* parse the filename */
26 path_parse(target
, f
);
29 if ((varlist
= var_get("LOCATE"))) {
30 f
->f_root
.ptr
= varlist
->string
;
31 f
->f_root
.len
= strlen(varlist
->string
);
32 path_build(f
, buf
, 1);
33 if (DEBUG_SEARCH
) printf("locate %s: %s\n", target
, buf
);
37 if ((varlist
= var_get("SEARCH"))) {
39 f
->f_root
.ptr
= varlist
->string
;
40 f
->f_root
.len
= strlen(varlist
->string
);
41 path_build(f
, buf
, 1);
42 if (DEBUG_SEARCH
) printf("search %s: %s\n", target
, buf
);
44 if (*time
) return newstr(buf
);
45 varlist
= list_next(varlist
);
48 /* look for the obvious */
49 /* this is a questionable move: should we look in the obvious place if SEARCH is set? */
52 path_build(f
, buf
, 1);
53 if (DEBUG_SEARCH
) printf("search %s: %s\n", target
, buf
);