I think it's a simple type mismatch in variables getting passed to a
function. I'd like to have r.le.* all working for 6.2.0 as it will
probably be the final time r.le.* is released.
> I think it's a simple type mismatch in variables getting passed to a
> function.
Glynn wrote:
It is. ux/uy are arrays of ints but calc_unit_loc() expects arrays of
doubles.
Try the attached patch.
[also cast to int for overlap() fn]
yes, thanks. funny, even with your patch it still messes up the "y"
values of draw_box() unless I add in the fn prototype to setup.h. Oh
well, done that and it's all working now without compiler warnings.
(and the segfault is gone)
I have also ported the r.le.setup help page from GRASS 5, fixed the
module descriptions, and sync'd all r.le changes with HEAD.
So all r.le should now be working & ready for the next release candidate.
> > I think it's a simple type mismatch in variables getting passed to a
> > function.
> It is. ux/uy are arrays of ints but calc_unit_loc() expects arrays of
> doubles.
>
> Try the attached patch.
[also cast to int for overlap() fn]
yes, thanks. funny, even with your patch it still messes up the "y"
values of draw_box() unless I add in the fn prototype to setup.h.
Right. overlap() expects "int"s, but some of the values passed are
changed to double by my patch. If a valid prototype is in scope, the
compiler will automatically cast them to int, otherwise it will pass
them as double.
All of those declarations in setup.h should be either fixed or
removed. If the compiler needs a prototype (because the function isn't
already in scope at the point that it's used), it needs the *correct*
prototype.
> > > I think it's a simple type mismatch in variables getting passed to a
> > > function.
>
> > It is. ux/uy are arrays of ints but calc_unit_loc() expects arrays of
> > doubles.
> >
> > Try the attached patch.
>
> [also cast to int for overlap() fn]
>
> yes, thanks. funny, even with your patch it still messes up the "y"
> values of draw_box() unless I add in the fn prototype to setup.h.
Right. overlap() expects "int"s, but some of the values passed are
changed to double by my patch. If a valid prototype is in scope, the
compiler will automatically cast them to int, otherwise it will pass
them as double.
All of those declarations in setup.h should be either fixed or
removed. If the compiler needs a prototype (because the function isn't
already in scope at the point that it's used), it needs the *correct*
prototype.
I've cleaned up r.le.setup. All of the functions have correct
prototypes, and any which aren't used outside of the file in which
they are defined have been declared "static". Also, I've removed the
local copy of the <dirent.h> stuff.
There is one warning which may indicate an error:
sample.c:826: warning: suggest parentheses around assignment used as truth value
which relates to:
if (n = i % h_d)
I don't know enough about the code to determine whether this is meant
to be an assignment or a comparison.