print the reason for parse errors in error messages
[project/uci.git] / libuci.c
index 262ca698c5f68753ecd68a4e6a156e1e50e295ec..cb0bc360ab442ee1b0cc4617c6b3674d945df212 100644 (file)
--- a/libuci.c
+++ b/libuci.c
@@ -116,7 +116,7 @@ void uci_perror(struct uci_context *ctx, const char *str)
        switch (err) {
        case UCI_ERR_PARSE:
                if (ctx->pctx) {
-                       fprintf(stderr, "%s: %s at line %d, byte %d\n", str, uci_errstr[err], ctx->pctx->line, ctx->pctx->byte);
+                       fprintf(stderr, "%s: %s (%s) at line %d, byte %d\n", str, uci_errstr[err], (ctx->pctx->reason ? ctx->pctx->reason : "unknown"), ctx->pctx->line, ctx->pctx->byte);
                        break;
                }
                /* fall through */