Trims zeroes off the end of the last number in the stringbuffer.
The number has to be the very last thing in the buffer. Only the last number will be trimmed. Returns the number of characters trimmed.
eg: 1.22000 -> 1.22 1.0 -> 1 0.0 -> 0
Definition at line 268 of file stringbuffer.c.
269{
270 char *ptr =
s->str_end;
271 char *decimal_ptr = NULL;
272 int dist;
273
274 if (
s->str_end -
s->str_start < 2)
275 return 0;
276
277
278 while( ptr >
s->str_start )
279 {
280 ptr--;
281 if ( *ptr == '.' )
282 {
283 decimal_ptr = ptr;
284 break;
285 }
286 if ( (*ptr >= '0') && (*ptr <= '9' ) )
287 continue;
288 else
289 break;
290 }
291
292
293 if ( ! decimal_ptr )
294 return 0;
295
297
298
299 while( ptr >= decimal_ptr )
300 {
301 ptr--;
302 if ( *ptr == '0' )
303 continue;
304 else
305 break;
306 }
307
308
309 if ( ptr ==
s->str_end )
310 return 0;
311
312
313
314
315 if ( *ptr != '.' )
316 ptr++;
317
318
319 *ptr = '\0';
320 dist =
s->str_end - ptr;
322 return dist;
323}
References s.
Referenced by ptarray_to_kml2_sb().