-
-
Notifications
You must be signed in to change notification settings - Fork 288
/
ascii_chk.c
49 lines (40 loc) · 925 Bytes
/
ascii_chk.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*!
* \file lib/gis/ascii_chk.c
*
* \brief GIS Library - Remove non-ascii characters
*
* (C) 2001-2014 by the GRASS Development Team
*
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
* \author GRASS GIS Development Team
*
* \date 1999-2014
*/
#include <grass/gis.h>
#define TAB 011
#define SPACE 040
/**
* \brief Removes non-ascii characters from buffer.
*
* Updates <b>string</b> with non_ascii characters removed, except for
* tabs, which are turned into spaces.
*
* \param[in,out] string buffer to have non-ascii characters removed
* \return
*/
void G_ascii_check(char *string)
{
char *ptr1, *ptr2;
ptr1 = string;
ptr2 = string;
while (*ptr1) {
if ((*ptr1 >= 040) && (*ptr1 <= 0176))
*ptr2++ = *ptr1;
else if (*ptr1 == TAB)
*ptr2++ = SPACE;
ptr1++;
}
*ptr2 = 0;
}