From b564370b908bc181fabd9c02b0ba9d9875560a3d Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Fri, 4 Mar 2005 11:08:05 +0000 Subject: [PATCH] [!MAC_OSX && HAVE_CARBON]: Include Carbon.h. [!MAC_OSX] (select) [TARGET_API_MAC_CARBON]: Use ReceiveNextEvent. (posix_pathname_to_fsspec, fsspec_to_posix_pathname): New functions. (mac_clear_font_name_table): Move extern to macterm.h. --- src/mac.c | 98 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 22 deletions(-) diff --git a/src/mac.c b/src/mac.c index cce1b858cb3..44d763562b0 100644 --- a/src/mac.c +++ b/src/mac.c @@ -25,20 +25,8 @@ Boston, MA 02111-1307, USA. */ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if __MWERKS__ -#include -#endif +#ifdef HAVE_CARBON #ifdef MAC_OSX #undef mktime #undef DEBUG @@ -57,7 +45,12 @@ Boston, MA 02111-1307, USA. */ #define realloc unexec_realloc #undef init_process #define init_process emacs_init_process -#else /* not MAC_OSX */ +#else /* not MAC_OSX */ +#undef SIGHUP +#define OLDP2C 1 +#include +#endif /* not MAC_OSX */ +#else /* not HAVE_CARBON */ #include #include #include @@ -69,7 +62,24 @@ Boston, MA 02111-1307, USA. */ #include #include #include -#endif /* not MAC_OSX */ +#include +#include +#include +#endif /* not HAVE_CARBON */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if __MWERKS__ +#include +#endif #include "lisp.h" #include "process.h" @@ -812,8 +822,6 @@ sys_fopen (const char *name, const char *mode) } -#include - long target_ticks = 0; #ifdef __MRC__ @@ -856,7 +864,24 @@ select (n, rfds, wfds, efds, timeout) struct timeval *timeout; { #if TARGET_API_MAC_CARBON - return 1; + OSErr err; + 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; #else /* not TARGET_API_MAC_CARBON */ EventRecord e; UInt32 sleep_time = EMACS_SECS (*timeout) * 60 + @@ -1421,6 +1446,39 @@ path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, return 1; /* success */ } + +OSErr +posix_pathname_to_fsspec (ufn, fs) + const char *ufn; + FSSpec *fs; +{ + Str255 mac_pathname; + + if (posix_to_mac_pathname (ufn, mac_pathname, sizeof (mac_pathname)) == 0) + return fnfErr; + else + { + c2pstr (mac_pathname); + return FSMakeFSSpec (0, 0, mac_pathname, fs); + } +} + +OSErr +fsspec_to_posix_pathname (fs, ufn, ufnbuflen) + const FSSpec *fs; + char *ufn; + int ufnbuflen; +{ + char mac_pathname[MAXPATHLEN]; + + if (path_from_vol_dir_name (mac_pathname, sizeof (mac_pathname) - 1, + fs->vRefNum, fs->parID, fs->name) + && mac_to_posix_pathname (mac_pathname, ufn, ufnbuflen)) + return noErr; + else + return fnfErr; +} + #ifndef MAC_OSX int @@ -1899,9 +1957,6 @@ uname (struct utsname *name) } -#include -#include - /* Event class of HLE sent to subprocess. */ const OSType kEmacsSubprocessSend = 'ESND'; @@ -2770,7 +2825,6 @@ and t is the same as `SECONDARY'. */) return Qnil; } -extern void mac_clear_font_name_table P_ ((void)); DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0, doc: /* Clear the font name table. */) -- 2.39.2