| 50 | */ |
| 51 | |
| 52 | void path_parse( char const * file, PATHNAME * f ) |
| 53 | { |
| 54 | char const * p; |
| 55 | char const * q; |
| 56 | char const * end; |
| 57 | |
| 58 | memset( (char *)f, 0, sizeof( *f ) ); |
| 59 | |
| 60 | /* Look for '<grist>'. */ |
| 61 | |
| 62 | if ( ( file[ 0 ] == '<' ) && ( p = strchr( file, '>' ) ) ) |
| 63 | { |
| 64 | f->f_grist.ptr = file; |
| 65 | f->f_grist.len = p - file; |
| 66 | file = p + 1; |
| 67 | } |
| 68 | |
| 69 | /* Look for 'dir/'. */ |
| 70 | |
| 71 | p = strrchr( file, '/' ); |
| 72 | |
| 73 | #if PATH_DELIM == '\\' |
| 74 | /* On NT, look for dir\ as well */ |
| 75 | { |
| 76 | char * const p1 = strrchr( p ? p + 1 : file, '\\' ); |
| 77 | if ( p1 ) p = p1; |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | if ( p ) |
| 82 | { |
| 83 | f->f_dir.ptr = file; |
| 84 | f->f_dir.len = p - file; |
| 85 | |
| 86 | /* Special case for / - dirname is /, not "" */ |
| 87 | if ( !f->f_dir.len ) |
| 88 | ++f->f_dir.len; |
| 89 | |
| 90 | #if PATH_DELIM == '\\' |
| 91 | /* Special case for D:/ - dirname is D:/, not "D:" */ |
| 92 | if ( f->f_dir.len == 2 && file[ 1 ] == ':' ) |
| 93 | ++f->f_dir.len; |
| 94 | #endif |
| 95 | |
| 96 | file = p + 1; |
| 97 | } |
| 98 | |
| 99 | end = file + strlen( file ); |
| 100 | |
| 101 | /* Look for '(member)'. */ |
| 102 | if ( ( p = strchr( file, '(' ) ) && ( end[ -1 ] == ')' ) ) |
| 103 | { |
| 104 | f->f_member.ptr = p + 1; |
| 105 | f->f_member.len = end - p - 2; |
| 106 | end = p; |
| 107 | } |
| 108 | |
| 109 | /* Look for '.suffix'. This would be memrchr(). */ |
no outgoing calls
no test coverage detected