MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLScanDouble

Function CPLScanDouble

port/cpl_conv.cpp:1186–1217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1184 */
1185
1186double CPLScanDouble(const char *pszString, int nMaxLength)
1187{
1188 char szValue[32] = {};
1189 char *pszValue = nullptr;
1190
1191 if (nMaxLength + 1 < static_cast<int>(sizeof(szValue)))
1192 pszValue = szValue;
1193 else
1194 pszValue = static_cast<char *>(CPLMalloc(nMaxLength + 1));
1195
1196 /* -------------------------------------------------------------------- */
1197 /* Compute string into local buffer, and terminate it. */
1198 /* -------------------------------------------------------------------- */
1199 strncpy(pszValue, pszString, nMaxLength);
1200 pszValue[nMaxLength] = '\0';
1201
1202 /* -------------------------------------------------------------------- */
1203 /* Make a pass through converting 'D's to 'E's. */
1204 /* -------------------------------------------------------------------- */
1205 for (int i = 0; i < nMaxLength; i++)
1206 if (pszValue[i] == 'd' || pszValue[i] == 'D')
1207 pszValue[i] = 'E';
1208
1209 /* -------------------------------------------------------------------- */
1210 /* The conversion itself. */
1211 /* -------------------------------------------------------------------- */
1212 const double dfValue = CPLAtof(pszValue);
1213
1214 if (pszValue != szValue)
1215 CPLFree(pszValue);
1216 return dfValue;
1217}
1218
1219/************************************************************************/
1220/* CPLPrintString() */

Callers 4

GetStatisticsMethod · 0.85
CreateCopyMethod · 0.85
OpenMethod · 0.85
OpenMethod · 0.85

Calls 2

CPLMallocFunction · 0.85
CPLAtofFunction · 0.85

Tested by

no test coverage detected