nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-workers] patch: cygwin fixes for nmh-1.1RC2


From: Jeremy Gebben
Subject: [Nmh-workers] patch: cygwin fixes for nmh-1.1RC2
Date: Wed, 07 Jan 2004 14:40:02 -0700

Here's a patch against nmh-1.1RC2 to make it compile on cygwin.
In order of ascending nastiness, here's what I changed to make it
go:

-make a .PHONY dependency for the install target.

-add checks for gdbm. This is essentially the change that is already
in CVS. However, the most recent versions of gdbm have moved dbm_open() 
and related functions from libgdbm.{a,so} to libgdbm_compat.{a,so}.

-cygwin puts the .exe extention on programs. Autoconf's AC_PROG_CC
macro sets EXEEXT to .exe when it is necessary. I've changed the
install and clean targets to handle EXEEXT

-cygwin doesn't provide a usable timezone variable in <time.h>,
it defines a function, char* timezone(void) instead.  Supposedly,
defining timezonevar before including <time.h> will #define timezone
to the right type,  but this causes <sys/time.h> to break
because it has a declaration for "struct timezone". Sigh. I've added
tests to configure.in that check if timezone is actually usable
as a long int, and if not it checks _timezone and uses that instead.

-discard.c thinks that fpurge() is present if _FSTDIO is defined. This
isn't true on cygwin. Addtionally, linux and solaris have __fpurge(),
which is defined in <stdio_ext.h>. So I've added stdio_ext.h to
AC_CHECK_HEADERS and fpurge() and __fpurge() AC_CHECK_FUNCS(). I've
also added code for the _FSTDIO implemenetation of stdio when no
version of fpurge() is found. Finally, there were some duplicated
macros in discardsbr.c and m_getfld.c that were probably needed in
discard.c, so I moved them to a new header, <h/stdio_internals.h>.

Hopefully this can get in to nmh-1.1. If there are any problems or
questions, please let me know.

Thanks,

Jeremy Gebben

diff -cwrN --exclude autom4te.cache --exclude CVS nmh-1.1RC2-orig/Makefile.in 
nmh-1.1RC2/Makefile.in
*** nmh-1.1RC2-orig/Makefile.in Sat Dec 30 02:51:55 2000
--- nmh-1.1RC2/Makefile.in      Tue Dec 30 19:52:17 2003
***************
*** 69,74 ****
--- 69,76 ----
  
  .SUFFIXES:
  
+ .PHONY: install
+ 
  # all files in this directory included in the distribution
  DIST = ChangeLog COPYRIGHT DATE INSTALL MACHINES README VERSION               
\
        ChangeLog install-sh mkinstalldirs Makefile.in aclocal.m4       \
diff -cwrN --exclude autom4te.cache --exclude CVS nmh-1.1RC2-orig/acconfig.h 
nmh-1.1RC2/acconfig.h
*** nmh-1.1RC2-orig/acconfig.h  Fri Dec 22 16:42:16 2000
--- nmh-1.1RC2/acconfig.h       Tue Dec 30 19:52:17 2003
***************
*** 287,289 ****
--- 287,295 ----
     (or a file it includes) rather than just having a "stealth" definition of 
it
     in libc.a the way AIX 4.1 does. */
  #undef HAVE_SNPRINTF_PROTOTYPE
+ 
+ /* Define if extern long timezone in time.h works */
+ #undef TIMEZONE_USABLE
+ 
+ /* Define if extern long _timezone in time.h works */
+ #undef UNDERSCORE_TIMEZONE_USABLE
diff -cwrN --exclude autom4te.cache --exclude CVS nmh-1.1RC2-orig/configure.in 
nmh-1.1RC2/configure.in
*** nmh-1.1RC2-orig/configure.in        Fri Sep  5 15:03:34 2003
--- nmh-1.1RC2/configure.in     Mon Jan  5 15:42:15 2004
***************
*** 445,451 ****
  AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
                   limits.h crypt.h termcap.h termio.h termios.h locale.h \
                   netdb.h sys/param.h sys/time.h sys/utsname.h arpa/inet.h \
!                  arpa/ftp.h)
  
  
  AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
--- 445,451 ----
  AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h errno.h fcntl.h \
                   limits.h crypt.h termcap.h termio.h termios.h locale.h \
                   netdb.h sys/param.h sys/time.h sys/utsname.h arpa/inet.h \
!                  arpa/ftp.h stdio_ext.h)
  
  
  AC_CACHE_CHECK(POSIX termios, nmh_cv_sys_posix_termios,
***************
*** 499,505 ****
  AC_CHECK_LIB(mkstemp,mkstemp)
  AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
                 sighold sigrelse writev lstat uname tzset killpg mkstemp \
!                sethostent getutent)
  
  dnl solaris screws this up
  AC_CHECK_FUNC(gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)],
