File: termios.patch

package info (click to toggle)
lookup 1.08b-16
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,792 kB
  • sloc: ansic: 12,639; makefile: 247; perl: 174; sh: 53
file content (61 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Index: lookup-1.08b/lib/termset.c
===================================================================
--- lookup-1.08b.orig/lib/termset.c	2026-01-27 09:36:16.000000000 +0100
+++ lookup-1.08b/lib/termset.c	2026-01-27 09:37:17.584643429 +0100
@@ -43,7 +43,7 @@
 #      include <termio.h>
 #      define _HAVE_SYS_TERMIO_H_
 #    else
-#      include <sgtty.h>
+#      include <termios.h>
 #    endif /* _HAVE_TERMIO_H */
 #  endif /* _HAVE_SYS_TERMIO_H */
 #endif
@@ -83,6 +83,7 @@
 #  endif
 
 #  include <stdio.h>
+#  include <unistd.h>
 #  define DIE(note)                                                          \
    {                                                                         \
      write(fileno(stderr), note, sizeof(note));                              \
@@ -99,29 +100,29 @@
 
 #  ifndef _HAVE_SYS_TERMIO_H_
 
-	static struct sgttyb original, new;
+	static struct termios original, new;
 
 	void set_tty_state_to_cbreak(NO_ARGS)
 	{
-	    if (original.sg_flags == 0)
+	    if (original.c_lflag == 0)
 	    {
-		if (ioctl(fileno(stdin), TIOCGETP, (char*)&original) < 0)
-		    DIE("ioctl TIOCGETP error\n");
+		if (tcgetattr(STDIN_FILENO, &original) < 0)
+		    DIE("tcgetattr error\n");
 
 		new = original;
-		new.sg_flags |= CBREAK;		/* turn cbreak on */
-		new.sg_flags &= ~ECHO;		/* turn echo off */
+		new.c_lflag &= ~ECHO;
+		new.c_lflag |= ICANON;
 	    }
 	    /* don't worry about "integer overflow" warnings on next line */
-	    if (ioctl(fileno(stdin), TIOCSETP, (char*)&new) < 0)
-		DIE("ioctl TIOCSETP error\n");
+	    if (tcsetattr(STDIN_FILENO, TCSANOW, &new) < 0)
+		DIE("tcsetattr error\n");
 	}
 
 	void reset_tty_state(NO_ARGS)
 	{
 	    /* don't worry about "integer overflow" warnings on next lines */
-	    if (original.sg_flags)
-		ioctl(fileno(stdin), TIOCSETP, (char*)&original);
+	    if (original.c_lflag)
+		tcsetattr(STDIN_FILENO, TCSANOW, &original);
 	}
 
 #  else /* _HAVE_SYS_TERMIO_H_ */