diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-11-20 10:02:26 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2023-11-20 10:02:26 -0500 |
commit | 463c541667f200e54847d5045ec034644dcf9490 (patch) | |
tree | 0940b2a45305b15c364486bee069fbd03c5da9a0 | |
parent | b2e7ee9d8ae4b6380d3352a882cafcbbc371c50a (diff) | |
download | stasis-463c541667f200e54847d5045ec034644dcf9490.tar.gz |
Prevent lstrip() will remove leading whitespace and new lines, but NOT if the line consists of one whitepace or new line character
* Document strsort()
-rw-r--r-- | src/str.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -220,7 +220,7 @@ char** split(char *_sptr, const char* delim, size_t max) size_t x = max; char *token = NULL; while((token = strsep(&sptr, delim)) != NULL) { - result[i] = calloc(BUFSIZ, sizeof(char)); + result[i] = calloc(OMC_BUFSIZ, sizeof(char)); if (x < max) { strcat(result[i], strstr(orig, delim) + 1); break; @@ -477,7 +477,12 @@ static int _strsort_dsc_compare(const void *a, const void *b) { /** * Sort an array of strings - * @param arr + * @param arr a NULL terminated array of strings + * @param sort_mode + * - OMC_SORT_LEN_DESCENDING + * - OMC_SORT_LEN_ASCENDING + * - OMC_SORT_ALPHA + * - OMC_SORT_NUMERIC */ void strsort(char **arr, unsigned int sort_mode) { if (arr == NULL) { @@ -587,7 +592,7 @@ char *lstrip(char *sptr) { return NULL; } - while (isblank(*tmp) || isspace(*tmp)) { + while (strlen(tmp) > 1 && (isblank(*tmp) || isspace(*tmp))) { bytes++; tmp++; } |