@@ -32,7 +32,7 @@ static int32_t dwim(JsonVariant v, int32_t def = 0) { // "Do What I Mean"
3232 return v; // ...return value directly
3333 } else if (v.is <float >()) { // If float...
3434 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...
3636 if ((strlen (v) == 6 ) && !strncasecmp (v, " 0x" , 2 )) { // 4-digit hex?
3737 uint16_t rgb = strtol (v, NULL , 0 ); // Probably a 16-bit RGB color,
3838 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"
4747 cc[i] = v[i].as <int >();
4848 } else if (v[i].is <float >()) {
4949 cc[i] = (int )(v[i].as <float >() * 255.999 );
50- } else if (v[i].is <char *>()) {
50+ } else if (v[i].is <const char *>()) {
5151 cc[i] = strtol (v[i], NULL , 0 );
5252 }
5353 if (cc[i] > 255 ) cc[i] = 255 ; // Clip to 8-bit range
@@ -75,7 +75,7 @@ static void getFilename(JsonVariant v, char **ptr) {
7575 free(*ptr); // delete old value...
7676 *ptr = NULL;
7777 }
78- if(v.is<char*>()) {
78+ if(v.is<const char*>()) {
7979 *ptr = strdup(v); // Make a copy of string, save that
8080 }
8181}
@@ -108,9 +108,9 @@ void loadConfig(char *filename) {
108108 v = doc[" coverage" ];
109109 if (v.is <int >() || v.is <float >()) coverage = v.as <float >();
110110 v = doc[" upperEyelid" ];
111- if (v.is <char *>()) upperEyelidFilename = strdup (v);
111+ if (v.is <const char *>()) upperEyelidFilename = strdup (v);
112112 v = doc[" lowerEyelid" ];
113- if (v.is <char *>()) lowerEyelidFilename = strdup (v);
113+ if (v.is <const char *>()) lowerEyelidFilename = strdup (v);
114114
115115 lightSensorMin = doc[" lightSensorMin" ] | lightSensorMin;
116116 lightSensorMax = doc[" lightSensorMax" ] | lightSensorMax;
@@ -222,8 +222,8 @@ void loadConfig(char *filename) {
222222 // below when overriding one or the other and trying to do the right
223223 // thing with free/strdup. So this does waste a tiny bit of RAM but
224224 // 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);
227227 eye[e].rotation = rotation; // Might get override in per-eye code below
228228 }
229229
@@ -258,12 +258,12 @@ void loadConfig(char *filename) {
258258 v = doc[eye[e].name ][" scleraMirror" ];
259259 if (v.is <bool >() || v.is <int >()) eye[e].sclera .mirror = v ? 1023 : 0 ;
260260 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?
262262 if (eye[e].iris .filename ) free (eye[e].iris .filename ); // Remove old name if any
263263 eye[e].iris .filename = strdup (v); // Save new name
264264 }
265265 v = doc[eye[e].name ][" scleraTexture" ]; // Ditto w/sclera
266- if (v.is <char *>()) {
266+ if (v.is <const char *>()) {
267267 if (eye[e].sclera .filename ) free (eye[e].sclera .filename );
268268 eye[e].sclera .filename = strdup (v);
269269 }
@@ -278,7 +278,7 @@ void loadConfig(char *filename) {
278278 gain = doc[" gain" ] | gain;
279279 modulate = doc[" modulate" ] | modulate;
280280 v = doc[" waveform" ];
281- if (v.is <char *>()) { // If string...
281+ if (v.is <const char *>()) { // If string...
282282 if (!strncasecmp ( v, " sq" , 2 )) waveform = 1 ;
283283 else if (!strncasecmp (v, " si" , 2 )) waveform = 2 ;
284284 else if (!strncasecmp (v, " t" , 1 )) waveform = 3 ;
0 commit comments