diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-01-03 09:12:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-01-03 09:12:17 -0300 |
commit | 8dd2c912d299b84566c6f6d659336edfa9b18e9b (patch) | |
tree | f4fda0bf84c1d52ceba86cbf8ecaeb42241ad6c0 /lobject.c | |
parent | 05ac2409ee9ea312124bf71dcc93711d652e265b (diff) | |
download | lua-8dd2c912d299b84566c6f6d659336edfa9b18e9b.tar.gz lua-8dd2c912d299b84566c6f6d659336edfa9b18e9b.tar.bz2 lua-8dd2c912d299b84566c6f6d659336edfa9b18e9b.zip |
Detail
Warnings with clang when using long double for Lua floats.
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -164,7 +164,7 @@ static int isneg (const char **s) { | |||
164 | */ | 164 | */ |
165 | static lua_Number lua_strx2number (const char *s, char **endptr) { | 165 | static lua_Number lua_strx2number (const char *s, char **endptr) { |
166 | int dot = lua_getlocaledecpoint(); | 166 | int dot = lua_getlocaledecpoint(); |
167 | lua_Number r = 0.0; /* result (accumulator) */ | 167 | lua_Number r = l_mathop(0.0); /* result (accumulator) */ |
168 | int sigdig = 0; /* number of significant digits */ | 168 | int sigdig = 0; /* number of significant digits */ |
169 | int nosigdig = 0; /* number of non-significant digits */ | 169 | int nosigdig = 0; /* number of non-significant digits */ |
170 | int e = 0; /* exponent correction */ | 170 | int e = 0; /* exponent correction */ |
@@ -174,7 +174,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
174 | while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ | 174 | while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ |
175 | neg = isneg(&s); /* check sign */ | 175 | neg = isneg(&s); /* check sign */ |
176 | if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ | 176 | if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ |
177 | return 0.0; /* invalid format (no '0x') */ | 177 | return l_mathop(0.0); /* invalid format (no '0x') */ |
178 | for (s += 2; ; s++) { /* skip '0x' and read numeral */ | 178 | for (s += 2; ; s++) { /* skip '0x' and read numeral */ |
179 | if (*s == dot) { | 179 | if (*s == dot) { |
180 | if (hasdot) break; /* second dot? stop loop */ | 180 | if (hasdot) break; /* second dot? stop loop */ |
@@ -184,14 +184,14 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
184 | if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ | 184 | if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ |
185 | nosigdig++; | 185 | nosigdig++; |
186 | else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ | 186 | else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ |
187 | r = (r * cast_num(16.0)) + luaO_hexavalue(*s); | 187 | r = (r * l_mathop(16.0)) + luaO_hexavalue(*s); |
188 | else e++; /* too many digits; ignore, but still count for exponent */ | 188 | else e++; /* too many digits; ignore, but still count for exponent */ |
189 | if (hasdot) e--; /* decimal digit? correct exponent */ | 189 | if (hasdot) e--; /* decimal digit? correct exponent */ |
190 | } | 190 | } |
191 | else break; /* neither a dot nor a digit */ | 191 | else break; /* neither a dot nor a digit */ |
192 | } | 192 | } |
193 | if (nosigdig + sigdig == 0) /* no digits? */ | 193 | if (nosigdig + sigdig == 0) /* no digits? */ |
194 | return 0.0; /* invalid format */ | 194 | return l_mathop(0.0); /* invalid format */ |
195 | *endptr = cast_charp(s); /* valid up to here */ | 195 | *endptr = cast_charp(s); /* valid up to here */ |
196 | e *= 4; /* each digit multiplies/divides value by 2^4 */ | 196 | e *= 4; /* each digit multiplies/divides value by 2^4 */ |
197 | if (*s == 'p' || *s == 'P') { /* exponent part? */ | 197 | if (*s == 'p' || *s == 'P') { /* exponent part? */ |
@@ -200,7 +200,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
200 | s++; /* skip 'p' */ | 200 | s++; /* skip 'p' */ |
201 | neg1 = isneg(&s); /* sign */ | 201 | neg1 = isneg(&s); /* sign */ |
202 | if (!lisdigit(cast_uchar(*s))) | 202 | if (!lisdigit(cast_uchar(*s))) |
203 | return 0.0; /* invalid; must have at least one digit */ | 203 | return l_mathop(0.0); /* invalid; must have at least one digit */ |
204 | while (lisdigit(cast_uchar(*s))) /* read exponent */ | 204 | while (lisdigit(cast_uchar(*s))) /* read exponent */ |
205 | exp1 = exp1 * 10 + *(s++) - '0'; | 205 | exp1 = exp1 * 10 + *(s++) - '0'; |
206 | if (neg1) exp1 = -exp1; | 206 | if (neg1) exp1 = -exp1; |