| 166 | */ |
| 167 | |
| 168 | void path_build( PATHNAME * f, string * file ) |
| 169 | { |
| 170 | int check_f; |
| 171 | int check_f_pos; |
| 172 | |
| 173 | file_build1( f, file ); |
| 174 | |
| 175 | /* Do not prepend root if it is '.' or the directory is rooted. */ |
| 176 | check_f = (f->f_root.len |
| 177 | && !( f->f_root.len == 1 && f->f_root.ptr[ 0 ] == '.') |
| 178 | && !( f->f_dir.len && f->f_dir.ptr[ 0 ] == '/' )); |
| 179 | #if PATH_DELIM == '\\' |
| 180 | check_f = (check_f |
| 181 | && !( f->f_dir.len && f->f_dir.ptr[ 0 ] == '\\' ) |
| 182 | && !( f->f_dir.len && f->f_dir.ptr[ 1 ] == ':' )); |
| 183 | #endif |
| 184 | if (check_f) |
| 185 | { |
| 186 | string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len |
| 187 | ); |
| 188 | /* If 'root' already ends with a path delimiter, do not add another one. |
| 189 | */ |
| 190 | if ( !is_path_delim( f->f_root.ptr[ f->f_root.len - 1 ] ) ) |
| 191 | string_push_back( file, as_path_delim( f->f_root.ptr[ f->f_root.len |
| 192 | ] ) ); |
| 193 | } |
| 194 | |
| 195 | if ( f->f_dir.len ) |
| 196 | string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len ); |
| 197 | |
| 198 | /* Put path separator between dir and file. */ |
| 199 | /* Special case for root dir: do not add another path separator. */ |
| 200 | check_f_pos = (f->f_dir.len && ( f->f_base.len || f->f_suffix.len )); |
| 201 | #if PATH_DELIM == '\\' |
| 202 | check_f_pos = (check_f_pos && !( f->f_dir.len == 3 && f->f_dir.ptr[ 1 ] == ':' )); |
| 203 | #endif |
| 204 | check_f_pos = (check_f_pos && !( f->f_dir.len == 1 && is_path_delim( f->f_dir.ptr[ 0 ]))); |
| 205 | if (check_f_pos) |
| 206 | string_push_back( file, as_path_delim( f->f_dir.ptr[ f->f_dir.len ] ) ); |
| 207 | |
| 208 | if ( f->f_base.len ) |
| 209 | string_append_range( file, f->f_base.ptr, f->f_base.ptr + f->f_base.len |
| 210 | ); |
| 211 | |
| 212 | if ( f->f_suffix.len ) |
| 213 | string_append_range( file, f->f_suffix.ptr, f->f_suffix.ptr + |
| 214 | f->f_suffix.len ); |
| 215 | |
| 216 | if ( f->f_member.len ) |
| 217 | { |
| 218 | string_push_back( file, '(' ); |
| 219 | string_append_range( file, f->f_member.ptr, f->f_member.ptr + |
| 220 | f->f_member.len ); |
| 221 | string_push_back( file, ')' ); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 |
no test coverage detected