From b2535354ca9f41c102a999a957ff9c004ae41706 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周一, 21 10月 2013 17:36:53 +0800 Subject: [PATCH] Reformat; change return parameter type --- libscpi/src/parser.c | 14 +++++++------- libscpi/inc/scpi/parser.h | 2 +- examples/common/scpi-def.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index 492ba8b..94a093f 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -100,13 +100,13 @@ scpi_result_t TEST_ChoiceQ(scpi_t * context) { - size_t param; + int32_t param; if (!SCPI_ParamChoice(context, trigger_source, ¶m, true)) { return SCPI_RES_ERR; } - fprintf(stderr, "\tP1=%s (%u)\r\n", trigger_source[param], param); + fprintf(stderr, "\tP1=%s (%d)\r\n", trigger_source[param], param); SCPI_ResultInt(context, param); diff --git a/libscpi/inc/scpi/parser.h b/libscpi/inc/scpi/parser.h index 6977d5f..feeca23 100644 --- a/libscpi/inc/scpi/parser.h +++ b/libscpi/inc/scpi/parser.h @@ -61,7 +61,7 @@ bool_t SCPI_ParamString(scpi_t * context, const char ** value, size_t * len, bool_t mandatory); bool_t SCPI_ParamText(scpi_t * context, const char ** value, size_t * len, bool_t mandatory); bool_t SCPI_ParamBool(scpi_t * context, bool_t * value, bool_t mandatory); - bool_t SCPI_ParamChoice(scpi_t * context, const char * options[], size_t * value, bool_t mandatory); + bool_t SCPI_ParamChoice(scpi_t * context, const char * options[], int32_t * value, bool_t mandatory); #ifdef __cplusplus diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index b036fb0..b4d018e 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -625,7 +625,7 @@ * @param mandatory * @return */ -bool_t SCPI_ParamChoice(scpi_t * context, const char * options[], size_t * value, bool_t mandatory) { +bool_t SCPI_ParamChoice(scpi_t * context, const char * options[], int32_t * value, bool_t mandatory) { const char * param; size_t param_len; size_t res; @@ -638,14 +638,14 @@ return FALSE; } - for (res = 0; options[res]; ++res) { - if (matchPattern(options[res], strlen(options[res]), param, param_len)) { - *value = res; - return TRUE; - } + for (res = 0; options[res]; ++res) { + if (matchPattern(options[res], strlen(options[res]), param, param_len)) { + *value = res; + return TRUE; + } } - SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE); + SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE); return FALSE; } -- Gitblit v1.9.1