This topic needs a title

I have heard over grassu that r.watershed (version 4.1) is not working. After
looking into the code, I realized that a bug was introduced into the code I
wrote to speed up execution of large DEM surfaces. I am sending this note to
OGI, but it is an easy fix for those of you in a hurry:

Line 8-10 of .../src/raster/r.watershed/ram/ramseg.h reads:

#define SEG_INDEX(s,r,c) (int) \
  ((((r) >> RAMSEGBITS) * (s) + ((((c) >> RAMSEGBITS)) << DOUBLEBITS)) \
   + ((((r) & SEGLENLESS) << RAMSEGBITS) + ((c) & SEGLENLESS)))

The parenthesis are all in the wrong places. They should be located:

#define SEG_INDEX(s,r,c) (int) \
  ((((r) >> RAMSEGBITS) * (s) + ((c) >> RAMSEGBITS)) << DOUBLEBITS) \
   + (((r) & SEGLENLESS) << RAMSEGBITS) + ((c) & SEGLENLESS)

If you replace lines 9 and 10 in ramseg.h (without the ">"s) and re-compile,
r.watershed 4.1 should work as well (or as poorly) as older versions of
r.watershed.

Chuck Ehlschlaeger