diff -c kterm-6.2.0/Imakefile.orig kterm-6.2.0/Imakefile
*** kterm-6.2.0/Imakefile.orig	Fri Jul 12 14:01:04 1996
--- kterm-6.2.0/Imakefile	Tue Oct  2 01:43:26 2001
***************
*** 57,63 ****
             SRCS = $(SRCS1)
             OBJS = $(OBJS1)
         DEPLIBS1 = XkbClientDepLibs XawClientDepLibs
!        PROGRAMS = kterm
  
  #ifndef TermcapLibrary
  #if SystemV && !defined(MacIIArchitecture)
--- 57,64 ----
             SRCS = $(SRCS1)
             OBJS = $(OBJS1)
         DEPLIBS1 = XkbClientDepLibs XawClientDepLibs
! XCOMM       PROGRAMS = kterm
!        PROGRAMS = kterm.exe
  
  #ifndef TermcapLibrary
  #if SystemV && !defined(MacIIArchitecture)
***************
*** 72,77 ****
--- 73,79 ----
  #endif
  
       TERMCAPLIB = TermcapLibrary
+ XCOMM     TERMCAPLIB = -lncurses
  
  AllTarget($(PROGRAMS))
  
diff -c kterm-6.2.0/KTerm.ad.orig kterm-6.2.0/KTerm.ad
*** kterm-6.2.0/KTerm.ad.orig	Sun Jun 23 17:00:22 1996
--- kterm-6.2.0/KTerm.ad	Tue Oct  2 01:42:50 2001
***************
*** 123,125 ****
--- 123,127 ----
  *tek4014*font3: 6x13
  *tek4014*fontSmall: 6x10
  
+ *VT100.translations: #override Alt <Key>Kanji: begin-conversion()
+ *VT100*kanjiMode:		sjis
diff -c kterm-6.2.0/kterm.h.orig kterm-6.2.0/kterm.h
*** kterm-6.2.0/kterm.h.orig	Fri Jul 12 14:01:37 1996
--- kterm-6.2.0/kterm.h	Tue Oct  2 01:44:25 2001
***************
*** 28,34 ****
  #ifndef _KTERM_H_
  #define _KTERM_H_
  
! #define KTERM_VERSION	"6.2.0"
  #define KTERM_MBCS	/* multi-byte character set */
  #define KTERM_MBCC	/* multi-byte character class for word selection */
  #define KTERM_KANJIMODE	/* euc/sjis Kanji modes */
--- 28,34 ----
  #ifndef _KTERM_H_
  #define _KTERM_H_
  
! #define KTERM_VERSION	"6.2.0-cygwin"
  #define KTERM_MBCS	/* multi-byte character set */
  #define KTERM_MBCC	/* multi-byte character class for word selection */
  #define KTERM_KANJIMODE	/* euc/sjis Kanji modes */
diff -c kterm-6.2.0/main.c.orig kterm-6.2.0/main.c
*** kterm-6.2.0/main.c.orig	Fri Jul 12 14:01:38 1996
--- kterm-6.2.0/main.c	Tue Oct  2 01:42:50 2001
***************
*** 142,147 ****
--- 142,162 ----
  #define WTMP
  #endif
  
+ #ifdef __CYGWIN__
+ #define LASTLOG
+ #define WTMP
+ #define ATT
+ #define USE_USG_PTYS
+ #define USE_SYSV_TERMIO
+ #define USE_SYSV_SIGNALS
+ #define USE_SYSV_PGRP
+ #define USE_SYSV_ENVVARS		/* COLUMNS/LINES vs. TERMCAP */
+ /* #define USE_SYSV_UTMP */
+ #define USE_HANDSHAKE
+ #define USE_SYSV_SIGHUP
+ /* #define KANJI */
+ #endif
+ 
  #include <sys/ioctl.h>
  #include <sys/stat.h>
  
***************
*** 155,166 ****
  #undef TCSETA
  #define TCSETA TCSETS
  #else /* USE_TERMIOS */
! #ifdef SYSV
  #include <sys/termio.h>
  #endif /* SYSV */
  #endif /* USE_TERMIOS else */
  
! #ifdef SVR4
  #undef TIOCSLTC				/* defined, but not useable */
  #endif
  
