diff options
| author | 2023-01-10 08:45:36 +0100 | |
|---|---|---|
| committer | 2023-01-10 08:45:36 +0100 | |
| commit | 061291cabfe23b5c7742ac5bc4dc7e968278ad00 (patch) | |
| tree | 15debb64bf1893106a9919d0f1d7b5f6cda59527 | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | penes-snac2-061291cabfe23b5c7742ac5bc4dc7e968278ad00.tar.gz penes-snac2-061291cabfe23b5c7742ac5bc4dc7e968278ad00.tar.xz penes-snac2-061291cabfe23b5c7742ac5bc4dc7e968278ad00.zip | |
Backport from xs.
| -rw-r--r-- | xs.h | 18 | ||||
| -rw-r--r-- | xs_version.h | 2 |
2 files changed, 14 insertions, 6 deletions
| @@ -459,13 +459,21 @@ d_char *xs_crop(d_char *str, int start, int end) | |||
| 459 | d_char *xs_strip_chars(d_char *str, const char *chars) | 459 | d_char *xs_strip_chars(d_char *str, const char *chars) |
| 460 | /* strips the string of chars from the start and the end */ | 460 | /* strips the string of chars from the start and the end */ |
| 461 | { | 461 | { |
| 462 | int s, e; | 462 | int n; |
| 463 | |||
| 464 | /* strip first from the end */ | ||
| 465 | for (n = strlen(str); n > 0 && strchr(chars, str[n - 1]); n--); | ||
| 466 | str[n] = '\0'; | ||
| 463 | 467 | ||
| 464 | for (s = 0; strchr(chars, str[s]); s++); | 468 | if (str[0]) { |
| 465 | for (e = strlen(str); e > 0 && strchr(chars, str[e - 1]); e--); | 469 | /* now strip from the beginning */ |
| 470 | for (n = 0; str[n] && strchr(chars, str[n]); n++); | ||
| 466 | 471 | ||
| 467 | str[e] = '\0'; | 472 | if (n) |
| 468 | return xs_collapse(str, 0, s); | 473 | str = xs_collapse(str, 0, n); |
| 474 | } | ||
| 475 | |||
| 476 | return str; | ||
| 469 | } | 477 | } |
| 470 | 478 | ||
| 471 | 479 | ||
diff --git a/xs_version.h b/xs_version.h index c58ea4e..2691aed 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* 52f1885c0439e886094a9506e6b06f3d657fe8d9 */ | /* e8f087f6b185939256227ea21b69f5f16f25a2dd */ | ||