diff options
author | Felix Fietkau <nbd@openwrt.org> | 2008-08-27 22:07:52 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2008-08-27 22:07:52 +0200 |
commit | ead1a3c6b0e27a33ee071e1e0736d440d0fa2740 (patch) | |
tree | 470fb00441234a47995b422d8390189c30e5b8f7 | |
parent | 493cf35e3fd4771e538fc230a478c417e7810ed4 (diff) | |
download | uci-ead1a3c6b0e27a33ee071e1e0736d440d0fa2740.tar.gz |
add \n to error messages only when output goes to stderr
-rw-r--r-- | libuci.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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) |