--- 170,181 ----
  #undef TCSETA
  #define TCSETA TCSETS
  #else /* USE_TERMIOS */
! #if defined(SYSV) || defined(__CYGWIN__)
  #include <sys/termio.h>
  #endif /* SYSV */
  #endif /* USE_TERMIOS else */
  
! #if defined(SVR4) || defined(__CYGWIN__)
  #undef TIOCSLTC				/* defined, but not useable */
  #endif
  
***************
*** 168,178 ****
  #undef TIOCLSET				/* defined, but not useable */
  #endif
  
! #ifdef SYSV /* { */
  #ifdef USE_USG_PTYS			/* AT&T SYSV has no ptyio.h */
  #include <sys/stream.h>			/* get typedef used in ptem.h */
  #include <sys/stropts.h>		/* for I_PUSH */
! #ifndef SVR4
  #include <sys/ptem.h>			/* get struct winsize */
  #endif
  #include <poll.h>			/* for POLLIN */
--- 183,195 ----
  #undef TIOCLSET				/* defined, but not useable */
  #endif
  
! #if defined(SYSV) || defined(__CYGWIN__) /* { */
  #ifdef USE_USG_PTYS			/* AT&T SYSV has no ptyio.h */
+ #ifndef __CYGWIN__
  #include <sys/stream.h>			/* get typedef used in ptem.h */
  #include <sys/stropts.h>		/* for I_PUSH */
! #endif
! #if !defined(SVR4) && !defined(__CYGWIN__)
  #include <sys/ptem.h>			/* get struct winsize */
  #endif
  #include <poll.h>			/* for POLLIN */
***************
*** 239,245 ****
  #ifdef _POSIX_SOURCE
  #define USE_POSIX_WAIT
  #endif
! #ifdef SVR4
  #define USE_POSIX_WAIT
  #endif
  
--- 256,262 ----
  #ifdef _POSIX_SOURCE
  #define USE_POSIX_WAIT
  #endif
! #if defined(SVR4) || defined(__CYGWIN__)
  #define USE_POSIX_WAIT
  #endif
  
***************
*** 321,327 ****
  #ifdef _PATH_WTMP
  #define WTMP_FILENAME _PATH_WTMP
  #else
! #ifdef SYSV
  #define WTMP_FILENAME "/etc/wtmp"
  #else
  #define WTMP_FILENAME "/usr/adm/wtmp"
--- 338,344 ----
  #ifdef _PATH_WTMP
  #define WTMP_FILENAME _PATH_WTMP
  #else
! #if defined(SYSV) || defined(__CYGWIN__)
  #define WTMP_FILENAME "/etc/wtmp"
  #else
  #define WTMP_FILENAME "/usr/adm/wtmp"
***************
*** 381,387 ****
  #include <locale.h>
  #endif
  
! #ifdef SYSV
  extern char *ptsname();
  #endif
  
--- 398,404 ----
  #include <locale.h>
  #endif
  
! #if defined(SYSV) || defined(__CYGWIN__)
  extern char *ptsname();
  #endif
  
***************
*** 1148,1154 ****
--- 1165,1173 ----
      	d_tio.c_cc[VEOF] = CEOF;
  	d_tio.c_cc[VEOL] = CNUL;
  	d_tio.c_cc[VEOL2] = CNUL;
+ #ifndef __CYGWIN__
  	d_tio.c_cc[VSWTCH] = CNUL;
+ #endif
  
  #ifdef USE_TERMIOS /* { */
  	d_tio.c_cc[VSUSP] = CSUSP;
***************
*** 1715,1721 ****
  	if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
  	    return 1;
  	}
! #if defined(SVR4) || defined(i386)
  	strcpy(ttydev, ptsname(*pty));
  #if defined (SYSV) && defined(i386) && !defined(SVR4)
  	IsPts = True;
--- 1734,1740 ----
  	if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
  	    return 1;
  	}
! #if defined(SVR4) || defined(i386) || defined(__CYGWIN__)
  	strcpy(ttydev, ptsname(*pty));
  #if defined (SYSV) && defined(i386) && !defined(SVR4)
  	IsPts = True;
