EXFUN (Fx_popup_dialog, 3);
extern void syms_of_xmenu P_ ((void));
+/* defined in termchar.h */
+struct tty_display_info;
+
+/* defined in termhooks.h */
+struct device;
+
/* defined in sysdep.c */
+ #ifndef HAVE_GET_CURRENT_DIR_NAME
+ extern char *get_current_dir_name P_ ((void));
+ #endif
extern void stuff_char P_ ((char c));
extern void init_sigio P_ ((int));
-extern void request_sigio P_ ((void));
-extern void unrequest_sigio P_ ((void));
-extern void reset_sys_modes P_ ((void));
extern void sys_subshell P_ ((void));
extern void sys_suspend P_ ((void));
extern void discard_tty_input P_ ((void));
#endif
#endif
+#include "sysselect.h"
+
#include "blockinput.h"
- #undef NULL
#ifdef MAC_OS8
/* It is essential to include stdlib.h so that this file picks up
SIGMASKTYPE sigprocmask_set;
+
+ #ifndef HAVE_GET_CURRENT_DIR_NAME
+
+ /* Return the current working directory. Returns NULL on errors.
+ Any other returned value must be freed with free. This is used
+ only when get_current_dir_name is not defined on the system. */
+ char*
+ get_current_dir_name ()
+ {
+ char *buf;
+ char *pwd;
+ struct stat dotstat, pwdstat;
+ /* If PWD is accurate, use it instead of calling getwd. PWD is
+ sometimes a nicer name, and using it may avoid a fatal error if a
+ parent directory is searchable but not readable. */
+ if ((pwd = getenv ("PWD")) != 0
+ && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1])))
+ && stat (pwd, &pwdstat) == 0
+ && stat (".", &dotstat) == 0
+ && dotstat.st_ino == pwdstat.st_ino
+ && dotstat.st_dev == pwdstat.st_dev
+ #ifdef MAXPATHLEN
+ && strlen (pwd) < MAXPATHLEN
+ #endif
+ )
+ {
+ buf = (char *) malloc (strlen (pwd) + 1);
+ if (!buf)
+ return NULL;
+ strcpy (buf, pwd);
+ }
+ #ifdef HAVE_GETCWD
+ else
+ {
+ size_t buf_size = 1024;
+ buf = (char *) malloc (buf_size);
+ if (!buf)
+ return NULL;
+ for (;;)
+ {
+ if (getcwd (buf, buf_size) == buf)
+ break;
+ if (errno != ERANGE)
+ {
+ int tmp_errno = errno;
+ free (buf);
+ errno = tmp_errno;
+ return NULL;
+ }
+ buf_size *= 2;
+ buf = (char *) realloc (buf, buf_size);
+ if (!buf)
+ return NULL;
+ }
+ }
+ #else
+ else
+ {
+ /* We need MAXPATHLEN here. */
+ buf = (char *) malloc (MAXPATHLEN + 1);
+ if (!buf)
+ return NULL;
+ if (getwd (buf) == NULL)
+ {
+ int tmp_errno = errno;
+ free (buf);
+ errno = tmp_errno;
+ return NULL;
+ }
+ }
+ #endif
+ return buf;
+ }
+ #endif
+
\f
-/* Specify a different file descriptor for further input operations. */
-
-void
-change_input_fd (fd)
- int fd;
-{
- input_fd = fd;
-}
-
-/* Discard pending input on descriptor input_fd. */
+/* Discard pending input on all input descriptors. */
void
discard_tty_input ()