Re: [Patch] MacOS X support

[email protected] Fri, 3 Feb 2006 13:45:22 -0800
Newsgroups gmane.comp.lib.libtai
Message-ID <[email protected]>
--Apple-Mail-7--365350582
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Sorry, I've attached the patch this time.

	David

--Apple-Mail-7--365350582
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="macos-libtai.patch"
Content-Disposition: attachment;
	filename=macos-libtai.patch

diff -r -C5 mlibtai-0.60/check.c libtai-0.60/check.c
*** mlibtai-0.60/check.c	Fri Feb  3 01:23:03 2006
--- libtai-0.60/check.c	Tue Oct 13 09:52:20 1998
***************
*** 1,7 ****
  #include <stdio.h>
- #include <stdlib.h>
  #include <time.h>
  #include "tai.h"
  #include "leapsecs.h"
  #include "caltime.h"
  
--- 1,6 ----
diff -r -C5 mlibtai-0.60/easter.c libtai-0.60/easter.c
*** mlibtai-0.60/easter.c	Fri Feb  3 01:23:33 2006
--- libtai-0.60/easter.c	Tue Oct 13 09:52:20 1998
***************
*** 1,7 ****
  #include <stdio.h>
- #include <stdlib.h>
  #include "caldate.h"
  
  char *dayname[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } ;
  
  char out[101];
--- 1,6 ----
diff -r -C5 mlibtai-0.60/leapsecs.c libtai-0.60/leapsecs.c
*** mlibtai-0.60/leapsecs.c	Fri Feb  3 01:22:57 2006
--- libtai-0.60/leapsecs.c	Tue Oct 13 09:52:20 1998
***************
*** 1,7 ****
  #include <stdio.h>
- #include <stdlib.h>
  #include "tai.h"
  #include "leapsecs.h"
  #include "caldate.h"
  
  /* XXX: breaks tai encapsulation */
--- 1,6 ----
diff -r -C5 mlibtai-0.60/leapsecs_read.c libtai-0.60/leapsecs_read.c
*** mlibtai-0.60/leapsecs_read.c	Fri Feb  3 01:22:25 2006
--- libtai-0.60/leapsecs_read.c	Tue Oct 13 09:52:20 1998
***************
*** 1,13 ****
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <errno.h>
- #include <sys/uio.h>
- #include <unistd.h>
- #include <stdlib.h>
- 
  extern int errno;
  #include "tai.h"
  #include "leapsecs.h"
  
  struct tai *leapsecs = 0;
--- 1,9 ----
diff -r -C5 mlibtai-0.60/nowutc.c libtai-0.60/nowutc.c
*** mlibtai-0.60/nowutc.c	Fri Feb  3 01:23:11 2006
--- libtai-0.60/nowutc.c	Tue Oct 13 09:52:20 1998
***************
*** 1,7 ****
  #include <stdio.h>
- #include <stdlib.h>
  #include "leapsecs.h"
  #include "tai.h"
  #include "taia.h"
  #include "caltime.h"
  
--- 1,6 ----
diff -r -C5 mlibtai-0.60/yearcal.c libtai-0.60/yearcal.c
*** mlibtai-0.60/yearcal.c	Fri Feb  3 13:35:48 2006
--- libtai-0.60/yearcal.c	Tue Oct 13 09:52:20 1998
***************
*** 1,7 ****
  #include <stdio.h>
- #include <stdlib.h>
  #include "caldate.h"
  
  char *montab[] = {
    "January"
  , "February"
--- 1,6 ----
***************
*** 15,25 ****
  , "October"
  , "November"
  , "December"
  } ;
  
! int main(argc, argv)
  int argc;
  char **argv;
  {
    int year;
    long daystart;
--- 14,24 ----
  , "October"
  , "November"
  , "December"
  } ;
  
! void main(argc,argv)
  int argc;
  char **argv;
  {
    int year;
    long daystart;
***************
*** 62,68 ****
        }
      }
      printf("\n");
    }
  
!   return 0;
  }
--- 61,67 ----
        }
      }
      printf("\n");
    }
  
!   exit(0);
  }

--Apple-Mail-7--365350582
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed


> First of all, thanks for making libtai available! I've attached a  
> patch that makes libtai compile without warning on MacOS 10.4. Most  
> of it is cosmetic, but the additional include files are required  
> for leapsecs_read.c because the implicit declaration of read() has  
> it returning an int when in fact it returns ssize_t (a long int).  
> This causes libtai to believe the read() returned 0 (because it is  
> only examining the upper 4 bytes of the returned number). libtai  
> then reports itself unable to read the leap seconds file and dies.
>
> 	Cheers,
> 	David
>


--Apple-Mail-7--365350582--