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

« back to all changes in this revision

Viewing changes to raster/r.mapcalc/xbitxor.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
1
 
2
2
#include <grass/gis.h>
 
3
#include <grass/raster.h>
3
4
#include "globals.h"
4
5
#include "expression.h"
5
6
#include "func_proto.h"
6
7
 
7
8
/****************************************************************
8
 
bitxor(a,b) = a ^ b
 
9
bitxor(a,b,c,...) = a ^ b ^ c ^ ...
9
10
****************************************************************/
10
11
 
11
12
int f_bitxor(int argc, const int *argt, void **args)
12
13
{
13
14
    CELL *res = args[0];
14
 
    CELL *arg1 = args[1];
15
 
    CELL *arg2 = args[2];
16
 
    int i;
 
15
    CELL **argz = (CELL **) args;
 
16
    int i, j;
17
17
 
18
 
    if (argc < 2)
 
18
    if (argc < 1)
19
19
        return E_ARG_LO;
20
 
    if (argc > 2)
21
 
        return E_ARG_HI;
22
 
 
23
 
    if (argt[1] != CELL_TYPE || argt[2] != CELL_TYPE)
24
 
        return E_ARG_TYPE;
25
20
 
26
21
    if (argt[0] != CELL_TYPE)
27
22
        return E_RES_TYPE;
28
23
 
 
24
    for (i = 1; i <= argc; i++)
 
25
        if (argt[i] != CELL_TYPE)
 
26
            return E_ARG_TYPE;
 
27
 
29
28
    for (i = 0; i < columns; i++) {
30
 
        if (IS_NULL_C(&arg1[i]) || IS_NULL_C(&arg2[i]))
31
 
            SET_NULL_C(&res[i]);
32
 
        else
33
 
            res[i] = arg1[i] ^ arg2[i];
 
29
        res[i] = 0;
 
30
        for (j = 1; j <= argc; j++) {
 
31
            if (IS_NULL_C(&argz[j][i])) {
 
32
                SET_NULL_C(&res[i]);
 
33
                break;
 
34
            }
 
35
            res[i] ^= argz[j][i];
 
36
        }
34
37
    }
35
38
 
36
39
    return 0;