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