MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fx_Date_parse_number

Function fx_Date_parse_number

xs/sources/xsDate.c:240–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240txInteger fx_Date_parse_number(txByte* theCharacter, txString* theString, txBoolean* overflow)
241{
242 txByte c = *theCharacter;
243 txString p = *theString;
244 txInteger aResult = c - '0';
245 c = c_read8(p++);
246 while (('0' <= c) && (c <= '9')) {
247#if __has_builtin(__builtin_add_overflow) && __has_builtin(__builtin_mul_overflow)
248 if (__builtin_mul_overflow(aResult, 10, &aResult) ||
249 __builtin_add_overflow(aResult, c - '0', &aResult))
250 *overflow = 1;
251#else
252 aResult = (aResult * 10) + c - '0';
253 if (aResult < 0)
254 *overflow = 1;
255#endif
256 c = c_read8(p++);
257 }
258 *theCharacter = c;
259 *theString = p;
260 return aResult;
261}
262
263txInteger fx_Date_parse_fraction(txByte* theCharacter, txString* theString)
264{

Callers 1

fx_Date_parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected