MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / AsciiStrToFloat

Function AsciiStrToFloat

rEFIt_UEFI/libeg/FloatLib.cpp:231–297  ·  view source on GitHub ↗

RETURN_STATUS EFIAPI AsciiStrDecimalToUintnS ( IN CONST CHAR8 *String, OUT CHAR8 **EndPointer, OPTIONAL OUT UINTN *Data ); */

Source from the content-addressed store, hash-verified

229 );
230*/
231RETURN_STATUS
232AsciiStrToFloat(IN CONST CHAR8 *String,
233 OUT CHAR8 **EndPointer, OPTIONAL
234 OUT float *Data)
235{
236 UINTN Temp = 0;
237 INTN Sign = 1;
238 float Mantissa, Ftemp;
239 CHAR8* TmpStr = NULL;
240 RETURN_STATUS Status = RETURN_SUCCESS;
241 if (EndPointer != NULL) {
242 *EndPointer = (CHAR8 *) String;
243 }
244 //
245 // Ignore the pad spaces (space or tab)
246 //
247 while ((*String == ' ') || (*String == '\t')) {
248 String++;
249 }
250 if (*String == '-') {
251 Sign = -1;
252 String++;
253 } else if (*String == '+') {
254 String++;
255 }
256
257 Status = AsciiStrDecimalToUintnS(String, &TmpStr, &Temp);
258 Mantissa = (float)Temp;
259 String = TmpStr;
260 if (*String == '.') {
261 String++;
262 Temp = 0;
263 Status = AsciiStrDecimalToUintnS(String, &TmpStr, &Temp);
264 Ftemp = (float)Temp;
265 while (String != TmpStr) {
266 if (*String == '\0') {
267 break;
268 }
269 Ftemp *= 0.1f;
270 String++;
271 }
272 Mantissa += Ftemp;
273 }
274
275 if ((*String == 'E') || (*String == 'e')){
276 INTN ExpSign = 1;
277 String++;
278 if (*String == '-') {
279 ExpSign = -1;
280 String++;
281 } else if (*String == '+') {
282 String++;
283 }
284 Temp = 0;
285 Status = AsciiStrDecimalToUintnS(String, &TmpStr, &Temp);
286 if ( Temp > MAX_INTN ) return RETURN_UNSUPPORTED;
287 if (Status == RETURN_SUCCESS) {
288 Ftemp = PowF(10.0f, ExpSign * (INTN)Temp); // cast to avoid warning

Callers 11

ParseTagFloatFunction · 0.85
GetPropertyFloatFunction · 0.85
nsvg__atofFunction · 0.85
nsvg__parseColorRGBFunction · 0.85
nsvg__parseOpacityFunction · 0.85
nsvg__parseMiterLimitFunction · 0.85
nsvg__parseCoordinateRawFunction · 0.85
nsvg__parseAttrFunction · 0.85
nsvg__parseSVGFunction · 0.85
nsvg__parseSymbolFunction · 0.85
nsvg__parseFontFaceFunction · 0.85

Calls 2

PowFFunction · 0.85
AsciiStrDecimalToUintnSFunction · 0.50

Tested by

no test coverage detected