diff options
Diffstat (limited to 'blob.c')
-rw-r--r-- | blob.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -180,3 +180,23 @@ blob_t blob_pull_cspn(blob_t *b, const blob_t reject) *b = BLOB_NULL; return t; } + +blob_t blob_expand_head(blob_t *b, blob_t limits, unsigned char sep) +{ + blob_t t = *b; + blob_t r; + + if (t.ptr <= limits.ptr || t.ptr+t.len > limits.ptr+limits.len) + return BLOB_NULL; + while (t.ptr > limits.ptr && t.ptr[-1] == sep) + t.ptr--, t.len++; + + r.ptr = t.ptr; + r.len = 0; + while (t.ptr > limits.ptr && t.ptr[-1] != sep) { + t.ptr--, t.len++; + r.ptr--, r.len++; + } + *b = t; + return r; +} |