00001 #include <grass/gis.h>
00002 #include <string.h>
00003
00004
00005
00006
00007
00008
00009
00010 int G_insert_commas(
00011 char *buf)
00012 {
00013 char number[100];
00014 int i,len;
00015 int comma;
00016
00017 while (*buf == ' ') buf++;
00018 strcpy (number, buf);
00019 for (len=0; number[len]; len++)
00020 if(number[len] == '.')
00021 break;
00022 if (len < 5)
00023 return 1;
00024
00025 i = 0;
00026 if (comma = len%3)
00027 {
00028 while (i < comma)
00029 *buf++ = number[i++];
00030 *buf++ = ',';
00031 }
00032 for (comma = 0; number[i]; comma++)
00033 {
00034 if (number[i] == '.')
00035 break;
00036 if (comma && (comma%3 == 0))
00037 *buf++ = ',';
00038 *buf++ = number[i++];
00039 }
00040 while (number[i])
00041 *buf++ = number[i++];
00042 *buf = 0;
00043
00044 return 0;
00045 }
00046
00047
00048
00049
00050
00051
00052
00053 #include <string.h>
00054
00055 int G_remove_commas(
00056 char *buf)
00057 {
00058 char *b;
00059
00060 for (b=buf; *b; b++)
00061 if(*b != ',')
00062 *buf++ = *b;
00063
00064 *buf = 0;
00065 return 0;
00066 }