Changeset 4704 for pjproject/trunk/pjlib/src/pj/string.c
- Timestamp:
- Jan 16, 2014 5:30:46 AM (11 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
- Property svn:mergeinfo changed
/pjproject/branches/projects/pjsua2 (added) merged: 4595,4597-4598,4600,4608,4619,4631,4638-4640,4642-4648,4654-4655,4657-4660,4662-4666,4668-4687,4689-4693,4696-4699,4702
- Property svn:mergeinfo changed
-
pjproject/trunk/pjlib/src/pj/string.c
r4537 r4704 176 176 } 177 177 178 PJ_DEF(float) pj_strtof(const pj_str_t *str) 179 { 180 pj_str_t part; 181 char *pdot; 182 float val; 183 184 if (str->slen == 0) 185 return 0; 186 187 pdot = (char*)pj_memchr(str->ptr, '.', str->slen); 188 part.ptr = str->ptr; 189 part.slen = pdot ? pdot - str->ptr : str->slen; 190 191 if (part.slen) 192 val = (float)pj_strtol(&part); 193 else 194 val = 0; 195 196 if (pdot) { 197 part.ptr = pdot + 1; 198 part.slen = (str->ptr + str->slen - pdot - 1); 199 if (part.slen) { 200 pj_str_t endptr; 201 float fpart, fdiv; 202 int i; 203 fpart = (float)pj_strtoul2(&part, &endptr, 10); 204 fdiv = 1.0; 205 for (i=0; i<(part.slen - endptr.slen); ++i) 206 fdiv = fdiv * 10; 207 if (val >= 0) 208 val += (fpart / fdiv); 209 else 210 val -= (fpart / fdiv); 211 } 212 } 213 return val; 214 } 215 178 216 PJ_DEF(int) pj_utoa(unsigned long val, char *buf) 179 217 {
Note: See TracChangeset
for help on using the changeset viewer.