--- kterm-6.2.0/main.c.orig_dist 2012-01-14 01:18:45.000000000 +0900 +++ kterm-6.2.0/main.c 2012-01-14 01:21:12.000000000 +0900 @@ -88,6 +88,15 @@ #include #endif /* KEEPALIVE */ +#if defined(CSRG_BASED) || defined(__GNU__) +#define USE_POSIX_TERMIOS 1 +#endif + +#ifdef USE_POSIX_TERMIOS +#define HAVE_TERMIOS_H 1 +#define HAVE_TCGETATTR 1 +#endif + #ifdef att #define ATT #endif @@ -145,6 +154,9 @@ #include #include +#ifdef USE_POSIX_TERMIOS +#include +#else #ifdef USE_TERMIOS #include /* this hacked termios support only works on SYSV */ @@ -159,6 +171,7 @@ #include #endif /* SYSV */ #endif /* USE_TERMIOS else */ +#endif /* USE_POSIX_TERMIOS */ #ifdef SVR4 #undef TIOCSLTC /* defined, but not useable */ @@ -225,8 +238,12 @@ #endif #else /* } !SYSV { */ /* BSD systems */ #ifndef linux +#ifndef USE_POSIX_TERMIOS +#ifndef USE_SYSV_TERMIO #include #endif +#endif +#endif #include #define HAS_UTMP_UT_HOST #define HAS_BSD_GROUPS @@ -381,6 +398,10 @@ #include #endif +#ifdef __NetBSD__ +#include +#endif + #ifdef SYSV extern char *ptsname(); #endif @@ -422,6 +443,8 @@ #ifdef TIOCLSET static unsigned int d_lmode; #endif /* TIOCLSET */ +#elif defined(USE_POSIX_TERMIOS) +static struct termios d_tio; #else /* not USE_SYSV_TERMIO */ static struct sgttyb d_sg = { 0, 0, 0177, CKILL, EVENP|ODDP|ECHO|XTABS|CRMOD @@ -1119,14 +1142,20 @@ strcpy (ptydev, PTYDEV); #endif -#ifdef USE_SYSV_TERMIO /* { */ +#if defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS) /* { */ /* Initialization is done here rather than above in order ** to prevent any assumptions about the order of the contents ** of the various terminal structures (which may change from ** implementation to implementation). */ d_tio.c_iflag = ICRNL|IXON; - d_tio.c_oflag = OPOST|ONLCR|TAB3; + d_tio.c_oflag = OPOST; +#ifdef TAB3 + d_tio.c_oflag |= TAB3; +#endif +#ifdef ONLCR + d_tio.c_oflag |= ONLCR; +#endif #if defined(macII) || defined(ATT) || defined(CRAY) /* { */ d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL; d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK; @@ -1150,13 +1179,15 @@ d_tio.c_cc[VEOL2] = CNUL; d_tio.c_cc[VSWTCH] = CNUL; -#ifdef USE_TERMIOS /* { */ +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ d_tio.c_cc[VSUSP] = CSUSP; d_tio.c_cc[VDSUSP] = CDSUSP; d_tio.c_cc[VREPRINT] = CRPRNT; d_tio.c_cc[VDISCARD] = CFLUSH; d_tio.c_cc[VWERASE] = CWERASE; d_tio.c_cc[VLNEXT] = CLNEXT; + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 0; #endif /* } */ #ifdef TIOCSLTC /* { */ d_ltc.t_suspc = CSUSP; /* t_suspc */ @@ -1170,11 +1201,17 @@ d_lmode = 0; #endif /* } TIOCLSET */ #else /* }{ else !macII, ATT, CRAY */ +#ifndef USE_POSIX_TERMIOS #ifdef BAUD_0 /* { */ d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL; #else /* }{ !BAUD_0 */ d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL; #endif /* } !BAUD_0 */ +#else + d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL; + cfsetispeed(&d_tio, B9600); + cfsetospeed(&d_tio, B9600); +#endif d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK; #ifdef ECHOKE d_tio.c_lflag |= ECHOKE|IEXTEN; @@ -1182,11 +1219,13 @@ #ifdef ECHOCTL d_tio.c_lflag |= ECHOCTL|IEXTEN; #endif +#ifndef USE_POSIX_TERMIOS #ifdef NTTYDISC d_tio.c_line = NTTYDISC; #else d_tio.c_line = 0; #endif +#endif #ifdef __sgi d_tio.c_cflag &= ~(HUPCL|PARENB); d_tio.c_iflag |= BRKINT|ISTRIP|IGNPAR; @@ -1235,8 +1274,14 @@ int i; for (i = 0; i <= 2; i++) { +#ifndef USE_POSIX_TERMIOS struct termio deftio; - if (ioctl (i, TCGETA, &deftio) == 0) { + if (ioctl (i, TCGETA, &deftio) == 0) +#else + struct termios deftio; + if (tcgetattr(i, &deftio) == 0) +#endif + { d_tio.c_cc[VINTR] = deftio.c_cc[VINTR]; d_tio.c_cc[VQUIT] = deftio.c_cc[VQUIT]; d_tio.c_cc[VERASE] = deftio.c_cc[VERASE]; @@ -1291,7 +1336,7 @@ d_ltc.t_werasc = '\377'; d_ltc.t_lnextc = '\377'; #endif /* } TIOCSLTC */ -#ifdef USE_TERMIOS /* { */ +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ d_tio.c_cc[VSUSP] = CSUSP; d_tio.c_cc[VDSUSP] = '\000'; d_tio.c_cc[VREPRINT] = '\377'; @@ -1680,7 +1725,7 @@ get_pty (pty) int *pty; { -#ifdef __osf__ +#if defined(__osf__) || defined(__NetBSD__) int tty; return (openpty(pty, &tty, ttydev, NULL, NULL)); #endif @@ -2025,6 +2070,8 @@ int one = 1; int zero = 0; int status; +#elif defined(USE_POSIX_TERMIOS) + struct termios tio; #else /* else not USE_SYSV_TERMIO */ unsigned lmode; struct tchars tc; @@ -2129,7 +2176,7 @@ #ifdef TIOCLSET lmode = d_lmode; #endif /* TIOCLSET */ -#ifdef USE_SYSV_TERMIO +#if defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS) tio = d_tio; #else /* not USE_SYSV_TERMIO */ sg = d_sg; @@ -2161,7 +2208,9 @@ #ifdef USE_SYSV_TERMIO if(ioctl(tty, TCGETA, &tio) == -1) tio = d_tio; - +#elif defined(USE_POSIX_TERMIOS) + if(tcgetattr(tty, &tio) == -1) + tio = d_tio; #else /* not USE_SYSV_TERMIO */ if(ioctl(tty, TIOCGETP, (char *)&sg) == -1) sg = d_sg; @@ -2539,7 +2588,7 @@ * set up the tty modes */ { -#ifdef USE_SYSV_TERMIO +#if defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS) #if defined(umips) || defined(CRAY) || defined(linux) /* If the control tty had its modes screwed around with, eg. by lineedit in the shell, or emacs, etc. then tio @@ -2556,12 +2605,17 @@ tio.c_iflag &= ~(INLCR|IGNCR); tio.c_iflag |= ICRNL; /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */ +#ifndef USE_POSIX_TERMIOS tio.c_oflag &= ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); +#endif +#ifdef ONLCR tio.c_oflag |= ONLCR; +#endif #ifdef OPOST tio.c_oflag |= OPOST; #endif /* OPOST */ +#ifndef USE_POSIX_TERMIOS #ifdef BAUD_0 /* baud rate is 0 (don't care) */ tio.c_cflag &= ~(CBAUD); @@ -2570,6 +2624,13 @@ tio.c_cflag &= ~(CBAUD); tio.c_cflag |= B9600; #endif /* !BAUD_0 */ +#else + cfsetispeed(&tio, B9600); + cfsetospeed(&tio, B9600); + /* Clear CLOCAL so that SIGHUP is sent to us + when the xterm ends */ + tio.c_cflag &= ~CLOCAL; +#endif tio.c_cflag &= ~CSIZE; if (screen->input_eight_bits) tio.c_cflag |= CS8; @@ -2681,9 +2742,14 @@ if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1) HsSysError(cp_pipe[1], ERROR_TIOCLSET); #endif /* TIOCLSET */ +#ifndef USE_POSIX_TERMIOS if (ioctl (tty, TCSETA, &tio) == -1) HsSysError(cp_pipe[1], ERROR_TIOCSETP); -#else /* USE_SYSV_TERMIO */ +#else + if (tcsetattr(tty, TCSANOW, &tio) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETP); +#endif +#else /* USE_SYSV_TERMIO || USE_POSIX_TERMIOS */ #ifdef KTERM sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW | EVENP | ODDP); @@ -3230,7 +3296,7 @@ shname_minus = malloc(strlen(shname) + 2); (void) strcpy(shname_minus, "-"); (void) strcat(shname_minus, shname); -#ifndef USE_SYSV_TERMIO +#if !defined(USE_SYSV_TERMIO) && !defined(USE_POSIX_TERMIOS) ldisc = XStrCmp("csh", shname + strlen(shname) - 3) == 0 ? NTTYDISC : 0; ioctl(0, TIOCSETD, (char *)&ldisc); --- kterm-6.2.0/Imakefile.orig 1996-07-12 14:01:04.000000000 +0900 +++ kterm-6.2.0/Imakefile 2012-01-14 01:23:09.000000000 +0900 @@ -23,6 +23,9 @@ PUCCPTYDDEF = -DPUCC_PTYD /* does not need to be setuid */ PTYLIB = -lpucc #endif +#ifdef NetBSDArchitecture + PTYLIB = -lutil +#endif OSMAJORVERSION = OSMajorVersion OSMINORVERSION = OSMinorVersion