diff src/sysdep.c @ 361:7347b34c275b r21-1-10

Import from CVS: tag r21-1-10
author cvs
date Mon, 13 Aug 2007 10:58:40 +0200
parents 8e84bee8ddd0
children a4f53d9b3154
line wrap: on
line diff
--- a/src/sysdep.c	Mon Aug 13 10:57:57 2007 +0200
+++ b/src/sysdep.c	Mon Aug 13 10:58:40 2007 +0200
@@ -769,18 +769,26 @@
 int
 get_pty_max_bytes (int fd)
 {
-  int pty_max_bytes;
-
+  /* DEC OSF fpathconf returns 255, but xemacs hangs on long shell
+     input lines if we return 253.  252 is OK!.  So let's leave a bit
+     of slack for the newline that xemacs will insert, and for those
+     inevitable vendor off-by-one-or-two-or-three bugs. */
+#define MAX_CANON_SLACK 10
+#define SAFE_MAX_CANON 120
 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
-  pty_max_bytes = fpathconf (fd, _PC_MAX_CANON);
-  if (pty_max_bytes < 0)
+  {
+    int max_canon = fpathconf (fd, _PC_MAX_CANON);
+    return (max_canon < 0 ? SAFE_MAX_CANON :
+	    max_canon > SAFE_MAX_CANON ? max_canon - MAX_CANON_SLACK :
+	    max_canon);
+  }
+#elif defined (_POSIX_MAX_CANON)
+  return (_POSIX_MAX_CANON > SAFE_MAX_CANON ?
+	  _POSIX_MAX_CANON - MAX_CANON_SLACK :
+	  _POSIX_MAX_CANON);
+#else
+  return SAFE_MAX_CANON;
 #endif
-    pty_max_bytes = 250;
-
-  /* Deduct one, to leave space for the eof.  */
-  pty_max_bytes--;
-
-  return pty_max_bytes;
 }
 
 /* Figure out the eof character for the FD. */