Browse code

- fixed error reported by Juha Heinanen

Jan Janak authored on 18/02/2005 18:16:48
Showing 1 changed files
... ...
@@ -40,7 +40,7 @@
40 40
  */
41 41
 int str2q(qvalue_t* q, char* s, int len)
42 42
 {
43
-	int i, digits;
43
+	int i, digits, order;
44 44
 
45 45
 	     /* States and equivalent regular expressions of input */
46 46
 	enum {
... ...
@@ -58,6 +58,7 @@ int str2q(qvalue_t* q, char* s, int len)
58 58
 	}
59 59
 
60 60
 	digits = 1;
61
+	order = 100;
61 62
 	for(i = 0; i < len; i++) {
62 63
 		switch(state) {
63 64
 		case ST_START:
... ...
@@ -123,7 +124,8 @@ int str2q(qvalue_t* q, char* s, int len)
123 124
 
124 125
 		case ST_0_PT:
125 126
 			if (s[i] >= '0' && s[i] <= '9') {
126
-				*q =  s[i] - '0';
127
+				*q =  (s[i] - '0') * order;
128
+				order /= 10;
127 129
 				state = ST_0_PT_N;
128 130
 			} else {
129 131
 				return E_Q_INV_CHAR;
... ...
@@ -156,8 +158,9 @@ int str2q(qvalue_t* q, char* s, int len)
156 158
 
157 159
 		case ST_0_PT_N:
158 160
 			if (s[i] >= '0' && s[i] <= '9') {
159
-				if (digits < 3) {
160
-					*q = *q * 10 + s[i] - '0';
161
+				if (digits <= 3) {
162
+					*q += (s[i] - '0') * order;
163
+					order /= 10;
161 164
 					digits++;
162 165
 				}
163 166
 			} else {