-/* With our mmapped file, we don't get the benefit of terminated
- * strings, so we can't use things like strchr(). We don't even know
- * if there's a newline at the end of the file so we also have to be
- * careful of that. Basically, every time we advance a pointer while
- * parsing we must ensure we don't go beyond our buffer.
- */
-#define WITHIN(s) (((s) - message->start) < (message->size -1))
-
-/* In each of the macros below, "without overrunning the buffer" means
- * that the macro will never dereference a character beyond the end of
- * the buffer. However, all of the macros may return a pointer
- * pointing to the first character beyond the buffer. So callers
- * should test with WITHIN before dereferencing the result. */
-
-/* Advance 'ptr' until pointing at a non-space character in the same
- * line, (without overrunning the buffer) */
-#define SKIP_SPACE_IN_LINE(ptr) \
- while (WITHIN (ptr) && (*(ptr) == ' ' || *(ptr) == '\t')) \
- (ptr)++;
-
-/* Advance 'ptr' until pointing at a non-space character, (without
- * overrunning the buffer) */
-#define SKIP_SPACE(ptr) \
- while (WITHIN (ptr) && isspace(*(ptr))) \
- (ptr)++;
-
-/* Advance 'ptr' to the first occurrence of 'c' within the same
- * line, (without overrunning the buffer). */
-#define ADVANCE_TO(ptr, c) \
- while (WITHIN (ptr) && *(ptr) != '\n' && \
- *(ptr) != (c)) \
- { \
- (ptr)++; \
+void
+copy_header_unfolding (header_value_closure_t *value,
+ const char *chunk)
+{
+ char *last;
+
+ if (chunk == NULL)
+ return;
+
+ while (*chunk == ' ' || *chunk == '\t')
+ chunk++;
+
+ if (value->len + 1 + strlen (chunk) + 1 > value->size) {
+ int new_size = value->size;
+ if (value->size == 0)
+ new_size = strlen (chunk) + 1;
+ else
+ while (value->len + 1 + strlen (chunk) + 1 > new_size)
+ new_size *= 2;
+ value->str = xrealloc (value->str, new_size);
+ value->size = new_size;