Branch: Tag:

2006-01-23

2006-01-23 19:48:02 by Martin Bähr <mbaehr@email.archlab.tuwien.ac.at>

fix endless loop caused by trying to split into more parts of size 'with' than fit.
when splitting by an integer don't return any reminding fraction as extra part but instead spread it over the existing parts. this will make some parts longer than others, but depending on the situation this is desired.
to get only equal sized parts with a remaining fractional part split by a float.

Rev: lib/modules/Calendar.pmod/YMD.pike:1.18

1032:    with=promote_program(with);       int length=(int)(how_many(with)/n); +  int remains; +  if(length && intp(n)) +  remains=(int)(how_many(with)%n); +  if(!length) +  length=1;       TimeRange start=beginning();    TimeRange end=end();    array result=({}); -  while(start+with*length < end) +  TimeRange next; +  while((next=start+with*(length+!!remains)) < end)    { -  result += ({ start->distance(start+with*length) }); -  start=start+with*length; +  result += ({ start->distance(next) }); +  start=next; +  if(remains) +  remains--;    }    result += ({ start->distance(end) });    return result;