summaryrefslogtreecommitdiff
path: root/openwrt/package/rrdcollect/patches/rrdcollect-scan.patch
blob: f47301ed13e422b3043f0bba01274ece8c6750c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff -ruN rrdcollect-0.2.3.orig/src/scan.c rrdcollect-0.2.3/src/scan.c
--- rrdcollect-0.2.3.orig/src/scan.c	2005-01-20 18:42:17.000000000 +0100
+++ rrdcollect-0.2.3/src/scan.c	2006-01-22 00:51:52.000000000 +0100
@@ -74,6 +74,11 @@
 						} while (isdigit(*fmt));
 					}
 
+					/* skip white spaces like scanf does */
+					if (strchr("difuoxX", *fmt))
+						while (isspace(*buf))
+							buf++;
+					
 					/* FIXME: we should check afterward:
 					 * if (start == buf || start == '-' && buf-start == 1)
 					 * 	die("WTF???  zero-length number???");
@@ -150,27 +155,22 @@
 								buf++, length--;
 							}
 
-							/* ignore if value not found */
-							if(value == 0)
-								return 0;
-
 							if (!ignore)
-								counter[i++]->value = valuedup(value);
+								counter[i++]->value = strndup(start, buf - start);
 							break;
 							
 						case 'c':
+							if (length < 0)
+							     length = 1;	// default length is 1
+							
 							while (*buf && length > 0) {
 								buf++, length--;
 							}
 							if (length > 0)
 								return 2;
 
-							/* ignore if value not found */
-							if(value == 0)
-								return 0;
-							
 							if (!ignore)
-								counter[i++]->value = valuedup(value);
+								counter[i++]->value = strndup(start, buf - start);
 							break;
 							
 							
@@ -192,7 +192,7 @@
 			case '\f':
 			case '\v':
 				/* don't match if not at least one space */
-				if(!isspace(*(buf)))
+				if(!isspace(*buf))
 					return 0;
 				else
 					buf++;
@@ -208,7 +208,7 @@
 					case '\v':
 						break;
 					default:
-						while (isspace(*(buf)))
+						while (isspace(*buf))
 							buf++;
 				}
 				fmt++;