From 94ccbc305cac38eb9c54384b9f47d3da6527299b Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周六, 25 4月 2015 22:29:42 +0800
Subject: [PATCH] Solve #16 Multiple Identical Capabilities

---
 libscpi/src/units.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libscpi/src/units.c b/libscpi/src/units.c
index 493c4ce..2f1f7a7 100644
--- a/libscpi/src/units.c
+++ b/libscpi/src/units.c
@@ -37,7 +37,8 @@
 #include <string.h>
 #include "scpi/parser.h"
 #include "scpi/units.h"
-#include "utils.h"
+#include "scpi/utils_private.h"
+#include "scpi/utils.h"
 #include "scpi/error.h"
 
 
@@ -109,8 +110,9 @@
     {/* name */ "UP",           /* type */ SCPI_NUM_UP},
     {/* name */ "DOWN",         /* type */ SCPI_NUM_DOWN},
     {/* name */ "NAN",          /* type */ SCPI_NUM_NAN},
-    {/* name */ "INF",          /* type */ SCPI_NUM_INF},
+    {/* name */ "INFinity",     /* type */ SCPI_NUM_INF},
     {/* name */ "NINF",         /* type */ SCPI_NUM_NINF},
+    {/* name */ "AUTO",         /* type */ SCPI_NUM_AUTO},
     SCPI_SPECIAL_NUMBERS_LIST_END,
 };
 
@@ -122,7 +124,7 @@
  * @param value resultin value
  * @return TRUE if str matches one of specs patterns
  */
-static bool_t translateSpecialNumber(const scpi_special_number_def_t * specs, const char * str, size_t len, scpi_number_t * value) {
+static scpi_bool_t translateSpecialNumber(const scpi_special_number_def_t * specs, const char * str, size_t len, scpi_number_t * value) {
     int i;
 
     value->value = 0.0;
@@ -134,7 +136,7 @@
     }
 
     for (i = 0; specs[i].name != NULL; i++) {
-        if (matchPattern(specs[i].name, strlen(specs[i].name), str, len)) {
+        if (matchPattern(specs[i].name, strlen(specs[i].name), str, len, NULL)) {
             value->type = specs[i].type;
             return TRUE;
         }
@@ -218,7 +220,7 @@
  * @param value preparsed numeric value
  * @return TRUE if value parameter was converted to base units
  */
-static bool_t transformNumber(scpi_t * context, const char * unit, size_t len, scpi_number_t * value) {
+static scpi_bool_t transformNumber(scpi_t * context, const char * unit, size_t len, scpi_number_t * value) {
     size_t s;
     const scpi_unit_def_t * unitDef;
     s = skipWhitespace(unit, len);
@@ -248,8 +250,8 @@
  * @param mandatory if the parameter is mandatory
  * @return 
  */
-bool_t SCPI_ParamNumber(scpi_t * context, scpi_number_t * value, bool_t mandatory) {
-    bool_t result;
+scpi_bool_t SCPI_ParamNumber(scpi_t * context, scpi_number_t * value, scpi_bool_t mandatory) {
+    scpi_bool_t result;
     const char * param;
     size_t len;
     size_t numlen;
@@ -311,7 +313,7 @@
         return min(strlen(type), len);
     }
 
-    result = doubleToStr(value->value, str, len);
+    result = SCPI_DoubleToStr(value->value, str, len);
 
     unit = translateUnitInverse(context->units, value->unit);
 

--
Gitblit v1.9.1