From: Junio C Hamano Date: Mon, 31 Oct 2016 20:15:22 +0000 (-0700) Subject: Merge branch 'jt/trailer-with-cruft' X-Git-Tag: v2.11.0-rc0~9 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cabb79d8c1c5e4f81f3435603f17c74480888395?ds=inline;hp=--cc Merge branch 'jt/trailer-with-cruft' Update "interpret-trailers" machinery and teaches it that people in real world write all sorts of crufts in the "trailer" that was originally designed to have the neat-o "Mail-Header: like thing" and nothing else. * jt/trailer-with-cruft: trailer: support values folded to multiple lines trailer: forbid leading whitespace in trailers trailer: allow non-trailers in trailer block trailer: clarify failure modes in parse_trailer trailer: make args have their own struct trailer: streamline trailer item create and add trailer: use list.h for doubly-linked list trailer: improve const correctness --- cabb79d8c1c5e4f81f3435603f17c74480888395 diff --cc trailer.c index aecaf9232a,d19a92cd1c..f0ecde2d2f --- a/trailer.c +++ b/trailer.c @@@ -425,23 -413,25 +413,22 @@@ static int set_if_missing(struct conf_i return 0; } - static void duplicate_conf(struct conf_info *dst, struct conf_info *src) + static void duplicate_conf(struct conf_info *dst, const struct conf_info *src) { *dst = *src; - if (src->name) - dst->name = xstrdup(src->name); - if (src->key) - dst->key = xstrdup(src->key); - if (src->command) - dst->command = xstrdup(src->command); + dst->name = xstrdup_or_null(src->name); + dst->key = xstrdup_or_null(src->key); + dst->command = xstrdup_or_null(src->command); } - static struct trailer_item *get_conf_item(const char *name) + static struct arg_item *get_conf_item(const char *name) { - struct trailer_item *item; - struct trailer_item *previous; + struct list_head *pos; + struct arg_item *item; /* Look up item with same name */ - for (previous = NULL, item = first_conf_item; - item; - previous = item, item = item->next) { + list_for_each(pos, &conf_head) { + item = list_entry(pos, struct arg_item, list); if (!strcasecmp(item->conf.name, name)) return item; }