Re: [misc] Code factorisation regarding time/duration parsing

On Sat, Apr 21, 2012 at 04:08:34PM +0200, Baptiste Jonglez wrote:
> Hello,
> 
> While investigating a slight bug (or feature request, if you like :) )
> in the time/duration parsing, I noticed that some code is duplicated.
> 
> For instance, it looks like the code that parses durations of the form
> "+2d4h50m" is roughly the same:
> 
>   in "day.c", l. 607 (function "day_edit_duration")
>   in "apoint.c", l. 217
> 
> The point is that it's not *exactly* the same (variable names differ),
> which makes it difficult to change the behavior consistently across
> calcurse.
> 
> Do you think it's possible to factorise that out?

Yes, that is definitely something we should work on.

I already suggested using more generic data structures back in 2011 [1]
but on second thought, I'd probably say we should keep the structures we
currently use for now and try to make use of macros to eliminate
duplicated code. I actually started doing that and refactoring out code
into a new compilation unit "generic.c" but it never made its way to the
mailing lists.

> 
> Regards,
> Baptiste

[1] http://lists.calcurse.org/misc/msg00052.html

Links