On Tue, Oct 13, 2015 at 11:19:17PM BST, Stuart Henderson wrote:
> Moved from ports-bugs to ports, I'm not sure if many people are likely
> to read ports-bugs... and adding maintainer to CC.
> 
> On 2015/10/13 21:10, Raf Czlonka wrote:
> > Hi all,
> > 
> > I had just installed calcurse on my i386 laptop and imported my Google
> > calendar into it. While all looks fine when I run it in curses mode,
> > when I simply run it in a "one-shot" mode with '-d' option (or '-Q
> > --filter-type cal --days') it displays erratic dates, i.e. 08/10/78 for
> > today or 07/07/42 for the coming Friday.
> > 
> > Dates appear correct (albeit in "American" format) on amd64.
> > 
> > time_t again?
> 
> Yes, calcurse is passing around various internal time values which are a
> "long" type (32 bits on 32-bit arch and non-Y2038 compliant), and passing
> them (usually as pointers) to system functions that expect time_t, so this
> fails on any arch where "long" isn't the same size as "time_t" (i.e. all
> 32-bit OpenBSD arch since 5.5).
> 
> This quick-and-dirty diff gets it working for me, but a better fix would
> be to convert calcurse to using time_t internally for its "seconds since
> 1 jan 1970" and similar values.

Hi Stuart,

I can confirm that the below diff fixes it for me.

Thanks for a prompt reply.

Raf

P.S. Should ports-bugs@ be promoted more widely and porters encouraged
to subscribe to it or should it disappear as www@ did a while ago?

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/productivity/calcurse/Makefile,v
> retrieving revision 1.20
> diff -u -p -r1.20 Makefile
> --- Makefile  15 Mar 2015 08:29:08 -0000      1.20
> +++ Makefile  13 Oct 2015 22:10:34 -0000
> @@ -3,6 +3,7 @@
>  COMMENT=     text-based calendar and scheduling application
>  
>  DISTNAME=    calcurse-4.0.0
> +REVISION=    0
>  EPOCH=               0
>  
>  CATEGORIES=  productivity
> Index: patches/patch-src_args_c
> ===================================================================
> RCS file: patches/patch-src_args_c
> diff -N patches/patch-src_args_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_args_c  13 Oct 2015 22:10:34 -0000
> @@ -0,0 +1,16 @@
> +$OpenBSD$
> +--- src/args.c.orig  Sun Feb 22 10:34:11 2015
> ++++ src/args.c       Tue Oct 13 23:07:51 2015
> +@@ -274,10 +274,11 @@ static void next_arg(void)
> + /*
> +  * Print the date on stdout.
> +  */
> +-static void arg_print_date(long date)
> ++static void arg_print_date(long date_l)
> + {
> +     char date_str[BUFSIZ];
> +     struct tm lt;
> ++    time_t date = date_l;
> + 
> +     localtime_r((time_t *) & date, &lt);
> +     strftime(date_str, BUFSIZ, conf.output_datefmt, &lt);
> Index: patches/patch-src_utils_c
> ===================================================================
> RCS file: patches/patch-src_utils_c
> diff -N patches/patch-src_utils_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_utils_c 13 Oct 2015 22:10:34 -0000
> @@ -0,0 +1,50 @@
> +$OpenBSD$
> +--- src/utils.c.orig Tue Oct 13 22:55:09 2015
> ++++ src/utils.c      Tue Oct 13 23:00:58 2015
> +@@ -349,17 +349,19 @@ long get_item_time(long date)
> +                   get_item_min(date) * MININSEC);
> + }
> + 
> +-int get_item_hour(long date)
> ++int get_item_hour(long date_l)
> + {
> +     struct tm lt;
> ++    time_t date = date_l;
> + 
> +     localtime_r((time_t *) & date, &lt);
> +     return lt.tm_hour;
> + }
> + 
> +-int get_item_min(long date)
> ++int get_item_min(long date_l)
> + {
> +     struct tm lt;
> ++    time_t date = date_l;
> + 
> +     localtime_r((time_t *) & date, &lt);
> +     return lt.tm_min;
> +@@ -387,10 +389,11 @@ long date2sec(struct date day, unsigned hour, unsigned
> + }
> + 
> + /* Return a string containing the date, given a date in seconds. */
> +-char *date_sec2date_str(long sec, const char *datefmt)
> ++char *date_sec2date_str(long sec_l, const char *datefmt)
> + {
> +     struct tm lt;
> +     char *datestr = (char *)mem_calloc(BUFSIZ, sizeof(char));
> ++    time_t sec = sec_l;
> + 
> +     if (sec == 0) {
> +             strncpy(datestr, "0", BUFSIZ);
> +@@ -403,8 +406,10 @@ char *date_sec2date_str(long sec, const char *datefmt)
> + }
> + 
> + /* Generic function to format date. */
> +-void date_sec2date_fmt(long sec, const char *fmt, char *datef)
> ++void date_sec2date_fmt(long sec_l, const char *fmt, char *datef)
> + {
> ++    time_t sec = sec_l;
> ++
> + #if ENABLE_NLS
> +     /* TODO: Find a better way to deal with localization and strftime(). */
> +     char *locale_old = mem_strdup(setlocale(LC_ALL, NULL));
> 

Reply via email to