File: ignore.cc

package info (click to toggle)
gri 2.4.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,540 kB
  • ctags: 1,966
  • sloc: cpp: 32,542; lisp: 3,243; perl: 806; makefile: 548; sh: 253
file content (97 lines) | stat: -rw-r--r-- 1,934 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include	<math.h>
#include	<string.h>
#include	"extern.hh"
static bool reduce_columns(unsigned int n);

bool
ignoreCmd()
{
    double           tmp;
    if (_nword != 3) {
	err("Proper syntax 'ignore last n'");
	return false;
    }
    if (!strcmp(_word[1], "last")) {
	if (!getdnum(_word[2], &tmp)) {
	    err("Can't read n in 'ignore last n'");
	    return false;
	}
	if (tmp < 0) {
	    err("Can't have n<0 in 'ignore last n'");
	    return false;
	}
	unsigned int n = unsigned(floor(0.5 + tmp));
	return reduce_columns(n);
    } else {
	err("Proper syntax 'ignore last n'");
	return false;
    }
}

static bool
reduce_columns(unsigned int n)
{
    if (!_columns_exist) {
	err("First 'read columns'");
	return false;
    }
    if (n > 0) {
	if (_colX.size()) {
	    if (_colX.size() >= n) {
		_colX.setDepth(_colX.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
	if (_colY.size()) {
	    if (_colY.size() >= n) {
		_colY.setDepth(_colY.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
	if (_colZ.size()) {
	    if (_colZ.size() >= n) {
		_colZ.setDepth(_colZ.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
	if (_colU.size()) {
	    if (_colU.size() >= n) {
		_colU.setDepth(_colU.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
	if (_colV.size()) {
	    if (_colV.size() >= n) {
		_colV.setDepth(_colV.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
	if (_colR.size()) {
	    if (_colR.size() >= n) {
		_colR.setDepth(_colR.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
	if (_colTHETA.size()) {
	    if (_colTHETA.size() >= n) {
		_colTHETA.setDepth(_colTHETA.size() - n);
	    } else {
		err("Too few columns to do that");
		return false;
	    }
	}
    }
    return true;
}