summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2008-08-27 22:07:52 +0200
committerFelix Fietkau <nbd@openwrt.org>2008-08-27 22:07:52 +0200
commitead1a3c6b0e27a33ee071e1e0736d440d0fa2740 (patch)
tree470fb00441234a47995b422d8390189c30e5b8f7
parent493cf35e3fd4771e538fc230a478c417e7810ed4 (diff)
downloaduci-ead1a3c6b0e27a33ee071e1e0736d440d0fa2740.tar.gz
add \n to error messages only when output goes to stderr
-rw-r--r--libuci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libuci.c b/libuci.c
index 29dab12..bc68462 100644
--- a/libuci.c
+++ b/libuci.c
@@ -145,7 +145,7 @@ uci_get_errorstr(struct uci_context *ctx, char **dest, const char *prefix)
"%s%s" /* prefix */
"%s%s" /* function */
"%s" /* error */
- "%s\n"; /* details */
+ "%s"; /* details */
error_info[0] = 0;
@@ -160,7 +160,7 @@ uci_get_errorstr(struct uci_context *ctx, char **dest, const char *prefix)
switch (err) {
case UCI_ERR_PARSE:
if (ctx->pctx) {
- snprintf(error_info, sizeof(error_info), " (%s) at line %d, byte %d", (ctx->pctx->reason ? ctx->pctx->reason : "unknown"), ctx->pctx->line, ctx->pctx->byte);
+ snprintf(error_info, sizeof(error_info) - 1, " (%s) at line %d, byte %d", (ctx->pctx->reason ? ctx->pctx->reason : "unknown"), ctx->pctx->line, ctx->pctx->byte);
break;
}
break;
@@ -173,12 +173,14 @@ uci_get_errorstr(struct uci_context *ctx, char **dest, const char *prefix)
(ctx->func ? ctx->func : ""), (ctx->func ? ": " : ""),
uci_errstr[err],
error_info);
- else
+ else {
+ strcat(error_info, "\n");
fprintf(stderr, format,
(prefix ? prefix : ""), (prefix ? ": " : ""),
(ctx->func ? ctx->func : ""), (ctx->func ? ": " : ""),
uci_errstr[err],
error_info);
+ }
}
int uci_list_configs(struct uci_context *ctx, char ***list)