Merge "[Feature][ZXW-243]merge T106_DRDI_20240305 modem 1.T106C WCDMA低温温补参数 2.T106C LTE低温温补参数"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-thermal/src/lynq_qser_thermal.c b/cap/zx297520v3/src/lynq/lib/liblynq-qser-thermal/src/lynq_qser_thermal.c
index 30114f0..acf7e24 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-thermal/src/lynq_qser_thermal.c
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-thermal/src/lynq_qser_thermal.c
@@ -1,23 +1,46 @@
#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
#include "lynq_qser_thermal.h"
+#define MAX_SIZE 100
void parseBuffer(const char *buf, int *numbers, int *count) {
int i = 0;
-
- while (buf[i] != '\0') {
- while (buf[i] == ' ' || buf[i] == '\n') {
+ *count = 0;
+
+ while (buf[i] != '\0' && *count < MAX_SIZE) {
+ while (buf[i] != '\0' && (buf[i] < '0' || buf[i] > '9') && buf[i] != '-' && buf[i] != '+') {
+ ++i;
+ }
+
+ bool negative = false;
+ if (buf[i] == '-') {
+ negative = true;
+ ++i;
+ } else if (buf[i] == '+') {
++i;
}
int num = 0;
- while (buf[i] >= '0' && buf[i] <= '9') {
+ while (buf[i] != '\0' && buf[i] >= '0' && buf[i] <= '9') {
num = num * 10 + (buf[i] - '0');
++i;
}
- numbers[(*count)++] = num;
+ if (negative) {
+ num = -num;
+ }
+
+
+ if (*count < MAX_SIZE) {
+ numbers[(*count)++] = num;
+ }
+
+ while (buf[i] != '\0' && (buf[i] >= '0' && buf[i] <= '9')) {
+ ++i;
+ }
}
}
@@ -27,7 +50,7 @@
int ch;
char buf[MAX_SIZE];
int i = 0;
- int count = 0;
+
if(NULL == numbers ){
printf("Error para\n");
@@ -55,6 +78,7 @@
buf[i] = '\0';
fclose(file);
+ int count = 0;
parseBuffer(buf, numbers, &count);
return count;