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 305 of file stringbuffer.c.
306{
307 char *ptr =
s->str_end;
308 char *decimal_ptr = NULL;
309 int dist;
310
311 if (
s->str_end -
s->str_start < 2)
312 return 0;
313
314
315 while( ptr >
s->str_start )
316 {
317 ptr--;
318 if ( *ptr == '.' )
319 {
320 decimal_ptr = ptr;
321 break;
322 }
323 if ( (*ptr >= '0') && (*ptr <= '9' ) )
324 continue;
325 else
326 break;
327 }
328
329
330 if ( ! decimal_ptr )
331 return 0;
332
334
335
336 while( ptr >= decimal_ptr )
337 {
338 ptr--;
339 if ( *ptr == '0' )
340 continue;
341 else
342 break;
343 }
344
345
346 if ( ptr ==
s->str_end )
347 return 0;
348
349
350
351
352 if ( *ptr != '.' )
353 ptr++;
354
355
356 *ptr = '\0';
357 dist =
s->str_end - ptr;
359 return dist;
360}
References s.