~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/gis/squeeze.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/**
3
 
 * \file squeeze.c
4
 
 *
5
 
 * \brief GIS Library - String white space removal functions.
6
 
 *
7
 
 * (C) 2001-2008 by the GRASS Development Team
8
 
 *
9
 
 * This program is free software under the GNU General Public License
10
 
 * (>=v2). Read the file COPYING that comes with GRASS for details.
11
 
 *
12
 
 * \author GRASS GIS Development Team
13
 
 *
14
 
 * \date 1998-2008
15
 
 */
16
 
 
17
 
#include <ctype.h>
18
 
#include <string.h>
19
 
#include <grass/gis.h>
20
 
 
21
 
 
22
 
/*
23
 
 * last modification: 12 aug 81, j w hamilton
24
 
 *
25
 
 * 1998-04-04  WBH
26
 
 *     Also squeezes out newlines -- easier to use with fgets()
27
 
 *
28
 
 * 1999-19-12 Werner Droege 
29
 
 *     changed line 37, line 48ff. -- return (strip_NL(line))
30
 
 */
31
 
 
32
 
 
33
 
/**
34
 
 * \brief Remove superfluous white space.
35
 
 *
36
 
 * Leading and trailing white space is removed from the string 
37
 
 * <b>line</b> and internal white space which is more than one character 
38
 
 * is reduced to a single space character. White space here means 
39
 
 * spaces, tabs, linefeeds, newlines, and formfeeds.
40
 
 *
41
 
 * \param[in,out] line
42
 
 * \return Pointer to <b>line</b>
43
 
 */
44
 
 
45
 
char *G_squeeze(char *line)
46
 
{
47
 
    register char *f = line, *t = line;
48
 
    int l;
49
 
 
50
 
    /* skip over space at the beginning of the line. */
51
 
    while (isspace(*f))
52
 
        f++;
53
 
 
54
 
    while (*f)
55
 
        if (!isspace(*f))
56
 
            *t++ = *f++;
57
 
        else if (*++f)
58
 
            if (!isspace(*f))
59
 
                *t++ = ' ';
60
 
    *t = '\0';
61
 
    l = strlen(line) - 1;
62
 
    if (*(line + l) == '\n')
63
 
        *(line + l) = '\0';
64
 
 
65
 
    return line;
66
 
}