| 67 | } |
| 68 | |
| 69 | const char *getUnits(const char *string, S32 startIndex, S32 endIndex, const char *set) |
| 70 | { |
| 71 | if( startIndex > endIndex ) |
| 72 | return ""; |
| 73 | |
| 74 | dsize_t sz; |
| 75 | S32 index = startIndex; |
| 76 | while(index--) |
| 77 | { |
| 78 | if(!*string) |
| 79 | return ""; |
| 80 | sz = dStrcspn(string, set); |
| 81 | if (string[sz] == 0) |
| 82 | return ""; |
| 83 | string += (sz + 1); |
| 84 | } |
| 85 | const char *startString = string; |
| 86 | |
| 87 | for( U32 i = startIndex; i <= endIndex && *string; i ++ ) |
| 88 | { |
| 89 | sz = dStrcspn(string, set); |
| 90 | string += sz; |
| 91 | |
| 92 | if( i < endIndex && *string ) |
| 93 | string ++; |
| 94 | } |
| 95 | |
| 96 | S32 totalSize = ( S32 )( string - startString ); |
| 97 | AssertWarn( totalSize + 1 < sizeof( _returnBuffer ), "Size of returned string too large for return buffer" ); |
| 98 | totalSize = getMin( totalSize, S32( sizeof( _returnBuffer ) - 1 ) ); |
| 99 | |
| 100 | if( totalSize > 0 ) |
| 101 | { |
| 102 | char *ret = &_returnBuffer[0]; |
| 103 | dStrncpy( ret, startString, totalSize ); |
| 104 | ret[ totalSize ] = '\0'; |
| 105 | |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | return ""; |
| 110 | } |
| 111 | |
| 112 | U32 getUnitCount(const char *string, const char *set) |
| 113 | { |
no test coverage detected