--- 499,505 ----
  AC_CHECK_LIB(mkstemp,mkstemp)
  AC_CHECK_FUNCS(waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
                 sighold sigrelse writev lstat uname tzset killpg mkstemp \
!                sethostent getutent fpurge __fpurge)
  
  dnl solaris screws this up
  AC_CHECK_FUNC(gethostbyname, [AC_DEFINE(HAVE_GETHOSTBYNAME)],
***************
*** 532,537 ****
--- 532,561 ----
  dnl prototype. 
  AC_EGREP_HEADER(snprintf, stdio.h, AC_DEFINE(HAVE_SNPRINTF_PROTOTYPE))
  
+ dnl On cygwin timezone is a function, but _timezone is usable.
+ AC_CACHE_CHECK(if timezone is usable, nmh_cv_timezone_usable,
+       [AC_TRY_COMPILE([#include <time.h>],
+       [extern long timezone,
+        long t= timezone],
+       nmh_cv_timezone_usable=yes,
+       nmh_cv_timezone_usable=no)])
+ if test $nmh_cv_timezone_usable = yes; then
+   AC_DEFINE(TIMEZONE_USABLE)
+ else
+       AC_CACHE_CHECK(if _timezone is usable,
+               nmh_cv_underscore_timezone_usable,
+               [AC_TRY_COMPILE(
+               [#include <time.h>],
+               [long t= _timezone],
+               nmh_cv_underscore_timezone_usable=yes,
+               nmh_cv_underscore_timezone_usable=no)])
+       if test $nmh_cv_underscore_timezone_usable = yes; then
+         AC_DEFINE(UNDERSCORE_TIMEZONE_USABLE)
+       fi
+ fi
+  
+ 
+ 
  dnl -------------------
  dnl CHECK FOR LIBRARIES
  dnl -------------------
***************
*** 553,559 ****
  dnl Checks for ndbm
  AC_CHECK_FUNC(dbm_open, ,
    AC_CHECK_LIB(ndbm, dbm_open, ,
!     AC_CHECK_LIB(dbm, dbm_open)))
  
  dnl ----------------
  dnl CHECK FOR NDBM.H
--- 577,594 ----
  dnl Checks for ndbm
  AC_CHECK_FUNC(dbm_open, ,
    AC_CHECK_LIB(ndbm, dbm_open, ,
!     AC_CHECK_LIB(dbm, dbm_open, ,
!       AC_CHECK_LIB(db1, dbm_open, ,
!         AC_CHECK_LIB(gdbm, dbm_open, ,
!           AC_CHECK_LIB(gdbm_compat, dbm_open, ,
!             AC_CHECK_LIB(db, __db_ndbm_open)))))))
! 
! dnl ----------------
! dnl CHECK FOR NDBM.H
! dnl ----------------
! 
! AC_CHECK_HEADERS(db1/ndbm.h gdbm/ndbm.h db.h, break, )
! 
  
  dnl ----------------
  dnl CHECK FOR NDBM.H
diff -cwrN --exclude autom4te.cache --exclude CVS 
nmh-1.1RC2-orig/h/stdio_internals.h nmh-1.1RC2/h/stdio_internals.h
*** nmh-1.1RC2-orig/h/stdio_internals.h Wed Dec 31 17:00:00 1969
--- nmh-1.1RC2/h/stdio_internals.h      Tue Dec 30 19:52:17 2003
***************
*** 0 ****
--- 1,18 ----
+ /*macros to handle various stdio implementations */
+ 
+ #if defined(_FSTDIO)
+ # define _ptr    _p
+ # define _cnt    _r
+ # define _filbuf __srget
+ # define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC
+ #elif defined(SCO_5_STDIO)
+ # define _ptr  __ptr
+ # define _cnt  __cnt
+ # define _base __base
+ # define _filbuf(fp)  ((fp)->__cnt = 0, __filbuf(fp))
+ # define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC
+ #endif
+ 
+ #ifndef DEFINED__FILBUF_TO_SOMETHING_SPECIFIC
+ extern int  _filbuf(FILE*);
+ #endif
diff -cwrN --exclude autom4te.cache --exclude CVS nmh-1.1RC2-orig/sbr/discard.c 
nmh-1.1RC2/sbr/discard.c
*** nmh-1.1RC2-orig/sbr/discard.c       Tue Jul  2 16:09:14 2002
--- nmh-1.1RC2/sbr/discard.c    Tue Dec 30 19:52:17 2003
***************
*** 10,16 ****
--- 10,20 ----
   */
  
  #include <h/mh.h>
+ #include <h/stdio_internals.h>
  
+ #ifdef HAVE_STDIO_EXT_H
+ # include <stdio_ext.h>
+ #endif
  #ifdef HAVE_TERMIOS_H
  # include <termios.h>
  #else
***************
*** 21,34 ****
  # endif
  #endif
  
- #ifdef SCO_5_STDIO
- # define _ptr  __ptr
- # define _cnt  __cnt
- # define _base __base
- # define _filbuf(fp)  ((fp)->__cnt = 0, __filbuf(fp))
- #endif
- 
- 
  void
  discard (FILE *io)
  {
--- 25,30 ----
***************
*** 55,69 ****
  # endif
  #endif
  
! #ifdef _FSTDIO
      fpurge (io);
! #else
! # ifdef LINUX_STDIO
      io->_IO_write_ptr = io->_IO_write_base;
  # else
      if ((io->_ptr = io->_base))
        io->_cnt = 0;
  # endif
- #endif
  }
  
--- 51,75 ----
  # endif
  #endif
  
! #if defined(HAVE_FPURGE)
      fpurge (io);
! #elif defined(HAVE__FPURGE)
!     /* solaris and at least some versions of linux */
!     __fpurge (io);
! #elif defined(LINUX_STDIO)
!     /* original linux code, is this needed? */
      io->_IO_write_ptr = io->_IO_write_base;
+ #elif defined(_FSTDIO)
+     /* BSDs define _FSTDIO and have fpurge(). cygwin 
+     *  doesn't have fpurge(), but it is _FSTDIO. This code
+     *  is based on comments in cygwin's <sys/reent.h>
+     */
+     io->_p = io->_bf._base;
+     io->_w = io->_bf._size;
+     io->_r = 0;
  # else
      if ((io->_ptr = io->_base))
        io->_cnt = 0;
  # endif
  }
  
diff -cwrN --exclude autom4te.cache --exclude CVS nmh-1.1RC2-orig/sbr/dtime.c 
nmh-1.1RC2/sbr/dtime.c
*** nmh-1.1RC2-orig/sbr/dtime.c Tue Jul  2 16:09:14 2002
--- nmh-1.1RC2/sbr/dtime.c      Tue Dec 30 19:52:17 2003
***************
*** 29,36 ****
  #endif
  
  #if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET)
! extern int daylight;
  extern long timezone;
  extern char *tzname[];
  #endif
  
--- 29,45 ----
  #endif
  
  #if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET)
! 
! # if defined(TIMEZONE_USABLE)
  extern long timezone;
+ # elif defined(UNDERSCORE_TIMEZONE_USABLE)
+ #  ifdef timezone
+ #   undef timezone
+ #  endif
+ #  define timezone _timezone
+ # endif 
+ 
+ extern int daylight;
  extern char *tzname[];
  #endif
  
diff -cwrN --exclude autom4te.cache --exclude CVS 
nmh-1.1RC2-orig/sbr/m_getfld.c nmh-1.1RC2/sbr/m_getfld.c
*** nmh-1.1RC2-orig/sbr/m_getfld.c      Tue Jul  2 16:09:14 2002
--- nmh-1.1RC2/sbr/m_getfld.c   Tue Dec 30 19:52:17 2003
***************
*** 11,16 ****
--- 11,17 ----
  
  #include <h/mh.h>
  #include <h/mts.h>
+ #include <h/stdio_internals.h>
  
  /* This module has a long and checkered history.  First, it didn't burst
     maildrops correctly because it considered two CTRL-A:s in a row to be
***************
*** 183,207 ****
  static int edelimlen;
  
  static int (*eom_action)() = NULL;
- 
- #ifdef _FSTDIO
- # define _ptr    _p           /* Gag   */
- # define _cnt    _r           /* Retch */
- # define _filbuf __srget      /* Puke  */
- # define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC
- #endif
- 
- #ifdef SCO_5_STDIO
- # define _ptr  __ptr
- # define _cnt  __cnt
- # define _base __base
- # define _filbuf(fp)  ((fp)->__cnt = 0, __filbuf(fp))
- # define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC
- #endif
- 
- #ifndef DEFINED__FILBUF_TO_SOMETHING_SPECIFIC
- extern int  _filbuf(FILE*);
- #endif
  
  
  int
--- 184,189 ----
diff -cwrN --exclude autom4te.cache --exclude CVS 
nmh-1.1RC2-orig/uip/Makefile.in nmh-1.1RC2/uip/Makefile.in
*** nmh-1.1RC2-orig/uip/Makefile.in     Fri Feb 28 12:08:36 2003
--- nmh-1.1RC2/uip/Makefile.in  Tue Dec 30 19:52:17 2003
***************
*** 23,28 ****
--- 23,29 ----
  SASL_INCLUDES = @SASL_INCLUDES@
  INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir) $(HESIOD_INCLUDES) 
$(SASL_INCLUDES)
  LDFLAGS  = @LDFLAGS@
+ EXEEXT   = @EXEEXT@
  
  LIBS     = @LIBS@
  MTSLIB   = ../mts/libmts.a
***************
*** 262,276 ****
  
  # install links
  install-lcmds:
!       rm -f $(bindir)/flists
!       rm -f $(bindir)/folders
!       rm -f $(bindir)/prev
!       rm -f $(bindir)/next
!       $(LN) $(bindir)/flist  $(bindir)/flists
!       $(LN) $(bindir)/folder $(bindir)/folders
!       $(LN) $(bindir)/show   $(bindir)/prev
!       $(LN) $(bindir)/show   $(bindir)/next
!       $(LN) $(bindir)/install-mh   $(libdir)/install-mh
  
  # install misc support binaries
  install-misc:
--- 263,278 ----
  
  # install links
  install-lcmds:
!       rm -f $(bindir)/flists$(EXEEXT)
!       rm -f $(bindir)/folders$(EXEEXT)
!       rm -f $(bindir)/prev$(EXEEXT)
!       rm -f $(bindir)/next$(EXEEXT)
!       rm -f $(libdir)/install-mh$(EXEEXT)
!       $(LN) $(bindir)/flist$(EXEEXT)  $(bindir)/flists$(EXEEXT)
!       $(LN) $(bindir)/folder$(EXEEXT) $(bindir)/folders$(EXEEXT)
!       $(LN) $(bindir)/show$(EXEEXT)   $(bindir)/prev$(EXEEXT)
!       $(LN) $(bindir)/show$(EXEEXT)   $(bindir)/next$(EXEEXT)
!       $(LN) $(bindir)/install-mh$(EXEEXT)   $(libdir)/install-mh$(EXEEXT)
  
  # install misc support binaries
  install-misc:
***************
*** 289,305 ****
  
  uninstall:
        for cmd in $(CMDS); do \
!         rm -f $(bindir)/$$cmd; \
        done
        for lcmd in $(LCMDS); do \
!         rm -f $(bindir)/$$lcmd; \
        done
        for misc in $(MISC); do \
!         rm -f $(libdir)/$$misc; \
        done
        for cmd in $(SCMDS); do \
!         rm -f $(bindir)/$$cmd; \
        done
  
  # ========== DEPENDENCIES FOR CLEANUP ==========
  
--- 291,308 ----
  
  uninstall:
        for cmd in $(CMDS); do \
!         rm -f $(bindir)/$$cmd$(EXEEXT); \
        done
        for lcmd in $(LCMDS); do \
!         rm -f $(bindir)/$$lcmd$(EXEEXT); \
        done
        for misc in $(MISC); do \
!         rm -f $(libdir)/$$misc$(EXEEXT); \
        done
        for cmd in $(SCMDS); do \
!         rm -f $(bindir)/$$cmd$(EXEEXT); \
        done
+       rm -f $(libdir)/install-mh$(EXEEXT)
  
  # ========== DEPENDENCIES FOR CLEANUP ==========
  
***************
*** 307,313 ****
        rm -f *.o *~
  
  clean: mostlyclean
!       rm -f $(CMDS) $(MISC) $(SCMDS)
  
  distclean: clean
        rm -f Makefile
--- 310,318 ----
        rm -f *.o *~
  
  clean: mostlyclean
!       for cmd in $(CMDS) $(MISC) $(SCMDS) ; do \
!         rm -f $$cmd$(EXEEXT); \
!       done
  
  distclean: clean
        rm -f Makefile
diff -cwrN --exclude autom4te.cache --exclude CVS nmh-1.1RC2-orig/uip/scansbr.c 
nmh-1.1RC2/uip/scansbr.c
*** nmh-1.1RC2-orig/uip/scansbr.c       Tue Jul  2 16:09:15 2002
--- nmh-1.1RC2/uip/scansbr.c    Tue Dec 30 19:52:17 2003
***************
*** 14,31 ****
  #include <h/fmt_scan.h>
  #include <h/scansbr.h>
  #include <h/tws.h>
! 
! #ifdef _FSTDIO
! # define _ptr _p                /* Gag    */
! # define _cnt _w                /* Wretch */
! #endif
! 
! #ifdef SCO_5_STDIO
! # define _ptr  __ptr
! # define _cnt  __cnt
! # define _base __base
! # define _filbuf(fp)  ((fp)->__cnt = 0, __filbuf(fp))
! #endif
  
  #define MAXSCANL 256          /* longest possible scan line */
  
--- 14,20 ----
  #include <h/fmt_scan.h>
  #include <h/scansbr.h>
  #include <h/tws.h>
! #include <h/stdio_internals.h>
  
  #define MAXSCANL 256          /* longest possible scan line */
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]