comparison src/sysdep.c @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 2f8bb876ab1d
children de805c49cfc1
comparison
equal deleted inserted replaced
405:0e08f63c74d2 406:b8cc9ab3f761
89 #endif 89 #endif
90 90
91 #ifdef WINDOWSNT 91 #ifdef WINDOWSNT
92 #include <sys/utime.h> 92 #include <sys/utime.h>
93 #include "ntheap.h" 93 #include "ntheap.h"
94 #endif
95
96 #ifdef HAVE_MMAP
97 #include <unistd.h>
98 #include <sys/mman.h>
99 #endif 94 #endif
100 95
101 /* ------------------------------- */ 96 /* ------------------------------- */
102 /* TTY definitions */ 97 /* TTY definitions */
103 /* ------------------------------- */ 98 /* ------------------------------- */
765 #endif 760 #endif
766 } 761 }
767 762
768 763
769 /* Given FD, obtain pty buffer size. When no luck, a good guess is made, 764 /* Given FD, obtain pty buffer size. When no luck, a good guess is made,
770 so that the function works even fd is not a pty. */ 765 so that the function works even when fd is not a pty. */
771 766
772 int 767 int
773 get_pty_max_bytes (int fd) 768 get_pty_max_bytes (int fd)
774 { 769 {
775 int pty_max_bytes; 770 /* DEC OSF 4.0 fpathconf returns 255, but xemacs hangs on long shell
776 771 input lines if we return 253. 252 is OK!. So let's leave a bit
772 of slack for the newline that xemacs will insert, and for those
773 inevitable vendor off-by-one-or-two-or-three bugs. */
774 #define MAX_CANON_SLACK 10
775 #define SAFE_MAX_CANON (127 - MAX_CANON_SLACK)
777 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) 776 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
778 pty_max_bytes = fpathconf (fd, _PC_MAX_CANON); 777 {
779 if (pty_max_bytes < 0) 778 int max_canon = fpathconf (fd, _PC_MAX_CANON);
780 #endif 779 return (max_canon < 0 ? SAFE_MAX_CANON :
781 pty_max_bytes = 250; 780 max_canon > SAFE_MAX_CANON ? max_canon - MAX_CANON_SLACK :
782 781 max_canon);
783 /* Deduct one, to leave space for the eof. */ 782 }
784 pty_max_bytes--; 783 #elif defined (_POSIX_MAX_CANON)
785 784 return (_POSIX_MAX_CANON > SAFE_MAX_CANON ?
786 return pty_max_bytes; 785 _POSIX_MAX_CANON - MAX_CANON_SLACK :
786 _POSIX_MAX_CANON);
787 #else
788 return SAFE_MAX_CANON;
789 #endif
787 } 790 }
788 791
789 /* Figure out the eof character for the FD. */ 792 /* Figure out the eof character for the FD. */
790 793
791 Bufbyte 794 Bufbyte