From d7e7fd43b8c8feeaca637fe8c054baa69c5b9c2f Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周五, 17 4月 2015 01:03:28 +0800 Subject: [PATCH] Correct error tests, resolve #29 unexpected error -108 --- libscpi/src/parser.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index b4f79ac..ecf26ec 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -546,8 +546,8 @@ /** * Parse string parameter * @param context - * @param value - * @param len + * @param value Pointer to string buffer where pointer to non-null terminated string will be returned + * @param len Length of returned non-null terminated string * @param mandatory * @return */ @@ -577,8 +577,8 @@ /** * Parse text parameter (can be inside "") * @param context - * @param value - * @param len + * @param value Pointer to string buffer where pointer to non-null terminated string will be returned + * @param len Length of returned non-null terminated string * @param mandatory * @return */ @@ -593,8 +593,10 @@ return FALSE; } + paramSkipWhitespace(context); if (locateText(context->paramlist.parameters, context->paramlist.length, value, &length)) { - paramSkipBytes(context, length); + paramSkipBytes(context, length + 2); + paramSkipWhitespace(context); if (len) { *len = length; } @@ -675,3 +677,11 @@ return FALSE; } +scpi_bool_t SCPI_IsCmd(scpi_t * context, const char * cmd) { + if (! context->paramlist.cmd) { + return FALSE; + } + + const char * pattern = context->paramlist.cmd->pattern; + return matchCommand (pattern, cmd, strlen (cmd)); +} -- Gitblit v1.9.1