diff options
Diffstat (limited to 'xs.h')
| -rw-r--r-- | xs.h | 5 |
1 files changed, 2 insertions, 3 deletions
| @@ -626,15 +626,14 @@ int xs_between(const char *prefix, const char *str, const char *suffix) | |||
| 626 | xs_str *xs_crop_i(xs_str *str, int start, int end) | 626 | xs_str *xs_crop_i(xs_str *str, int start, int end) |
| 627 | /* crops the string to be only from start to end */ | 627 | /* crops the string to be only from start to end */ |
| 628 | { | 628 | { |
| 629 | XS_ASSERT_TYPE(str, XSTYPE_STRING); | ||
| 630 | |||
| 631 | int sz = strlen(str); | 629 | int sz = strlen(str); |
| 632 | 630 | ||
| 633 | if (end <= 0) | 631 | if (end <= 0) |
| 634 | end = sz + end; | 632 | end = sz + end; |
| 635 | 633 | ||
| 636 | /* crop from the top */ | 634 | /* crop from the top */ |
| 637 | str[end] = '\0'; | 635 | if (end > 0 && end < sz) |
| 636 | str[end] = '\0'; | ||
| 638 | 637 | ||
| 639 | /* crop from the bottom */ | 638 | /* crop from the bottom */ |
| 640 | str = xs_collapse(str, 0, start); | 639 | str = xs_collapse(str, 0, start); |