GRASS Programmer's Manual
6.4.2(2012)
|
00001 00007 /* db_strip(buf) 00008 * char *buf buffer to be worked on 00009 * 00010 * 'buf' is rewritten in place with leading and trailing white 00011 * space removed. 00012 */ 00013 00014 00015 void db_strip(char *buf) 00016 { 00017 char *a, *b; 00018 00019 /* remove leading white space */ 00020 for (a = b = buf; *a == ' ' || *a == '\t'; a++) ; 00021 if (a != b) 00022 while ((*b++ = *a++)) ; 00023 00024 /* remove trailing white space */ 00025 for (a = buf; *a; a++) ; 00026 if (a != buf) { 00027 for (a--; *a == ' ' || *a == '\t'; a--) ; 00028 a++; 00029 *a = 0; 00030 } 00031 }