#include "syssignal.h"
#include "systime.h"
+/* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */
+#ifndef LPASS8
+#define LPASS8 0
+#endif
+
+#ifdef BSD4_1
+#define LNOFLSH 0100000
+#endif
+
static int baud_convert[] =
#ifdef BAUD_CONVERT
BAUD_CONVERT;
#ifdef TIOCSTI
ioctl (input_fd, TIOCSTI, &c);
#else /* no TIOCSTI */
- error ("Cannot stuff terminal input characters in this version of Unix.");
+ error ("Cannot stuff terminal input characters in this version of Unix");
#endif /* no TIOCSTI */
}
#ifdef HAVE_TERMIOS
struct termios sg;
- sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600;
+ sg.c_cflag = B9600;
tcgetattr (input_fd, &sg);
ospeed = cfgetospeed (&sg);
#else /* neither VMS nor TERMIOS */
#ifdef HAVE_TERMIO
struct termio sg;
- sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600;
+ sg.c_cflag = B9600;
#ifdef HAVE_TCATTR
tcgetattr (input_fd, &sg);
#else
input */
s.main.c_oflag &= ~OLCUC; /* Disable map of lower case to upper on
output */
+ s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */
#if 0
/* Said to be unnecessary: */
s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */
s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE
| CBREAK | TANDEM);
+ s.main.sg_flags |= LPASS8;
s.main.sg_erase = 0377;
s.main.sg_kill = 0377;
+ s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */
#endif /* not HAVE_TERMIO */
#ifdef SIGTSTP
{
-#ifdef USG
- int pgrp = getpgrp ();
-#else
- int pgrp = getpgrp (0);
-#endif
+ int pgrp = EMACS_GETPGRP (0);
EMACS_KILLPG (pgrp, SIGTSTP);
}
tty.tchars.t_stopc = '\023';
}
-/* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */
-#ifndef LPASS8
-#define LPASS8 0
-#endif
-
-#ifdef BSD4_1
-#define LNOFLSH 0100000
-#endif
-
tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | old_tty.lmode;
#ifdef ultrix
/* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
read_input_waiting ()
{
- char buf[256 * BUFFER_SIZE_FACTOR];
struct input_event e;
int nread, i;
extern int quit_char;
if (read_socket_hook)
{
+ struct input_event buf[256];
+
read_alarm_should_throw = 0;
if (! setjmp (read_alarm_throw))
- nread = (*read_socket_hook) (0, buf, 256 * BUFFER_SIZE_FACTOR, 1, 0);
+ nread = (*read_socket_hook) (0, buf, 256, 1, 0);
else
nread = -1;
+
+ /* Scan the chars for C-g and store them in kbd_buffer. */
+ for (i = 0; i < nread; i++)
+ {
+ kbd_buffer_store_event (&buf[i]);
+ /* Don't look at input that follows a C-g too closely.
+ This reduces lossage due to autorepeat on C-g. */
+ if (buf[i].kind == ascii_keystroke
+ && XINT(buf[i].code) == quit_char)
+ break;
+ }
}
else
- nread = read (fileno (stdin), buf, 1);
-
- /* Scan the chars for C-g and store them in kbd_buffer. */
- e.kind = ascii_keystroke;
- e.frame_or_window = selected_frame;
- e.modifiers = 0;
- for (i = 0; i < nread; i++)
{
- XSET (e.code, Lisp_Int, buf[i]);
- kbd_buffer_store_event (&e);
- /* Don't look at input that follows a C-g too closely.
- This reduces lossage due to autorepeat on C-g. */
- if (buf[i] == quit_char)
- break;
+ char buf[3];
+ nread = read (fileno (stdin), buf, 1);
+
+ /* Scan the chars for C-g and store them in kbd_buffer. */
+ e.kind = ascii_keystroke;
+ e.frame_or_window = selected_frame;
+ e.modifiers = 0;
+ for (i = 0; i < nread; i++)
+ {
+ /* Convert chars > 0177 to meta events if desired.
+ We do this under the same conditions that read_avail_input does. */
+ if (read_socket_hook == 0)
+ {
+ /* If the user says she has a meta key, then believe her. */
+ if (meta_key == 1 && (buf[i] & 0x80))
+ e.modifiers = meta_modifier;
+ if (meta_key != 2)
+ buf[i] &= ~0x80;
+ }
+
+ XSET (e.code, Lisp_Int, buf[i]);
+ kbd_buffer_store_event (&e);
+ /* Don't look at input that follows a C-g too closely.
+ This reduces lossage due to autorepeat on C-g. */
+ if (buf[i] == quit_char)
+ break;
+ }
}
}
\f
#ifndef BSTRING
+#ifndef bzero
+
void
bzero (b, length)
register char *b;
#endif /* not VMS */
}
+#endif /* no bzero */
+
+#ifndef bcopy
/* Saying `void' requires a declaration, above, where bcopy is used
and that declaration causes pain for systems where bcopy is a macro. */
bcopy (b1, b2, length)
*b2++ = *b1++;
#endif /* not VMS */
}
+#endif /* no bcopy */
+#ifndef bcmp
int
bcmp (b1, b2, length) /* This could be a macro! */
register char *b1;
return 0;
#endif /* not VMS */
}
+#endif /* no bcmp */
+
#endif /* not BSTRING */
\f
#ifndef HAVE_RANDOM
char *buf;
unsigned int nbyte;
{
- register int rtnval;
+ register int rtnval, bytes_written;
- while ((rtnval = write (fildes, buf, nbyte)) == -1
- && (errno == EINTR));
- return (rtnval);
+ bytes_written = 0;
+
+ while (nbyte > 0)
+ {
+ rtnval = write (fildes, buf, nbyte);
+
+ if (rtnval == -1)
+ {
+ if (errno == EINTR)
+ continue;
+ else
+ return (-1);
+ }
+
+ buf += rtnval;
+ nbyte -= rtnval;
+ bytes_written += rtnval;
+ }
+ return (bytes_written);
}
#endif /* INTERRUPTIBLE_IO */
BLOCK_INPUT; /* getcwd uses malloc */
spath = npath = getcwd ((char *) 0, MAXPATHLEN);
+ if (spath == 0)
+ return spath;
/* On Altos 3068, getcwd can return @hostname/dir, so discard
up to first slash. Should be harmless on other systems. */
while (*npath && *npath != '/')
#include <dirent.h>
-#ifndef HAVE_CLOSEDIR
+#if defined(BROKEN_CLOSEDIR) || !defined(HAVE_CLOSEDIR)
+
int
closedir (dirp)
register DIR *dirp; /* stream from opendir */
{
- sys_close (dirp->dd_fd);
+ int rtnval;
+
+ rtnval = sys_close (dirp->dd_fd);
/* Some systems (like Solaris) allocate the buffer and the DIR all
in one block. Why in the world are we freeing this ourselves
xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */
#endif
xfree ((char *) dirp);
+
+ return rtnval;
}
-#endif /* not HAVE_CLOSEDIR */
+#endif /* BROKEN_CLOSEDIR or not HAVE_CLOSEDIR */
#endif /* SYSV_SYSTEM_DIR */
#ifdef NONSYSTEM_DIR_LIBRARY
getwd (pathname)
char *pathname;
{
- char *ptr;
+ char *ptr, *val;
extern char *getcwd ();
#define MAXPATHLEN 1024
ptr = xmalloc (MAXPATHLEN);
- getcwd (ptr, MAXPATHLEN);
+ val = getcwd (ptr, MAXPATHLEN);
+ if (val == 0)
+ {
+ xfree (ptr);
+ return val;
+ }
strcpy (pathname, ptr);
xfree (ptr);