Avoid Microsoft-specific localtime_s
authorJ. Ali Harlow <ali@juiblex.co.uk>
Fri Jul 08 08:33:44 2016 +0100 (2016-07-08)
changeset 60772ff096a326
parent 59 296eac3183bc
child 61 31fb35727621
Avoid Microsoft-specific localtime_s
configure.ac
plover/log.c
     1.1 --- a/configure.ac	Fri Jul 08 08:26:29 2016 +0100
     1.2 +++ b/configure.ac	Fri Jul 08 08:33:44 2016 +0100
     1.3 @@ -217,7 +217,7 @@
     1.4  ##################################################
     1.5  # Checks for library functions.
     1.6  ##################################################
     1.7 -AC_CHECK_FUNCS_ONCE([fchdir fpathconf dirfd])
     1.8 +AC_CHECK_FUNCS_ONCE([fchdir fpathconf dirfd localtime_r])
     1.9  
    1.10  ##################################################
    1.11  # Checks for processor independent files.
     2.1 --- a/plover/log.c	Fri Jul 08 08:26:29 2016 +0100
     2.2 +++ b/plover/log.c	Fri Jul 08 08:33:44 2016 +0100
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (C) 2014  J. Ali Harlow <ali@juiblex.co.uk>
     2.6 + * Copyright (C) 2014, 2016  J. Ali Harlow <ali@juiblex.co.uk>
     2.7   *
     2.8   * This program is free software; you can redistribute it and/or modify
     2.9   * it under the terms of the GNU General Public License as published by
    2.10 @@ -346,12 +346,12 @@
    2.11      else
    2.12      {
    2.13  	time(&t);
    2.14 -#ifdef WIN32
    2.15 -	localtime_s(&today,&t);
    2.16 -	localtime_s(&modified,&sb.st_mtime);
    2.17 -#else
    2.18 +#if HAVE_LOCALTIME_R
    2.19  	localtime_r(&t,&today);
    2.20  	localtime_r(&sb.st_mtime,&modified);
    2.21 +#else
    2.22 +	today=*localtime(&t);
    2.23 +	modified=*localtime(&sb.st_mtime);
    2.24  #endif
    2.25  	if (modified.tm_yday!=today.tm_yday || modified.tm_year!=today.tm_year)
    2.26  	    rotate_logfile(filename,&modified);