***************
*** 2105,2110 ****
--- 2124,2135 ----
   		alarm(2);		/* alarm(1) might return too soon */
   		if (! setjmp(env)) {
   			tty = open ("/dev/tty", O_RDWR, 0);
+ #ifdef __CYGWIN__
+ 			if (tty == -1) {	/* retry for Cygwin */
+ 				alarm(2);
+ 				tty = open("/dev/tty", O_RDWR, 0);
+ 			}
+ #endif
   			alarm(0);
   		} else {
  			tty_got_hung = True;
***************
*** 2334,2340 ****
  		 * now in child process
  		 */
  		extern char **environ;
! #if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__)
  		int pgrp = setsid();
  #else
  		int pgrp = getpid();
--- 2359,2365 ----
  		 * now in child process
  		 */
  		extern char **environ;
! #if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__CYGWIN__)
  		int pgrp = setsid();
  #else
  		int pgrp = getpid();
***************
*** 2361,2378 ****
  		if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) {
  		    SysError (1);
  		}
  		if (ioctl (ptyfd, I_PUSH, "ptem") < 0) {
  		    SysError (2);
  		}
! #if !defined(SVR4) && !(defined(SYSV) && defined(i386))
  		if (!getenv("CONSEM") && ioctl (ptyfd, I_PUSH, "consem") < 0) {
  		    SysError (3);
  		}
  #endif /* !SVR4 */
  		if (ioctl (ptyfd, I_PUSH, "ldterm") < 0) {
  		    SysError (4);
  		}
! #ifdef SVR4			/* from Sony */
  		if (ioctl (ptyfd, I_PUSH, "ttcompat") < 0) {
  		    SysError (5);
  		}
--- 2386,2407 ----
  		if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) {
  		    SysError (1);
  		}
+ #if !defined(__CYGWIN__)
  		if (ioctl (ptyfd, I_PUSH, "ptem") < 0) {
  		    SysError (2);
  		}
! #endif
! #if !defined(SVR4) && !(defined(SYSV) && defined(i386)) && !defined(__CYGWIN__)
  		if (!getenv("CONSEM") && ioctl (ptyfd, I_PUSH, "consem") < 0) {
  		    SysError (3);
  		}
  #endif /* !SVR4 */
+ #if !defined(__CYGWIN__)
  		if (ioctl (ptyfd, I_PUSH, "ldterm") < 0) {
  		    SysError (4);
  		}
! #endif
! #if defined(SVR4)  /* from Sony */
  		if (ioctl (ptyfd, I_PUSH, "ttcompat") < 0) {
  		    SysError (5);
  		}
***************
*** 2946,2952 ****
  
  		/* set up the new entry */
  		utmp.ut_type = USER_PROCESS;
! #ifndef linux
  		utmp.ut_exit.e_exit = 2;
  #endif
  		(void) strncpy(utmp.ut_user,
--- 2975,2981 ----
  
  		/* set up the new entry */
  		utmp.ut_type = USER_PROCESS;
! #if !defined(linux) && !defined(__CYGWIN__)
  		utmp.ut_exit.e_exit = 2;
  #endif
  		(void) strncpy(utmp.ut_user,
***************
*** 3696,3701 ****
--- 3725,3740 ----
  #else
  #if defined(KTERM_XAW3D) && defined(FIORDCK)
      return ioctl (fd, FIORDCHK, NULL);
+ #elif defined(__CYGWIN__)
+     fd_set set;
+     struct timeval timeout = {0, 0};
+ 
+     FD_ZERO (&set);
+     FD_SET (fd, &set);
+     if (select (fd+1, &set, NULL, NULL, &timeout) > 0)
+       return 1;
+     else
+       return 0;
  #else /* !KTERM_XAW3D || !FIORDCK */
      struct pollfd pollfds[1];
  
***************
*** 3717,3723 ****
  #ifndef X_NOT_POSIX
      return kill (-pid, sig);
  #else
! #if defined(SVR4) || defined(SYSV)
      return kill (-pid, sig);
  #else
      return killpg (pid, sig);
--- 3756,3762 ----
  #ifndef X_NOT_POSIX
      return kill (-pid, sig);
  #else
! #if defined(SVR4) || defined(SYSV) || defined(__CYGWIN__)
      return kill (-pid, sig);
  #else
      return killpg (pid, sig);
