chop.c

Go to the documentation of this file.
00001 /*
00002  * G_chop - chop leading and trailing white spaces: 
00003  *          space, \f, \n, \r, \t, \v
00004  *        - returns pointer to string
00005  *    
00006  * char *G_chop (char *s)
00007  *
00008  * modified copy of G_squeeze();    RB March 2000
00009  *                          <Radim.Blazek@dhv.cz>
00010  *
00011  */
00012 
00013 #include <ctype.h>
00014 
00015 
00026 char *G_chop (char *line)
00027 {
00028     register char *f = line, *t = line;
00029 
00030     while (isspace (*f))        /* go to first non white-space char */
00031         f++;
00032 
00033     if (! *f)                   /* no more chars in string */
00034     {
00035         *t = '\0';
00036         return (line);
00037     }
00038 
00039     for (t = line; *t; t++)     /* go to end */
00040         ;
00041     while ( isspace (*--t) )    
00042         ;
00043     *++t = '\0';                /* remove trailing white-spaces */
00044 
00045     t = line;
00046     while (*f)                  /* copy */   
00047             *t++ = *f++;
00048     *t = '\0';
00049 
00050     return (line);
00051 }

Generated on Sat Jul 22 22:06:14 2006 for GRASS by  doxygen 1.4.7