GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
commas.c
Go to the documentation of this file.
1
17
#include <string.h>
18
#include <grass/gis.h>
19
20
38
int
G_insert_commas
(
char
*buf)
39
{
40
char
number[100];
41
int
i, len;
42
int
comma;
43
44
while
(*buf ==
' '
)
45
buf++;
46
strcpy(number, buf);
47
for
(len = 0; number[len]; len++)
48
if
(number[len] ==
'.'
)
49
break
;
50
if
(len < 5)
51
return
1;
52
53
i = 0;
54
if
((comma = len % 3)) {
55
while
(i < comma)
56
*buf++ = number[i++];
57
*buf++ =
','
;
58
}
59
60
for
(comma = 0; number[i]; comma++) {
61
if
(number[i] ==
'.'
)
62
break
;
63
if
(comma && (comma % 3 == 0))
64
*buf++ =
','
;
65
*buf++ = number[i++];
66
}
67
while
(number[i])
68
*buf++ = number[i++];
69
*buf = 0;
70
71
return
0;
72
}
73
74
88
int
G_remove_commas
(
char
*buf)
89
{
90
char
*
b
;
91
92
for
(b = buf; *
b
; b++)
93
if
(*b !=
','
)
94
*buf++ = *
b
;
95
96
*buf = 0;
97
98
return
0;
99
}
lib
gis
commas.c
Generated on Thu Sep 26 2013 09:47:59 for GRASS Programmer's Manual by
1.8.4