squeeze.c

Go to the documentation of this file.
00001 #include <string.h>
00002 #include <grass/gis.h>
00003 /*
00004  * squeeze - edit superfluous white space out of strings
00005  *
00006  *  char *G_squeeze (s)
00007  *     char *s;
00008  *
00009  * scan a string of text, converting tabs to spaces and
00010  * compressing out leading spaces, redundant internal spaces,
00011  * and trailing spaces.
00012  * returns the address of the resulting compressed string.
00013  *
00014  * last modification: 12 aug 81, j w hamilton
00015  *
00016  * 1998-04-04  WBH
00017  *     Also squeezes out newlines -- easier to use with fgets()
00018  *
00019  * 1999-19-12 Werner Droege 
00020  *     changed line 37, line 48ff. -- return (strip_NL(line))
00021  */
00022 
00023 #include <ctype.h>
00024 
00025 
00038 char *G_squeeze (char *line)
00039 {
00040     register char *f = line, *t = line;
00041     int l;
00042 
00043     /* skip over space at the beginning of the line. */
00044     while (isspace (*f))
00045         f++;
00046 
00047     while (*f)
00048         if (! isspace (*f))
00049             *t++ = *f++;
00050         else
00051             if (*++f)
00052                 if (! isspace (*f))
00053                     *t++ = ' ';
00054     *t = '\0';
00055     l=strlen(line)-1;
00056     if(*(line+l)=='\n') *(line+l)='\0';
00057     return line;
00058 }

Generated on Fri Nov 21 11:02:18 2008 for GRASS by  doxygen 1.5.1