2 * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
4 * This file is part of Jam - see jam.c for Copyright information.
8 * search.c - find a target along $(SEARCH) or $(LOCATE)
10 * 11/04/02 (seiwald) - const-ing for string literals
16 # include "timestamp.h"
18 # include "variable.h"
21 const char *search (const char *target
, time_t *time
) {
26 /* Parse the filename */
27 path_parse(target
, f
);
30 if ((varlist
= var_get("LOCATE"))) {
31 f
->f_root
.ptr
= varlist
->string
;
32 f
->f_root
.len
= strlen(varlist
->string
);
33 path_build(f
, buf
, 1);
34 if (DEBUG_SEARCH
) printf("locate %s: %s\n", target
, buf
);
37 } else 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 */
50 /* obvious place if SEARCH is set? */
53 path_build(f
, buf
, 1);
54 if (DEBUG_SEARCH
) printf("search %s: %s\n", target
, buf
);