summaryrefslogtreecommitdiffstats
path: root/blob.c
diff options
context:
space:
mode:
Diffstat (limited to 'blob.c')
-rw-r--r--blob.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/blob.c b/blob.c
index 377ec62..a417a0b 100644
--- a/blob.c
+++ b/blob.c
@@ -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;
+}