Stefan Schuermans

Stefan Schuermans commited on 2011-09-11 17:16:30
Showing 26 changed files, with 178 additions and 29 deletions.

... ...
@@ -1,3 +1,8 @@
1
+1.0.3 2010-09-12
2
+----------------
3
+now parsing doubles in config file using own function
4
+  - accept numbers with dots in every locale (LC_NUMERIC)
5
+
1 6
 1.0.2 2010-08-30
2 7
 ----------------
3 8
 replaced strerror() with strerror_r()
... ...
@@ -1,5 +1,5 @@
1 1
 # FlexiPix library
2
-# !version: 1.0.2! !date: 2010-08-30!
2
+# !version: 1.0.3! !date: 2010-09-12!
3 3
 #
4 4
 # Copyright 2010 Stefan Schuermans <stefan schuermans info>
5 5
 #
... ...
@@ -19,7 +19,7 @@
19 19
 LIBTARGET=libflexipix
20 20
 VER=1
21 21
 VERMIN=0
22
-VERREV=2
22
+VERREV=3
23 23
 
24 24
 SRCS=$(wildcard src/*.c)
25 25
 EX_SRCS=$(wildcard examples/src/*.c)
... ...
@@ -121,8 +121,8 @@ pack:
121 121
 	$(MAKE) clean
122 122
 	mkdir -p pack/$(PACKNAME)
123 123
 	cp -r $(PACKDATA) pack/$(PACKNAME)
124
-	sed -i 's/!version: 1.0.2!]*!/!version: 1.0.2!/g' $$(find pack -type f)
125
-	sed -i 's/!date: 2010-08-30!]*!/!date: 2010-08-30!/g' $$(find pack -type f)
124
+	sed -i 's/!version: 1.0.3!]*!/!version: 1.0.3!/g' $$(find pack -type f)
125
+	sed -i 's/!date: 2010-09-12!]*!/!date: 2010-09-12!/g' $$(find pack -type f)
126 126
 	cd pack; tar jcf ../$(PACKNAME).tar.bz2 $(PACKNAME)
127 127
 	$(MAKE) clean
128 128
 
... ...
@@ -1,5 +1,5 @@
1 1
 FlexiPix library
2
-!version: 1.0.2! !date: 2010-08-30!
2
+!version: 1.0.3! !date: 2010-09-12!
3 3
 
4 4
 FlexPix is a large scale display architecure that is driven using UDP/IP.
5 5
 It consists of single pixels that are connected to chains. A number of those
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -0,0 +1,37 @@
1
+/*
2
+ * FlexiPix library
3
+ * !version: 1.0.3! !date: 2010-09-12!
4
+ *
5
+ * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, version 3 of the License.
10
+ *
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+#ifndef FLP_STRTOD_NOLOC_H
22
+#define FLP_STRTOD_NOLOC_H
23
+
24
+/**
25
+ * \brief own version of strtod ignoring locale
26
+ *
27
+ * This version of strtod always expects dots in floating point numbers.
28
+ * The reason is to be able to use the same config files for all locales.
29
+ *
30
+ * \param[in] nptr string containing number to parse
31
+ * \param[out] endptr filled with pointer to
32
+ * \return value read from the string
33
+ */
34
+double flp_strtod_noloc(const char *nptr, char **endptr);
35
+
36
+#endif /* #ifndef FLP_STRTOD_NOLOC_H */
37
+
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -31,6 +31,7 @@
31 31
 #include <intern/mapping.h>
32 32
 #include <intern/net.h>
33 33
 #include <intern/parse.h>
34
+#include <intern/strtod_noloc.h>
34 35
 #include <intern/types.h>
35 36
 
36 37
 /**
... ...
@@ -219,7 +220,7 @@ int flp_config_proc_mapping(flp_config_ctx_t *p_ctx, char *p_setting_part2,
219 220
   }
220 221
 
221 222
   /* get mapping parameters: base, factor, gamma */
222
-  base = strtod(value, &ptr);
223
+  base = flp_strtod_noloc(value, &ptr);
223 224
   if (ptr == value
224 225
       || (*ptr != 0 && *ptr != ' ' && *ptr != '\t'
225 226
           && *ptr != '\r' && *ptr != '\n')) {
... ...
@@ -230,7 +231,7 @@ int flp_config_proc_mapping(flp_config_ctx_t *p_ctx, char *p_setting_part2,
230 231
                         value, p_ctx->line_no);
231 232
     return -1;
232 233
   }
233
-  factor = strtod(ptr, &ptr2);
234
+  factor = flp_strtod_noloc(ptr, &ptr2);
234 235
   if (ptr2 == ptr
235 236
       || (*ptr2 != 0 && *ptr2 != ' ' && *ptr2 != '\t'
236 237
           && *ptr2 != '\r' && *ptr2 != '\n')) {
... ...
@@ -241,7 +242,7 @@ int flp_config_proc_mapping(flp_config_ctx_t *p_ctx, char *p_setting_part2,
241 242
                         value, p_ctx->line_no);
242 243
     return -1;
243 244
   }
244
-  gamma = strtod(ptr2, &ptr);
245
+  gamma = flp_strtod_noloc(ptr2, &ptr);
245 246
   if (ptr == ptr2
246 247
       || (*ptr != 0 && *ptr != ' ' && *ptr != '\t'
247 248
           && *ptr != '\r' && *ptr != '\n')) {
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * FlexiPix library
3
- * !version: 1.0.2! !date: 2010-08-30!
3
+ * !version: 1.0.3! !date: 2010-09-12!
4 4
  *
5 5
  * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6 6
  *
... ...
@@ -0,0 +1,106 @@
1
+/*
2
+ * FlexiPix library
3
+ * !version: 1.0.3! !date: 2010-09-12!
4
+ *
5
+ * Copyright 2010 Stefan Schuermans <stefan schuermans info>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, version 3 of the License.
10
+ *
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+#include <math.h>
22
+
23
+#include <intern/strtod_noloc.h>
24
+
25
+/**
26
+ * \brief own version of strtod ignoring locale
27
+ *
28
+ * This version of strtod always expects dots in floating point numbers.
29
+ * The reason is to be able to use the same config files for all locales.
30
+ *
31
+ * \param[in] nptr string containing number to parse
32
+ * \param[out] endptr filled with pointer to
33
+ * \return value read from the string
34
+ */
35
+double flp_strtod_noloc(const char *nptr, char **endptr)
36
+{
37
+  double sign = 1.0, value = 0.0, weight = 0.1;
38
+  int exp_sign = 1, exp_value = 0;
39
+
40
+  /* skip whitespace */
41
+  while (*nptr == ' ' || *nptr == '\t')
42
+    ++nptr;
43
+
44
+  /* read optional sign */
45
+  if (*nptr == '+') {
46
+    sign = 1.0;
47
+    ++nptr;
48
+  } else if (*nptr == '-') {
49
+    sign = -1.0;
50
+    ++nptr;
51
+  }
52
+
53
+  /* read digits before dot */
54
+  while (*nptr >= '0' && *nptr <= '9') {
55
+    value = value * 10.0 + (double)(*nptr - '0');
56
+    ++nptr;
57
+  }
58
+
59
+  /* read dot and digits after it */
60
+  if (*nptr == '.') {
61
+    ++nptr;
62
+
63
+    /* read digits after dot */
64
+    while (*nptr >= '0' && *nptr <= '9') {
65
+      value += weight * (double)(*nptr - '0');
66
+      weight *= 0.1;
67
+      ++nptr;
68
+    }
69
+
70
+  } /* if (*nptr == '.') */
71
+
72
+  /* merge sign into value */
73
+  value *= sign;
74
+
75
+  /* read exponent */
76
+  if (*nptr == 'E' || *nptr == 'e') {
77
+    ++nptr;
78
+
79
+    /* read optional sign */
80
+    if (*nptr == '+') {
81
+      exp_sign = 1;
82
+      ++nptr;
83
+    } else if (*nptr == '-') {
84
+      exp_sign = -1;
85
+      ++nptr;
86
+    }
87
+
88
+    /* read digits */
89
+    while (*nptr >= '0' && *nptr <= '9') {
90
+      exp_value = exp_value * 10 + (int)(*nptr - '0');
91
+      ++nptr;
92
+    }
93
+
94
+    /* merge exponent into value */
95
+    value *= pow(10.0, exp_sign * exp_value);
96
+
97
+  } /* if (*nptr == 'E' || *nptr == 'e') */
98
+
99
+  /* return pointer behind end */
100
+  if (endptr)
101
+    *endptr = (char *)nptr;
102
+
103
+  /* return value */
104
+  return value;
105
+}
106
+
0 107