GRASS Programmer's Manual
6.4.1(2011)
|
00001 00017 #include <ctype.h> 00018 #include <string.h> 00019 #include <grass/gis.h> 00020 00021 00022 /* 00023 * last modification: 12 aug 81, j w hamilton 00024 * 00025 * 1998-04-04 WBH 00026 * Also squeezes out newlines -- easier to use with fgets() 00027 * 00028 * 1999-19-12 Werner Droege 00029 * changed line 37, line 48ff. -- return (strip_NL(line)) 00030 */ 00031 00032 00045 char *G_squeeze(char *line) 00046 { 00047 register char *f = line, *t = line; 00048 int l; 00049 00050 /* skip over space at the beginning of the line. */ 00051 while (isspace(*f)) 00052 f++; 00053 00054 while (*f) 00055 if (!isspace(*f)) 00056 *t++ = *f++; 00057 else if (*++f) 00058 if (!isspace(*f)) 00059 *t++ = ' '; 00060 *t = '\0'; 00061 l = strlen(line) - 1; 00062 if (*(line + l) == '\n') 00063 *(line + l) = '\0'; 00064 00065 return line; 00066 }