diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/.gdbinit | 38 | ||||
-rw-r--r-- | src/ChangeLog | 87 | ||||
-rw-r--r-- | src/alloc.c | 7 | ||||
-rw-r--r-- | src/emacs.c | 23 | ||||
-rw-r--r-- | src/fileio.c | 51 | ||||
-rw-r--r-- | src/keyboard.c | 82 | ||||
-rw-r--r-- | src/mac.c | 299 | ||||
-rw-r--r-- | src/macfns.c | 1 | ||||
-rw-r--r-- | src/macmenu.c | 1 | ||||
-rw-r--r-- | src/macselect.c | 4 | ||||
-rw-r--r-- | src/macterm.c | 85 | ||||
-rw-r--r-- | src/process.c | 7 | ||||
-rw-r--r-- | src/unexmacosx.c | 98 | ||||
-rw-r--r-- | src/xdisp.c | 23 |
14 files changed, 535 insertions, 271 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index c3c7e6fd428..f1cc2d35d4b 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -112,21 +112,45 @@ define pitx if ($it->start.pos.charpos != $it->start.pos.bytepos) printf "[%d]", $it->start.pos.bytepos end - printf " stop=%d ", $it->stop_charpos - output $it->what + printf " end=%d", $it->end_charpos + printf " stop=%d", $it->stop_charpos + printf " face=%d", $it->face_id + if ($it->multibyte_p) + printf " MB" + end + if ($it->header_line_p) + printf " HL" + end + if ($it->n_overlay_strings > 0) + printf " nov=%d" + end + if ($it->sp != 0) + printf " sp=%d", $it->sp + end if ($it->what == IT_CHARACTER) if ($it->len == 1 && $it->c >= ' ' && it->c < 255) - printf "['%c']", $it->c + printf "ch='%c'", $it->c else - printf "[%d,%d]", $it->c, $it->len + printf "ch=[%d,%d]", $it->c, $it->len + end + else + if ($it->what == IT_IMAGE) + printf "IMAGE=%d", $it->image_id + else + output $it->what end end - printf " next=" - output $it->method + if ($it->method != GET_FROM_BUFFER) + printf " next=" + output $it->method + end printf "\n" + if ($it->region_beg_charpos >= 0) + printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos + end printf "vpos=%d hpos=%d", $it->vpos, $it->hpos, printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y - printf " x=%d lvx=%d", $it->current_x, $it->last_visible_x + printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent printf "\n" diff --git a/src/ChangeLog b/src/ChangeLog index a0999f79f64..10d3bd31bda 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,90 @@ +2005-05-19 Nick Roberts <nickrob@snap.net.nz> + + * keyboard.c (syms_of_keyboard): Remove lisp variables + post-command-idle-hook and post-command-idle-delay. + (command_loop_1): Don't try to execute post-command-idle-hook. + +2005-05-16 Kim F. Storm <storm@cua.dk> + + * xdisp.c (handle_display_prop): Handle empty replacement. + (handle_single_display_spec): Return -1 for empty replacement. + + * keyboard.c (adjust_point_for_property): Skip empty overlay string. + + * .gdbinit (pitx): Print more info about iterator. + +2005-05-16 Andreas Schwab <schwab@suse.de> + + * unexmacosx.c (unexec_realloc): Move declarations before + statements. + +2005-05-14 Richard M. Stallman <rms@gnu.org> + + * xdisp.c (message3): Call cancel_echoing. + + * alloc.c (Fmemory_full_p): New function. + (syms_of_alloc): defsubr it. + + * process.c (send_process_trap): Unblock SIGPIPE. + (send_process): Reset SIGPIPE handler before reporting error. + +2005-05-14 Nick Roberts <nickrob@snap.net.nz> + + * emacs.c (syms_of_emacs): Fix doc string for system-type. + +2005-05-13 Richard M. Stallman <rms@gnu.org> + + * fileio.c (Ffind_file_name_handler): Handle lambda-exp as handler. + (Finsert_file_contents): If we read 0 bytes from a special file, + unlock the visited file if we locked it. + (Fmake_symbolic_link, Frecent_auto_save_p): Doc fixes. + (Ffile_exists_p, Ffile_symlink_p): Doc fixes. + +2005-05-13 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * emacs.c (main) [MAC_OS8]: Call init_atimer before mac_term_init. + + * keyboard.c (readable_events) [USE_TOOLKIT_SCROLL_BARS]: Regard + toolkit scroll bar thumb drag events as squeezable and prevent + redisplay from being paused by them. + + * mac.c [!MAC_OSX]: Include keyboard.h and syssignal.h. + [!MAC_OSX] (target_ticks): Remove variable. + [!MAC_OSX] (check_alarm, pause, index): Remove functions. + [!MAC_OSX && __MRC__] (sys_strftime): Likewise. + [!MAC_OSX] (select): If fd 0 is not set in rfds and some input + event occurs before timeout, behave as if the function were + interrupted. + [!MAC_OSX] (sigblock, sigsetmask, alarm): Simulate SIGALRM + handling using Time Manager routines. + [!MAC_OSX] (mac_atimer_task, mac_atimer_qlink, signal_mask): New + variables. + [!MAC_OSX] (mac_atimer_handler, set_mac_atimer, remove_mac_atimer) + (setitimer): New functions. + + * macfns.c, macmenu.c: Don't include signal.h. + + * macterm.c [USE_TOOLKIT_SCROLL_BARS] (get_control_part_bounds): + Rename from get_control_part_bound. All callers changed. + (x_scroll_bar_clear): New function. + (x_clear_frame): Use it. + (XTset_vertical_scroll_bar): Don't call Draw1Control. + (x_scroll_bar_handle_click): Change type of second argument from + int to ControlPartCode. + (check_alarm): Remove declaration. + (XTread_Socket) [!TARGET_API_MAC_CARBON]: Don't call it. + (XTread_Socket): Use ControlPartCode instead of SInt16. + +2005-05-13 Nozomu Ando <nand@mac.com> + + * unexmacosx.c: Include assert.h. + (MACOSX_MALLOC_MULT16): New define. + [MACOSX_MALLOC_MULT16] (ptr_in_unexec_regions): Determine whether + ptr is in unexec regions by checking it is multiple of 16. + (unexec_malloc_header_t): New typedef. + (unexec_malloc, unexec_realloc, unexec_free): Store and use + allocated size information in unexec_malloc_header. + 2005-05-10 Richard M. Stallman <rms@gnu.org> * xterm.c (noinclude): Add #undef. diff --git a/src/alloc.c b/src/alloc.c index 1aa07b01da2..1eeea72ea7e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -534,6 +534,12 @@ memory_full () Fsignal (Qnil, Vmemory_signal_data); } +DEFUN ("memory-full-p", Fmemory_full_p, Smemory_full_p, 0, 0, 0, + doc: /* t if memory is nearly full, nil otherwise. */) + () +{ + return (spare_memory ? Qnil : Qt); +} /* Called if we can't allocate relocatable space for a buffer. */ @@ -6035,6 +6041,7 @@ The time is in seconds as a floating point value. */); DEFVAR_INT ("gcs-done", &gcs_done, doc: /* Accumulated number of garbage collections done. */); + defsubr (&Smemory_full_p); defsubr (&Scons); defsubr (&Slist); defsubr (&Svector); diff --git a/src/emacs.c b/src/emacs.c index 597a86d2eec..65a6d549845 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1326,6 +1326,7 @@ main (argc, argv syms_of_search (); syms_of_frame (); + init_atimer (); mac_term_init (build_string ("Mac"), NULL, NULL); init_keyboard (); #endif @@ -1351,7 +1352,9 @@ main (argc, argv #ifdef CLASH_DETECTION init_filelock (); #endif +#ifndef MAC_OS8 init_atimer (); +#endif running_asynch_code = 0; /* Handle --unibyte and the EMACS_UNIBYTE envvar, @@ -2447,16 +2450,16 @@ syms_of_emacs () Many arguments are deleted from the list as they are processed. */); DEFVAR_LISP ("system-type", &Vsystem_type, -+ doc: /* Value is symbol indicating type of operating system you are using. -+Special values: -+ `gnu/linux' compiled for a GNU/Linux system. -+ `darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...). -+ `macos' compiled for Mac OS 9. -+ `ms-dos' compiled as an MS-DOS application. -+ `windows-nt' compiled as a native W32 application. -+ `cygwin' compiled using the Cygwin library. -+ `vax-vms' or `axp-vms': compiled for a (Open)VMS system. -+Anything else indicates some sort of Unix system. */); + doc: /* Value is symbol indicating type of operating system you are using. +Special values: + `gnu/linux' compiled for a GNU/Linux system. + `darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...). + `macos' compiled for Mac OS 9. + `ms-dos' compiled as an MS-DOS application. + `windows-nt' compiled as a native W32 application. + `cygwin' compiled using the Cygwin library. + `vax-vms' or `axp-vms': compiled for a (Open)VMS system. +Anything else indicates some sort of Unix system. */); Vsystem_type = intern (SYSTEM_TYPE); DEFVAR_LISP ("system-configuration", &Vsystem_configuration, diff --git a/src/fileio.c b/src/fileio.c index 1d6100a2a81..58912a7cb8c 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -377,7 +377,10 @@ use the standard functions without calling themselves recursively. */) Lisp_Object string = XCAR (elt); int match_pos; Lisp_Object handler = XCDR (elt); - Lisp_Object operations = Fget (handler, Qoperations); + Lisp_Object operations = Qnil; + + if (SYMBOLP (handler)) + operations = Fget (handler, Qoperations); if (STRINGP (string) && (match_pos = fast_string_match (string, filename)) > pos @@ -2867,7 +2870,8 @@ This is what happens in interactive use with M-x. */) #ifdef S_IFLNK DEFUN ("make-symbolic-link", Fmake_symbolic_link, Smake_symbolic_link, 2, 3, "FMake symbolic link to file: \nGMake symbolic link to file %s: \np", - doc: /* Make a symbolic link to FILENAME, named LINKNAME. Both args must be strings. + doc: /* Make a symbolic link to FILENAME, named LINKNAME. +Both args must be strings. Signals a `file-already-exists' error if a file LINKNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. A number as third arg means request confirmation if LINKNAME already exists. @@ -3065,8 +3069,10 @@ check_writable (filename) } DEFUN ("file-exists-p", Ffile_exists_p, Sfile_exists_p, 1, 1, 0, - doc: /* Return t if file FILENAME exists. (This does not mean you can read it.) -See also `file-readable-p' and `file-attributes'. */) + doc: /* Return t if file FILENAME exists (whether or not you can read it.) +See also `file-readable-p' and `file-attributes'. +This returns nil for a symlink to a nonexistent file. +Use `file-symlink-p' to test for such links. */) (filename) Lisp_Object filename; { @@ -3243,7 +3249,10 @@ If there is no error, returns nil. */) DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0, doc: /* Return non-nil if file FILENAME is the name of a symbolic link. The value is the link target, as a string. -Otherwise returns nil. */) +Otherwise it returns nil. + +This function returns t when given the name of a symlink that +points to a nonexistent file. */) (filename) Lisp_Object filename; { @@ -3733,6 +3742,8 @@ actually used. */) int set_coding_system = 0; Lisp_Object coding_system; int read_quit = 0; + int old_Vdeactivate_mark = Vdeactivate_mark; + int we_locked_file = 0; if (current_buffer->base_buffer && ! NILP (visit)) error ("Cannot do file visiting in an indirect buffer"); @@ -4381,8 +4392,17 @@ actually used. */) /* For a special file, all we can do is guess. */ total = READ_BUF_SIZE; - if (NILP (visit) && total > 0) - prepare_to_modify_buffer (PT, PT, NULL); + if (NILP (visit) && inserted > 0) + { +#ifdef CLASH_DETECTION + if (!NILP (current_buffer->file_truename) + /* Make binding buffer-file-name to nil effective. */ + && !NILP (current_buffer->filename) + && SAVE_MODIFF >= MODIFF) + we_locked_file = 1; +#endif /* CLASH_DETECTION */ + prepare_to_modify_buffer (GPT, GPT, NULL); + } move_gap (PT); if (GAP_SIZE < total) @@ -4472,6 +4492,18 @@ actually used. */) } } + /* Now we have read all the file data into the gap. + If it was empty, undo marking the buffer modified. */ + + if (inserted == 0) + { +#ifdef CLASH_DETECTION + if (we_locked_file) + unlock_file (current_buffer->file_truename); +#endif + Vdeactivate_mark = old_Vdeactivate_mark; + } + /* Make the text read part of the buffer. */ GAP_SIZE -= inserted; GPT += inserted; @@ -5952,7 +5984,10 @@ DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, DEFUN ("recent-auto-save-p", Frecent_auto_save_p, Srecent_auto_save_p, 0, 0, 0, - doc: /* Return t if current buffer has been auto-saved since last read in or saved. */) + doc: /* Return t if current buffer has been auto-saved recently. +More precisely, if it has been auto-saved since last read from or saved +in the visited file. If the buffer has no visited file, +then any auto-save counts as "recent". */) () { return (SAVE_MODIFF < current_buffer->auto_save_modified) ? Qt : Qnil; diff --git a/src/keyboard.c b/src/keyboard.c index dd4767585b7..0e7fb1c2719 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -450,11 +450,6 @@ Lisp_Object Qecho_area_clear_hook; Lisp_Object Qpre_command_hook, Vpre_command_hook; Lisp_Object Qpost_command_hook, Vpost_command_hook; Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal; -/* Hook run after a command if there's no more input soon. */ -Lisp_Object Qpost_command_idle_hook, Vpost_command_idle_hook; - -/* Delay time in microseconds before running post-command-idle-hook. */ -EMACS_INT post_command_idle_delay; /* List of deferred actions to be performed at a later time. The precise format isn't relevant here; we just check whether it is nil. */ @@ -1447,16 +1442,6 @@ command_loop_1 () if (!NILP (Vdeferred_action_list)) safe_run_hooks (Qdeferred_action_function); - - if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks)) - { - if (NILP (Vunread_command_events) - && NILP (Vunread_input_method_events) - && NILP (Vunread_post_input_method_events) - && NILP (Vexecuting_kbd_macro) - && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1))) - safe_run_hooks (Qpost_command_idle_hook); - } } Vmemory_full = Qnil; @@ -1822,16 +1807,6 @@ command_loop_1 () if (!NILP (Vdeferred_action_list)) safe_run_hooks (Qdeferred_action_function); - if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks)) - { - if (NILP (Vunread_command_events) - && NILP (Vunread_input_method_events) - && NILP (Vunread_post_input_method_events) - && NILP (Vexecuting_kbd_macro) - && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1))) - safe_run_hooks (Qpost_command_idle_hook); - } - /* If there is a prefix argument, 1) We don't want Vlast_command to be ``universal-argument'' (that would be dumb), so don't set Vlast_command, @@ -1947,10 +1922,13 @@ adjust_point_for_property (last_pt, modified) ? get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil) : (beg = OVERLAY_POSITION (OVERLAY_START (overlay)), end = OVERLAY_POSITION (OVERLAY_END (overlay)))) - && beg < PT) /* && end > PT <- It's always the case. */ + && (beg < PT /* && end > PT <- It's always the case. */ + || (beg <= PT && STRINGP (val) && SCHARS (val) == 0))) { xassert (end > PT); - SET_PT (PT < last_pt ? beg : end); + SET_PT (PT < last_pt + ? (STRINGP (val) && SCHARS (val) == 0 ? beg - 1 : beg) + : end); check_composition = check_invisible = 1; } check_display = 0; @@ -3530,9 +3508,11 @@ readable_events (flags) READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */ if (kbd_fetch_ptr != kbd_store_ptr) { - int have_live_event = 1; - - if (flags & READABLE_EVENTS_FILTER_EVENTS) + if (flags & (READABLE_EVENTS_FILTER_EVENTS +#ifdef USE_TOOLKIT_SCROLL_BARS + | READABLE_EVENTS_IGNORE_SQUEEZABLES +#endif + )) { struct input_event *event; @@ -3540,16 +3520,29 @@ readable_events (flags) ? kbd_fetch_ptr : kbd_buffer); - while (have_live_event && event->kind == FOCUS_IN_EVENT) - { - event++; + do + { + if (!( +#ifdef USE_TOOLKIT_SCROLL_BARS + (flags & READABLE_EVENTS_FILTER_EVENTS) && +#endif + event->kind == FOCUS_IN_EVENT) +#ifdef USE_TOOLKIT_SCROLL_BARS + && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES) + && event->kind == SCROLL_BAR_CLICK_EVENT + && event->part == scroll_bar_handle + && event->modifiers == 0) +#endif + ) + return 1; + event++; if (event == kbd_buffer + KBD_BUFFER_SIZE) event = kbd_buffer; - if (event == kbd_store_ptr) - have_live_event = 0; - } + } + while (event != kbd_store_ptr); } - if (have_live_event) return 1; + else + return 1; } #ifdef HAVE_MOUSE @@ -6544,7 +6537,7 @@ lucid_event_type_list_p (object) If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal events (FOCUS_IN_EVENT). If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse - movements. */ + movements and toolkit scroll bar thumb drags. */ static void get_input_pending (addr, flags) @@ -10835,9 +10828,6 @@ syms_of_keyboard () Qpost_command_hook = intern ("post-command-hook"); staticpro (&Qpost_command_hook); - Qpost_command_idle_hook = intern ("post-command-idle-hook"); - staticpro (&Qpost_command_idle_hook); - Qdeferred_action_function = intern ("deferred-action-function"); staticpro (&Qdeferred_action_function); @@ -11283,16 +11273,6 @@ the hook value is set to nil, since otherwise the error might happen repeatedly and make Emacs nonfunctional. */); Vpost_command_hook = Qnil; - DEFVAR_LISP ("post-command-idle-hook", &Vpost_command_idle_hook, - doc: /* Normal hook run after each command is executed, if idle. -Errors running the hook are caught and ignored. */); - Vpost_command_idle_hook = Qnil; - - DEFVAR_INT ("post-command-idle-delay", &post_command_idle_delay, - doc: /* Delay time before running `post-command-idle-hook'. -This is measured in microseconds. */); - post_command_idle_delay = 100000; - #if 0 DEFVAR_LISP ("echo-area-clear-hook", ..., doc: /* Normal hook run when clearing the echo area. */); diff --git a/src/mac.c b/src/mac.c index 14257fdee94..eaf4f029cf1 100644 --- a/src/mac.c +++ b/src/mac.c @@ -1672,37 +1672,7 @@ sys_fopen (const char *name, const char *mode) } -long target_ticks = 0; - -#ifdef __MRC__ -__sigfun alarm_signal_func = (__sigfun) 0; -#elif __MWERKS__ -__signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0; -#else /* not __MRC__ and not __MWERKS__ */ -You lose!!! -#endif /* not __MRC__ and not __MWERKS__ */ - - -/* These functions simulate SIG_ALRM. The stub for function signal - stores the signal handler function in alarm_signal_func if a - SIG_ALRM is encountered. check_alarm is called in XTread_socket, - which emacs calls periodically. A pending alarm is represented by - a non-zero target_ticks value. check_alarm calls the handler - function pointed to by alarm_signal_func if one has been set up and - an alarm is pending. */ - -void -check_alarm () -{ - if (target_ticks && TickCount () > target_ticks) - { - target_ticks = 0; - if (alarm_signal_func) - (*alarm_signal_func)(SIGALRM); - } -} - - +#include "keyboard.h" extern Boolean mac_wait_next_event (EventRecord *, UInt32, Boolean); int @@ -1713,25 +1683,17 @@ select (n, rfds, wfds, efds, timeout) SELECT_TYPE *efds; struct timeval *timeout; { -#if TARGET_API_MAC_CARBON OSErr err; +#if TARGET_API_MAC_CARBON EventTimeout timeout_sec = (timeout ? (EMACS_SECS (*timeout) * kEventDurationSecond + EMACS_USECS (*timeout) * kEventDurationMicrosecond) : kEventDurationForever); - if (FD_ISSET (0, rfds)) - { - BLOCK_INPUT; - err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL); - UNBLOCK_INPUT; - if (err == noErr) - return 1; - else - FD_ZERO (rfds); - } - return 0; + BLOCK_INPUT; + err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL); + UNBLOCK_INPUT; #else /* not TARGET_API_MAC_CARBON */ EventRecord e; UInt32 sleep_time = EMACS_SECS (*timeout) * 60 + @@ -1746,47 +1708,62 @@ select (n, rfds, wfds, efds, timeout) read_avail_input which in turn calls XTread_socket to poll for these events. Otherwise these never get processed except but a very slow poll timer. */ - if (FD_ISSET (0, rfds) && mac_wait_next_event (&e, sleep_time, false)) - return 1; - - return 0; + if (mac_wait_next_event (&e, sleep_time, false)) + err = noErr; + else + err = -9875; /* eventLoopTimedOutErr */ #endif /* not TARGET_API_MAC_CARBON */ -} - - -/* Called in sys_select to wait for an alarm signal to arrive. */ - -int -pause () -{ - EventRecord e; - unsigned long tick; - - if (!target_ticks) /* no alarm pending */ - return -1; - if ((tick = TickCount ()) < target_ticks) - WaitNextEvent (0, &e, target_ticks - tick, NULL); /* Accept no event; - just wait. by T.I. */ + if (FD_ISSET (0, rfds)) + if (err == noErr) + return 1; + else + { + FD_ZERO (rfds); + return 0; + } + else + if (err == noErr) + { + if (input_polling_used ()) + { + /* It could be confusing if a real alarm arrives while + processing the fake one. Turn it off and let the + handler reset it. */ + extern void poll_for_input_1 P_ ((void)); + int old_poll_suppress_count = poll_suppress_count; + poll_suppress_count = 1; + poll_for_input_1 (); + poll_suppress_count = old_poll_suppress_count; + } + errno = EINTR; + return -1; + } + else + return 0; +} - target_ticks = 0; - if (alarm_signal_func) - (*alarm_signal_func)(SIGALRM); - return 0; -} +/* Simulation of SIGALRM. The stub for function signal stores the + signal handler function in alarm_signal_func if a SIGALRM is + encountered. */ +#include <signal.h> +#include "syssignal.h" -int -alarm (int seconds) -{ - long remaining = target_ticks ? (TickCount () - target_ticks) / 60 : 0; +static TMTask mac_atimer_task; - target_ticks = seconds ? TickCount () + 60 * seconds : 0; +static QElemPtr mac_atimer_qlink = (QElemPtr) &mac_atimer_task; - return (remaining < 0) ? 0 : (unsigned int) remaining; -} +static int signal_mask = 0; +#ifdef __MRC__ +__sigfun alarm_signal_func = (__sigfun) 0; +#elif __MWERKS__ +__signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0; +#else /* not __MRC__ and not __MWERKS__ */ +You lose!!! +#endif /* not __MRC__ and not __MWERKS__ */ #undef signal #ifdef __MRC__ @@ -1819,6 +1796,128 @@ sys_signal (int signal_num, __signal_func_ptr signal_func) } +static pascal void +mac_atimer_handler (qlink) + TMTaskPtr qlink; +{ + if (alarm_signal_func) + (alarm_signal_func) (SIGALRM); +} + + +static void +set_mac_atimer (count) + long count; +{ + static TimerUPP mac_atimer_handlerUPP = NULL; + + if (mac_atimer_handlerUPP == NULL) + mac_atimer_handlerUPP = NewTimerUPP (mac_atimer_handler); + mac_atimer_task.tmCount = 0; + mac_atimer_task.tmAddr = mac_atimer_handlerUPP; + mac_atimer_qlink = (QElemPtr) &mac_atimer_task; + InsTime (mac_atimer_qlink); + if (count) + PrimeTime (mac_atimer_qlink, count); +} + + +int +remove_mac_atimer (remaining_count) + long *remaining_count; +{ + if (mac_atimer_qlink) + { + RmvTime (mac_atimer_qlink); + if (remaining_count) + *remaining_count = mac_atimer_task.tmCount; + mac_atimer_qlink = NULL; + + return 0; + } + else + return -1; +} + + +int +sigblock (int mask) +{ + int old_mask = signal_mask; + + signal_mask |= mask; + + if ((old_mask ^ signal_mask) & sigmask (SIGALRM)) + remove_mac_atimer (NULL); + + return old_mask; +} + + +int +sigsetmask (int mask) +{ + int old_mask = signal_mask; + + signal_mask = mask; + + if ((old_mask ^ signal_mask) & sigmask (SIGALRM)) + if (signal_mask & sigmask (SIGALRM)) + remove_mac_atimer (NULL); + else + set_mac_atimer (mac_atimer_task.tmCount); + + return old_mask; +} + + +int +alarm (int seconds) +{ + long remaining_count; + + if (remove_mac_atimer (&remaining_count) == 0) + { + set_mac_atimer (seconds * 1000); + + return remaining_count / 1000; + } + else + { + mac_atimer_task.tmCount = seconds * 1000; + + return 0; + } +} + + +int +setitimer (which, value, ovalue) + int which; + const struct itimerval *value; + struct itimerval *ovalue; +{ + long remaining_count; + long count = (EMACS_SECS (value->it_value) * 1000 + + (EMACS_USECS (value->it_value) + 999) / 1000); + + if (remove_mac_atimer (&remaining_count) == 0) + { + if (ovalue) + { + bzero (ovalue, sizeof (*ovalue)); + EMACS_SET_SECS_USECS (ovalue->it_value, remaining_count / 1000, + (remaining_count % 1000) * 1000); + } + set_mac_atimer (count); + } + else + mac_atimer_task.tmCount = count; + + return 0; +} + + /* gettimeofday should return the amount of time (in a timeval structure) since midnight today. The toolbox function Microseconds returns the number of microseconds (in a UnsignedWide value) since @@ -1946,35 +2045,6 @@ sys_time (time_t *timer) } -/* MPW strftime broken for "%p" format */ -#ifdef __MRC__ -#undef strftime -#include <time.h> -size_t -sys_strftime (char * s, size_t maxsize, const char * format, - const struct tm * timeptr) -{ - if (strcmp (format, "%p") == 0) - { - if (maxsize < 3) - return 0; - if (timeptr->tm_hour < 12) - { - strcpy (s, "AM"); - return 2; - } - else - { - strcpy (s, "PM"); - return 2; - } - } - else - return strftime (s, maxsize, format, timeptr); -} -#endif /* __MRC__ */ - - /* no subprocesses, empty wait */ int @@ -1993,13 +2063,6 @@ croak (char *badfunc) char * -index (const char * str, int chr) -{ - return strchr (str, chr); -} - - -char * mktemp (char *template) { int len, k; @@ -2187,20 +2250,6 @@ sys_subshell () } -int -sigsetmask (int x) -{ - return 0; -} - - -int -sigblock (int mask) -{ - return 0; -} - - void request_sigio (void) { diff --git a/src/macfns.c b/src/macfns.c index 75cd7e76576..8ec05b59e19 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -22,7 +22,6 @@ Boston, MA 02111-1307, USA. */ #include <config.h> -#include <signal.h> #include <stdio.h> #include <math.h> #include <limits.h> diff --git a/src/macmenu.c b/src/macmenu.c index 35615cc3796..eb870176f12 100644 --- a/src/macmenu.c +++ b/src/macmenu.c @@ -21,7 +21,6 @@ Boston, MA 02111-1307, USA. */ /* Contributed by Andrew Choi (akochoi@mac.com). */ #include <config.h> -#include <signal.h> #include <stdio.h> #include "lisp.h" diff --git a/src/macselect.c b/src/macselect.c index a115c9b3229..890bb62d1d4 100644 --- a/src/macselect.c +++ b/src/macselect.c @@ -1104,9 +1104,11 @@ next communication only. After the communication, this variable is set to nil. */); Vnext_selection_coding_system = Qnil; +#ifdef MAC_OSX DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, doc: /* Selection name for communication via Services menu. */); - Vmac_services_selection = intern ("CLIPBOARD"); + Vmac_services_selection = intern ("PRIMARY"); +#endif QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY); diff --git a/src/macterm.c b/src/macterm.c index b988fb25c31..fe80b779cf3 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -3277,11 +3277,9 @@ x_clear_frame () BLOCK_INPUT; XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f)); -#if 0 /* Clearing frame on Mac OS clears scroll bars. */ /* We have to clear the scroll bars, too. If we have changed colors or something like that, then they should be notified. */ x_scroll_bar_clear (f); -#endif XFlush (FRAME_MAC_DISPLAY (f)); UNBLOCK_INPUT; @@ -4141,12 +4139,12 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *)); static OSStatus install_scroll_bar_timer P_ ((void)); static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); -static int control_part_code_to_scroll_bar_part P_((ControlPartCode)); +static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, unsigned long, struct input_event *)); -static OSErr get_control_part_bound P_((ControlHandle, ControlPartCode, - Rect *)); +static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode, + Rect *)); static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, ControlPartCode, unsigned long, @@ -4273,7 +4271,7 @@ construct_scroll_bar_click (bar, part, timestamp, bufp) } static OSErr -get_control_part_bound (ch, part_code, rect) +get_control_part_bounds (ch, part_code, rect) ControlHandle ch; ControlPartCode part_code; Rect *rect; @@ -4346,8 +4344,8 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp) int top, top_range; Rect r; - get_control_part_bound (SCROLL_BAR_CONTROL_HANDLE (bar), - kControlIndicatorPart, &r); + get_control_part_bounds (SCROLL_BAR_CONTROL_HANDLE (bar), + kControlIndicatorPart, &r); if (GC_NILP (bar->dragging)) XSETINT (bar->dragging, mouse_pos.v - r.top); @@ -4675,13 +4673,11 @@ XTset_vertical_scroll_bar (w, portion, whole, position) BLOCK_INPUT; /* If already correctly positioned, do nothing. */ - if (XINT (bar->left) == sb_left - && XINT (bar->top) == top - && XINT (bar->width) == sb_width - && XINT (bar->height) == height) - Draw1Control (ch); - else - { + if (!(XINT (bar->left) == sb_left + && XINT (bar->top) == top + && XINT (bar->width) == sb_width + && XINT (bar->height) == height)) + { /* Clear areas not covered by the scroll bar because it's not as wide as the area reserved for it . This makes sure a previous mode line display is cleared after C-x 2 C-x 1, for @@ -4730,11 +4726,11 @@ XTset_vertical_scroll_bar (w, portion, whole, position) /* Move the scroll bar thumb to the top. */ SetControl32BitValue (ch, 0); - get_control_part_bound (ch, kControlIndicatorPart, &r0); + get_control_part_bounds (ch, kControlIndicatorPart, &r0); /* Move the scroll bar thumb to the bottom. */ SetControl32BitValue (ch, 1); - get_control_part_bound (ch, kControlIndicatorPart, &r1); + get_control_part_bounds (ch, kControlIndicatorPart, &r1); UnionRect (&r0, &r1, &r0); XSETINT (bar->track_top, r0.top); @@ -4882,7 +4878,7 @@ XTjudge_scroll_bars (f) static void x_scroll_bar_handle_click (bar, part_code, er, bufp) struct scroll_bar *bar; - int part_code; + ControlPartCode part_code; EventRecord *er; struct input_event *bufp; { @@ -5040,6 +5036,21 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) *time = last_mouse_movement_time; } + + +/* The screen has been cleared so we may have changed foreground or + background colors, and the scroll bars may need to be redrawn. + Clear out the scroll bars, and ask for expose events, so we can + redraw them. */ + +void +x_scroll_bar_clear (f) + FRAME_PTR f; +{ + XTcondemn_scroll_bars (f); + XTjudge_scroll_bars (f); +} + /*********************************************************************** Text Cursor @@ -7516,7 +7527,6 @@ OSErr install_window_handler (WindowPtr); extern void init_emacs_passwd_dir (); extern int emacs_main (int, char **, char **); -extern void check_alarm (); extern void initialize_applescript(); extern void terminate_applescript(); @@ -8668,23 +8678,18 @@ profiler_exit_proc () #endif /* These few functions implement Emacs as a normal Mac application - (almost): set up the heap and the Toolbox, handle necessary - system events plus a few simple menu events. They also set up - Emacs's access to functions defined in the rest of this file. - Emacs uses function hooks to perform all its terminal I/O. A - complete list of these functions appear in termhooks.h. For what - they do, read the comments there and see also w32term.c and - xterm.c. What's noticeably missing here is the event loop, which - is normally present in most Mac application. After performing the - necessary Mac initializations, main passes off control to - emacs_main (corresponding to main in emacs.c). Emacs_main calls - mac_read_socket (defined further below) to read input. This is - where WaitNextEvent is called to process Mac events. This is also - where check_alarm in sysdep.c is called to simulate alarm signals. - This makes the cursor jump back to its correct position after - briefly jumping to that of the matching parenthesis, print useful - hints and prompts in the minibuffer after the user stops typing for - a wait, etc. */ + (almost): set up the heap and the Toolbox, handle necessary system + events plus a few simple menu events. They also set up Emacs's + access to functions defined in the rest of this file. Emacs uses + function hooks to perform all its terminal I/O. A complete list of + these functions appear in termhooks.h. For what they do, read the + comments there and see also w32term.c and xterm.c. What's + noticeably missing here is the event loop, which is normally + present in most Mac application. After performing the necessary + Mac initializations, main passes off control to emacs_main + (corresponding to main in emacs.c). Emacs_main calls XTread_socket + (defined further below) to read input. This is where + WaitNextEvent/ReceiveNextEvent is called to process Mac events. */ #ifdef MAC_OS8 #undef main @@ -8947,7 +8952,7 @@ XTread_socket (sd, expected, hold_quit) case mouseUp: { WindowPtr window_ptr; - SInt16 part_code; + ControlPartCode part_code; int tool_bar_p = 0; #if USE_CARBON_EVENTS @@ -8991,7 +8996,7 @@ XTread_socket (sd, expected, hold_quit) SelectWindow (window_ptr); else { - SInt16 control_part_code; + ControlPartCode control_part_code; ControlHandle ch; Point mouse_loc = er.where; #ifdef MAC_OSX @@ -9566,10 +9571,6 @@ XTread_socket (sd, expected, hold_quit) pending_autoraise_frame = 0; } -#if !TARGET_API_MAC_CARBON - check_alarm (); /* simulate the handling of a SIGALRM */ -#endif - UNBLOCK_INPUT; return count; } diff --git a/src/process.c b/src/process.c index 26d40c26cd5..84d373ff37b 100644 --- a/src/process.c +++ b/src/process.c @@ -5113,6 +5113,7 @@ send_process_trap () sigrelse (SIGPIPE); sigrelse (SIGALRM); #endif /* BSD4_1 */ + sigunblock (sigmask (SIGPIPE)); longjmp (send_process_frame, 1); } @@ -5297,7 +5298,11 @@ send_process (proc, buf, len, object) 0, datagram_address[outfd].sa, datagram_address[outfd].len); if (rv < 0 && errno == EMSGSIZE) - report_file_error ("sending datagram", Fcons (proc, Qnil)); + { + signal (SIGPIPE, old_sigpipe); + report_file_error ("sending datagram", + Fcons (proc, Qnil)); + } } else #endif diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 1f2b4c96620..e54dbea448c 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -1,5 +1,5 @@ /* Dump Emacs in Mach-O format for use on Mac OS X. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -105,6 +105,8 @@ Boston, MA 02111-1307, USA. */ #include <objc/malloc.h> #endif +#include <assert.h> + #define VERBOSE 1 @@ -998,6 +1000,23 @@ unexec_init_emacs_zone () malloc_set_zone_name (emacs_zone, "EmacsZone"); } +#ifndef MACOSX_MALLOC_MULT16 +#define MACOSX_MALLOC_MULT16 1 +#endif + +typedef struct unexec_malloc_header { + union { + char c[8]; + size_t size; + } u; +} unexec_malloc_header_t; + +#if MACOSX_MALLOC_MULT16 + +#define ptr_in_unexec_regions(p) ((((vm_address_t) (p)) & 8) != 0) + +#else + int ptr_in_unexec_regions (void *ptr) { @@ -1011,36 +1030,75 @@ ptr_in_unexec_regions (void *ptr) return 0; } +#endif + void * unexec_malloc (size_t size) { if (in_dumped_exec) - return malloc (size); + { + void *p; + + p = malloc (size); +#if MACOSX_MALLOC_MULT16 + assert (((vm_address_t) p % 16) == 0); +#endif + return p; + } else - return malloc_zone_malloc (emacs_zone, size); + { + unexec_malloc_header_t *ptr; + + ptr = (unexec_malloc_header_t *) + malloc_zone_malloc (emacs_zone, size + sizeof (unexec_malloc_header_t)); + ptr->u.size = size; + ptr++; +#if MACOSX_MALLOC_MULT16 + assert (((vm_address_t) ptr % 16) == 8); +#endif + return (void *) ptr; + } } void * unexec_realloc (void *old_ptr, size_t new_size) { if (in_dumped_exec) - if (ptr_in_unexec_regions (old_ptr)) - { - char *p = malloc (new_size); - /* 2002-04-15 T. Ikegami <ikegami@adam.uprr.pr>. The original - code to get size failed to reallocate read_buffer - (lread.c). */ - int old_size = malloc_default_zone()->size (emacs_zone, old_ptr); - int size = new_size > old_size ? old_size : new_size; - - if (size) - memcpy (p, old_ptr, size); - return p; - } - else - return realloc (old_ptr, new_size); + { + void *p; + + if (ptr_in_unexec_regions (old_ptr)) + { + size_t old_size = ((unexec_malloc_header_t *) old_ptr)[-1].u.size; + size_t size = new_size > old_size ? old_size : new_size; + + p = (size_t *) malloc (new_size); + if (size) + memcpy (p, old_ptr, size); + } + else + { + p = realloc (old_ptr, new_size); + } +#if MACOSX_MALLOC_MULT16 + assert (((vm_address_t) p % 16) == 0); +#endif + return p; + } else - return malloc_zone_realloc (emacs_zone, old_ptr, new_size); + { + unexec_malloc_header_t *ptr; + + ptr = (unexec_malloc_header_t *) + malloc_zone_realloc (emacs_zone, (unexec_malloc_header_t *) old_ptr - 1, + new_size + sizeof (unexec_malloc_header_t)); + ptr->u.size = new_size; + ptr++; +#if MACOSX_MALLOC_MULT16 + assert (((vm_address_t) ptr % 16) == 8); +#endif + return (void *) ptr; + } } void @@ -1052,7 +1110,7 @@ unexec_free (void *ptr) free (ptr); } else - malloc_zone_free (emacs_zone, ptr); + malloc_zone_free (emacs_zone, (unexec_malloc_header_t *) ptr - 1); } /* arch-tag: 1a784f7b-a184-4c4f-9544-da8619593d72 diff --git a/src/xdisp.c b/src/xdisp.c index 23898e78774..2284c34d3bd 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3474,7 +3474,10 @@ handle_display_prop (it) } else { - if (handle_single_display_spec (it, prop, object, position, 0)) + int ret = handle_single_display_spec (it, prop, object, position, 0); + if (ret < 0) /* Replaced by "", i.e. nothing. */ + return HANDLED_RECOMPUTE_PROPS; + if (ret) display_replaced_p = 1; } @@ -3518,7 +3521,8 @@ display_prop_end (it, object, start_pos) property ends. Value is non-zero if something was found which replaces the display - of buffer or string text. */ + of buffer or string text. Specifically, the value is -1 if that + "something" is "nothing". */ static int handle_single_display_spec (it, spec, object, position, @@ -3833,6 +3837,11 @@ handle_single_display_spec (it, spec, object, position, if (STRINGP (value)) { + if (SCHARS (value) == 0) + { + pop_it (it); + return -1; /* Replaced by "", i.e. nothing. */ + } it->string = value; it->multibyte_p = STRING_MULTIBYTE (it->string); it->current.overlay_string_index = -1; @@ -7033,7 +7042,9 @@ message2_nolog (m, nbytes, multibyte) /* Display an echo area message M with a specified length of NBYTES bytes. The string may include null characters. If M is not a string, clear out any existing message, and let the mini-buffer - text show through. */ + text show through. + + This function cancels echoing. */ void message3 (m, nbytes, multibyte) @@ -7045,6 +7056,7 @@ message3 (m, nbytes, multibyte) GCPRO1 (m); clear_message (1,1); + cancel_echoing (); /* First flush out any partial line written with print. */ message_log_maybe_newline (); @@ -7056,7 +7068,10 @@ message3 (m, nbytes, multibyte) } -/* The non-logging version of message3. */ +/* The non-logging version of message3. + This does not cancel echoing, because it is used for echoing. + Perhaps we need to make a separate function for echoing + and make this cancel echoing. */ void message3_nolog (m, nbytes, multibyte) |