V_trim_dec.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * \file V_trim_dec.c
  3. *
  4. * \brief Display trim functions.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * \author GRASS GIS Development Team
  21. *
  22. * \date 1999-2006
  23. */
  24. #include <grass/vask.h>
  25. /**
  26. * \fn int V__trim_decimal (char *buf)
  27. *
  28. * \brief Remove trailing zeros from decimal number.
  29. *
  30. * For example: 23.45000 would return 23.45.
  31. *
  32. * \param[in,out] buf
  33. * \return always returns 0
  34. */
  35. void V__trim_decimal(char *buf)
  36. {
  37. char *mark;
  38. /* find the . */
  39. while (*buf != '.')
  40. if (*buf++ == '\0')
  41. return;
  42. mark = buf;
  43. while (*++buf)
  44. if (*buf != '0')
  45. mark = buf + 1;
  46. while (*mark)
  47. *mark++ = 0;
  48. }