MCPcopy Create free account
hub / github.com/creatale/node-dv / parseStringForNumbers

Function parseStringForNumbers

deps/leptonica/src/kernel.c:1039–1067  ·  view source on GitHub ↗

------------------------------------------------------------------------* * Parse string to extract numbers * *------------------------------------------------------------------------*/ ! * \brief parseStringForNumbers() * * \param[in] str string containing numbers; not changed * \param[in] seps string of characters that can be used between ints

Source from the content-addressed store, hash-verified

1037 * </pre>
1038 */
1039NUMA *
1040parseStringForNumbers(const char *str,
1041 const char *seps)
1042{
1043char *newstr, *head;
1044char *tail = NULL;
1045l_float32 val;
1046NUMA *na;
1047
1048 PROCNAME("parseStringForNumbers");
1049
1050 if (!str)
1051 return (NUMA *)ERROR_PTR("str not defined", procName, NULL);
1052
1053 newstr = stringNew(str); /* to enforce const-ness of str */
1054 na = numaCreate(0);
1055 head = strtokSafe(newstr, seps, &tail);
1056 val = atof(head);
1057 numaAddNumber(na, val);
1058 LEPT_FREE(head);
1059 while ((head = strtokSafe(NULL, seps, &tail)) != NULL) {
1060 val = atof(head);
1061 numaAddNumber(na, val);
1062 LEPT_FREE(head);
1063 }
1064
1065 LEPT_FREE(newstr);
1066 return na;
1067}
1068
1069
1070/*------------------------------------------------------------------------*

Callers 3

pixThresholdGrayArbFunction · 0.85
kernelCreateFromStringFunction · 0.85
kernelCreateFromFileFunction · 0.85

Calls 4

stringNewFunction · 0.85
numaCreateFunction · 0.85
strtokSafeFunction · 0.85
numaAddNumberFunction · 0.85

Tested by

no test coverage detected