Bug 122889

Summary: [Patch] chinese/ve: remove sgtty
Product: Ports & Packages Reporter: Ed Schouten <ed>
Component: Individual Port(s)Assignee: chinsan <chinsan>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Ed Schouten 2008-04-18 15:20:03 UTC
The chinese/ve port still uses sgtty. The source code is quite odd,
because it assumes termios is Linux-only, but also calls stty(1)
manually. We should just port this to termios, to make it work without
COMPAT_43TTY. I hope I've done it right.

Fix: 

Apply the following patch:

--- chinese/ve/files/patch-bbs.h
+++ chinese/ve/files/patch-bbs.h
@@ -0,0 +1,16 @@
+--- bbs.h
++++ bbs.h
+@@ -26,13 +26,6 @@
+ #include <sys/file.h>
+ 
+ 
+-#ifdef	LINUX
+-#include <bsd/sgtty.h>
+-#else
+-#include <sgtty.h>
+-#endif
+-
+-
+ #ifdef  SYSV
+ 
+ #ifndef LOCK_EX
--- chinese/ve/files/patch-term.c
+++ chinese/ve/files/patch-term.c
@@ -0,0 +1,95 @@
+--- term.c
++++ term.c
+@@ -9,17 +9,16 @@
+ 
+ #include "bbs.h"
+ #include <sys/ioctl.h>
++#include <stdlib.h>
+ 
+ #ifdef HP_UX
+ #define O_HUPCL 01
+ #define O_XTABS 02
+ #endif
+ 
+-#ifdef LINUX
+-#include <linux/termios.h>
+-#define stty(fd, data) tcsetattr( fd, TCSETS, data )
++#include <termios.h>
++#define stty(fd, data) tcsetattr( fd, TCSANOW, data )
+ #define gtty(fd, data) tcgetattr( fd, data )
+-#endif
+ 
+ #ifndef TANDEM
+ #define TANDEM  0x00000001
+@@ -29,11 +28,7 @@
+ #define CBREAK  0x00000002
+ #endif
+ 
+-#ifdef LINUX
+ struct termios tty_state, tty_new;
+-#else
+-struct sgttyb tty_state, tty_new;
+-#endif
+ 
+ 
+ /* ----------------------------------------------------- */
+@@ -62,37 +57,11 @@
+   }
+   memcpy(&tty_new, &tty_state, sizeof(tty_new));
+ 
+-#ifdef  LINUX
+-
+-  tty_new.c_lflag &= ~(ICANON | ECHO | RAW | ISIG);
+-  tcsetattr(1, TCSANOW, &tty_new);
++  tty_new.c_lflag &= ~(ICANON | ECHO | ISIG);
+   restore_tty();
+-
+-#else
+-
+-  tty_new.sg_flags |= RAW;
+-
+-#ifdef  HP_UX
+-  tty_new.sg_flags &= ~(O_HUPCL | O_XTABS | LCASE | ECHO | CRMOD);
+-#else
+-  tty_new.sg_flags &= ~(TANDEM | CBREAK | LCASE | ECHO | CRMOD);
+-#endif
+-
+-  stty(1, &tty_new);
+-#endif
+ }
+ 
+ 
+-#ifdef LINUX
+-reset_tty()
+-{
+-   system("stty -raw echo");
+-}
+-restore_tty()
+-{
+-   system("stty raw -echo");
+-}
+-#else
+ void
+ reset_tty()
+ {
+@@ -104,8 +73,6 @@
+   stty(1, &tty_new);
+ }
+ 
+-#endif
+-
+ 
+ 
+ /* ----------------------------------------------------- */
+@@ -171,11 +138,7 @@
+   char *sbp, *s;
+   char *tgetstr();
+ 
+-#ifdef LINUX
+   ospeed = cfgetospeed(&tty_state);
+-#else
+-  ospeed = tty_state.sg_ospeed;
+-#endif
+ 
+   if (tgetent(buf, term) != 1)
+     return NA;
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-04-18 15:20:13 UTC
Responsible Changed
From-To: freebsd-ports-bugs->chinsan

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer freebsd_triage 2008-05-01 15:08:25 UTC
chinsan     2008-05-01 14:08:18 UTC

  FreeBSD ports repository

  Modified files:
    chinese/ve           Makefile 
  Added files:
    chinese/ve/files     patch-bbs.h patch-term.c 
  Log:
  - Use termios instead of sgtty.
  
  PR:             ports/119115, ports/122889
  Submitted by:   Ed Schouten <ed@80386 dot nl>
  
  Revision  Changes    Path
  1.15      +1 -0      ports/chinese/ve/Makefile
  1.1       +17 -0     ports/chinese/ve/files/patch-bbs.h (new)
  1.1       +95 -0     ports/chinese/ve/files/patch-term.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"
Comment 3 chinsan freebsd_committer freebsd_triage 2008-05-01 15:09:08 UTC
State Changed
From-To: open->closed

Committed with some modification, thanks.