Bug 124466 - [Patch] japanese/mh: port to termios
Summary: [Patch] japanese/mh: port to termios
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: motoyuki
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-11 08:00 UTC by Ed Schouten
Modified: 2008-07-05 02:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Schouten freebsd_committer freebsd_triage 2008-06-11 08:00:08 UTC
The japanese/mh port is one of the last ports that still depends on
COMPAT_43TTY, because it uses the sgtty programming interface. We'd
better port it to the POSIX termios interface. The source code already
contains code for SysV termio, which makes it easier to port.

Fix: 

Apply the following patch:

--- japanese/mh/files/patch-uip:msh.c
+++ japanese/mh/files/patch-uip:msh.c
@@ -0,0 +1,17 @@
+--- uip/msh.c
++++ uip/msh.c
+@@ -17,14 +17,7 @@
+ #include <ctype.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+-#ifndef	SYS5
+-#include <sgtty.h>
+-#else	/* SYS5 */
+-#include <termio.h>
+-#ifndef	NOIOCTLH
+ #include <sys/ioctl.h>
+-#endif	/* NOIOCTLH */
+-#endif	/* SYS5 */
+ #include <pwd.h>
+ #include <setjmp.h>
+ #include <signal.h>
--- japanese/mh/files/patch-uip:prompter.c
+++ japanese/mh/files/patch-uip:prompter.c
@@ -0,0 +1,100 @@
+--- uip/prompter.c
++++ uip/prompter.c
+@@ -6,15 +6,7 @@
+ #include "../h/mh.h"
+ #include <stdio.h>
+ #include <errno.h>
+-#ifndef	SYS5
+-#include <sgtty.h>
+-#else	/* SYS5 */
+-#include <sys/types.h>
+-#include <termio.h>
+-#ifndef	NOIOCTLH
+-#include <sys/ioctl.h>
+-#endif	/* NOIOCTLH */
+-#endif	/* SYS5 */
++#include <termios.h>
+ #if defined(BSD42) || defined(SVR4)
+ #include <setjmp.h>
+ #endif	/* BSD42 || SVR4 */
+@@ -71,19 +63,10 @@
+ extern int  errno;
+ 
+ 
+-#ifndef	SYS5
+-#define	ERASE	sg.sg_erase
+-#define	KILL	sg.sg_kill
+-static struct sgttyb    sg;
+-
+-#define	INTR	tc.t_intrc
+-static struct tchars    tc;
+-#else	/* SYS5 */
+ #define	ERASE	sg.c_cc[VERASE]
+ #define	KILL	sg.c_cc[VKILL]
+ #define	INTR	sg.c_cc[VINTR]
+-static struct termio    sg;
+-#endif	/* SYS5 */
++static struct termios    sg;
+ 
+ 
+ static TYPESIG	intrser ();
+@@ -209,29 +192,14 @@
+     (void) chmod (tmpfil, 0600);
+ 
+     if (killp || erasep) {
+-#ifndef	SYS5
+-	int    serase,
+-	       skill;
+-#else	/* SYS5 */
+-	char   serase,
+-	       skill;
+-#endif	/* SYS5 */
+-
+-#ifndef	SYS5
+-	(void) ioctl (0, TIOCGETP, (char *) &sg);
+-	(void) ioctl (0, TIOCGETC, (char *) &tc);
+-#else	/* SYS5 */
+-	(void) ioctl(0, TCGETA, &sg);
+-#endif	/* SYS5 */
++	cc_t serase, skill;
++
++	(void) tcgetattr(0, &sg);
+ 	skill = KILL;
+ 	serase = ERASE;
+ 	KILL = killp ? chrcnv (killp) : skill;
+ 	ERASE = erasep ? chrcnv (erasep) : serase;
+-#ifndef	SYS5
+-	(void) ioctl (0, TIOCSETN, (char *) &sg);
+-#else	/* SYS5 */
+-	(void) ioctl(0, TCSETAW, &sg);
+-#endif	/* SYS5 */
++	(void) tcsetattr(0, TCSADRAIN, &sg);
+ 
+ 	chrdsp ("erase", ERASE);
+ 	chrdsp (", kill", KILL);
+@@ -273,11 +241,7 @@
+ 		    if (i == -1) {
+ abort: ;
+ 			if (killp || erasep)
+-#ifndef	SYS5
+-			    (void) ioctl (0, TIOCSETN, (char *) &sg);
+-#else	/* SYS5 */
+-			    (void) ioctl (0, TCSETA, &sg);
+-#endif	/* SYS5 */
++			    (void) tcsetattr (0, TCSANOW, &sg);
+ 			(void) unlink (tmpfil);
+ 			done (1);
+ 		    }
+@@ -365,11 +329,7 @@
+ /*  */
+ 
+     if (killp || erasep)
+-#ifndef	SYS5
+-	(void) ioctl (0, TIOCSETN, (char *) &sg);
+-#else	/* SYS5 */
+-	(void) ioctl (0, TCSETAW, &sg);
+-#endif	/* SYS5 */
++	(void) tcsetattr (0, TCSANOW, &sg);
+ 
+     if ((fdi = open (tmpfil, 0)) == NOTOK)
+ 	adios (tmpfil, "unable to re-open");
--- japanese/mh/files/patch-uip:trmsbr.c
+++ japanese/mh/files/patch-uip:trmsbr.c
@@ -0,0 +1,51 @@
+--- uip/trmsbr.c
++++ uip/trmsbr.c
+@@ -5,19 +5,8 @@
+ 
+ #include "../h/mh.h"
+ #include <stdio.h>
+-#ifndef	SYS5
+-#include <sgtty.h>
+-#if	defined(ULTRIX) && !defined(BSD43)
+-#undef	TIOCGWINSZ
+-#endif
+-#else	/* SYS5 */
+-#include <sys/types.h>
+-#include <termio.h>
+-#ifndef	NOIOCTLH
+ #include <sys/ioctl.h>
+-#endif	/* NOIOCTLH */
+-#undef	TIOCGWINSZ
+-#endif	/* SYS5 */
++#include <termios.h>
+ 
+ 
+ #if	BUFSIZ<2048
+@@ -58,11 +47,7 @@
+                    *term;
+     char   *cp,
+ 	    myterm[TXTSIZ];
+-#ifndef	SYS5
+-    struct sgttyb   sg;
+-#else	/* SYS5 */
+-    struct termio   sg;
+-#endif	/* SYS5 */
++    struct termios  sg;
+     static int  inited = 0;
+ 
+     if (inited++)
+@@ -71,13 +56,7 @@
+     if ((term = getenv ("TERM")) == NULL || tgetent (myterm, term) <= OK)
+ 	return;
+ 
+-#ifndef	SYS5
+-    ospeed = ioctl (fileno (stdout), TIOCGETP, (char *) &sg) != NOTOK
+-		? sg.sg_ospeed : 0;
+-#else	/* SYS5 */
+-    ospeed = ioctl (fileno (stdout), TCGETA, &sg) != NOTOK
+-		? sg.c_cflag & CBAUD : 0;
+-#endif	/* SYS5 */
++    ospeed = tcgetattr (fileno (stdout), &sg) != NOTOK ? cfgetospeed(&sg) : 0;
+ 
+     HC = tgetflag ("hc");
+
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-06-11 08:00:15 UTC
Responsible Changed
From-To: freebsd-ports-bugs->motoyuki

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2008-07-05 02:15:49 UTC
State Changed
From-To: open->closed

Committed, thanks!
Comment 3 dfilter service freebsd_committer freebsd_triage 2008-07-05 02:15:52 UTC
edwin       2008-07-05 01:15:43 UTC

  FreeBSD ports repository

  Modified files:
    japanese/mh          Makefile 
  Added files:
    japanese/mh/files    patch-uip_msh.c patch-uip_prompter.c 
                         patch-uip_trmsbr.c 
  Log:
  [Patch] japanese/mh: port to termios
  
          The japanese/mh port is one of the last ports that still depends on
          COMPAT_43TTY, because it uses the sgtty programming interface. We'd
          better port it to the POSIX termios interface. The source code already
          contains code for SysV termio, which makes it easier to port.
  
  PR:             ports/124466
  Submitted by:   Ed Schouten <ed@FreeBSD.org>
  Approved by:    maintainer timeout
  
  Revision  Changes    Path
  1.31      +4 -0      ports/japanese/mh/Makefile
  1.1       +17 -0     ports/japanese/mh/files/patch-uip_msh.c (new)
  1.1       +100 -0    ports/japanese/mh/files/patch-uip_prompter.c (new)
  1.1       +51 -0     ports/japanese/mh/files/patch-uip_trmsbr.c (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"