diff options
| author | David Bremner <david@tethera.net> | 2022-02-15 20:53:12 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2022-02-15 20:54:56 -0400 |
| commit | f1b2ab70c39cacb53c0b3c1d49358260a8d1818d (patch) | |
| tree | 8b06d207475c256081a10ec5eb1fbd7c959610e0 /util/string-util.c | |
| parent | cf342d7302544532a1f66fd7a1cc42df99fcd228 (diff) | |
| parent | 7b5921877e748338359a25dae578771f768183af (diff) | |
Merge tag '0.35' into debian/bullseye-backportsdebian/0.35-1_bpo11+1archive/debian/0.35-1_bpo11+1
notmuch 0.35 release
Diffstat (limited to 'util/string-util.c')
| -rw-r--r-- | util/string-util.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/util/string-util.c b/util/string-util.c index 9c46a81a..03d7648d 100644 --- a/util/string-util.c +++ b/util/string-util.c @@ -42,13 +42,15 @@ const char * strsplit_len (const char *s, char delim, size_t *len) { bool escaping = false; - size_t count = 0; + size_t count = 0, last_nonspace = 0; - /* Skip initial unescaped delimiters */ - while (*s && *s == delim) + /* Skip initial unescaped delimiters and whitespace */ + while (*s && (*s == delim || isspace (*s))) s++; while (s[count] && (escaping || s[count] != delim)) { + if (! isspace (s[count])) + last_nonspace = count; escaping = (s[count] == '\\'); count++; } @@ -56,7 +58,7 @@ strsplit_len (const char *s, char delim, size_t *len) if (count == 0) return NULL; - *len = count; + *len = last_nonspace + 1; return s; } |
