Records the binding of a target with an explicit LOCATE. */
| 74 | |
| 75 | /* Records the binding of a target with an explicit LOCATE. */ |
| 76 | void set_explicit_binding( OBJECT * target, OBJECT * locate ) |
| 77 | { |
| 78 | OBJECT * boundname; |
| 79 | OBJECT * key; |
| 80 | PATHNAME f[ 1 ]; |
| 81 | string buf[ 1 ]; |
| 82 | int found; |
| 83 | BINDING * ba; |
| 84 | |
| 85 | if ( !explicit_bindings ) |
| 86 | explicit_bindings = hashinit( sizeof( BINDING ), "explicitly specified " |
| 87 | "locations" ); |
| 88 | |
| 89 | string_new( buf ); |
| 90 | |
| 91 | /* Parse the filename. */ |
| 92 | path_parse( object_str( target ), f ); |
| 93 | |
| 94 | /* Ignore the grist. */ |
| 95 | f->f_grist.ptr = 0; |
| 96 | f->f_grist.len = 0; |
| 97 | |
| 98 | /* Root the target path at the given location. */ |
| 99 | f->f_root.ptr = object_str( locate ); |
| 100 | f->f_root.len = strlen( object_str( locate ) ); |
| 101 | |
| 102 | path_build( f, buf ); |
| 103 | boundname = object_new( buf->value ); |
| 104 | if ( DEBUG_SEARCH ) |
| 105 | printf( "explicit locate %s: %s\n", object_str( target ), buf->value ); |
| 106 | string_free( buf ); |
| 107 | key = path_as_key( boundname ); |
| 108 | object_free( boundname ); |
| 109 | |
| 110 | ba = (BINDING *)hash_insert( explicit_bindings, key, &found ); |
| 111 | if ( !found ) |
| 112 | { |
| 113 | ba->binding = key; |
| 114 | ba->target = target; |
| 115 | } |
| 116 | else |
| 117 | object_free( key ); |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * search.c - find a target along $(SEARCH) or $(LOCATE). |
no test coverage detected