X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/9173a8fbd77df7db68247a331df1c84f8ff074ec..1260aef1aea35be161846b0411aa387ade44e35f:/src/msdos.c diff --git a/src/msdos.c b/src/msdos.c index 964fde0cbf..6b6e365a16 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -1,7 +1,6 @@ /* MS-DOS specific C utilities. -*- coding: raw-text -*- - Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - Free Software Foundation, Inc. + +Copyright (C) 1993-1997, 1999-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -82,6 +81,9 @@ extern int spawnve (int, const char *, char *const [], char *const []); #include #include "syssignal.h" +#include "careadlinkat.h" +#include "allocator.h" + #ifndef SYSTEM_MALLOC #ifdef GNU_MALLOC @@ -285,7 +287,7 @@ mouse_button_depressed (int b, int *xp, int *yp) void mouse_get_pos (FRAME_PTR *f, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, - unsigned long *time) + Time *time) { int ix, iy; Lisp_Object frame, tail; @@ -294,7 +296,7 @@ mouse_get_pos (FRAME_PTR *f, int insist, Lisp_Object *bar_window, FOR_EACH_FRAME (tail, frame) XFRAME (frame)->mouse_moved = 0; - *f = SELECTED_FRAME(); + *f = SELECTED_FRAME (); *bar_window = Qnil; mouse_get_xy (&ix, &iy); *time = event_timestamp (); @@ -308,7 +310,7 @@ mouse_check_moved (void) int x, y; mouse_get_xy (&x, &y); - SELECTED_FRAME()->mouse_moved |= (x != mouse_last_x || y != mouse_last_y); + SELECTED_FRAME ()->mouse_moved |= (x != mouse_last_x || y != mouse_last_y); mouse_last_x = x; mouse_last_y = y; } @@ -404,9 +406,6 @@ static unsigned long screen_old_address = 0; /* Segment and offset of the virtual screen. If 0, DOS/V is NOT loaded. */ static unsigned short screen_virtual_segment = 0; static unsigned short screen_virtual_offset = 0; -/* A flag to control how to display unibyte 8-bit characters. */ -extern int unibyte_display_via_language_environment; - extern Lisp_Object Qcursor_type; extern Lisp_Object Qbar, Qhbar; @@ -583,7 +582,7 @@ dos_set_window_size (int *rows, int *cols) /* If the dimensions changed, the mouse highlight info is invalid. */ if (current_rows != *rows || current_cols != *cols) { - struct frame *f = SELECTED_FRAME(); + struct frame *f = SELECTED_FRAME (); Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); Lisp_Object window = hlinfo->mouse_face_window; @@ -640,7 +639,7 @@ msdos_set_cursor_shape (struct frame *f, int start_line, int width) /* Avoid the costly BIOS call if F isn't the currently selected frame. Allow for NULL as unconditionally meaning the selected frame. */ - if (f && f != SELECTED_FRAME()) + if (f && f != SELECTED_FRAME ()) return; if (tty->termscript) @@ -777,7 +776,7 @@ IT_ring_bell (struct frame *f) static void IT_set_face (int face) { - struct frame *sf = SELECTED_FRAME(); + struct frame *sf = SELECTED_FRAME (); struct face *fp = FACE_FROM_ID (sf, face); struct face *dfp = FACE_FROM_ID (sf, DEFAULT_FACE_ID); unsigned long fg, bg, dflt_fg, dflt_bg; @@ -843,12 +842,12 @@ IT_set_face (int face) /* According to RBIL (INTERRUP.A, V-1000), 160 is the maximum possible width of a DOS display in any known text mode. We multiply by 2 to - accomodate the screen attribute byte. */ + accommodate the screen attribute byte. */ #define MAX_SCREEN_BUF 160*2 -Lisp_Object Vdos_unsupported_char_glyph; extern unsigned char *encode_terminal_code (struct glyph *, int, struct coding_system *); + static void IT_write_glyphs (struct frame *f, struct glyph *str, int str_len) { @@ -869,7 +868,7 @@ IT_write_glyphs (struct frame *f, struct glyph *str, int str_len) if (str_len <= 0) return; - sf = SELECTED_FRAME(); + sf = SELECTED_FRAME (); /* Since faces get cached and uncached behind our back, we can't rely on their indices in the cache being consistent across @@ -1322,12 +1321,12 @@ IT_frame_up_to_date (struct frame *f) { struct buffer *b = XBUFFER (sw->buffer); - if (EQ (b->cursor_type, Qt)) + if (EQ (BVAR (b,cursor_type), Qt)) new_cursor = frame_desired_cursor; - else if (NILP (b->cursor_type)) /* nil means no cursor */ + else if (NILP (BVAR (b, cursor_type))) /* nil means no cursor */ new_cursor = Fcons (Qbar, make_number (0)); else - new_cursor = b->cursor_type; + new_cursor = BVAR (b, cursor_type); } IT_set_cursor_type (f, new_cursor); @@ -1394,8 +1393,6 @@ IT_delete_glyphs (struct frame *f, int n) void x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) { - extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); - set_menu_bar_lines (f, value, oldval); } @@ -1758,7 +1755,7 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist) if (redraw) { face_change_count++; /* forces xdisp.c to recompute basic faces */ - if (f == SELECTED_FRAME()) + if (f == SELECTED_FRAME ()) redraw_frame (f); } } @@ -1775,7 +1772,7 @@ internal_terminal_init (void) { static int init_needed = 1; char *term = getenv ("TERM"), *colors; - struct frame *sf = SELECTED_FRAME(); + struct frame *sf = SELECTED_FRAME (); struct tty_display_info *tty; #ifdef HAVE_X_WINDOWS @@ -1798,7 +1795,7 @@ internal_terminal_init (void) } tty = FRAME_TTY (sf); - current_kboard->Vwindow_system = Qpc; + KVAR (current_kboard, Vwindow_system) = Qpc; sf->output_method = output_msdos_raw; if (init_needed) { @@ -1926,7 +1923,7 @@ dos_get_saved_screen (char **screen, int *rows, int *cols) void check_x (void) { - if (! FRAME_MSDOS_P (SELECTED_FRAME())) + if (! FRAME_MSDOS_P (SELECTED_FRAME ())) error ("Not running under a window system"); } @@ -2445,12 +2442,12 @@ dos_rawgetc (void) { struct input_event event; union REGS regs; - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (SELECTED_FRAME()); + Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (SELECTED_FRAME ()); EVENT_INIT (event); #ifndef HAVE_X_WINDOWS /* Maybe put the cursor where it should be. */ - IT_cmgoto (SELECTED_FRAME()); + IT_cmgoto (SELECTED_FRAME ()); #endif /* The following condition is equivalent to `kbhit ()', except that @@ -2695,7 +2692,7 @@ dos_rawgetc (void) /* Generate SELECT_WINDOW_EVENTs when needed. */ if (!NILP (Vmouse_autoselect_window)) { - mouse_window = window_from_coordinates (SELECTED_FRAME(), + mouse_window = window_from_coordinates (SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0); @@ -2721,21 +2718,12 @@ dos_rawgetc (void) previous_help_echo_string = help_echo_string; help_echo_string = help_echo_object = help_echo_window = Qnil; help_echo_pos = -1; - note_mouse_highlight (SELECTED_FRAME(), mouse_last_x, mouse_last_y); + note_mouse_highlight (SELECTED_FRAME (), mouse_last_x, mouse_last_y); /* If the contents of the global variable help_echo has changed, generate a HELP_EVENT. */ if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) - { - event.kind = HELP_EVENT; - event.frame_or_window = selected_frame; - event.arg = help_echo_object; - event.x = WINDOWP (help_echo_window) - ? help_echo_window : selected_frame; - event.y = help_echo_string; - event.timestamp = event_timestamp (); - event.code = help_echo_pos; - kbd_buffer_store_event (&event); - } + gen_help_event (help_echo_string, selected_frame, help_echo_window, + help_echo_object, help_echo_pos); } for (but = 0; but < NUM_MOUSE_BUTTONS; but++) @@ -2824,7 +2812,7 @@ dos_keyread (void) left), but I don't think it's worth the effort. */ /* These hold text of the current and the previous menu help messages. */ -static char *menu_help_message, *prev_menu_help_message; +static const char *menu_help_message, *prev_menu_help_message; /* Pane number and item number of the menu item which generated the last menu help message. */ static int menu_help_paneno, menu_help_itemno; @@ -2851,7 +2839,7 @@ IT_menu_make_room (XMenu *menu) menu->text = (char **) xmalloc (count * sizeof (char *)); menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); menu->panenumber = (int *) xmalloc (count * sizeof (int)); - menu->help_text = (char **) xmalloc (count * sizeof (char *)); + menu->help_text = (const char **) xmalloc (count * sizeof (char *)); } else if (menu->allocated == menu->count) { @@ -2863,7 +2851,7 @@ IT_menu_make_room (XMenu *menu) menu->panenumber = (int *) xrealloc (menu->panenumber, count * sizeof (int)); menu->help_text - = (char **) xrealloc (menu->help_text, count * sizeof (char *)); + = (const char **) xrealloc (menu->help_text, count * sizeof (char *)); } } @@ -2925,7 +2913,7 @@ IT_menu_display (XMenu *menu, int y, int x, int pn, int *faces, int disp_help) int i, j, face, width, mx, my, enabled, mousehere, row, col; struct glyph *text, *p; const unsigned char *q; - struct frame *sf = SELECTED_FRAME(); + struct frame *sf = SELECTED_FRAME (); menu_help_message = NULL; @@ -3014,17 +3002,17 @@ XMenuCreate (Display *foo1, Window foo2, char *foo3) to do. */ int -XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable) +XMenuAddPane (Display *foo, XMenu *menu, const char *txt, int enable) { int len; - char *p; + const char *p; if (!enable) abort (); IT_menu_make_room (menu); menu->submenu[menu->count] = IT_menu_create (); - menu->text[menu->count] = txt; + menu->text[menu->count] = (char *)txt; menu->panenumber[menu->count] = ++menu->panecount; menu->help_text[menu->count] = NULL; menu->count++; @@ -3045,7 +3033,7 @@ XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable) int XMenuAddSelection (Display *bar, XMenu *menu, int pane, - int foo, char *txt, int enable, char *help_text) + int foo, char *txt, int enable, char const *help_text) { int len; char *p; @@ -3098,13 +3086,13 @@ struct IT_menu_state int XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, int x0, int y0, unsigned ButtonMask, char **txt, - void (*help_callback)(char *, int, int)) + void (*help_callback)(char const *, int, int)) { struct IT_menu_state *state; int statecount, x, y, i, b, screensize, leave, result, onepane; int title_faces[4]; /* face to display the menu title */ int faces[4], buffers_num_deleted = 0; - struct frame *sf = SELECTED_FRAME(); + struct frame *sf = SELECTED_FRAME (); Lisp_Object saved_echo_area_message, selectface; /* Just in case we got here without a mouse present... */ @@ -3551,10 +3539,10 @@ init_environment (int argc, char **argv, int skip_args) /* Some lusers set TMPDIR=e:, probably because some losing programs cannot handle multiple slashes if they use e:/. e: fails in `access' below, so we interpret e: as e:/. */ - tmp_len = strlen(tmp); + tmp_len = strlen (tmp); if (tmp[tmp_len - 1] != '/' && tmp[tmp_len - 1] != '\\') { - strcpy(buf, tmp); + strcpy (buf, tmp); buf[tmp_len++] = '/', buf[tmp_len] = 0; tmp = buf; } @@ -3936,6 +3924,53 @@ croak (char *badfunc) */ int setpgrp (void) {return 0; } int setpriority (int x, int y, int z) { return 0; } + +#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 +ssize_t +readlink (const char *name, char *dummy1, size_t dummy2) +{ + /* `access' is much faster than `stat' on MS-DOS. */ + if (access (name, F_OK) == 0) + errno = EINVAL; + return -1; +} +#endif + +char * +careadlinkat (int fd, char const *filename, + char *buffer, size_t buffer_size, + struct allocator const *alloc, + ssize_t (*preadlinkat) (int, char const *, char *, size_t)) +{ + if (!buffer) + { + /* We don't support the fancy auto-allocation feature. */ + if (!buffer_size) + errno = ENOSYS; + else + errno = EINVAL; + buffer = NULL; + } + else + { + ssize_t len = preadlinkat (fd, filename, buffer, buffer_size); + + if (len < 0 || len == buffer_size) + buffer = NULL; + else + buffer[len + 1] = '\0'; + } + return buffer; +} + +ssize_t +careadlinkatcwd (int fd, char const *filename, char *buffer, + size_t buffer_size) +{ + (void) fd; + return readlink (filename, buffer, buffer_size); +} + #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 @@ -4232,10 +4267,9 @@ syms_of_msdos (void) #ifndef HAVE_X_WINDOWS /* The following two are from xfns.c: */ - Qreverse = intern_c_string ("reverse"); - staticpro (&Qreverse); + DEFSYM (Qreverse, "reverse"); - DEFVAR_LISP ("dos-unsupported-char-glyph", &Vdos_unsupported_char_glyph, + 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'); @@ -4250,6 +4284,3 @@ This variable is used only by MS-DOS terminals. */); } #endif /* MSDOS */ - -/* arch-tag: db404e92-52a5-475f-9eb2-1cb78dd05f30 - (do not change this comment) */