X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=sprinter-text.c;h=10343be4b4f1dafe514afa25281586631b376a89;hp=b208840be72df7d0b2431737abb0f0c28b760eac;hb=7f54db1f04f6d0d0e7edc917ea634badd5d4d679;hpb=36522fca1cac6ca23c2c4c0280e3e20e96f7bfbb diff --git a/sprinter-text.c b/sprinter-text.c index b208840b..10343be4 100644 --- a/sprinter-text.c +++ b/sprinter-text.c @@ -25,14 +25,22 @@ struct sprinter_text { }; static void -text_string (struct sprinter *sp, const char *val) +text_string_len (struct sprinter *sp, const char *val, size_t len) { struct sprinter_text *sptxt = (struct sprinter_text *) sp; if (sptxt->current_prefix != NULL) fprintf (sptxt->stream, "%s:", sptxt->current_prefix); - fputs(val, sptxt->stream); + fwrite (val, len, 1, sptxt->stream); +} + +static void +text_string (struct sprinter *sp, const char *val) +{ + if (val == NULL) + val = ""; + text_string_len (sp, val, strlen (val)); } static void @@ -105,6 +113,7 @@ sprinter_text_create (const void *ctx, FILE *stream) .begin_list = text_begin_list, .end = text_end, .string = text_string, + .string_len = text_string_len, .integer = text_integer, .boolean = text_boolean, .null = text_null,