MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / CaptureDecimalInteger

Function CaptureDecimalInteger

src/External/CascLib/src/CascFiles.cpp:146–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146static const char * CaptureDecimalInteger(const char * szDataPtr, const char * szDataEnd, PDWORD PtrValue)
147{
148 const char * szSaveDataPtr = szDataPtr;
149 DWORD TotalValue = 0;
150 DWORD AddValue = 0;
151
152 // Skip all spaces
153 while (szDataPtr < szDataEnd && szDataPtr[0] == ' ')
154 szDataPtr++;
155
156 // Load the number
157 while (szDataPtr < szDataEnd && szDataPtr[0] != ' ')
158 {
159 // Must only contain decimal digits ('0' - '9')
160 if(!IsCharDigit(szDataPtr[0]))
161 break;
162
163 // Get the next value and verify overflow
164 AddValue = szDataPtr[0] - '0';
165 if((TotalValue + AddValue) < TotalValue)
166 return NULL;
167
168 TotalValue = (TotalValue * 10) + AddValue;
169 szDataPtr++;
170 }
171
172 // If there were no decimal digits, we consider it failure
173 if(szDataPtr == szSaveDataPtr)
174 return NULL;
175
176 // Give the result
177 PtrValue[0] = TotalValue;
178 return szDataPtr;
179}
180
181static const char * CaptureSingleString(const char * szDataPtr, const char * szDataEnd, char * szBuffer, size_t ccBuffer)
182{

Callers 2

LoadCKeyEntryFunction · 0.85
LoadVfsRootEntryFunction · 0.85

Calls 1

IsCharDigitFunction · 0.85

Tested by

no test coverage detected