Date: Mon, 28 Jan 2008 21:13:51 +0100 (CET) From: Ed Schouten <ed@fxq.nl> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/120097: [Patch] japanese/kterm16c: don't use sgtty, but termios Message-ID: <20080128201351.9D19E1CDAB@palm.hoeg.nl> Resent-Message-ID: <200801282020.m0SKK3IQ065140@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 120097 >Category: ports >Synopsis: [Patch] japanese/kterm16c: don't use sgtty, but termios >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jan 28 20:20:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Ed Schouten >Release: FreeBSD 6.3-PRERELEASE i386 >Organization: >Environment: System: FreeBSD palm.hoeg.nl 6.3-PRERELEASE FreeBSD 6.3-PRERELEASE #0: Wed Dec 19 16:07:46 CET 2007 ed@palm.hoeg.nl:/usr/obj/usr/src/sys/PALM i386 >Description: One of the last remaining FreeBSD ports that still uses sgtty is japanese/kterm16c. If we switch this port to termios, it can still be used on systems that don't have COMPAT_43TTY in the kernel. We'd better port it to termios, which isn't hard, because it already runs on other platforms that use termios. >How-To-Repeat: >Fix: Place the following patch in the files/ directory. --- main.c 2008-01-28 08:42:32.000000000 +0100 +++ main.c 2008-01-28 08:42:25.000000000 +0100 @@ -224,8 +224,14 @@ #define HAS_UTMP_UT_HOST #endif #else /* } !SYSV { */ /* BSD systems */ -#ifndef linux -#include <sgtty.h> +#ifdef __FreeBSD__ +#include <termios.h> +#define USE_TERMIOS +#define USE_TERMINFO +#define USE_SYSV_TERMIO +#define termio termios +#define USE_POSIX_WAIT +#define HAS_POSIX_SAVED_IDS #endif #include <sys/resource.h> #define HAS_UTMP_UT_HOST @@ -249,11 +255,6 @@ #include <sys/param.h> /* for NOFILE */ #endif -#if (BSD >= 199103) -#define USE_POSIX_WAIT -#define HAS_POSIX_SAVED_IDS -#endif - #include <stdio.h> #include <errno.h> #include <setjmp.h> @@ -1293,7 +1294,7 @@ ** implementation to implementation). */ d_tio.c_iflag = ICRNL|IXON; - d_tio.c_oflag = OPOST|ONLCR|TAB3; + d_tio.c_oflag = OPOST|ONLCR|OXTABS; #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; @@ -1349,11 +1350,13 @@ #ifdef ECHOCTL d_tio.c_lflag |= ECHOCTL|IEXTEN; #endif +#ifndef __FreeBSD__ #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; @@ -1403,7 +1406,11 @@ for (i = 0; i <= 2; i++) { struct termio deftio; +#ifdef USE_TERMIOS + if (tcgetattr(i, &deftio) == 0) { +#else if (ioctl (i, TCGETA, &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]; @@ -2370,7 +2377,11 @@ lmode = d_lmode; #endif /* TIOCLSET */ #ifdef USE_SYSV_TERMIO +#ifdef USE_TERMIOS + if(tcgetattr(tty, &tio) == -1) +#else if(ioctl(tty, TCGETA, &tio) == -1) +#endif tio = d_tio; #else /* not USE_SYSV_TERMIO */ @@ -2770,19 +2781,17 @@ tio.c_iflag &= ~(INLCR|IGNCR); tio.c_iflag |= ICRNL; /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */ - tio.c_oflag &= - ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); + tio.c_oflag &= ~(OCRNL|ONLRET); tio.c_oflag |= ONLCR; #ifdef OPOST tio.c_oflag |= OPOST; #endif /* OPOST */ #ifdef BAUD_0 /* baud rate is 0 (don't care) */ - tio.c_cflag &= ~(CBAUD); + cfsetspeed(&tio, 0); #else /* !BAUD_0 */ /* baud rate is 9600 (nice default) */ - tio.c_cflag &= ~(CBAUD); - tio.c_cflag |= B9600; + cfsetspeed(&tio, 9600); #endif /* !BAUD_0 */ tio.c_cflag &= ~CSIZE; if (screen->input_eight_bits) @@ -2895,7 +2904,11 @@ if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1) HsSysError(cp_pipe[1], ERROR_TIOCLSET); #endif /* TIOCLSET */ +#ifdef USE_TERMIOS + if (tcsetattr(tty, TCSANOW, &tio) == -1) +#else if (ioctl (tty, TCSETA, &tio) == -1) +#endif HsSysError(cp_pipe[1], ERROR_TIOCSETP); #else /* USE_SYSV_TERMIO */ #ifdef KTERM >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080128201351.9D19E1CDAB>