diff options
| author | Richard M. Stallman | 1993-11-23 11:06:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-11-23 11:06:13 +0000 |
| commit | f4a7e5bd470df636724f8f5bda763c9435891dd5 (patch) | |
| tree | 0435cb6af3627706c53891ab0c68c3d27d4fc971 /src | |
| parent | db16f109c931e0c0d4c2d995032bf5f2896ffaec (diff) | |
| download | emacs-f4a7e5bd470df636724f8f5bda763c9435891dd5.tar.gz emacs-f4a7e5bd470df636724f8f5bda763c9435891dd5.zip | |
(getwd): If getcwd returns 0, we return 0.
(getwd for VMS): Likewise.
(read_input_waiting): read_socket_hook
delivers events, not characters. Make buf smaller
in the case where we actually call read itself.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sysdep.c | 74 |
1 files changed, 48 insertions, 26 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 0eacd05cc3e..47e6836d01d 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -2093,45 +2093,60 @@ select (nfds, rfds, wfds, efds, timeout) | |||
| 2093 | 2093 | ||
| 2094 | read_input_waiting () | 2094 | read_input_waiting () |
| 2095 | { | 2095 | { |
| 2096 | char buf[256 * BUFFER_SIZE_FACTOR]; | ||
| 2097 | struct input_event e; | 2096 | struct input_event e; |
| 2098 | int nread, i; | 2097 | int nread, i; |
| 2099 | extern int quit_char; | 2098 | extern int quit_char; |
| 2100 | 2099 | ||
| 2101 | if (read_socket_hook) | 2100 | if (read_socket_hook) |
| 2102 | { | 2101 | { |
| 2102 | struct input_event buf[256]; | ||
| 2103 | |||
| 2103 | read_alarm_should_throw = 0; | 2104 | read_alarm_should_throw = 0; |
| 2104 | if (! setjmp (read_alarm_throw)) | 2105 | if (! setjmp (read_alarm_throw)) |
| 2105 | nread = (*read_socket_hook) (0, buf, 256 * BUFFER_SIZE_FACTOR, 1, 0); | 2106 | nread = (*read_socket_hook) (0, buf, 256, 1, 0); |
| 2106 | else | 2107 | else |
| 2107 | nread = -1; | 2108 | nread = -1; |
| 2109 | |||
| 2110 | /* Scan the chars for C-g and store them in kbd_buffer. */ | ||
| 2111 | for (i = 0; i < nread; i++) | ||
| 2112 | { | ||
| 2113 | kbd_buffer_store_event (&buf[i]); | ||
| 2114 | /* Don't look at input that follows a C-g too closely. | ||
| 2115 | This reduces lossage due to autorepeat on C-g. */ | ||
| 2116 | if (buf[i].kind == ascii_keystroke | ||
| 2117 | && XINT(buf[i].code) == quit_char) | ||
| 2118 | break; | ||
| 2119 | } | ||
| 2108 | } | 2120 | } |
| 2109 | else | 2121 | else |
| 2110 | nread = read (fileno (stdin), buf, 1); | ||
| 2111 | |||
| 2112 | /* Scan the chars for C-g and store them in kbd_buffer. */ | ||
| 2113 | e.kind = ascii_keystroke; | ||
| 2114 | e.frame_or_window = selected_frame; | ||
| 2115 | e.modifiers = 0; | ||
| 2116 | for (i = 0; i < nread; i++) | ||
| 2117 | { | 2122 | { |
| 2118 | /* Convert chars > 0177 to meta events if desired. | 2123 | char buf[3]; |
| 2119 | We do this under the same conditions that read_avail_input does. */ | 2124 | nread = read (fileno (stdin), buf, 1); |
| 2120 | if (read_socket_hook == 0) | 2125 | |
| 2126 | /* Scan the chars for C-g and store them in kbd_buffer. */ | ||
| 2127 | e.kind = ascii_keystroke; | ||
| 2128 | e.frame_or_window = selected_frame; | ||
| 2129 | e.modifiers = 0; | ||
| 2130 | for (i = 0; i < nread; i++) | ||
| 2121 | { | 2131 | { |
| 2122 | /* If the user says she has a meta key, then believe her. */ | 2132 | /* Convert chars > 0177 to meta events if desired. |
| 2123 | if (meta_key == 1 && (buf[i] & 0x80)) | 2133 | We do this under the same conditions that read_avail_input does. */ |
| 2124 | e.modifiers = meta_modifier; | 2134 | if (read_socket_hook == 0) |
| 2125 | if (meta_key != 2) | 2135 | { |
| 2126 | buf[i] &= ~0x80; | 2136 | /* If the user says she has a meta key, then believe her. */ |
| 2127 | } | 2137 | if (meta_key == 1 && (buf[i] & 0x80)) |
| 2138 | e.modifiers = meta_modifier; | ||
| 2139 | if (meta_key != 2) | ||
| 2140 | buf[i] &= ~0x80; | ||
| 2141 | } | ||
| 2128 | 2142 | ||
| 2129 | XSET (e.code, Lisp_Int, buf[i]); | 2143 | XSET (e.code, Lisp_Int, buf[i]); |
| 2130 | kbd_buffer_store_event (&e); | 2144 | kbd_buffer_store_event (&e); |
| 2131 | /* Don't look at input that follows a C-g too closely. | 2145 | /* Don't look at input that follows a C-g too closely. |
| 2132 | This reduces lossage due to autorepeat on C-g. */ | 2146 | This reduces lossage due to autorepeat on C-g. */ |
| 2133 | if (buf[i] == quit_char) | 2147 | if (buf[i] == quit_char) |
| 2134 | break; | 2148 | break; |
| 2149 | } | ||
| 2135 | } | 2150 | } |
| 2136 | } | 2151 | } |
| 2137 | 2152 | ||
| @@ -2734,6 +2749,8 @@ getwd (pathname) | |||
| 2734 | 2749 | ||
| 2735 | BLOCK_INPUT; /* getcwd uses malloc */ | 2750 | BLOCK_INPUT; /* getcwd uses malloc */ |
| 2736 | spath = npath = getcwd ((char *) 0, MAXPATHLEN); | 2751 | spath = npath = getcwd ((char *) 0, MAXPATHLEN); |
| 2752 | if (spath == 0) | ||
| 2753 | return spath; | ||
| 2737 | /* On Altos 3068, getcwd can return @hostname/dir, so discard | 2754 | /* On Altos 3068, getcwd can return @hostname/dir, so discard |
| 2738 | up to first slash. Should be harmless on other systems. */ | 2755 | up to first slash. Should be harmless on other systems. */ |
| 2739 | while (*npath && *npath != '/') | 2756 | while (*npath && *npath != '/') |
| @@ -3613,13 +3630,18 @@ char * | |||
| 3613 | getwd (pathname) | 3630 | getwd (pathname) |
| 3614 | char *pathname; | 3631 | char *pathname; |
| 3615 | { | 3632 | { |
| 3616 | char *ptr; | 3633 | char *ptr, *val; |
| 3617 | extern char *getcwd (); | 3634 | extern char *getcwd (); |
| 3618 | 3635 | ||
| 3619 | #define MAXPATHLEN 1024 | 3636 | #define MAXPATHLEN 1024 |
| 3620 | 3637 | ||
| 3621 | ptr = xmalloc (MAXPATHLEN); | 3638 | ptr = xmalloc (MAXPATHLEN); |
| 3622 | getcwd (ptr, MAXPATHLEN); | 3639 | val = getcwd (ptr, MAXPATHLEN); |
| 3640 | if (val == 0) | ||
| 3641 | { | ||
| 3642 | xfree (ptr); | ||
| 3643 | return val; | ||
| 3644 | } | ||
| 3623 | strcpy (pathname, ptr); | 3645 | strcpy (pathname, ptr); |
| 3624 | xfree (ptr); | 3646 | xfree (ptr); |
| 3625 | 3647 | ||