X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2ea99a1e340cb4cd8737c3c70e6bdd37ff0abc7f..8030369ccb5c871d3ce11b96c220f318bc741ed8:/src/sysdep.c diff --git a/src/sysdep.c b/src/sysdep.c index 28de7dba01..206ecca427 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -19,8 +19,10 @@ along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif -#include "config.h" #include #include #ifdef HAVE_UNISTD_H @@ -46,7 +48,7 @@ extern void srandom P_ ((unsigned int)); #include "blockinput.h" #undef NULL -#ifdef macintosh +#ifdef MAC_OS8 /* It is essential to include stdlib.h so that this file picks up the correct definitions of rand, srand, and RAND_MAX. Otherwise random numbers will not work correctly. */ @@ -56,7 +58,7 @@ extern void srandom P_ ((unsigned int)); /* Nonzero means delete a process right away if it exits (process.c). */ static int delete_exited_processes; #endif -#endif /* macintosh */ +#endif /* MAC_OS8 */ #ifdef WINDOWSNT #define read sys_read @@ -245,7 +247,7 @@ static int baud_convert[] = #else #if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T) #else -#if defined (HAVE_TERMIOS_H) && defined (LINUX) +#if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX) #include #endif #endif @@ -476,7 +478,7 @@ wait_for_termination (pid) break; wait (0); #else /* neither BSD_SYSTEM nor UNIPLUS: random sysV */ -#ifdef POSIX_SIGNALS /* would this work for LINUX as well? */ +#ifdef POSIX_SIGNALS /* would this work for GNU/Linux as well? */ sigblock (sigmask (SIGCHLD)); errno = 0; if (kill (pid, 0) == -1 && errno == ESRCH) @@ -485,11 +487,7 @@ wait_for_termination (pid) break; } - /* FIXME: Since sigpause is not POSIX and its use is deprecated, - this should probably be `sigsuspend (&empty_mask)', which is - POSIX. I'm not making that change right away because the - release is nearing. 2001-09-20 gerd. */ - sigpause (SIGEMPTYMASK); + sigsuspend (&empty_mask); #else /* not POSIX_SIGNALS */ #ifdef HAVE_SYSV_SIGPAUSE sighold (SIGCHLD); @@ -761,7 +759,7 @@ sys_suspend () /* Fork a subshell. */ -#ifndef macintosh +#ifndef MAC_OS8 void sys_subshell () { @@ -797,9 +795,9 @@ sys_subshell () goto xyzzy; dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); - str = (unsigned char *) alloca (XSTRING (dir)->size + 2); - len = XSTRING (dir)->size; - bcopy (XSTRING (dir)->data, str, len); + str = (unsigned char *) alloca (SCHARS (dir) + 2); + len = SCHARS (dir); + bcopy (SDATA (dir), str, len); if (str[len - 1] != '/') str[len++] = '/'; str[len] = 0; xyzzy: @@ -840,7 +838,7 @@ sys_subshell () #ifdef SET_EMACS_PRIORITY { - extern int emacs_priority; + extern EMACS_INT emacs_priority; if (emacs_priority < 0) nice (-emacs_priority); @@ -848,8 +846,23 @@ sys_subshell () #endif #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ - st = system (sh); - chdir (oldwd); + { + char *epwd = getenv ("PWD"); + char old_pwd[MAXPATHLEN+1+4]; + + /* If PWD is set, pass it with corrected value. */ + if (epwd) + { + strcpy (old_pwd, epwd); + if (str[len - 1] == '/') + str[len - 1] = '\0'; + setenv ("PWD", str, 1); + } + st = system (sh); + chdir (oldwd); + if (epwd) + putenv (old_pwd); /* restore previous value */ + } #if 0 /* This is also reported if last command executed in subshell failed, KFS */ if (st) report_file_error ("Can't execute subshell", Fcons (build_string (sh), Qnil)); @@ -882,7 +895,7 @@ sys_subshell () synch_process_alive = 0; #endif /* !VMS */ } -#endif /* !macintosh */ +#endif /* !MAC_OS8 */ static void save_signal_handlers (saved_handlers) @@ -1292,7 +1305,7 @@ init_sys_modes () { struct emacs_tty tty; -#ifdef macintosh +#ifdef MAC_OS8 /* cus-start.el complains if delete-exited-processes is not defined */ #ifndef subprocesses DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, @@ -1300,7 +1313,7 @@ init_sys_modes () nil means don't delete them until `list-processes' is run. */); delete_exited_processes = 0; #endif -#endif /* not macintosh */ +#endif /* MAC_OS8 */ #ifdef VMS #if 0 @@ -1998,7 +2011,7 @@ kbd_input_ast () if (c >= 0) { struct input_event e; - e.kind = ascii_keystroke; + e.kind = ASCII_KEYSTROKE_EVENT; XSETINT (e.code, c); e.frame_or_window = selected_frame; kbd_buffer_store_event (&e); @@ -2224,6 +2237,7 @@ start_of_text () * */ +#ifndef start_of_data char * start_of_data () { @@ -2246,44 +2260,8 @@ start_of_data () #endif /* ORDINARY_LINK */ #endif /* DATA_START */ } +#endif /* start_of_data */ #endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ - -#ifndef CANNOT_DUMP -/* Some systems that cannot dump also cannot implement these. */ - -/* - * Return the address of the end of the text segment prior to - * doing an unexec. After unexec the return value is undefined. - */ - -char * -end_of_text () -{ -#ifdef TEXT_END - return ((char *) TEXT_END); -#else - extern int etext; - return ((char *) &etext); -#endif -} - -/* - * Return the address of the end of the data segment prior to - * doing an unexec. After unexec the return value is undefined. - */ - -char * -end_of_data () -{ -#ifdef DATA_END - return ((char *) DATA_END); -#else - extern int edata; - return ((char *) &edata); -#endif -} - -#endif /* not CANNOT_DUMP */ /* init_system_name sets up the string for the Lisp function system-name to return. */ @@ -2376,7 +2354,9 @@ init_system_name () if (hp) { char *fqdn = (char *) hp->h_name; +#if 0 char *p; +#endif if (!index (fqdn, '.')) { @@ -2450,7 +2430,7 @@ init_system_name () #endif /* BSD4_1 */ { unsigned char *p; - for (p = XSTRING (Vsystem_name)->data; *p; p++) + for (p = SDATA (Vsystem_name); *p; p++) if (*p == ' ' || *p == '\t') *p = '-'; } @@ -2665,7 +2645,7 @@ read_input_waiting () 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 + if (buf[i].kind == ASCII_KEYSTROKE_EVENT && buf[i].code == quit_char) break; } @@ -2676,7 +2656,7 @@ read_input_waiting () nread = read (fileno (stdin), buf, 1); /* Scan the chars for C-g and store them in kbd_buffer. */ - e.kind = ascii_keystroke; + e.kind = ASCII_KEYSTROKE_EVENT; e.frame_or_window = selected_frame; e.modifiers = 0; for (i = 0; i < nread; i++) @@ -2801,10 +2781,12 @@ sys_signal (int signal_number, signal_handler_t action) struct sigaction new_action, old_action; sigemptyset (&new_action.sa_mask); new_action.sa_handler = action; -#ifdef SA_RESTART +#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) /* Emacs mostly works better with restartable system services. If this - * flag exists, we probably want to turn it on here. - */ + flag exists, we probably want to turn it on here. + However, on some systems this resets the timeout of `select' + which means that `select' never finishes if it keeps getting signals. + BROKEN_SA_RESTART is defined on those systems. */ new_action.sa_flags = SA_RESTART; #else new_action.sa_flags = 0; @@ -3245,7 +3227,7 @@ strerror (errnum) int emacs_open (path, oflag, mode) - char *path; + const char *path; int oflag, mode; { register int rtnval; @@ -3296,7 +3278,7 @@ emacs_read (fildes, buf, nbyte) int emacs_write (fildes, buf, nbyte) int fildes; - char *buf; + const char *buf; unsigned int nbyte; { register int rtnval, bytes_written; @@ -3668,7 +3650,7 @@ readdirver (dirp) int set_file_times (filename, atime, mtime) - char *filename; + const char *filename; EMACS_TIME atime, mtime; { #ifdef HAVE_UTIMES