From: Mathieu Pilato Date: Mon, 20 Mar 2023 20:20:08 +0000 (+0100) Subject: fluke-dmm: Fix counts_digits compatibility with 28x format X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d9a026ea7d1100b781641615730680113bec31ed;p=libsigrok.git fluke-dmm: Fix counts_digits compatibility with 28x format Remove sign, then only take into account numerical characters (this correctly excludes the exponent in the scientific notation used by 28x models). --- diff --git a/src/hardware/fluke-dmm/protocol.c b/src/hardware/fluke-dmm/protocol.c index cb641af9..212e4c40 100644 --- a/src/hardware/fluke-dmm/protocol.c +++ b/src/hardware/fluke-dmm/protocol.c @@ -26,16 +26,20 @@ #include "libsigrok-internal.h" #include "protocol.h" -static int count_digits(const char *str) { +static int count_digits(const char *str) +{ int digits; - while (*str && *str != ' ' && *str != ',' && *str != '.') + if (*str == '-' || *str == '+') + str++; + + while (*str >= '0' && *str <= '9') str++; digits = 0; if (*str == '.') { str++; - while (*str && *str != ' ' && *str != ',') { + while (*str >= '0' && *str <= '9') { str++; digits++; }