@@ -32,7 +32,7 @@ static int32_t dwim(JsonVariant v, int32_t def = 0) { // "Do What I Mean"
32
32
return v; // ...return value directly
33
33
} else if (v.is <float >()) { // If float...
34
34
return (int )(v.as <float >() + 0.5 ); // ...return rounded integer
35
- } else if (v.is <char *>()) { // If string...
35
+ } else if (v.is <const char *>()) { // If string...
36
36
if ((strlen (v) == 6 ) && !strncasecmp (v, " 0x" , 2 )) { // 4-digit hex?
37
37
uint16_t rgb = strtol (v, NULL , 0 ); // Probably a 16-bit RGB color,
38
38
return __builtin_bswap16 (rgb); // convert to big-endian
@@ -47,7 +47,7 @@ static int32_t dwim(JsonVariant v, int32_t def = 0) { // "Do What I Mean"
47
47
cc[i] = v[i].as <int >();
48
48
} else if (v[i].is <float >()) {
49
49
cc[i] = (int )(v[i].as <float >() * 255.999 );
50
- } else if (v[i].is <char *>()) {
50
+ } else if (v[i].is <const char *>()) {
51
51
cc[i] = strtol (v[i], NULL , 0 );
52
52
}
53
53
if (cc[i] > 255 ) cc[i] = 255 ; // Clip to 8-bit range
@@ -75,7 +75,7 @@ static void getFilename(JsonVariant v, char **ptr) {
75
75
free(*ptr); // delete old value...
76
76
*ptr = NULL;
77
77
}
78
- if(v.is<char*>()) {
78
+ if(v.is<const char*>()) {
79
79
*ptr = strdup(v); // Make a copy of string, save that
80
80
}
81
81
}
@@ -108,9 +108,9 @@ void loadConfig(char *filename) {
108
108
v = doc[" coverage" ];
109
109
if (v.is <int >() || v.is <float >()) coverage = v.as <float >();
110
110
v = doc[" upperEyelid" ];
111
- if (v.is <char *>()) upperEyelidFilename = strdup (v);
111
+ if (v.is <const char *>()) upperEyelidFilename = strdup (v);
112
112
v = doc[" lowerEyelid" ];
113
- if (v.is <char *>()) lowerEyelidFilename = strdup (v);
113
+ if (v.is <const char *>()) lowerEyelidFilename = strdup (v);
114
114
115
115
lightSensorMin = doc[" lightSensorMin" ] | lightSensorMin;
116
116
lightSensorMax = doc[" lightSensorMax" ] | lightSensorMax;
@@ -222,8 +222,8 @@ void loadConfig(char *filename) {
222
222
// below when overriding one or the other and trying to do the right
223
223
// thing with free/strdup. So this does waste a tiny bit of RAM but
224
224
// it's only the size of the filenames and only during init. NBD.
225
- if (iristv.is <char *>()) eye[e].iris .filename = strdup (iristv);
226
- if (scleratv.is <char *>()) eye[e].sclera .filename = strdup (scleratv);
225
+ if (iristv.is <const char *>()) eye[e].iris .filename = strdup (iristv);
226
+ if (scleratv.is <const char *>()) eye[e].sclera .filename = strdup (scleratv);
227
227
eye[e].rotation = rotation; // Might get override in per-eye code below
228
228
}
229
229
@@ -258,12 +258,12 @@ void loadConfig(char *filename) {
258
258
v = doc[eye[e].name ][" scleraMirror" ];
259
259
if (v.is <bool >() || v.is <int >()) eye[e].sclera .mirror = v ? 1023 : 0 ;
260
260
v = doc[eye[e].name ][" irisTexture" ];
261
- if (v.is <char *>()) { // Per-eye iris texture specified?
261
+ if (v.is <const char *>()) { // Per-eye iris texture specified?
262
262
if (eye[e].iris .filename ) free (eye[e].iris .filename ); // Remove old name if any
263
263
eye[e].iris .filename = strdup (v); // Save new name
264
264
}
265
265
v = doc[eye[e].name ][" scleraTexture" ]; // Ditto w/sclera
266
- if (v.is <char *>()) {
266
+ if (v.is <const char *>()) {
267
267
if (eye[e].sclera .filename ) free (eye[e].sclera .filename );
268
268
eye[e].sclera .filename = strdup (v);
269
269
}
@@ -278,7 +278,7 @@ void loadConfig(char *filename) {
278
278
gain = doc[" gain" ] | gain;
279
279
modulate = doc[" modulate" ] | modulate;
280
280
v = doc[" waveform" ];
281
- if (v.is <char *>()) { // If string...
281
+ if (v.is <const char *>()) { // If string...
282
282
if (!strncasecmp ( v, " sq" , 2 )) waveform = 1 ;
283
283
else if (!strncasecmp (v, " si" , 2 )) waveform = 2 ;
284
284
else if (!strncasecmp (v, " t" , 1 )) waveform = 3 ;
0 commit comments