From f3bbdc592cbac70c9286d655ee8e3602fc3213b0 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 15 Jun 2017 23:52:15 +0000 Subject: [PATCH] Allow multiline makeoptions to work by quoting the newline.. --- usr.bin/config/mkmakefile.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/usr.bin/config/mkmakefile.c b/usr.bin/config/mkmakefile.c index d848ef15ad42..180ae03c4aa5 100644 --- a/usr.bin/config/mkmakefile.c +++ b/usr.bin/config/mkmakefile.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkmakefile.c,v 1.68 2015/09/04 10:16:35 uebayasi Exp $ */ +/* $NetBSD: mkmakefile.c,v 1.69 2017/06/15 23:52:15 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include -__RCSID("$NetBSD: mkmakefile.c,v 1.68 2015/09/04 10:16:35 uebayasi Exp $"); +__RCSID("$NetBSD: mkmakefile.c,v 1.69 2017/06/15 23:52:15 christos Exp $"); #include #include @@ -77,6 +77,7 @@ static void emitrules(FILE *); static void emitload(FILE *); static void emitincludes(FILE *); static void emitappmkoptions(FILE *); +static void emitmkoption(FILE *, const char *, const struct nvlist *); static void emitsubs(FILE *, const char *, const char *, int); static int selectopt(const char *, void *); @@ -210,6 +211,21 @@ mkmakefile(void) return (1); } +static void +emitmkoption(FILE *fp, const char *ass, const struct nvlist *nv) +{ + + fprintf(fp, "%s%s", nv->nv_name, ass); + + for (const char *p = nv->nv_str; *p; p++) { + if (*p == '\n') + fputs(" \\", fp); + fputc(*p, fp); + } + + fputc('\n', fp); +} + static void emitsubs(FILE *fp, const char *line, const char *file, int lineno) { @@ -292,7 +308,7 @@ emitdefs(FILE *fp) fprintf(fp, "___USE_SUFFIX_RULES___=1\n"); } for (nv = mkoptions; nv != NULL; nv = nv->nv_next) - fprintf(fp, "%s=%s\n", nv->nv_name, nv->nv_str); + emitmkoption(fp, "=", nv); } static void @@ -583,7 +599,7 @@ emitappmkoptions(FILE *fp) for (nv = condmkoptions; nv != NULL; nv = nv->nv_next) { cond = nv->nv_ptr; if (expr_eval(cond, selectopt, NULL)) - fprintf(fp, "%s+=%s\n", nv->nv_name, nv->nv_str); + emitmkoption(fp, "+=", nv); condexpr_destroy(cond); nv->nv_ptr = NULL; }