Turn the string into a smaller (or equal) string containing only the * substring specified by the 'start' and 'end' indexes. * * start and end can be negative, where -1 means the last character of the * string, -2 the penultimate character, and so forth. * * The interval is inclusive, so the start and end characters will be part * of the resulting string. * * The string is modified in-pla
| 796 | * sdsrange(s,1,-1); => "ello World" |
| 797 | */ |
| 798 | void sdsrange(sds s, ssize_t start, ssize_t end) { |
| 799 | size_t newlen, len = sdslen(s); |
| 800 | if (len == 0) return; |
| 801 | if (start < 0) |
| 802 | start = len + start; |
| 803 | if (end < 0) |
| 804 | end = len + end; |
| 805 | newlen = (start > end) ? 0 : (end-start)+1; |
| 806 | sdssubstr(s, start, newlen); |
| 807 | } |
| 808 | |
| 809 | /* Apply tolower() to every character of the sds string 's'. */ |
| 810 | void sdstolower(sds s) { |
no test coverage detected