summaryrefslogtreecommitdiff
path: root/src/msdos.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c167
1 files changed, 137 insertions, 30 deletions
diff --git a/src/msdos.c b/src/msdos.c
index a8aef9ac405..1d3fdd528d7 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1,6 +1,6 @@
/* MS-DOS specific C utilities. -*- coding: cp850 -*-
-Copyright (C) 1993-1997, 1999-2017 Free Software Foundation, Inc.
+Copyright (C) 1993-1997, 1999-2022 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -223,8 +223,8 @@ them. This happens with wheeled mice on Windows 9X, for example. */)
{
int n;
- CHECK_NUMBER (nbuttons);
- n = XINT (nbuttons);
+ CHECK_FIXNUM (nbuttons);
+ n = XFIXNUM (nbuttons);
if (n < 2 || n > 3)
xsignal2 (Qargs_out_of_range,
build_string ("only 2 or 3 mouse buttons are supported"),
@@ -322,8 +322,8 @@ mouse_get_pos (struct frame **f, int insist, Lisp_Object *bar_window,
*bar_window = Qnil;
mouse_get_xy (&ix, &iy);
*time = event_timestamp ();
- *x = make_number (mouse_last_x = ix);
- *y = make_number (mouse_last_y = iy);
+ *x = make_fixnum (mouse_last_x = ix);
+ *y = make_fixnum (mouse_last_y = iy);
}
static void
@@ -420,6 +420,9 @@ static unsigned short outside_cursor;
/* The only display since MS-DOS does not support multiple ones. */
struct tty_display_info the_only_display_info;
+/* The only tty_output, since MS-DOS supports only 1 display. */
+struct tty_output the_only_tty_output;
+
/* Support for DOS/V (allows Japanese characters to be displayed on
standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */
@@ -539,8 +542,8 @@ dos_set_window_size (int *rows, int *cols)
(video_name, "screen-dimensions-%dx%d",
*rows, *cols), Qnil));
- if (INTEGERP (video_mode)
- && (video_mode_value = XINT (video_mode)) > 0)
+ if (FIXNUMP (video_mode)
+ && (video_mode_value = XFIXNUM (video_mode)) > 0)
{
regs.x.ax = video_mode_value;
int86 (0x10, &regs, &regs);
@@ -742,21 +745,21 @@ IT_set_cursor_type (struct frame *f, Lisp_Object cursor_type)
Lisp_Object bar_parms = XCDR (cursor_type);
int width;
- if (INTEGERP (bar_parms))
+ if (FIXNUMP (bar_parms))
{
/* Feature: negative WIDTH means cursor at the top
of the character cell, zero means invisible cursor. */
- width = XINT (bar_parms);
+ width = XFIXNUM (bar_parms);
msdos_set_cursor_shape (f, width >= 0 ? DEFAULT_CURSOR_START : 0,
width);
}
else if (CONSP (bar_parms)
- && INTEGERP (XCAR (bar_parms))
- && INTEGERP (XCDR (bar_parms)))
+ && FIXNUMP (XCAR (bar_parms))
+ && FIXNUMP (XCDR (bar_parms)))
{
- int start_line = XINT (XCDR (bar_parms));
+ int start_line = XFIXNUM (XCDR (bar_parms));
- width = XINT (XCAR (bar_parms));
+ width = XFIXNUM (XCAR (bar_parms));
msdos_set_cursor_shape (f, start_line, width);
}
}
@@ -1321,7 +1324,7 @@ IT_frame_up_to_date (struct frame *f)
if (EQ (BVAR (b,cursor_type), Qt))
new_cursor = frame_desired_cursor;
else if (NILP (BVAR (b, cursor_type))) /* nil means no cursor */
- new_cursor = Fcons (Qbar, make_number (0));
+ new_cursor = Fcons (Qbar, make_fixnum (0));
else
new_cursor = BVAR (b, cursor_type);
}
@@ -1564,7 +1567,7 @@ void
IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
{
Lisp_Object tail;
- int i, j, length = XINT (Flength (alist));
+ int i, j, length = XFIXNUM (Flength (alist));
Lisp_Object *parms
= (Lisp_Object *) alloca (length * word_size);
Lisp_Object *values
@@ -1791,7 +1794,6 @@ internal_terminal_init (void)
}
Vinitial_window_system = Qpc;
- Vwindow_system_version = make_number (27); /* RE Emacs version */
tty->terminal->type = output_msdos_raw;
/* If Emacs was dumped on DOS/V machine, forget the stale VRAM
@@ -1871,6 +1873,7 @@ initialize_msdos_display (struct terminal *term)
term->redeem_scroll_bar_hook = 0;
term->judge_scroll_bars_hook = 0;
term->read_socket_hook = &tty_read_avail_input; /* from keyboard.c */
+ term->defined_color_hook = &tty_defined_color; /* from xfaces.c */
}
int
@@ -2423,11 +2426,11 @@ dos_rawgetc (void)
sc = regs.h.ah;
total_doskeys += 2;
- ASET (recent_doskeys, recent_doskeys_index, make_number (c));
+ ASET (recent_doskeys, recent_doskeys_index, make_fixnum (c));
recent_doskeys_index++;
if (recent_doskeys_index == NUM_RECENT_DOSKEYS)
recent_doskeys_index = 0;
- ASET (recent_doskeys, recent_doskeys_index, make_number (sc));
+ ASET (recent_doskeys, recent_doskeys_index, make_fixnum (sc));
recent_doskeys_index++;
if (recent_doskeys_index == NUM_RECENT_DOSKEYS)
recent_doskeys_index = 0;
@@ -2609,7 +2612,7 @@ dos_rawgetc (void)
if (code == 0)
continue;
- if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
+ if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight))
{
clear_mouse_face (hlinfo);
hlinfo->mouse_face_hidden = 1;
@@ -2652,7 +2655,7 @@ dos_rawgetc (void)
static Lisp_Object last_mouse_window;
mouse_window = window_from_coordinates
- (SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0);
+ (SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0, 0);
/* A window will be selected only when it is not
selected now, and the last mouse movement event was
not in it. A minibuffer window will be selected iff
@@ -2718,10 +2721,11 @@ dos_rawgetc (void)
event.code = button_num;
event.modifiers = dos_get_modifiers (0)
| (press ? down_modifier : up_modifier);
- event.x = make_number (x);
- event.y = make_number (y);
+ event.x = make_fixnum (x);
+ event.y = make_fixnum (y);
event.frame_or_window = selected_frame;
- event.arg = Qnil;
+ event.arg = tty_handle_tab_bar_click (SELECTED_FRAME (),
+ x, y, press, &event);
event.timestamp = event_timestamp ();
kbd_buffer_store_event (&event);
}
@@ -2902,7 +2906,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help)
p++;
for (j = 0, q = menu->text[i]; *q; j++)
{
- unsigned c = STRING_CHAR_ADVANCE (q);
+ unsigned c = string_char_advance (&q);
if (c > 26)
{
@@ -3063,15 +3067,15 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
state = alloca (menu->panecount * sizeof (struct IT_menu_state));
screensize = screen_size * 2;
faces[0]
- = lookup_derived_face (sf, intern ("msdos-menu-passive-face"),
+ = lookup_derived_face (NULL, sf, intern ("msdos-menu-passive-face"),
DEFAULT_FACE_ID, 1);
faces[1]
- = lookup_derived_face (sf, intern ("msdos-menu-active-face"),
+ = lookup_derived_face (NULL, sf, intern ("msdos-menu-active-face"),
DEFAULT_FACE_ID, 1);
selectface = intern ("msdos-menu-select-face");
- faces[2] = lookup_derived_face (sf, selectface,
+ faces[2] = lookup_derived_face (NULL, sf, selectface,
faces[0], 1);
- faces[3] = lookup_derived_face (sf, selectface,
+ faces[3] = lookup_derived_face (NULL, sf, selectface,
faces[1], 1);
/* Make sure the menu title is always displayed with
@@ -3912,6 +3916,50 @@ readlinkat (int fd, char const *name, char *buffer, size_t buffer_size)
return readlink (name, buffer, buffer_size);
}
+
+int
+openat (int fd, const char * path, int oflag, int mode)
+{
+ /* Rely on a hack: an open directory is modeled as file descriptor 0,
+ as in fstatat. FIXME: Add proper support for openat. */
+ char fullname[MAXPATHLEN];
+
+ if (fd != AT_FDCWD)
+ {
+ if (strlen (dir_pathname) + strlen (path) + 1 >= MAXPATHLEN)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ sprintf (fullname, "%s/%s", dir_pathname, path);
+ path = fullname;
+ }
+
+ return open (path, oflag, mode);
+}
+
+int
+fchmodat (int fd, const char *path, mode_t mode, int flags)
+{
+ /* Rely on a hack: an open directory is modeled as file descriptor 0,
+ as in fstatat. FIXME: Add proper support for openat. */
+ char fullname[MAXPATHLEN];
+
+ if (fd != AT_FDCWD)
+ {
+ if (strlen (dir_pathname) + strlen (path) + 1 >= MAXPATHLEN)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ sprintf (fullname, "%s/%s", dir_pathname, path);
+ path = fullname;
+ }
+
+ return chmod (path, mode);
+}
+
char *
careadlinkat (int fd, char const *filename,
char *buffer, size_t buffer_size,
@@ -3939,10 +3987,69 @@ careadlinkat (int fd, char const *filename,
return buffer;
}
+int
+futimens (int fd, const struct timespec times[2])
+{
+ struct tm *tm;
+ struct ftime ft;
+ time_t t;
+
+ block_input ();
+ if (times[1].tv_sec == UTIME_NOW)
+ t = time (NULL);
+ else
+ t = times[1].tv_sec;
+
+ tm = localtime (&t);
+ ft.ft_tsec = min (29, tm->tm_sec / 2);
+ ft.ft_min = tm->tm_min;
+ ft.ft_hour = tm->tm_hour;
+ ft.ft_day = tm->tm_mday;
+ ft.ft_month = tm->tm_mon + 1;
+ ft.ft_year = max (0, tm->tm_year - 80);
+ unblock_input ();
+
+ return setftime (fd, &ft);
+}
+
+int
+utimensat (int dirfd, const char *pathname,
+ const struct timespec times[2], int flags)
+{
+ int fd, ret;
+ char fullname[MAXPATHLEN];
+
+ /* Rely on a hack: dirfd in its current usage in Emacs is always
+ AT_FDCWD. */
+
+ if (dirfd != AT_FDCWD)
+ {
+ if (strlen (dir_pathname) + strlen (pathname) + 1 >= MAXPATHLEN)
+ {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ sprintf (fullname, "%s/%s", dir_pathname, pathname);
+ pathname = fullname;
+ }
+
+ fd = open (pathname, O_WRONLY);
+
+ if (fd < 0)
+ return -1;
+
+ ret = futimens (fd, times);
+ close (fd);
+
+ return ret;
+}
+
/* Emulate faccessat(2). */
int
faccessat (int dirfd, const char * path, int mode, int flags)
{
+ char fullname[MAXPATHLEN];
+
/* We silently ignore FLAGS. */
flags = flags;
@@ -4194,7 +4301,7 @@ msdos_fatal_signal (int sig)
void
syms_of_msdos (void)
{
- recent_doskeys = Fmake_vector (make_number (NUM_RECENT_DOSKEYS), Qnil);
+ recent_doskeys = Fmake_vector (make_fixnum (NUM_RECENT_DOSKEYS), Qnil);
staticpro (&recent_doskeys);
#ifndef HAVE_X_WINDOWS
@@ -4205,7 +4312,7 @@ syms_of_msdos (void)
DEFVAR_LISP ("dos-unsupported-char-glyph", Vdos_unsupported_char_glyph,
doc: /* Glyph to display instead of chars not supported by current codepage.
This variable is used only by MS-DOS terminals. */);
- Vdos_unsupported_char_glyph = make_number ('\177');
+ Vdos_unsupported_char_glyph = make_fixnum ('\177');
#endif