From 0012030bc792380d2b24f7894e0efb7a332d936a Mon Sep 17 00:00:00 2001 From: Milan Cejnar Date: Mon, 18 Feb 2013 10:09:12 +0100 Subject: [PATCH] Patch for bug #1756, Append new line to string from poptStrerror() This patch changes function usage() in tools_util.c which is used by BAD_POPT_PARAMS macro. Since BAD_POPT_PARAMS macro is called by multiple functions in multiple files with both custom messages termited with \n as well as popt messages which are not terminated by default, this patch offers a correction by checking the string just after printing out to console and printing out additional \n if new line wasn't present. --- src/tools/tools_util.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c index 731b2d04f4fa24d40de03e44c76bb86b40093e18..2124544a43a4e1b0dcc36fe0c61605ee7650adbe 100644 --- a/src/tools/tools_util.c +++ b/src/tools/tools_util.c @@ -70,8 +70,16 @@ static int setup_db(struct tools_ctx *ctx) */ void usage(poptContext pc, const char *error) { + size_t lentmp; + poptPrintUsage(pc, stderr, 0); - if (error) fprintf(stderr, "%s", error); + + if (error) { + fprintf(stderr, "%s", error); + lentmp = strlen(error); + if ((lentmp > 0) && (error[lentmp - 1] != '\n')) + fprintf(stderr, "%c", '\n'); + } } int parse_groups(TALLOC_CTX *mem_ctx, const char *optstr, char ***_out) -- 1.7.1