summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMilan Cejnar <milancejnar@gmail.com>2013-02-18 10:09:12 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-02-21 10:52:12 +0100
commit12ee35f8275f94e080b6a990e7a4f87882282453 (patch)
treed1f6525707321205c8abceb8a8867b896a05a56d /src
parentad65d4ef017e87c1be4b1054e1276f5256a77bfc (diff)
downloadsssd-12ee35f8275f94e080b6a990e7a4f87882282453.tar.gz
sssd-12ee35f8275f94e080b6a990e7a4f87882282453.tar.bz2
sssd-12ee35f8275f94e080b6a990e7a4f87882282453.zip
tools: append new line to string from poptStrerror()
https://fedorahosted.org/sssd/ticket/1756 Messages from poptStrerror() passed to BAD_POPT_PARAMS macro were printed out to the console without new line character at the end of the message. BAD_POPT_PARAMS should now behave correctly with strings both with or without new line character at the end.
Diffstat (limited to 'src')
-rw-r--r--src/tools/tools_util.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c
index 731b2d04..85164c61 100644
--- a/src/tools/tools_util.c
+++ b/src/tools/tools_util.c
@@ -70,8 +70,20 @@ static int setup_db(struct tools_ctx *ctx)
*/
void usage(poptContext pc, const char *error)
{
+ size_t lentmp;
+ char nl[2] = "";
+
poptPrintUsage(pc, stderr, 0);
- if (error) fprintf(stderr, "%s", error);
+
+ if (error) {
+ lentmp = strlen(error);
+ if ((lentmp > 0) && (error[lentmp - 1] != '\n')) {
+ nl[0]='\n';
+ nl[1]='\0';
+ }
+
+ fprintf(stderr, "%s%s", error, nl);
+ }
}
int parse_groups(TALLOC_CTX *mem_ctx, const char *optstr, char ***_out)