diff options
| author | Andrew Choi | 2000-10-22 16:50:16 +0000 |
|---|---|---|
| committer | Andrew Choi | 2000-10-22 16:50:16 +0000 |
| commit | 1a578e9be2034298bb8ac29b7b84086a4ab290f4 (patch) | |
| tree | 52e921cd58e9ac6688757ff1b1d0531c9820475f /src | |
| parent | d371949a0f0d152bcc9013b7bbd15418465a1792 (diff) | |
| download | emacs-1a578e9be2034298bb8ac29b7b84086a4ab290f4.tar.gz emacs-1a578e9be2034298bb8ac29b7b84086a4ab290f4.zip | |
Initial check-in: changes for building Emacs under Mac OS.
2000-10-23 Andrew Choi <akochoi@i-cable.com>
* dispextern.h [macintosh]: Include macgui.h instead of macterm.h.
* dispnew.c [macintosh]: Include macterm.h.
(init_display) [macintosh]: initialization for window system.
* emacs.c (main) [macintosh]: Call syms_of_textprop,
syms_of_macfns, syms_of_ccl, syms_of_fontset, syms_of_xterm,
syms_of_search, x_term_init, and init_keyboard before calling
init_window_once. Also, call syms_of_xmenu.
* fontset.c (syms_of_fontset) [macintosh]: Set ASCII font of
default fontset to Monaco.
* frame.c [macintosh]: Include macterm.h. Remove declarations of
NewMacWindow and DisposeMacWindow.
(make_terminal_frame) [macintosh]: Call make_mac_terminal_frame
instead of calling NewMacWindow and setting fields of
f->output_data.mac directly. Call init_frame_faces.
(Fdelete_frame) [macintosh]: Remove unused code.
(Fmodify_frame_parameters) [macintosh]: Call
x_set_frame_parameters instead of mac_set_frame_parameters.
* frame.h [macintosh]: Define menu_bar_lines field in struct
frame. Define FRAME_EXTERNAL_MENU_BAR macro.
* keyboard.c [macintosh]: Include macterm.h.
(kbd_buffer_get_event) [macintosh]: Generate delete_window_event
and menu_bar_activate_event type events as for X and NT.
(make_lispy_event) [macintosh]: Construct lisp events of type
MENU_BAR_EVENT as for X and NT.
* sysdep.c [macintosh]: Remove declaration for sys_signal.
Include stdlib.h. Remove definition of Vx_bitmap_file_path.
(sys_subshell) [macintosh]: Remove definition entirely.
(init_sys_modes) [macintosh]: Do not initialize Vwindow_system and
Vwindow_system_version here. Remove initialization of
Vx_bitmap_file_path.
(read_input_waiting): Correct the number of parameters passed to
read_socket_hook.
Move all Macintosh functions to mac/mac.c.
* term.c [macintosh]: Include macterm.h.
* window.c [macintosh]: Include macterm.h.
* xdisp.c [macintosh]: Include macterm.h. Declare
set_frame_menubar and pending_menu_activation.
(echo_area_display) [macintosh]: Do not return if terminal frame
is the selected frame.
(update_menu_bar) [macintosh]: Check FRAME_EXTERNAL_MENU_BAR (f).
Allow only the selected frame to set menu bar.
(redisplay_window) [macintosh]: Obtain menu bar to redisplay by
calling FRAME_EXTERNAL_MENU_BAR (f).
(display_menu_bar) [macintosh]: Check FRAME_MAC_P (f).
* xfaces.c [macintosh]: Include macterm.h. Define x_display_info
and check_x. Declare XCreateGC. Define x_create_gc and
x_free_gc. Initialize font_sort_order.
(x_face_list_fonts) [macintosh]: Use the same code as WINDOWSNT,
but call x_list_fonts instead of w32_list_fonts.
(Finternal_face_x_get_resource) [macintosh]: Do not call
display_x_get_resource.
(prepare_face_for_display) [macintosh]: Set xgcv.font.
(realize_x_face) [macintosh]: Load the font if it is specified in
ATTRS.
(syms_of_xfaces) [macintosh]: Initialize Vscalable_fonts_allowed
to Qt.
* cus-edit.el (custom-button-face): Use 3D look for mac.
(custom-button-pressed-face): Likewise.
* faces.el (set-face-attributes-from-resources): Handle mac frames
in the same way as x and w32 frames.
(face-valid-attribute-values): Likewise.
(read-face-attribute): Likewise.
(defined-colors): Likewise.
(color-defined-p): Likewise.
(color-values): Likewise.
(display-grayscale-p): Likewise.
(face-set-after-frame-default): Likewise.
(mode-line): Same default face as for x and w32.
(tool-bar): Likewise.
* frame.el: Remove call to frame-notice-user-settings at end of
the file.
* info.el (Info-fontify-node): make underlines invisible for mac
as for x, pc, and w32 frame types.
* term/mac-win.el: New file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 70 | ||||
| -rw-r--r-- | src/dispextern.h | 2 | ||||
| -rw-r--r-- | src/dispnew.c | 14 | ||||
| -rw-r--r-- | src/emacs.c | 37 | ||||
| -rw-r--r-- | src/fontset.c | 6 | ||||
| -rw-r--r-- | src/frame.c | 39 | ||||
| -rw-r--r-- | src/frame.h | 4 | ||||
| -rw-r--r-- | src/keyboard.c | 14 | ||||
| -rw-r--r-- | src/sysdep.c | 1574 | ||||
| -rw-r--r-- | src/term.c | 3 | ||||
| -rw-r--r-- | src/window.c | 3 | ||||
| -rw-r--r-- | src/xdisp.c | 28 | ||||
| -rw-r--r-- | src/xfaces.c | 60 |
13 files changed, 238 insertions, 1616 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index eaedd49679f..04736e027bf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,73 @@ | |||
| 1 | 2000-10-23 Andrew Choi <akochoi@i-cable.com> | ||
| 2 | |||
| 3 | * dispextern.h [macintosh]: Include macgui.h instead of macterm.h. | ||
| 4 | |||
| 5 | * dispnew.c [macintosh]: Include macterm.h. | ||
| 6 | (init_display) [macintosh]: initialization for window system. | ||
| 7 | |||
| 8 | * emacs.c (main) [macintosh]: Call syms_of_textprop, | ||
| 9 | syms_of_macfns, syms_of_ccl, syms_of_fontset, syms_of_xterm, | ||
| 10 | syms_of_search, x_term_init, and init_keyboard before calling | ||
| 11 | init_window_once. Also, call syms_of_xmenu. | ||
| 12 | |||
| 13 | * fontset.c (syms_of_fontset) [macintosh]: Set ASCII font of | ||
| 14 | default fontset to Monaco. | ||
| 15 | |||
| 16 | * frame.c [macintosh]: Include macterm.h. Remove declarations of | ||
| 17 | NewMacWindow and DisposeMacWindow. | ||
| 18 | (make_terminal_frame) [macintosh]: Call make_mac_terminal_frame | ||
| 19 | instead of calling NewMacWindow and setting fields of | ||
| 20 | f->output_data.mac directly. Call init_frame_faces. | ||
| 21 | (Fdelete_frame) [macintosh]: Remove unused code. | ||
| 22 | (Fmodify_frame_parameters) [macintosh]: Call | ||
| 23 | x_set_frame_parameters instead of mac_set_frame_parameters. | ||
| 24 | |||
| 25 | * frame.h [macintosh]: Define menu_bar_lines field in struct | ||
| 26 | frame. Define FRAME_EXTERNAL_MENU_BAR macro. | ||
| 27 | |||
| 28 | * keyboard.c [macintosh]: Include macterm.h. | ||
| 29 | (kbd_buffer_get_event) [macintosh]: Generate delete_window_event | ||
| 30 | and menu_bar_activate_event type events as for X and NT. | ||
| 31 | (make_lispy_event) [macintosh]: Construct lisp events of type | ||
| 32 | MENU_BAR_EVENT as for X and NT. | ||
| 33 | |||
| 34 | * sysdep.c [macintosh]: Remove declaration for sys_signal. | ||
| 35 | Include stdlib.h. Remove definition of Vx_bitmap_file_path. | ||
| 36 | (sys_subshell) [macintosh]: Remove definition entirely. | ||
| 37 | (init_sys_modes) [macintosh]: Do not initialize Vwindow_system and | ||
| 38 | Vwindow_system_version here. Remove initialization of | ||
| 39 | Vx_bitmap_file_path. | ||
| 40 | (read_input_waiting): Correct the number of parameters passed to | ||
| 41 | read_socket_hook. | ||
| 42 | Move all Macintosh functions to mac/mac.c. | ||
| 43 | |||
| 44 | * term.c [macintosh]: Include macterm.h. | ||
| 45 | |||
| 46 | * window.c [macintosh]: Include macterm.h. | ||
| 47 | |||
| 48 | * xdisp.c [macintosh]: Include macterm.h. Declare | ||
| 49 | set_frame_menubar and pending_menu_activation. | ||
| 50 | (echo_area_display) [macintosh]: Do not return if terminal frame | ||
| 51 | is the selected frame. | ||
| 52 | (update_menu_bar) [macintosh]: Check FRAME_EXTERNAL_MENU_BAR (f). | ||
| 53 | Allow only the selected frame to set menu bar. | ||
| 54 | (redisplay_window) [macintosh]: Obtain menu bar to redisplay by | ||
| 55 | calling FRAME_EXTERNAL_MENU_BAR (f). | ||
| 56 | (display_menu_bar) [macintosh]: Check FRAME_MAC_P (f). | ||
| 57 | |||
| 58 | * xfaces.c [macintosh]: Include macterm.h. Define x_display_info | ||
| 59 | and check_x. Declare XCreateGC. Define x_create_gc and | ||
| 60 | x_free_gc. Initialize font_sort_order. | ||
| 61 | (x_face_list_fonts) [macintosh]: Use the same code as WINDOWSNT, | ||
| 62 | but call x_list_fonts instead of w32_list_fonts. | ||
| 63 | (Finternal_face_x_get_resource) [macintosh]: Do not call | ||
| 64 | display_x_get_resource. | ||
| 65 | (prepare_face_for_display) [macintosh]: Set xgcv.font. | ||
| 66 | (realize_x_face) [macintosh]: Load the font if it is specified in | ||
| 67 | ATTRS. | ||
| 68 | (syms_of_xfaces) [macintosh]: Initialize Vscalable_fonts_allowed | ||
| 69 | to Qt. | ||
| 70 | |||
| 1 | 2000-10-22 Stefan Monnier <monnier@cs.yale.edu> | 71 | 2000-10-22 Stefan Monnier <monnier@cs.yale.edu> |
| 2 | 72 | ||
| 3 | * keymap.c (fix_submap_inheritance): Don't do anything if parent_entry | 73 | * keymap.c (fix_submap_inheritance): Don't do anything if parent_entry |
diff --git a/src/dispextern.h b/src/dispextern.h index 795387b9978..15ff0227dba 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -40,7 +40,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | #ifdef macintosh | 42 | #ifdef macintosh |
| 43 | #include "macterm.h" | 43 | #include "macgui.h" |
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | /* Structure forward declarations. Some are here because function | 46 | /* Structure forward declarations. Some are here because function |
diff --git a/src/dispnew.c b/src/dispnew.c index be01f6756e2..14e4d968760 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -60,6 +60,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 60 | #include "w32term.h" | 60 | #include "w32term.h" |
| 61 | #endif /* HAVE_NTGUI */ | 61 | #endif /* HAVE_NTGUI */ |
| 62 | 62 | ||
| 63 | #ifdef macintosh | ||
| 64 | #include "macterm.h" | ||
| 65 | #endif /* macintosh */ | ||
| 66 | |||
| 63 | /* Include systime.h after xterm.h to avoid double inclusion of time.h. */ | 67 | /* Include systime.h after xterm.h to avoid double inclusion of time.h. */ |
| 64 | 68 | ||
| 65 | #include "systime.h" | 69 | #include "systime.h" |
| @@ -6087,6 +6091,16 @@ init_display () | |||
| 6087 | } | 6091 | } |
| 6088 | #endif /* HAVE_NTGUI */ | 6092 | #endif /* HAVE_NTGUI */ |
| 6089 | 6093 | ||
| 6094 | #ifdef macintosh | ||
| 6095 | if (!inhibit_window_system) | ||
| 6096 | { | ||
| 6097 | Vwindow_system = intern ("mac"); | ||
| 6098 | Vwindow_system_version = make_number (1); | ||
| 6099 | adjust_frame_glyphs_initially (); | ||
| 6100 | return; | ||
| 6101 | } | ||
| 6102 | #endif /* macintosh */ | ||
| 6103 | |||
| 6090 | /* If no window system has been specified, try to use the terminal. */ | 6104 | /* If no window system has been specified, try to use the terminal. */ |
| 6091 | if (! isatty (0)) | 6105 | if (! isatty (0)) |
| 6092 | { | 6106 | { |
diff --git a/src/emacs.c b/src/emacs.c index 9c2645f361f..92f70206d72 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1110,6 +1110,25 @@ main (argc, argv, envp) | |||
| 1110 | CANNOT_DUMP is defined. */ | 1110 | CANNOT_DUMP is defined. */ |
| 1111 | syms_of_keyboard (); | 1111 | syms_of_keyboard (); |
| 1112 | 1112 | ||
| 1113 | #ifdef macintosh | ||
| 1114 | /* init_window_once calls make_terminal_frame which on Mac OS creates | ||
| 1115 | a full-fledge output_mac type frame. This does not work correctly | ||
| 1116 | before syms_of_textprop, syms_of_macfns, syms_of_ccl, | ||
| 1117 | syms_of_fontset, syms_of_xterm, syms_of_search, x_term_init, and | ||
| 1118 | init_keyboard have already been called. */ | ||
| 1119 | syms_of_textprop (); | ||
| 1120 | syms_of_macfns (); | ||
| 1121 | syms_of_ccl (); | ||
| 1122 | syms_of_fontset (); | ||
| 1123 | syms_of_macterm (); | ||
| 1124 | syms_of_macmenu (); | ||
| 1125 | syms_of_data (); | ||
| 1126 | syms_of_search (); | ||
| 1127 | |||
| 1128 | x_term_init (); | ||
| 1129 | init_keyboard (); | ||
| 1130 | #endif | ||
| 1131 | |||
| 1113 | init_window_once (); /* Init the window system */ | 1132 | init_window_once (); /* Init the window system */ |
| 1114 | init_fileio_once (); /* Must precede any path manipulation. */ | 1133 | init_fileio_once (); /* Must precede any path manipulation. */ |
| 1115 | } | 1134 | } |
| @@ -1306,7 +1325,10 @@ main (argc, argv, envp) | |||
| 1306 | /* The basic levels of Lisp must come first */ | 1325 | /* The basic levels of Lisp must come first */ |
| 1307 | /* And data must come first of all | 1326 | /* And data must come first of all |
| 1308 | for the sake of symbols like error-message */ | 1327 | for the sake of symbols like error-message */ |
| 1328 | #ifndef macintosh | ||
| 1329 | /* Called before init_window_once for Mac OS. */ | ||
| 1309 | syms_of_data (); | 1330 | syms_of_data (); |
| 1331 | #endif | ||
| 1310 | syms_of_alloc (); | 1332 | syms_of_alloc (); |
| 1311 | syms_of_lread (); | 1333 | syms_of_lread (); |
| 1312 | syms_of_print (); | 1334 | syms_of_print (); |
| @@ -1322,7 +1344,10 @@ main (argc, argv, envp) | |||
| 1322 | syms_of_casetab (); | 1344 | syms_of_casetab (); |
| 1323 | syms_of_callproc (); | 1345 | syms_of_callproc (); |
| 1324 | syms_of_category (); | 1346 | syms_of_category (); |
| 1347 | #ifndef macintosh | ||
| 1348 | /* Called before init_window_once for Mac OS. */ | ||
| 1325 | syms_of_ccl (); | 1349 | syms_of_ccl (); |
| 1350 | #endif | ||
| 1326 | syms_of_charset (); | 1351 | syms_of_charset (); |
| 1327 | syms_of_cmds (); | 1352 | syms_of_cmds (); |
| 1328 | #ifndef NO_DIR_LIBRARY | 1353 | #ifndef NO_DIR_LIBRARY |
| @@ -1345,7 +1370,10 @@ main (argc, argv, envp) | |||
| 1345 | syms_of_minibuf (); | 1370 | syms_of_minibuf (); |
| 1346 | syms_of_mocklisp (); | 1371 | syms_of_mocklisp (); |
| 1347 | syms_of_process (); | 1372 | syms_of_process (); |
| 1373 | #ifndef macintosh | ||
| 1374 | /* Called before init_window_once for Mac OS. */ | ||
| 1348 | syms_of_search (); | 1375 | syms_of_search (); |
| 1376 | #endif | ||
| 1349 | syms_of_frame (); | 1377 | syms_of_frame (); |
| 1350 | syms_of_syntax (); | 1378 | syms_of_syntax (); |
| 1351 | syms_of_term (); | 1379 | syms_of_term (); |
| @@ -1353,8 +1381,10 @@ main (argc, argv, envp) | |||
| 1353 | #ifdef HAVE_SOUND | 1381 | #ifdef HAVE_SOUND |
| 1354 | syms_of_sound (); | 1382 | syms_of_sound (); |
| 1355 | #endif | 1383 | #endif |
| 1356 | 1384 | #ifndef macintosh | |
| 1385 | /* Called before init_window_once for Mac OS. */ | ||
| 1357 | syms_of_textprop (); | 1386 | syms_of_textprop (); |
| 1387 | #endif | ||
| 1358 | syms_of_composite (); | 1388 | syms_of_composite (); |
| 1359 | #ifdef VMS | 1389 | #ifdef VMS |
| 1360 | syms_of_vmsproc (); | 1390 | syms_of_vmsproc (); |
| @@ -1374,8 +1404,10 @@ main (argc, argv, envp) | |||
| 1374 | #endif /* HAVE_X_WINDOWS */ | 1404 | #endif /* HAVE_X_WINDOWS */ |
| 1375 | 1405 | ||
| 1376 | #ifndef HAVE_NTGUI | 1406 | #ifndef HAVE_NTGUI |
| 1407 | #ifndef macintosh | ||
| 1377 | syms_of_xmenu (); | 1408 | syms_of_xmenu (); |
| 1378 | #endif | 1409 | #endif |
| 1410 | #endif | ||
| 1379 | 1411 | ||
| 1380 | #ifdef HAVE_NTGUI | 1412 | #ifdef HAVE_NTGUI |
| 1381 | syms_of_w32term (); | 1413 | syms_of_w32term (); |
| @@ -1411,7 +1443,10 @@ main (argc, argv, envp) | |||
| 1411 | #endif /* VMS */ | 1443 | #endif /* VMS */ |
| 1412 | init_display (); /* Determine terminal type. init_sys_modes uses results */ | 1444 | init_display (); /* Determine terminal type. init_sys_modes uses results */ |
| 1413 | } | 1445 | } |
| 1446 | #ifndef macintosh | ||
| 1447 | /* Called before init_window_once for Mac OS. */ | ||
| 1414 | init_keyboard (); /* This too must precede init_sys_modes */ | 1448 | init_keyboard (); /* This too must precede init_sys_modes */ |
| 1449 | #endif | ||
| 1415 | #ifdef VMS | 1450 | #ifdef VMS |
| 1416 | init_vmsproc (); /* And this too. */ | 1451 | init_vmsproc (); /* And this too. */ |
| 1417 | #endif /* VMS */ | 1452 | #endif /* VMS */ |
diff --git a/src/fontset.c b/src/fontset.c index 7b8f5ce73c9..56f782a2638 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -1397,9 +1397,15 @@ syms_of_fontset () | |||
| 1397 | FONTSET_ID (Vdefault_fontset) = make_number (0); | 1397 | FONTSET_ID (Vdefault_fontset) = make_number (0); |
| 1398 | FONTSET_NAME (Vdefault_fontset) | 1398 | FONTSET_NAME (Vdefault_fontset) |
| 1399 | = build_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"); | 1399 | = build_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"); |
| 1400 | #ifdef macintosh | ||
| 1401 | FONTSET_ASCII (Vdefault_fontset) | ||
| 1402 | = Fcons (make_number (0), | ||
| 1403 | build_string ("-apple-monaco-medium-r-*--*-120-*-*-*-*-mac-roman")); | ||
| 1404 | #else | ||
| 1400 | FONTSET_ASCII (Vdefault_fontset) | 1405 | FONTSET_ASCII (Vdefault_fontset) |
| 1401 | = Fcons (make_number (0), | 1406 | = Fcons (make_number (0), |
| 1402 | build_string ("-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1")); | 1407 | build_string ("-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1")); |
| 1408 | #endif | ||
| 1403 | AREF (Vfontset_table, 0) = Vdefault_fontset; | 1409 | AREF (Vfontset_table, 0) = Vdefault_fontset; |
| 1404 | next_fontset_id = 1; | 1410 | next_fontset_id = 1; |
| 1405 | 1411 | ||
diff --git a/src/frame.c b/src/frame.c index b4afa56803b..403261ed326 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -29,6 +29,9 @@ Boston, MA 02111-1307, USA. */ | |||
| 29 | #ifdef WINDOWSNT | 29 | #ifdef WINDOWSNT |
| 30 | #include "w32term.h" | 30 | #include "w32term.h" |
| 31 | #endif | 31 | #endif |
| 32 | #ifdef macintosh | ||
| 33 | #include "macterm.h" | ||
| 34 | #endif | ||
| 32 | #include "buffer.h" | 35 | #include "buffer.h" |
| 33 | /* These help us bind and responding to switch-frame events. */ | 36 | /* These help us bind and responding to switch-frame events. */ |
| 34 | #include "commands.h" | 37 | #include "commands.h" |
| @@ -45,11 +48,6 @@ Boston, MA 02111-1307, USA. */ | |||
| 45 | #include "dosfns.h" | 48 | #include "dosfns.h" |
| 46 | #endif | 49 | #endif |
| 47 | 50 | ||
| 48 | #ifdef macintosh | ||
| 49 | extern struct mac_output *NewMacWindow (); | ||
| 50 | extern void DisposeMacWindow (struct mac_output *); | ||
| 51 | #endif | ||
| 52 | |||
| 53 | /* Evaluate this expression to rebuild the section of syms_of_frame | 51 | /* Evaluate this expression to rebuild the section of syms_of_frame |
| 54 | that initializes and staticpros the symbols declared below. Note | 52 | that initializes and staticpros the symbols declared below. Note |
| 55 | that Emacs 18 has a bug that keeps C-x C-e from being able to | 53 | that Emacs 18 has a bug that keeps C-x C-e from being able to |
| @@ -582,25 +580,15 @@ make_terminal_frame () | |||
| 582 | f->output_method = output_termcap; | 580 | f->output_method = output_termcap; |
| 583 | #else | 581 | #else |
| 584 | #ifdef macintosh | 582 | #ifdef macintosh |
| 585 | f->output_data.mac = NewMacWindow(f); | 583 | make_mac_terminal_frame (f); |
| 586 | f->output_data.mac->background_pixel = 0xffffff; | 584 | #else |
| 587 | f->output_data.mac->foreground_pixel = 0; | ||
| 588 | f->output_data.mac->n_param_faces = 0; | ||
| 589 | f->output_data.mac->n_computed_faces = 0; | ||
| 590 | f->output_data.mac->size_computed_faces = 0; | ||
| 591 | f->output_method = output_mac; | ||
| 592 | f->auto_raise = 1; | ||
| 593 | f->auto_lower = 1; | ||
| 594 | init_frame_faces (f); | ||
| 595 | #else /* !macintosh */ | ||
| 596 | f->output_data.x = &tty_display; | 585 | f->output_data.x = &tty_display; |
| 597 | #endif /* !macintosh */ | 586 | #endif /* macintosh */ |
| 598 | #endif /* MSDOS */ | 587 | #endif /* MSDOS */ |
| 599 | 588 | ||
| 600 | #ifndef macintosh | ||
| 601 | if (!noninteractive) | 589 | if (!noninteractive) |
| 602 | init_frame_faces (f); | 590 | init_frame_faces (f); |
| 603 | #endif | 591 | |
| 604 | return f; | 592 | return f; |
| 605 | } | 593 | } |
| 606 | 594 | ||
| @@ -1288,14 +1276,6 @@ but if the second optional argument FORCE is non-nil, you may do so.") | |||
| 1288 | x_destroy_window (f); | 1276 | x_destroy_window (f); |
| 1289 | #endif | 1277 | #endif |
| 1290 | 1278 | ||
| 1291 | /* Done by x_destroy_window above already */ | ||
| 1292 | #if 0 | ||
| 1293 | #ifdef macintosh | ||
| 1294 | if (FRAME_MAC_P (f)) | ||
| 1295 | DisposeMacWindow (f->output_data.mac); | ||
| 1296 | #endif | ||
| 1297 | #endif | ||
| 1298 | |||
| 1299 | f->output_data.nothing = 0; | 1279 | f->output_data.nothing = 0; |
| 1300 | 1280 | ||
| 1301 | /* If we've deleted the last_nonminibuf_frame, then try to find | 1281 | /* If we've deleted the last_nonminibuf_frame, then try to find |
| @@ -2229,11 +2209,6 @@ enabled such bindings for that variable with `make-variable-frame-local'.") | |||
| 2229 | IT_set_frame_parameters (f, alist); | 2209 | IT_set_frame_parameters (f, alist); |
| 2230 | else | 2210 | else |
| 2231 | #endif | 2211 | #endif |
| 2232 | #ifdef macintosh | ||
| 2233 | if (FRAME_MAC_P (f)) | ||
| 2234 | mac_set_frame_parameters (f, alist); | ||
| 2235 | else | ||
| 2236 | #endif | ||
| 2237 | 2212 | ||
| 2238 | { | 2213 | { |
| 2239 | int length = XINT (Flength (alist)); | 2214 | int length = XINT (Flength (alist)); |
diff --git a/src/frame.h b/src/frame.h index 01ba8f8f5cf..a8c759fe407 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -259,7 +259,7 @@ struct frame | |||
| 259 | /* Number of lines of menu bar. */ | 259 | /* Number of lines of menu bar. */ |
| 260 | int menu_bar_lines; | 260 | int menu_bar_lines; |
| 261 | 261 | ||
| 262 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 262 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 263 | /* Nonzero means using a menu bar that comes from the X toolkit. */ | 263 | /* Nonzero means using a menu bar that comes from the X toolkit. */ |
| 264 | int external_menu_bar; | 264 | int external_menu_bar; |
| 265 | #endif | 265 | #endif |
| @@ -442,7 +442,7 @@ typedef struct frame *FRAME_PTR; | |||
| 442 | 442 | ||
| 443 | /* Nonzero if this frame should display a menu bar | 443 | /* Nonzero if this frame should display a menu bar |
| 444 | in a way that does not use any text lines. */ | 444 | in a way that does not use any text lines. */ |
| 445 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 445 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 446 | #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar | 446 | #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar |
| 447 | #else | 447 | #else |
| 448 | #define FRAME_EXTERNAL_MENU_BAR(f) 0 | 448 | #define FRAME_EXTERNAL_MENU_BAR(f) 0 |
diff --git a/src/keyboard.c b/src/keyboard.c index e4aac125a61..4e08cc5c3d6 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -70,6 +70,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 70 | #include "w32term.h" | 70 | #include "w32term.h" |
| 71 | #endif /* HAVE_NTGUI */ | 71 | #endif /* HAVE_NTGUI */ |
| 72 | 72 | ||
| 73 | #ifdef macintosh | ||
| 74 | #include "macterm.h" | ||
| 75 | #endif | ||
| 76 | |||
| 73 | /* Include systime.h after xterm.h to avoid double inclusion of time.h. */ | 77 | /* Include systime.h after xterm.h to avoid double inclusion of time.h. */ |
| 74 | #include "systime.h" | 78 | #include "systime.h" |
| 75 | 79 | ||
| @@ -93,7 +97,7 @@ extern int input_fd; | |||
| 93 | #ifdef HAVE_WINDOW_SYSTEM | 97 | #ifdef HAVE_WINDOW_SYSTEM |
| 94 | /* Make all keyboard buffers much bigger when using X windows. */ | 98 | /* Make all keyboard buffers much bigger when using X windows. */ |
| 95 | #ifdef macintosh | 99 | #ifdef macintosh |
| 96 | /* But not too big (local data > 32K error) if on macintosh */ | 100 | /* But not too big (local data > 32K error) if on macintosh. */ |
| 97 | #define KBD_BUFFER_SIZE 512 | 101 | #define KBD_BUFFER_SIZE 512 |
| 98 | #else | 102 | #else |
| 99 | #define KBD_BUFFER_SIZE 4096 | 103 | #define KBD_BUFFER_SIZE 4096 |
| @@ -3474,7 +3478,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 3474 | abort (); | 3478 | abort (); |
| 3475 | #endif | 3479 | #endif |
| 3476 | } | 3480 | } |
| 3477 | #if defined (HAVE_X11) || defined (HAVE_NTGUI) | 3481 | #if defined (HAVE_X11) || defined (HAVE_NTGUI) || defined (macintosh) |
| 3478 | else if (event->kind == delete_window_event) | 3482 | else if (event->kind == delete_window_event) |
| 3479 | { | 3483 | { |
| 3480 | /* Make an event (delete-frame (FRAME)). */ | 3484 | /* Make an event (delete-frame (FRAME)). */ |
| @@ -3482,6 +3486,8 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 3482 | obj = Fcons (Qdelete_frame, Fcons (obj, Qnil)); | 3486 | obj = Fcons (Qdelete_frame, Fcons (obj, Qnil)); |
| 3483 | kbd_fetch_ptr = event + 1; | 3487 | kbd_fetch_ptr = event + 1; |
| 3484 | } | 3488 | } |
| 3489 | #endif | ||
| 3490 | #if defined (HAVE_X11) || defined (HAVE_NTGUI) | ||
| 3485 | else if (event->kind == iconify_event) | 3491 | else if (event->kind == iconify_event) |
| 3486 | { | 3492 | { |
| 3487 | /* Make an event (iconify-frame (FRAME)). */ | 3493 | /* Make an event (iconify-frame (FRAME)). */ |
| @@ -3503,7 +3509,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 3503 | XSETBUFFER (obj, current_buffer); | 3509 | XSETBUFFER (obj, current_buffer); |
| 3504 | kbd_fetch_ptr = event + 1; | 3510 | kbd_fetch_ptr = event + 1; |
| 3505 | } | 3511 | } |
| 3506 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 3512 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 3507 | else if (event->kind == menu_bar_activate_event) | 3513 | else if (event->kind == menu_bar_activate_event) |
| 3508 | { | 3514 | { |
| 3509 | kbd_fetch_ptr = event + 1; | 3515 | kbd_fetch_ptr = event + 1; |
| @@ -5093,7 +5099,7 @@ make_lispy_event (event) | |||
| 5093 | } | 5099 | } |
| 5094 | #endif /* HAVE_MOUSE */ | 5100 | #endif /* HAVE_MOUSE */ |
| 5095 | 5101 | ||
| 5096 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 5102 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 5097 | case MENU_BAR_EVENT: | 5103 | case MENU_BAR_EVENT: |
| 5098 | if (EQ (event->arg, event->frame_or_window)) | 5104 | if (EQ (event->arg, event->frame_or_window)) |
| 5099 | /* This is the prefix key. We translate this to | 5105 | /* This is the prefix key. We translate this to |
diff --git a/src/sysdep.c b/src/sysdep.c index d53b7d93db2..3b336f6bf7f 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -31,21 +31,15 @@ Boston, MA 02111-1307, USA. */ | |||
| 31 | #undef NULL | 31 | #undef NULL |
| 32 | 32 | ||
| 33 | #ifdef macintosh | 33 | #ifdef macintosh |
| 34 | #ifdef __MRC__ | 34 | /* It is essential to include stdlib.h so that this file picks up |
| 35 | __sigfun sys_signal (int signal, __sigfun signal_func); | 35 | the correct definitions of rand, srand, and RAND_MAX. |
| 36 | #elif __MWERKS__ | 36 | Otherwise random numbers will not work correctly. */ |
| 37 | __signal_func_ptr sys_signal (int signal, __signal_func_ptr signal_func); | 37 | #include <stdlib.h> |
| 38 | #else | 38 | |
| 39 | You lose!!! | ||
| 40 | #endif | ||
| 41 | #ifndef subprocesses | 39 | #ifndef subprocesses |
| 42 | /* Nonzero means delete a process right away if it exits (process.c). */ | 40 | /* Nonzero means delete a process right away if it exits (process.c). */ |
| 43 | static int delete_exited_processes; | 41 | static int delete_exited_processes; |
| 44 | #endif | 42 | #endif |
| 45 | #ifndef HAVE_X_WINDOWS | ||
| 46 | /* Search path for bitmap files (xfns.c). */ | ||
| 47 | Lisp_Object Vx_bitmap_file_path; | ||
| 48 | #endif | ||
| 49 | #endif /* macintosh */ | 43 | #endif /* macintosh */ |
| 50 | 44 | ||
| 51 | #define min(x,y) ((x) > (y) ? (y) : (x)) | 45 | #define min(x,y) ((x) > (y) ? (y) : (x)) |
| @@ -751,12 +745,10 @@ sys_suspend () | |||
| 751 | 745 | ||
| 752 | /* Fork a subshell. */ | 746 | /* Fork a subshell. */ |
| 753 | 747 | ||
| 748 | #ifndef macintosh | ||
| 754 | void | 749 | void |
| 755 | sys_subshell () | 750 | sys_subshell () |
| 756 | { | 751 | { |
| 757 | #ifdef macintosh | ||
| 758 | error ("Can't spawn subshell"); | ||
| 759 | #else | ||
| 760 | #ifndef VMS | 752 | #ifndef VMS |
| 761 | #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ | 753 | #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ |
| 762 | int st; | 754 | int st; |
| @@ -873,8 +865,8 @@ sys_subshell () | |||
| 873 | restore_signal_handlers (saved_handlers); | 865 | restore_signal_handlers (saved_handlers); |
| 874 | synch_process_alive = 0; | 866 | synch_process_alive = 0; |
| 875 | #endif /* !VMS */ | 867 | #endif /* !VMS */ |
| 876 | #endif /* !macintosh */ | ||
| 877 | } | 868 | } |
| 869 | #endif /* !macintosh */ | ||
| 878 | 870 | ||
| 879 | static void | 871 | static void |
| 880 | save_signal_handlers (saved_handlers) | 872 | save_signal_handlers (saved_handlers) |
| @@ -1285,23 +1277,13 @@ init_sys_modes () | |||
| 1285 | struct emacs_tty tty; | 1277 | struct emacs_tty tty; |
| 1286 | 1278 | ||
| 1287 | #ifdef macintosh | 1279 | #ifdef macintosh |
| 1288 | Vwindow_system = intern ("mac"); | 1280 | /* cus-start.el complains if delete-exited-processes is not defined */ |
| 1289 | Vwindow_system_version = make_number (1); | ||
| 1290 | |||
| 1291 | /* cus-start.el complains if delete-exited-processes and x-bitmap-file-path not defined */ | ||
| 1292 | #ifndef subprocesses | 1281 | #ifndef subprocesses |
| 1293 | DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, | 1282 | DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, |
| 1294 | "*Non-nil means delete processes immediately when they exit.\n\ | 1283 | "*Non-nil means delete processes immediately when they exit.\n\ |
| 1295 | nil means don't delete them until `list-processes' is run."); | 1284 | nil means don't delete them until `list-processes' is run."); |
| 1296 | delete_exited_processes = 0; | 1285 | delete_exited_processes = 0; |
| 1297 | #endif | 1286 | #endif |
| 1298 | |||
| 1299 | #ifndef HAVE_X_WINDOWS | ||
| 1300 | DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path, | ||
| 1301 | "List of directories to search for bitmap files for X."); | ||
| 1302 | Vx_bitmap_file_path = decode_env_path ((char *) 0, "."); | ||
| 1303 | #endif | ||
| 1304 | |||
| 1305 | #endif /* not macintosh */ | 1287 | #endif /* not macintosh */ |
| 1306 | 1288 | ||
| 1307 | #ifdef VMS | 1289 | #ifdef VMS |
| @@ -2651,7 +2633,7 @@ read_input_waiting () | |||
| 2651 | 2633 | ||
| 2652 | read_alarm_should_throw = 0; | 2634 | read_alarm_should_throw = 0; |
| 2653 | if (! setjmp (read_alarm_throw)) | 2635 | if (! setjmp (read_alarm_throw)) |
| 2654 | nread = (*read_socket_hook) (0, buf, 256, 1); | 2636 | nread = (*read_socket_hook) (0, buf, 256, 1, 0); |
| 2655 | else | 2637 | else |
| 2656 | nread = -1; | 2638 | nread = -1; |
| 2657 | 2639 | ||
| @@ -5306,1542 +5288,4 @@ strsignal (code) | |||
| 5306 | return signame; | 5288 | return signame; |
| 5307 | } | 5289 | } |
| 5308 | #endif /* HAVE_STRSIGNAL */ | 5290 | #endif /* HAVE_STRSIGNAL */ |
| 5309 | |||
| 5310 | /* All the Macintosh stuffs go here */ | ||
| 5311 | |||
| 5312 | #ifdef macintosh | ||
| 5313 | |||
| 5314 | #include <Files.h> | ||
| 5315 | #include <MacTypes.h> | ||
| 5316 | #include <TextUtils.h> | ||
| 5317 | #include <Folders.h> | ||
| 5318 | |||
| 5319 | #include <dirent.h> | ||
| 5320 | #include <sys/stat.h> | ||
| 5321 | #include <string.h> | ||
| 5322 | #include <pwd.h> | ||
| 5323 | #include <sys/param.h> | ||
| 5324 | |||
| 5325 | /* Convert a Mac pathname to Unix form. A Mac full pathname is one | ||
| 5326 | that does not begin with a ':' and contains at least one ':'. A Mac | ||
| 5327 | full pathname causes an '/' to be prepended to the Unix pathname. | ||
| 5328 | The algorithm for the rest of the pathname is as follows: | ||
| 5329 | For each segment between two ':', | ||
| 5330 | if it is non-null, copy as is and then add a '/' at the end, | ||
| 5331 | otherwise, insert a "../" into the Unix pathname. | ||
| 5332 | Returns 1 if successful; 0 if fails. */ | ||
| 5333 | |||
| 5334 | int | ||
| 5335 | Mac2UnixPathname (const char *mfn, char *ufn, int ufnbuflen) | ||
| 5336 | { | ||
| 5337 | const char *p, *q, *pe; | ||
| 5338 | |||
| 5339 | strcpy (ufn, ""); | ||
| 5340 | |||
| 5341 | if (*mfn == '\0') | ||
| 5342 | return 1; | ||
| 5343 | |||
| 5344 | p = strchr (mfn, ':'); | ||
| 5345 | if (p != 0 && p != mfn) /* full pathname */ | ||
| 5346 | strcat (ufn, "/"); | ||
| 5347 | |||
| 5348 | p = mfn; | ||
| 5349 | if (*p == ':') | ||
| 5350 | p++; | ||
| 5351 | |||
| 5352 | pe = mfn + strlen (mfn); | ||
| 5353 | while (p < pe) | ||
| 5354 | { | ||
| 5355 | q = strchr (p, ':'); | ||
| 5356 | if (q) | ||
| 5357 | { | ||
| 5358 | if (q == p) | ||
| 5359 | { /* two consecutive ':' */ | ||
| 5360 | if (strlen (ufn) + 3 >= ufnbuflen) | ||
| 5361 | return 0; | ||
| 5362 | strcat (ufn, "../"); | ||
| 5363 | } | ||
| 5364 | else | ||
| 5365 | { | ||
| 5366 | if (strlen (ufn) + (q - p) + 1 >= ufnbuflen) | ||
| 5367 | return 0; | ||
| 5368 | strncat (ufn, p, q - p); | ||
| 5369 | strcat (ufn, "/"); | ||
| 5370 | } | ||
| 5371 | p = q + 1; | ||
| 5372 | } | ||
| 5373 | else | ||
| 5374 | { | ||
| 5375 | if (strlen (ufn) + (pe - p) >= ufnbuflen) | ||
| 5376 | return 0; | ||
| 5377 | strncat (ufn, p, pe - p); /* no separator for last one */ | ||
| 5378 | p = pe; | ||
| 5379 | } | ||
| 5380 | } | ||
| 5381 | |||
| 5382 | return 1; | ||
| 5383 | } | ||
| 5384 | |||
| 5385 | extern char *GetTempDirName (); | ||
| 5386 | |||
| 5387 | /* Convert a Unix pathname to Mac form. Approximately reverse of the | ||
| 5388 | above in algorithm. */ | ||
| 5389 | int | ||
| 5390 | Unix2MacPathname (const char *ufn, char *mfn, int mfnbuflen) | ||
| 5391 | { | ||
| 5392 | const char *p, *q, *pe; | ||
| 5393 | char expandedPathname[MAXPATHLEN+1]; | ||
| 5394 | |||
| 5395 | strcpy (mfn, ""); | ||
| 5396 | |||
| 5397 | if (*ufn == '\0') | ||
| 5398 | return 1; | ||
| 5399 | |||
| 5400 | p = ufn; | ||
| 5401 | |||
| 5402 | /* Check for and handle volume names. Last comparison: strangely | ||
| 5403 | somewhere `/.emacs' is passed. A temporary fix for now. */ | ||
| 5404 | if (*p == '/' && strchr (p+1, '/') == NULL && strcmp (p, "/.emacs") != 0) | ||
| 5405 | { | ||
| 5406 | if (strlen (p) + 1 > mfnbuflen) | ||
| 5407 | return 0; | ||
| 5408 | strcpy (mfn, p+1); | ||
| 5409 | strcat (mfn, ":"); | ||
| 5410 | return 1; | ||
| 5411 | } | ||
| 5412 | |||
| 5413 | if (strncmp (p, "~emacs/", 7) == 0) | ||
| 5414 | { /* expand to emacs dir found by InitEmacsPasswdDir */ | ||
| 5415 | struct passwd *pw = getpwnam ("emacs"); | ||
| 5416 | p += 7; | ||
| 5417 | if (strlen (pw->pw_dir) + strlen (p) > MAXPATHLEN) | ||
| 5418 | return 0; | ||
| 5419 | strcpy (expandedPathname, pw->pw_dir); | ||
| 5420 | strcat (expandedPathname, p); | ||
| 5421 | p = expandedPathname; | ||
| 5422 | /* Now p points to the pathname with emacs dir prefix. */ | ||
| 5423 | } | ||
| 5424 | else if (strncmp (p, "/tmp/", 5) == 0) | ||
| 5425 | { | ||
| 5426 | char *t = GetTempDirName (); | ||
| 5427 | p += 5; | ||
| 5428 | if (strlen (t) + strlen (p) > MAXPATHLEN) | ||
| 5429 | return 0; | ||
| 5430 | strcpy (expandedPathname, t); | ||
| 5431 | strcat (expandedPathname, p); | ||
| 5432 | p = expandedPathname; | ||
| 5433 | /* Now p points to the pathname with emacs dir prefix. */ | ||
| 5434 | } | ||
| 5435 | else if (*p != '/') /* relative pathname */ | ||
| 5436 | strcat (mfn, ":"); | ||
| 5437 | |||
| 5438 | if (*p == '/') | ||
| 5439 | p++; | ||
| 5440 | |||
| 5441 | pe = p + strlen (p); | ||
| 5442 | while (p < pe) | ||
| 5443 | { | ||
| 5444 | q = strchr (p, '/'); | ||
| 5445 | if (q) | ||
| 5446 | { | ||
| 5447 | if (q - p == 2 && *p == '.' && *(p+1) == '.') | ||
| 5448 | { | ||
| 5449 | if (strlen (mfn) + 1 >= mfnbuflen) | ||
| 5450 | return 0; | ||
| 5451 | strcat (mfn, ":"); | ||
| 5452 | } | ||
| 5453 | else | ||
| 5454 | { | ||
| 5455 | if (strlen (mfn) + (q - p) + 1 >= mfnbuflen) | ||
| 5456 | return 0; | ||
| 5457 | strncat (mfn, p, q - p); | ||
| 5458 | strcat (mfn, ":"); | ||
| 5459 | } | ||
| 5460 | p = q + 1; | ||
| 5461 | } | ||
| 5462 | else | ||
| 5463 | { | ||
| 5464 | if (strlen (mfn) + (pe - p) >= mfnbuflen) | ||
| 5465 | return 0; | ||
| 5466 | strncat (mfn, p, pe - p); | ||
| 5467 | p = pe; | ||
| 5468 | } | ||
| 5469 | } | ||
| 5470 | |||
| 5471 | return 1; | ||
| 5472 | } | ||
| 5473 | |||
| 5474 | /* The following functions with "sys_" prefix are stubs to Unix | ||
| 5475 | functions that have already been implemented by CW or MPW. The | ||
| 5476 | calls to them in Emacs source course are #define'd to call the sys_ | ||
| 5477 | versions by the header files s-mac.h. In these stubs pathnames are | ||
| 5478 | converted between their Unix and Mac forms. */ | ||
| 5479 | /* Unix Epoch is Jan 1, 1970 while Mac Epoch is Jan 1, 1904: 66 years | ||
| 5480 | + 17 leap days */ | ||
| 5481 | #define MAC_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60) | ||
| 5482 | |||
| 5483 | /* CW Epoch is Jan 1, 1900 (aaarghhhhh!); remember, 1900 is not a leap | ||
| 5484 | year! */ | ||
| 5485 | #define CW_UNIX_EPOCH_DIFF ((365L * 70 + 17) * 24 * 60 * 60) | ||
| 5486 | |||
| 5487 | /* Define our own stat function for both MrC and CW. The reason for | ||
| 5488 | doing this: "stat" is both the name of a struct and function name: | ||
| 5489 | we can't #define stat to something else to | ||
| 5490 | redirect Emacs's calls to our own version that converts Unix style | ||
| 5491 | filenames to Mac style filename because all sorts of compilation | ||
| 5492 | errors will be generated if stat is #define'd to be something else. */ | ||
| 5493 | |||
| 5494 | int | ||
| 5495 | stat (const char *path, struct stat *buf) | ||
| 5496 | { | ||
| 5497 | char MacPathname[MAXPATHLEN+1]; | ||
| 5498 | CInfoPBRec cipb; | ||
| 5499 | |||
| 5500 | if (Unix2MacPathname (path, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5501 | return -1; | ||
| 5502 | |||
| 5503 | c2pstr (MacPathname); | ||
| 5504 | cipb.hFileInfo.ioNamePtr = MacPathname; | ||
| 5505 | cipb.hFileInfo.ioVRefNum = 0; | ||
| 5506 | cipb.hFileInfo.ioDirID = 0; | ||
| 5507 | cipb.hFileInfo.ioFDirIndex = 0; /* set to 0 to get information about specific dir or file */ | ||
| 5508 | |||
| 5509 | errno = PBGetCatInfo (&cipb, false); | ||
| 5510 | if (errno == -43) /* -43: fnfErr defined in Errors.h */ | ||
| 5511 | errno = ENOENT; | ||
| 5512 | if (errno != noErr) | ||
| 5513 | return -1; | ||
| 5514 | |||
| 5515 | if (cipb.hFileInfo.ioFlAttrib & 0x10) | ||
| 5516 | { /* bit 4 = 1 for directories */ | ||
| 5517 | buf->st_mode = S_IFDIR | S_IREAD | S_IEXEC; | ||
| 5518 | if (!(cipb.hFileInfo.ioFlAttrib & 0x1)) /* bit 1 = 1 for locked files/directories */ | ||
| 5519 | buf->st_mode |= S_IWRITE; | ||
| 5520 | buf->st_ino = cipb.dirInfo.ioDrDirID; | ||
| 5521 | buf->st_dev = cipb.dirInfo.ioVRefNum; | ||
| 5522 | buf->st_size = cipb.dirInfo.ioDrNmFls; /* size of dir = number of files and dirs */ | ||
| 5523 | buf->st_atime = buf->st_mtime = cipb.dirInfo.ioDrMdDat - MAC_UNIX_EPOCH_DIFF; | ||
| 5524 | buf->st_ctime = cipb.dirInfo.ioDrCrDat - MAC_UNIX_EPOCH_DIFF; | ||
| 5525 | } | ||
| 5526 | else | ||
| 5527 | { | ||
| 5528 | buf->st_mode = S_IFREG | S_IREAD; | ||
| 5529 | if (!(cipb.hFileInfo.ioFlAttrib & 0x1)) /* bit 1 = 1 for locked files/directories */ | ||
| 5530 | buf->st_mode |= S_IWRITE; | ||
| 5531 | if (cipb.hFileInfo.ioFlFndrInfo.fdType == 'APPL') | ||
| 5532 | buf->st_mode |= S_IEXEC; | ||
| 5533 | buf->st_ino = cipb.hFileInfo.ioDirID; | ||
| 5534 | buf->st_dev = cipb.hFileInfo.ioVRefNum; | ||
| 5535 | buf->st_size = cipb.hFileInfo.ioFlLgLen; | ||
| 5536 | buf->st_atime = buf->st_mtime = cipb.hFileInfo.ioFlMdDat - MAC_UNIX_EPOCH_DIFF; | ||
| 5537 | buf->st_ctime = cipb.hFileInfo.ioFlCrDat - MAC_UNIX_EPOCH_DIFF; | ||
| 5538 | } | ||
| 5539 | buf->st_nlink = 1; | ||
| 5540 | buf->st_uid = getuid (); | ||
| 5541 | buf->st_gid = getgid (); | ||
| 5542 | buf->st_rdev = 0; | ||
| 5543 | |||
| 5544 | return 0; | ||
| 5545 | } | ||
| 5546 | |||
| 5547 | #if __MRC__ | ||
| 5548 | |||
| 5549 | /* CW defines fstat in stat.mac.c while MPW does not provide this | ||
| 5550 | function. Without the information of how to get from a file | ||
| 5551 | descriptor in MPW StdCLib to a Mac OS file spec, it should be hard | ||
| 5552 | to implement this function. Fortunately, there is only one place | ||
| 5553 | where this function is called in our configuration: in fileio.c, | ||
| 5554 | where only the st_dev and st_ino fields are used to determine | ||
| 5555 | whether two fildes point to different i-nodes to prevent copying | ||
| 5556 | a file onto itself equal. What we have here probably needs | ||
| 5557 | improvement. */ | ||
| 5558 | int | ||
| 5559 | fstat (int fildes, struct stat *buf) | ||
| 5560 | { | ||
| 5561 | buf->st_dev = 0; | ||
| 5562 | buf->st_ino = fildes; | ||
| 5563 | return 0; /* success */ | ||
| 5564 | } | ||
| 5565 | |||
| 5566 | #endif /* __MRC__ */ | ||
| 5567 | |||
| 5568 | /* From Think Reference code example */ | ||
| 5569 | int | ||
| 5570 | mkdir (const char *dirname, int mode) | ||
| 5571 | { | ||
| 5572 | #pragma unused (mode) | ||
| 5573 | |||
| 5574 | HFileParam hfpb; | ||
| 5575 | char MacPathname[MAXPATHLEN+1]; | ||
| 5576 | |||
| 5577 | if (Unix2MacPathname (dirname, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5578 | return -1; | ||
| 5579 | |||
| 5580 | c2pstr (MacPathname); | ||
| 5581 | hfpb.ioNamePtr = MacPathname; | ||
| 5582 | hfpb.ioVRefNum = 0; /*ignored unless name is invalid */ | ||
| 5583 | hfpb.ioDirID = 0; /*parent is the root */ | ||
| 5584 | |||
| 5585 | /* Just return the Mac OSErr code for now. */ | ||
| 5586 | errno = PBDirCreate ((HParmBlkPtr) &hfpb, false); | ||
| 5587 | return errno == noErr ? 0 : -1; | ||
| 5588 | } | ||
| 5589 | |||
| 5590 | int | ||
| 5591 | rmdir (const char *dirname) | ||
| 5592 | { | ||
| 5593 | HFileParam hfpb; | ||
| 5594 | char MacPathname[MAXPATHLEN+1]; | ||
| 5595 | |||
| 5596 | if (Unix2MacPathname (dirname, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5597 | return -1; | ||
| 5598 | |||
| 5599 | c2pstr (MacPathname); | ||
| 5600 | hfpb.ioNamePtr = MacPathname; | ||
| 5601 | hfpb.ioVRefNum = 0; /*ignored unless name is invalid */ | ||
| 5602 | hfpb.ioDirID = 0; /*parent is the root */ | ||
| 5603 | |||
| 5604 | errno = PBHDelete ((HParmBlkPtr) &hfpb, false); | ||
| 5605 | return errno == noErr ? 0 : -1; | ||
| 5606 | } | ||
| 5607 | |||
| 5608 | #ifdef __MRC__ | ||
| 5609 | |||
| 5610 | /* No implementation yet. */ | ||
| 5611 | int | ||
| 5612 | execvp (const char *path, ...) | ||
| 5613 | { | ||
| 5614 | return -1; | ||
| 5615 | } | ||
| 5616 | |||
| 5617 | #endif /* __MRC__ */ | ||
| 5618 | |||
| 5619 | int | ||
| 5620 | utime (const char *path, const struct utimbuf *times) | ||
| 5621 | { | ||
| 5622 | char MacPathname[MAXPATHLEN+1]; | ||
| 5623 | CInfoPBRec cipb; | ||
| 5624 | |||
| 5625 | if (Unix2MacPathname (path, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5626 | return -1; | ||
| 5627 | |||
| 5628 | c2pstr (MacPathname); | ||
| 5629 | cipb.hFileInfo.ioNamePtr = MacPathname; | ||
| 5630 | cipb.hFileInfo.ioVRefNum = 0; | ||
| 5631 | cipb.hFileInfo.ioDirID = 0; | ||
| 5632 | /* Set to 0 to get information about specific dir or file. */ | ||
| 5633 | cipb.hFileInfo.ioFDirIndex = 0; | ||
| 5634 | |||
| 5635 | errno = PBGetCatInfo (&cipb, false); | ||
| 5636 | if (errno != noErr) | ||
| 5637 | return -1; | ||
| 5638 | |||
| 5639 | if (cipb.hFileInfo.ioFlAttrib & 0x10) | ||
| 5640 | { /* bit 4 = 1 for directories */ | ||
| 5641 | if (times) | ||
| 5642 | cipb.dirInfo.ioDrMdDat = times->modtime + MAC_UNIX_EPOCH_DIFF; | ||
| 5643 | else | ||
| 5644 | GetDateTime (&cipb.dirInfo.ioDrMdDat); | ||
| 5645 | } | ||
| 5646 | else | ||
| 5647 | { | ||
| 5648 | if (times) | ||
| 5649 | cipb.hFileInfo.ioFlMdDat = times->modtime + MAC_UNIX_EPOCH_DIFF; | ||
| 5650 | else | ||
| 5651 | GetDateTime (&cipb.hFileInfo.ioFlMdDat); | ||
| 5652 | } | ||
| 5653 | |||
| 5654 | errno = PBSetCatInfo (&cipb, false); | ||
| 5655 | return errno == noErr ? 0 : -1; | ||
| 5656 | } | ||
| 5657 | |||
| 5658 | #define F_OK 0 | ||
| 5659 | #define X_OK 1 | ||
| 5660 | #define W_OK 2 | ||
| 5661 | |||
| 5662 | /* Like stat, but test for access mode in hfpb.ioFlAttrib. */ | ||
| 5663 | int | ||
| 5664 | access (const char *path, int mode) | ||
| 5665 | { | ||
| 5666 | char MacPathname[MAXPATHLEN+1]; | ||
| 5667 | CInfoPBRec cipb; | ||
| 5668 | |||
| 5669 | if (Unix2MacPathname (path, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5670 | return -1; | ||
| 5671 | |||
| 5672 | c2pstr (MacPathname); | ||
| 5673 | cipb.hFileInfo.ioNamePtr = MacPathname; | ||
| 5674 | cipb.hFileInfo.ioVRefNum = 0; | ||
| 5675 | cipb.hFileInfo.ioDirID = 0; | ||
| 5676 | cipb.hFileInfo.ioFDirIndex = 0; /* set to 0 to get information about specific dir or file */ | ||
| 5677 | |||
| 5678 | errno = PBGetCatInfo (&cipb, false); | ||
| 5679 | if (errno != noErr) | ||
| 5680 | return -1; | ||
| 5681 | |||
| 5682 | if (mode == F_OK) /* got this far, file exists */ | ||
| 5683 | return 0; | ||
| 5684 | |||
| 5685 | if (mode & X_OK) | ||
| 5686 | if (cipb.hFileInfo.ioFlAttrib & 0x10) /* path refers to a directory */ | ||
| 5687 | return 0; | ||
| 5688 | else | ||
| 5689 | { | ||
| 5690 | if (cipb.hFileInfo.ioFlFndrInfo.fdType == 'APPL') | ||
| 5691 | return 0; | ||
| 5692 | else | ||
| 5693 | return -1; | ||
| 5694 | } | ||
| 5695 | |||
| 5696 | if (mode & W_OK) | ||
| 5697 | return (cipb.hFileInfo.ioFlAttrib & 0x1) ? -1 : 0; /* don't allow if lock bit on */ | ||
| 5698 | |||
| 5699 | return -1; | ||
| 5700 | } | ||
| 5701 | |||
| 5702 | #define DEV_NULL_FD 0x10000 | ||
| 5703 | |||
| 5704 | #undef open | ||
| 5705 | int | ||
| 5706 | sys_open (const char *path, int oflag) | ||
| 5707 | { | ||
| 5708 | char MacPathname[MAXPATHLEN+1]; | ||
| 5709 | |||
| 5710 | if (strcmp (path, "/dev/null") == 0) | ||
| 5711 | return DEV_NULL_FD; /* some bogus fd to be ignored in write */ | ||
| 5712 | |||
| 5713 | if (Unix2MacPathname (path, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5714 | return -1; | ||
| 5715 | else | ||
| 5716 | return open (MacPathname, oflag); | ||
| 5717 | } | ||
| 5718 | |||
| 5719 | #undef creat | ||
| 5720 | int | ||
| 5721 | sys_creat (const char *path, mode_t mode) | ||
| 5722 | { | ||
| 5723 | char MacPathname[MAXPATHLEN+1]; | ||
| 5724 | |||
| 5725 | if (Unix2MacPathname (path, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5726 | return -1; | ||
| 5727 | else | ||
| 5728 | return creat (MacPathname, mode); | ||
| 5729 | } | ||
| 5730 | |||
| 5731 | #undef unlink | ||
| 5732 | int | ||
| 5733 | sys_unlink (const char *path) | ||
| 5734 | { | ||
| 5735 | char MacPathname[MAXPATHLEN+1]; | ||
| 5736 | |||
| 5737 | if (Unix2MacPathname (path, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5738 | return -1; | ||
| 5739 | else | ||
| 5740 | return unlink (MacPathname); | ||
| 5741 | } | ||
| 5742 | |||
| 5743 | #undef read | ||
| 5744 | int | ||
| 5745 | sys_read (int fildes, char *buf, int count) | ||
| 5746 | { | ||
| 5747 | if (fildes == 0) | ||
| 5748 | { /* if stdin, call (non-echoing) "getch" in console.h */ | ||
| 5749 | if (MacKeyPending ()) | ||
| 5750 | { /* don't wait for a key if none has been pressed */ | ||
| 5751 | *buf = MacGetChar (); | ||
| 5752 | return 1; | ||
| 5753 | } | ||
| 5754 | else | ||
| 5755 | return 0; | ||
| 5756 | } | ||
| 5757 | else | ||
| 5758 | return read (fildes, buf, count); | ||
| 5759 | } | ||
| 5760 | |||
| 5761 | #undef write | ||
| 5762 | int | ||
| 5763 | sys_write (int fildes, char *buf, int count) | ||
| 5764 | { | ||
| 5765 | if (fildes == DEV_NULL_FD) | ||
| 5766 | return count; | ||
| 5767 | else | ||
| 5768 | return write (fildes, buf, count); | ||
| 5769 | } | ||
| 5770 | |||
| 5771 | #undef rename | ||
| 5772 | int | ||
| 5773 | sys_rename (const char * old_name, const char * new_name) | ||
| 5774 | { | ||
| 5775 | char MacOldName[MAXPATHLEN+1], MacNewName[MAXPATHLEN+1]; | ||
| 5776 | |||
| 5777 | if (strcmp (old_name, new_name) == 0) | ||
| 5778 | return 0; | ||
| 5779 | |||
| 5780 | if (Unix2MacPathname (old_name, MacOldName, MAXPATHLEN+1) == 0) | ||
| 5781 | return 1; | ||
| 5782 | |||
| 5783 | if (Unix2MacPathname (new_name, MacNewName, MAXPATHLEN+1) == 0) | ||
| 5784 | return 1; | ||
| 5785 | |||
| 5786 | return rename (MacOldName, MacNewName); | ||
| 5787 | } | ||
| 5788 | |||
| 5789 | #undef fopen | ||
| 5790 | extern FILE *fopen (const char *name, const char *mode); | ||
| 5791 | FILE | ||
| 5792 | sys_fopen (const char *name, const char *mode) | ||
| 5793 | { | ||
| 5794 | char MacPathname[MAXPATHLEN+1]; | ||
| 5795 | |||
| 5796 | if (Unix2MacPathname (name, MacPathname, MAXPATHLEN+1) == 0) | ||
| 5797 | return 0; | ||
| 5798 | else | ||
| 5799 | return fopen (MacPathname, mode); | ||
| 5800 | } | ||
| 5801 | |||
| 5802 | #include <Events.h> | ||
| 5803 | |||
| 5804 | long targetTicks = 0; | ||
| 5805 | |||
| 5806 | #ifdef __MRC__ | ||
| 5807 | __sigfun alarm_signal_func = (__sigfun) 0; | ||
| 5808 | #elif __MWERKS__ | ||
| 5809 | __signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0; | ||
| 5810 | #else | ||
| 5811 | You lose!!! | ||
| 5812 | #endif | ||
| 5813 | |||
| 5814 | /* These functions simulate SIG_ALRM. The stub for function signal | ||
| 5815 | stores the signal handler function in alarm_signal_func if a | ||
| 5816 | SIG_ALRM is encountered. CheckAlarm is called in mac_read_socket, | ||
| 5817 | which emacs calls periodically. A pending alarm is represented by | ||
| 5818 | a non-zero targetTicks value. CheckAlarm calls the handler | ||
| 5819 | function pointed to by alarm_signal_func if one has been set up and | ||
| 5820 | an alarm is pending. */ | ||
| 5821 | void | ||
| 5822 | CheckAlarm () | ||
| 5823 | { | ||
| 5824 | if (targetTicks && TickCount () > targetTicks) | ||
| 5825 | { | ||
| 5826 | targetTicks = 0; | ||
| 5827 | if (alarm_signal_func) | ||
| 5828 | (*alarm_signal_func)(SIGALRM); | ||
| 5829 | } | ||
| 5830 | } | ||
| 5831 | |||
| 5832 | /* Called in sys_select to wait for an alarm signal to arrive. */ | ||
| 5833 | int | ||
| 5834 | pause () | ||
| 5835 | { | ||
| 5836 | unsigned long finalTick; | ||
| 5837 | |||
| 5838 | if (!targetTicks) /* no alarm pending */ | ||
| 5839 | return -1; | ||
| 5840 | |||
| 5841 | while (TickCount () <= targetTicks) | ||
| 5842 | Delay (1UL, &finalTick); /* wait for 1/60 second before trying again */ | ||
| 5843 | |||
| 5844 | targetTicks = 0; | ||
| 5845 | if (alarm_signal_func) | ||
| 5846 | (*alarm_signal_func)(SIGALRM); | ||
| 5847 | |||
| 5848 | return 0; | ||
| 5849 | } | ||
| 5850 | |||
| 5851 | int | ||
| 5852 | alarm (int seconds) | ||
| 5853 | { | ||
| 5854 | long remaining = targetTicks ? (TickCount () - targetTicks) / 60 : 0; | ||
| 5855 | |||
| 5856 | targetTicks = seconds ? TickCount () + 60 * seconds : 0; | ||
| 5857 | |||
| 5858 | return (remaining < 0) ? 0 : (unsigned int) remaining; | ||
| 5859 | } | ||
| 5860 | |||
| 5861 | #undef signal | ||
| 5862 | #ifdef __MRC__ | ||
| 5863 | extern __sigfun signal (int signal, __sigfun signal_func); | ||
| 5864 | __sigfun | ||
| 5865 | sys_signal (int signal_num, __sigfun signal_func) | ||
| 5866 | #elif __MWERKS__ | ||
| 5867 | extern __signal_func_ptr signal (int signal, __signal_func_ptr signal_func); | ||
| 5868 | __signal_func_ptr | ||
| 5869 | sys_signal (int signal_num, __signal_func_ptr signal_func) | ||
| 5870 | #else | ||
| 5871 | You lose!!! | ||
| 5872 | #endif | ||
| 5873 | { | ||
| 5874 | if (signal_num != SIGALRM) | ||
| 5875 | return signal (signal_num, signal_func); | ||
| 5876 | else | ||
| 5877 | { | ||
| 5878 | #ifdef __MRC__ | ||
| 5879 | __sigfun old_signal_func; | ||
| 5880 | #elif __MWERKS__ | ||
| 5881 | __signal_func_ptr old_signal_func; | ||
| 5882 | #else | ||
| 5883 | You lose!!! | ||
| 5884 | #endif | ||
| 5885 | old_signal_func = alarm_signal_func; | ||
| 5886 | alarm_signal_func = signal_func; | ||
| 5887 | return old_signal_func; | ||
| 5888 | } | ||
| 5889 | } | ||
| 5890 | |||
| 5891 | /* The time functions adjust time values according to the difference | ||
| 5892 | between the Unix and CW epoches. */ | ||
| 5893 | |||
| 5894 | #undef gmtime | ||
| 5895 | extern struct tm *gmtime (const time_t *); | ||
| 5896 | struct tm | ||
| 5897 | sys_gmtime (const time_t *timer) | ||
| 5898 | { | ||
| 5899 | time_t unixTime = *timer + CW_UNIX_EPOCH_DIFF; | ||
| 5900 | |||
| 5901 | return gmtime (&unixTime); | ||
| 5902 | } | ||
| 5903 | |||
| 5904 | #undef localtime | ||
| 5905 | extern struct tm *localtime (const time_t *); | ||
| 5906 | struct tm * | ||
| 5907 | sys_localtime (const time_t *timer) | ||
| 5908 | { | ||
| 5909 | time_t unixTime = *timer + CW_UNIX_EPOCH_DIFF; | ||
| 5910 | |||
| 5911 | return localtime (&unixTime); | ||
| 5912 | } | ||
| 5913 | |||
| 5914 | #undef ctime | ||
| 5915 | extern char *ctime (const time_t *); | ||
| 5916 | char * | ||
| 5917 | sys_ctime (const time_t *timer) | ||
| 5918 | { | ||
| 5919 | time_t unixTime = *timer + CW_UNIX_EPOCH_DIFF; | ||
| 5920 | |||
| 5921 | return ctime (&unixTime); | ||
| 5922 | } | ||
| 5923 | |||
| 5924 | #undef time | ||
| 5925 | extern time_t time (time_t *); | ||
| 5926 | time_t | ||
| 5927 | sys_time (time_t *timer) | ||
| 5928 | { | ||
| 5929 | time_t macTime = time (NULL) - CW_UNIX_EPOCH_DIFF; | ||
| 5930 | |||
| 5931 | if (timer) | ||
| 5932 | *timer = macTime; | ||
| 5933 | |||
| 5934 | return macTime; | ||
| 5935 | } | ||
| 5936 | |||
| 5937 | /* no subprocesses, empty wait */ | ||
| 5938 | int | ||
| 5939 | wait (int pid) | ||
| 5940 | { | ||
| 5941 | return 0; | ||
| 5942 | } | ||
| 5943 | |||
| 5944 | void | ||
| 5945 | croak (char *badfunc) | ||
| 5946 | { | ||
| 5947 | printf ("%s not yet implemented\r\n", badfunc); | ||
| 5948 | exit (1); | ||
| 5949 | } | ||
| 5950 | |||
| 5951 | char * | ||
| 5952 | index (const char * str, int chr) | ||
| 5953 | { | ||
| 5954 | return strchr (str, chr); | ||
| 5955 | } | ||
| 5956 | |||
| 5957 | char *e[] = { 0 }; | ||
| 5958 | char **environ = &e[0]; | ||
| 5959 | |||
| 5960 | char * | ||
| 5961 | mktemp (char *template) | ||
| 5962 | { | ||
| 5963 | int len, k; | ||
| 5964 | static seqnum = 0; | ||
| 5965 | |||
| 5966 | len = strlen (template); | ||
| 5967 | k = len - 1; | ||
| 5968 | while (k >= 0 && template[k] == 'X') | ||
| 5969 | k--; | ||
| 5970 | |||
| 5971 | k++; /* make k index of first 'X' */ | ||
| 5972 | |||
| 5973 | if (k < len) | ||
| 5974 | { | ||
| 5975 | /* Zero filled, number of digits equal to the number of X's. */ | ||
| 5976 | sprintf (&template[k], "%0*d", len-k, seqnum++); | ||
| 5977 | |||
| 5978 | return template; | ||
| 5979 | } | ||
| 5980 | else | ||
| 5981 | return 0; | ||
| 5982 | } | ||
| 5983 | |||
| 5984 | /* Emulate getpwuid, getpwnam and others. */ | ||
| 5985 | |||
| 5986 | #define PASSWD_FIELD_SIZE 256 | ||
| 5987 | |||
| 5988 | static char myPasswdName[PASSWD_FIELD_SIZE]; | ||
| 5989 | static char myPasswdDir[MAXPATHLEN+1]; | ||
| 5990 | |||
| 5991 | static struct passwd myPasswd = | ||
| 5992 | { | ||
| 5993 | myPasswdName, | ||
| 5994 | myPasswdDir, | ||
| 5995 | }; | ||
| 5996 | |||
| 5997 | /* Initialized by main () in macterm.c to pathname of emacs directory. */ | ||
| 5998 | char emacsPasswdDir[MAXPATHLEN+1]; | ||
| 5999 | |||
| 6000 | void | ||
| 6001 | InitEmacsPasswdDir () | ||
| 6002 | { | ||
| 6003 | int found = false; | ||
| 6004 | |||
| 6005 | if (getwd (emacsPasswdDir) && getwd (myPasswdDir)) | ||
| 6006 | { | ||
| 6007 | /* Need pathname of first ancestor that begins with `emacs' since | ||
| 6008 | Mac emacs application is somewhere in the emacs-20.3 tree. */ | ||
| 6009 | int len = strlen (emacsPasswdDir); | ||
| 6010 | /* J points to the "/" following the directory name being compared. */ | ||
| 6011 | int j = len - 1; | ||
| 6012 | int i = j - 1; | ||
| 6013 | while (i >= 0 && !found) | ||
| 6014 | { | ||
| 6015 | while (i >= 0 && emacsPasswdDir[i] != '/') | ||
| 6016 | i--; | ||
| 6017 | if (emacsPasswdDir[i] == '/' && i+5 < len) | ||
| 6018 | found = (strncmp (&(emacsPasswdDir[i+1]), "emacs", 5) == 0); | ||
| 6019 | if (found) | ||
| 6020 | emacsPasswdDir[j+1] = '\0'; | ||
| 6021 | else | ||
| 6022 | { | ||
| 6023 | j = i; | ||
| 6024 | i = j - 1; | ||
| 6025 | } | ||
| 6026 | } | ||
| 6027 | } | ||
| 6028 | |||
| 6029 | if (!found) | ||
| 6030 | { /* setting to "/" probably won't work, | ||
| 6031 | but set it to something anyway. */ | ||
| 6032 | strcpy (emacsPasswdDir, "/"); | ||
| 6033 | strcpy (myPasswdDir, "/"); | ||
| 6034 | } | ||
| 6035 | } | ||
| 6036 | |||
| 6037 | static struct passwd emacsPasswd = | ||
| 6038 | { | ||
| 6039 | "emacs", | ||
| 6040 | emacsPasswdDir, | ||
| 6041 | }; | ||
| 6042 | |||
| 6043 | static int myPasswdInited = 0; | ||
| 6044 | |||
| 6045 | static void | ||
| 6046 | InitMyPasswd () | ||
| 6047 | { | ||
| 6048 | char **ownerName; | ||
| 6049 | |||
| 6050 | /* Note: myPasswdDir initialized in InitEmacsPasswdDir to directory | ||
| 6051 | where Emacs was started. */ | ||
| 6052 | |||
| 6053 | ownerName = (char **) GetResource ('STR ',-16096); | ||
| 6054 | if (ownerName) | ||
| 6055 | { | ||
| 6056 | HLock (ownerName); | ||
| 6057 | BlockMove ((unsigned char *) *ownerName, | ||
| 6058 | (unsigned char *) myPasswdName, *ownerName[0] + 1); | ||
| 6059 | HUnlock (ownerName); | ||
| 6060 | p2cstr ((unsigned char *) myPasswdName); | ||
| 6061 | } | ||
| 6062 | else | ||
| 6063 | myPasswdName[0] = 0; | ||
| 6064 | } | ||
| 6065 | |||
| 6066 | struct passwd * | ||
| 6067 | getpwuid (uid_t uid) | ||
| 6068 | { | ||
| 6069 | if (!myPasswdInited) | ||
| 6070 | { | ||
| 6071 | InitMyPasswd (); | ||
| 6072 | myPasswdInited = 1; | ||
| 6073 | } | ||
| 6074 | |||
| 6075 | return &myPasswd; | ||
| 6076 | } | ||
| 6077 | |||
| 6078 | struct passwd * | ||
| 6079 | getpwnam (const char *name) | ||
| 6080 | { | ||
| 6081 | if (strcmp (name, "emacs") == 0) | ||
| 6082 | return &emacsPasswd; | ||
| 6083 | |||
| 6084 | if (!myPasswdInited) | ||
| 6085 | { | ||
| 6086 | InitMyPasswd (); | ||
| 6087 | myPasswdInited = 1; | ||
| 6088 | } | ||
| 6089 | |||
| 6090 | return &myPasswd; | ||
| 6091 | } | ||
| 6092 | |||
| 6093 | /* The functions fork, kill, sigsetmask, sigblock, request_sigio, | ||
| 6094 | setpgrp, setpriority, and unrequest_sigio are defined to be empty | ||
| 6095 | as in msdos.c. */ | ||
| 6096 | |||
| 6097 | int | ||
| 6098 | fork () | ||
| 6099 | { | ||
| 6100 | return -1; | ||
| 6101 | } | ||
| 6102 | |||
| 6103 | int | ||
| 6104 | kill (int x, int y) | ||
| 6105 | { | ||
| 6106 | return -1; | ||
| 6107 | } | ||
| 6108 | |||
| 6109 | int | ||
| 6110 | sigsetmask (int x) | ||
| 6111 | { | ||
| 6112 | return 0; | ||
| 6113 | } | ||
| 6114 | |||
| 6115 | int | ||
| 6116 | sigblock (int mask) | ||
| 6117 | { | ||
| 6118 | return 0; | ||
| 6119 | } | ||
| 6120 | |||
| 6121 | void | ||
| 6122 | request_sigio (void) | ||
| 6123 | { | ||
| 6124 | } | ||
| 6125 | |||
| 6126 | int | ||
| 6127 | setpgrp () | ||
| 6128 | { | ||
| 6129 | return 0; | ||
| 6130 | } | ||
| 6131 | |||
| 6132 | void | ||
| 6133 | unrequest_sigio (void) | ||
| 6134 | { | ||
| 6135 | } | ||
| 6136 | |||
| 6137 | /* djgpp does not implement pipe either. */ | ||
| 6138 | int | ||
| 6139 | pipe (int _fildes[2]) | ||
| 6140 | { | ||
| 6141 | errno = EACCES; | ||
| 6142 | return -1; | ||
| 6143 | } | ||
| 6144 | |||
| 6145 | /* Hard and symbolic links. */ | ||
| 6146 | int | ||
| 6147 | symlink (const char *name1, const char *name2) | ||
| 6148 | { | ||
| 6149 | errno = ENOENT; | ||
| 6150 | return -1; | ||
| 6151 | } | ||
| 6152 | |||
| 6153 | int | ||
| 6154 | link (const char *name1, const char *name2) | ||
| 6155 | { | ||
| 6156 | errno = ENOENT; | ||
| 6157 | return -1; | ||
| 6158 | } | ||
| 6159 | |||
| 6160 | int | ||
| 6161 | lstat (const char *path, struct stat *sb) | ||
| 6162 | { | ||
| 6163 | return stat (path, sb); | ||
| 6164 | } | ||
| 6165 | |||
| 6166 | int | ||
| 6167 | readlink (const char *path, char *buf, int bufsiz) | ||
| 6168 | { | ||
| 6169 | errno = ENOENT; | ||
| 6170 | return -1; | ||
| 6171 | } | ||
| 6172 | |||
| 6173 | mode_t | ||
| 6174 | umask (mode_t numask) | ||
| 6175 | { | ||
| 6176 | static mode_t mask = 022; | ||
| 6177 | mode_t oldmask = mask; | ||
| 6178 | mask = numask; | ||
| 6179 | return oldmask; | ||
| 6180 | } | ||
| 6181 | |||
| 6182 | int | ||
| 6183 | chmod (const char *path, mode_t mode) | ||
| 6184 | { | ||
| 6185 | /* say it always succeed for now */ | ||
| 6186 | return 0; | ||
| 6187 | } | ||
| 6188 | |||
| 6189 | int | ||
| 6190 | dup (int oldd) | ||
| 6191 | { | ||
| 6192 | #ifdef __MRC__ | ||
| 6193 | return fcntl (oldd, F_DUPFD, 0); | ||
| 6194 | #elif __MWERKS__ | ||
| 6195 | /* current implementation of fcntl in fcntl.mac.c simply returns old | ||
| 6196 | descriptor */ | ||
| 6197 | return fcntl (oldd, F_DUPFD); | ||
| 6198 | #else | ||
| 6199 | You lose!!! | ||
| 6200 | #endif | ||
| 6201 | } | ||
| 6202 | |||
| 6203 | /* This is from the original sysdep.c. Emulate BSD dup2. First close | ||
| 6204 | newd if it already exists. Then, attempt to dup oldd. If not | ||
| 6205 | successful, call dup2 recursively until we are, then close the | ||
| 6206 | unsuccessful ones. */ | ||
| 6207 | int | ||
| 6208 | dup2 (int oldd, int newd) | ||
| 6209 | { | ||
| 6210 | int fd, ret; | ||
| 6211 | |||
| 6212 | close (newd); | ||
| 6213 | |||
| 6214 | fd = dup (oldd); | ||
| 6215 | if (fd == -1) | ||
| 6216 | return -1; | ||
| 6217 | if (fd == newd) | ||
| 6218 | return newd; | ||
| 6219 | ret = dup2 (oldd, newd); | ||
| 6220 | close (fd); | ||
| 6221 | return ret; | ||
| 6222 | } | ||
| 6223 | |||
| 6224 | /* let it fail for now */ | ||
| 6225 | char * | ||
| 6226 | sbrk (int incr) | ||
| 6227 | { | ||
| 6228 | return (char *) -1; | ||
| 6229 | } | ||
| 6230 | |||
| 6231 | int | ||
| 6232 | fsync (int fd) | ||
| 6233 | { | ||
| 6234 | return 0; | ||
| 6235 | } | ||
| 6236 | |||
| 6237 | int | ||
| 6238 | ioctl (int d, int request, void *argp) | ||
| 6239 | { | ||
| 6240 | return -1; | ||
| 6241 | } | ||
| 6242 | |||
| 6243 | #ifdef __MRC__ | ||
| 6244 | int | ||
| 6245 | isatty (int fildes) | ||
| 6246 | { | ||
| 6247 | if (fildes >=0 && fildes <= 2) | ||
| 6248 | return 1; | ||
| 6249 | else | ||
| 6250 | return 0; | ||
| 6251 | } | ||
| 6252 | |||
| 6253 | int | ||
| 6254 | getgid () | ||
| 6255 | { | ||
| 6256 | return 100; | ||
| 6257 | } | ||
| 6258 | |||
| 6259 | int | ||
| 6260 | getegid () | ||
| 6261 | { | ||
| 6262 | return 100; | ||
| 6263 | } | ||
| 6264 | |||
| 6265 | int | ||
| 6266 | getuid () | ||
| 6267 | { | ||
| 6268 | return 200; | ||
| 6269 | } | ||
| 6270 | |||
| 6271 | int | ||
| 6272 | geteuid () | ||
| 6273 | { | ||
| 6274 | return 200; | ||
| 6275 | } | ||
| 6276 | |||
| 6277 | unsigned int | ||
| 6278 | sleep (unsigned int seconds) | ||
| 6279 | { | ||
| 6280 | unsigned long finalTick; | ||
| 6281 | |||
| 6282 | Delay (seconds * 60UL, &finalTick); | ||
| 6283 | return (0); | ||
| 6284 | } | ||
| 6285 | #endif /* __MRC__ */ | ||
| 6286 | |||
| 6287 | #ifdef __MWERKS__ | ||
| 6288 | #undef getpid | ||
| 6289 | int | ||
| 6290 | getpid () | ||
| 6291 | { | ||
| 6292 | return 9999; | ||
| 6293 | } | ||
| 6294 | #endif /* __MWERKS__ */ | ||
| 6295 | |||
| 6296 | /* Return the path to the directory in which Emacs can create | ||
| 6297 | temporary files. The MacOS "temporary items" directory cannot be | ||
| 6298 | used because it removes the file written by a process when it | ||
| 6299 | exits. In that sense it's more like "/dev/null" than "/tmp" (but | ||
| 6300 | again not exactly). And of course Emacs needs to read back the | ||
| 6301 | files written by its subprocesses. So here we write the files to a | ||
| 6302 | directory "Emacs" in the Preferences Folder. This directory is | ||
| 6303 | created if it does not exist. */ | ||
| 6304 | static char * | ||
| 6305 | GetTempDirName () | ||
| 6306 | { | ||
| 6307 | static char *TempDirName = NULL; | ||
| 6308 | short vRefNum; | ||
| 6309 | long dirID; | ||
| 6310 | OSErr err; | ||
| 6311 | Str255 dirName, fullPath; | ||
| 6312 | CInfoPBRec cpb; | ||
| 6313 | char unixDirName[MAXPATHLEN+1]; | ||
| 6314 | DIR *dir; | ||
| 6315 | |||
| 6316 | /* Cache directory name with pointer TempDirName. | ||
| 6317 | Look for it only the first time. */ | ||
| 6318 | if (!TempDirName) | ||
| 6319 | { | ||
| 6320 | err = FindFolder (kOnSystemDisk, kPreferencesFolderType, | ||
| 6321 | kCreateFolder, &vRefNum, &dirID); | ||
| 6322 | if (err != noErr) | ||
| 6323 | return NULL; | ||
| 6324 | |||
| 6325 | *fullPath = '\0'; | ||
| 6326 | cpb.dirInfo.ioNamePtr = dirName; | ||
| 6327 | cpb.dirInfo.ioDrParID = dirID; | ||
| 6328 | |||
| 6329 | /* Standard ref num to full path name loop */ | ||
| 6330 | do { | ||
| 6331 | cpb.dirInfo.ioVRefNum = vRefNum; | ||
| 6332 | cpb.dirInfo.ioFDirIndex = -1; | ||
| 6333 | cpb.dirInfo.ioDrDirID = cpb.dirInfo.ioDrParID; | ||
| 6334 | |||
| 6335 | err = PBGetCatInfo (&cpb, false); | ||
| 6336 | |||
| 6337 | p2cstr (dirName); | ||
| 6338 | strcat (dirName, ":"); | ||
| 6339 | if (strlen (fullPath) + strlen (dirName) <= MAXPATHLEN) | ||
| 6340 | { | ||
| 6341 | strcat (dirName, fullPath); | ||
| 6342 | strcpy (fullPath, dirName); | ||
| 6343 | } | ||
| 6344 | else | ||
| 6345 | return NULL; | ||
| 6346 | } | ||
| 6347 | while (cpb.dirInfo.ioDrDirID != fsRtDirID && err == noErr); | ||
| 6348 | |||
| 6349 | if (strlen (fullPath) + 6 <= MAXPATHLEN) | ||
| 6350 | strcat (fullPath, "Emacs:"); | ||
| 6351 | else | ||
| 6352 | return NULL; | ||
| 6353 | |||
| 6354 | if (Mac2UnixPathname (fullPath, unixDirName, MAXPATHLEN+1) == 0) | ||
| 6355 | return NULL; | ||
| 6356 | |||
| 6357 | dir = opendir (unixDirName); /* check whether temp directory exists */ | ||
| 6358 | if (dir) | ||
| 6359 | closedir (dir); | ||
| 6360 | else if (mkdir (unixDirName, 0700) != 0) /* create it if not */ | ||
| 6361 | return NULL; | ||
| 6362 | |||
| 6363 | TempDirName = (char *) xmalloc (strlen (unixDirName) + 1); | ||
| 6364 | strcpy (TempDirName, unixDirName); | ||
| 6365 | } | ||
| 6366 | |||
| 6367 | return TempDirName; | ||
| 6368 | } | ||
| 6369 | |||
| 6370 | char * | ||
| 6371 | getenv (const char * name) | ||
| 6372 | { | ||
| 6373 | if (strcmp (name, "TERM") == 0) | ||
| 6374 | return "vt100"; | ||
| 6375 | else if (strcmp (name, "TERMCAP") == 0) | ||
| 6376 | /* for debugging purpose when code was still outputting to dumb terminal */ | ||
| 6377 | return "d0|vt100|vt100-am|vt100am|dec vt100:do=[do]:co#100:li#32:cl=[cl]:sf=[sf]:km:\ | ||
| 6378 | :le=[le]:bs:am:cm=[cm-%d,%d]:nd=[nd]:up=[up]:ce=[ce]:cd=[cd]:so=[so]:se=[se]:\ | ||
| 6379 | :us=[us]:ue=[ue]:md=[md]:mr=[mr]:mb=[mb]:me=[me]:is=[is]:\ | ||
| 6380 | :rf=/usr/share/lib/tabset/vt100:rs=[rs]:ks=[ks]:ke=[ke]:\ | ||
| 6381 | :ku=\\036:kd=\\037:kr=\\035:kl=\\034:kb=[kb]:ho=[ho]:k1=[k1]:k2=[k2]:k3=[k3]:k4=[k4]:\ | ||
| 6382 | :pt:sr=[sr]:vt#3:xn:sc=[sc]:rc=[rc]:cs=[cs-%d,%d]"; | ||
| 6383 | else if (strcmp (name, "TMPDIR") == 0) | ||
| 6384 | return GetTempDirName (); | ||
| 6385 | else | ||
| 6386 | return (NULL); | ||
| 6387 | } | ||
| 6388 | |||
| 6389 | #ifdef __MRC__ | ||
| 6390 | #include <utsname.h> | ||
| 6391 | |||
| 6392 | int | ||
| 6393 | uname (struct utsname *name) | ||
| 6394 | { | ||
| 6395 | char **systemName; | ||
| 6396 | systemName = GetString (-16413); /* IM - Resource Manager Reference */ | ||
| 6397 | if (systemName) | ||
| 6398 | { | ||
| 6399 | BlockMove (*systemName, name->nodename, (*systemName)[0]+1); | ||
| 6400 | p2cstr (name->nodename); | ||
| 6401 | } | ||
| 6402 | else | ||
| 6403 | return -1; | ||
| 6404 | } | ||
| 6405 | #endif | ||
| 6406 | |||
| 6407 | #include <Processes.h> | ||
| 6408 | #include <EPPC.h> | ||
| 6409 | |||
| 6410 | /* Event class of HLE sent to subprocess. */ | ||
| 6411 | const OSType kEmacsSubprocessSend = 'ESND'; | ||
| 6412 | /* Event class of HLE sent back from subprocess. */ | ||
| 6413 | const OSType kEmacsSubprocessReply = 'ERPY'; | ||
| 6414 | |||
| 6415 | char * | ||
| 6416 | mystrchr (char *s, char c) | ||
| 6417 | { | ||
| 6418 | while (*s && *s != c) | ||
| 6419 | { | ||
| 6420 | if (*s == '\\') | ||
| 6421 | s++; | ||
| 6422 | s++; | ||
| 6423 | } | ||
| 6424 | |||
| 6425 | if (*s) | ||
| 6426 | { | ||
| 6427 | *s = '\0'; | ||
| 6428 | return s; | ||
| 6429 | } | ||
| 6430 | else | ||
| 6431 | return NULL; | ||
| 6432 | } | ||
| 6433 | |||
| 6434 | char * | ||
| 6435 | mystrtok (char *s) | ||
| 6436 | { | ||
| 6437 | while (*s) | ||
| 6438 | s++; | ||
| 6439 | |||
| 6440 | return s + 1; | ||
| 6441 | } | ||
| 6442 | |||
| 6443 | void | ||
| 6444 | mystrcpy (char *to, char *from) | ||
| 6445 | { | ||
| 6446 | while (*from) | ||
| 6447 | { | ||
| 6448 | if (*from == '\\') | ||
| 6449 | from++; | ||
| 6450 | *to++ = *from++; | ||
| 6451 | } | ||
| 6452 | *to = '\0'; | ||
| 6453 | } | ||
| 6454 | |||
| 6455 | /* Start a Mac subprocess. Arguments for it is passed in argv (null | ||
| 6456 | terminated). The process should run with the default directory | ||
| 6457 | "workdir", read input from "infn", and write output and error to | ||
| 6458 | "outfn" and "errfn", resp. The Process Manager call | ||
| 6459 | LaunchApplication is used to start the subprocess. We use high | ||
| 6460 | level events as the mechanism to pass arguments to the subprocess | ||
| 6461 | and to make Emacs wait for the subprocess to terminate and pass | ||
| 6462 | back a result code. The bulk of the code here packs the arguments | ||
| 6463 | into one message to be passed together with the high level event. | ||
| 6464 | Emacs also sometimes starts a subprocess using a shell to perform | ||
| 6465 | wildcard filename expansion. Since we don't really have a shell on | ||
| 6466 | the Mac, this case is detected and the starting of the shell is | ||
| 6467 | by-passed. We really need to add code here to do filename | ||
| 6468 | expansion to support such functionality. */ | ||
| 6469 | int | ||
| 6470 | run_mac_command (argv, workdir, infn, outfn, errfn) | ||
| 6471 | unsigned char **argv; | ||
| 6472 | const char *workdir; | ||
| 6473 | const char *infn, *outfn, errfn; | ||
| 6474 | { | ||
| 6475 | char macappname[MAXPATHLEN+1], macworkdir[MAXPATHLEN+1]; | ||
| 6476 | char macinfn[MAXPATHLEN+1], macoutfn[MAXPATHLEN+1], macerrfn[MAXPATHLEN+1]; | ||
| 6477 | int paramlen, argc, newargc, j, retries; | ||
| 6478 | char **newargv, *param, *p; | ||
| 6479 | OSErr iErr; | ||
| 6480 | FSSpec spec; | ||
| 6481 | LaunchParamBlockRec lpbr; | ||
| 6482 | EventRecord sendEvent, replyEvent; | ||
| 6483 | RgnHandle cursorRegionHdl; | ||
| 6484 | TargetID targ; | ||
| 6485 | unsigned long refCon, len; | ||
| 6486 | |||
| 6487 | if (Unix2MacPathname (workdir, macworkdir, MAXPATHLEN+1) == 0) | ||
| 6488 | return -1; | ||
| 6489 | if (Unix2MacPathname (infn, macinfn, MAXPATHLEN+1) == 0) | ||
| 6490 | return -1; | ||
| 6491 | if (Unix2MacPathname (outfn, macoutfn, MAXPATHLEN+1) == 0) | ||
| 6492 | return -1; | ||
| 6493 | if (Unix2MacPathname (errfn, macerrfn, MAXPATHLEN+1) == 0) | ||
| 6494 | return -1; | ||
| 6495 | |||
| 6496 | paramlen = strlen (macworkdir) + strlen (macinfn) + strlen (macoutfn) + strlen (macerrfn) + 4; | ||
| 6497 | /* count nulls at end of strings */ | ||
| 6498 | |||
| 6499 | argc = 0; | ||
| 6500 | while (argv[argc]) | ||
| 6501 | argc++; | ||
| 6502 | |||
| 6503 | if (argc == 0) | ||
| 6504 | return -1; | ||
| 6505 | |||
| 6506 | /* If a subprocess is invoked with a shell, we receive 3 arguments of the form: | ||
| 6507 | "<path to emacs bins>/sh" "-c" "<path to emacs bins>/<command> <command args>" */ | ||
| 6508 | j = strlen (argv[0]); | ||
| 6509 | if (j >= 3 && strcmp (argv[0]+j-3, "/sh") == 0 && argc == 3 && strcmp (argv[1], "-c") == 0) | ||
| 6510 | { | ||
| 6511 | char *command, *t, tempmacpathname[MAXPATHLEN+1]; | ||
| 6512 | |||
| 6513 | /* The arguments for the command in argv[2] are separated by | ||
| 6514 | spaces. Count them and put the count in newargc. */ | ||
| 6515 | command = (char *) alloca (strlen (argv[2])+2); | ||
| 6516 | strcpy (command, argv[2]); | ||
| 6517 | if (command[strlen (command) - 1] != ' ') | ||
| 6518 | strcat (command, " "); | ||
| 6519 | |||
| 6520 | t = command; | ||
| 6521 | newargc = 0; | ||
| 6522 | t = mystrchr (t, ' '); | ||
| 6523 | while (t) | ||
| 6524 | { | ||
| 6525 | newargc++; | ||
| 6526 | t = mystrchr (t+1, ' '); | ||
| 6527 | } | ||
| 6528 | |||
| 6529 | newargv = (char **) alloca (sizeof (char *) * newargc); | ||
| 6530 | |||
| 6531 | t = command; | ||
| 6532 | for (j = 0; j < newargc; j++) | ||
| 6533 | { | ||
| 6534 | newargv[j] = (char *) alloca (strlen (t) + 1); | ||
| 6535 | mystrcpy (newargv[j], t); | ||
| 6536 | |||
| 6537 | t = mystrtok (t); | ||
| 6538 | paramlen += strlen (newargv[j]) + 1; | ||
| 6539 | } | ||
| 6540 | |||
| 6541 | if (strncmp (newargv[0], "~emacs/", 7) == 0) | ||
| 6542 | { | ||
| 6543 | if (Unix2MacPathname (newargv[0], tempmacpathname, MAXPATHLEN+1) == 0) | ||
| 6544 | return -1; | ||
| 6545 | } | ||
| 6546 | else | ||
| 6547 | { /* sometimes Emacs call "sh" without a path for the command */ | ||
| 6548 | #if 0 | ||
| 6549 | char *t = (char *) alloca (strlen (newargv[0]) + 7 + 1); | ||
| 6550 | strcpy (t, "~emacs/"); | ||
| 6551 | strcat (t, newargv[0]); | ||
| 6552 | #endif | ||
| 6553 | Lisp_Object path; | ||
| 6554 | openp (Vexec_path, build_string (newargv[0]), EXEC_SUFFIXES, &path, 1); | ||
| 6555 | |||
| 6556 | if (NILP (path)) | ||
| 6557 | return -1; | ||
| 6558 | if (Unix2MacPathname (XSTRING (path)->data, tempmacpathname, MAXPATHLEN+1) == 0) | ||
| 6559 | return -1; | ||
| 6560 | } | ||
| 6561 | strcpy (macappname, tempmacpathname); | ||
| 6562 | } | ||
| 6563 | else | ||
| 6564 | { | ||
| 6565 | if (Unix2MacPathname (argv[0], macappname, MAXPATHLEN+1) == 0) | ||
| 6566 | return -1; | ||
| 6567 | |||
| 6568 | newargv = (char **) alloca (sizeof (char *) * argc); | ||
| 6569 | newargc = argc; | ||
| 6570 | for (j = 1; j < argc; j++) | ||
| 6571 | { | ||
| 6572 | if (strncmp (argv[j], "~emacs/", 7) == 0) | ||
| 6573 | { | ||
| 6574 | char *t = strchr (argv[j], ' '); | ||
| 6575 | if (t) | ||
| 6576 | { | ||
| 6577 | char tempcmdname[MAXPATHLEN+1], tempmaccmdname[MAXPATHLEN+1]; | ||
| 6578 | strncpy (tempcmdname, argv[j], t-argv[j]); | ||
| 6579 | tempcmdname[t-argv[j]] = '\0'; | ||
| 6580 | if (Unix2MacPathname (tempcmdname, tempmaccmdname, MAXPATHLEN+1) == 0) | ||
| 6581 | return -1; | ||
| 6582 | newargv[j] = (char *) alloca (strlen (tempmaccmdname) + strlen (t) + 1); | ||
| 6583 | strcpy (newargv[j], tempmaccmdname); | ||
| 6584 | strcat (newargv[j], t); | ||
| 6585 | } | ||
| 6586 | else | ||
| 6587 | { | ||
| 6588 | char tempmaccmdname[MAXPATHLEN+1]; | ||
| 6589 | if (Unix2MacPathname (argv[j], tempmaccmdname, MAXPATHLEN+1) == 0) | ||
| 6590 | return -1; | ||
| 6591 | newargv[j] = (char *) alloca (strlen (tempmaccmdname)+1); | ||
| 6592 | strcpy (newargv[j], tempmaccmdname); | ||
| 6593 | } | ||
| 6594 | } | ||
| 6595 | else | ||
| 6596 | newargv[j] = argv[j]; | ||
| 6597 | paramlen += strlen (newargv[j]) + 1; | ||
| 6598 | } | ||
| 6599 | } | ||
| 6600 | |||
| 6601 | /* After expanding all the arguments, we now know the length of the parameter block to be | ||
| 6602 | sent to the subprocess as a message attached to the HLE. */ | ||
| 6603 | param = (char *) xmalloc (paramlen + 1); | ||
| 6604 | if (!param) | ||
| 6605 | return -1; | ||
| 6606 | |||
| 6607 | p = param; | ||
| 6608 | *p++ = newargc; /* first byte of message contains number of arguments for command */ | ||
| 6609 | strcpy (p, macworkdir); | ||
| 6610 | p += strlen (macworkdir); | ||
| 6611 | *p++ = '\0'; /* null terminate strings sent so it's possible to use strcpy over there */ | ||
| 6612 | strcpy (p, macinfn); | ||
| 6613 | p += strlen (macinfn); | ||
| 6614 | *p++ = '\0'; | ||
| 6615 | strcpy (p, macoutfn); | ||
| 6616 | p += strlen (macoutfn); | ||
| 6617 | *p++ = '\0'; | ||
| 6618 | strcpy (p, macerrfn); | ||
| 6619 | p += strlen (macerrfn); | ||
| 6620 | *p++ = '\0'; | ||
| 6621 | for (j = 1; j < newargc; j++) { | ||
| 6622 | strcpy (p, newargv[j]); | ||
| 6623 | p += strlen (newargv[j]); | ||
| 6624 | *p++ = '\0'; | ||
| 6625 | } | ||
| 6626 | |||
| 6627 | c2pstr (macappname); | ||
| 6628 | |||
| 6629 | iErr = FSMakeFSSpec (0, 0, macappname, &spec); | ||
| 6630 | |||
| 6631 | if (iErr != noErr) { | ||
| 6632 | xfree (param); | ||
| 6633 | return -1; | ||
| 6634 | } | ||
| 6635 | |||
| 6636 | lpbr.launchBlockID = extendedBlock; | ||
| 6637 | lpbr.launchEPBLength = extendedBlockLen; | ||
| 6638 | lpbr.launchControlFlags = launchContinue + launchNoFileFlags; | ||
| 6639 | lpbr.launchAppSpec = &spec; | ||
| 6640 | lpbr.launchAppParameters = NULL; | ||
| 6641 | |||
| 6642 | iErr = LaunchApplication (&lpbr); /* call the subprocess */ | ||
| 6643 | if (iErr != noErr) | ||
| 6644 | { | ||
| 6645 | xfree (param); | ||
| 6646 | return -1; | ||
| 6647 | } | ||
| 6648 | |||
| 6649 | sendEvent.what = kHighLevelEvent; | ||
| 6650 | sendEvent.message = kEmacsSubprocessSend; /* Event ID stored in "where" unused */ | ||
| 6651 | |||
| 6652 | retries = 3; | ||
| 6653 | do { /* OS may think current subprocess has terminated if previous one terminated recently */ | ||
| 6654 | iErr = PostHighLevelEvent (&sendEvent, &lpbr.launchProcessSN, 0, param, paramlen + 1, receiverIDisPSN); | ||
| 6655 | } | ||
| 6656 | while (iErr == sessClosedErr && retries-- > 0); | ||
| 6657 | |||
| 6658 | if (iErr != noErr) { | ||
| 6659 | xfree (param); | ||
| 6660 | return -1; | ||
| 6661 | } | ||
| 6662 | |||
| 6663 | cursorRegionHdl = NewRgn (); | ||
| 6664 | |||
| 6665 | /* Wait for the subprocess to finish, when it will send us a ERPY high level event */ | ||
| 6666 | while (1) | ||
| 6667 | if (WaitNextEvent (highLevelEventMask, &replyEvent, 180, cursorRegionHdl) && replyEvent.message == kEmacsSubprocessReply) | ||
| 6668 | break; | ||
| 6669 | |||
| 6670 | /* The return code is sent through the refCon */ | ||
| 6671 | iErr = AcceptHighLevelEvent (&targ, &refCon, NULL, &len); | ||
| 6672 | if (iErr != noErr) { | ||
| 6673 | DisposeHandle ((Handle) cursorRegionHdl); | ||
| 6674 | xfree (param); | ||
| 6675 | return -1; | ||
| 6676 | } | ||
| 6677 | |||
| 6678 | DisposeHandle ((Handle) cursorRegionHdl); | ||
| 6679 | xfree (param); | ||
| 6680 | |||
| 6681 | return refCon; | ||
| 6682 | } | ||
| 6683 | |||
| 6684 | DIR * | ||
| 6685 | opendir (const char *dirname) | ||
| 6686 | { | ||
| 6687 | char MacPathname[MAXPATHLEN+1]; | ||
| 6688 | DIR *dirp; | ||
| 6689 | CInfoPBRec cipb; | ||
| 6690 | int len; | ||
| 6691 | |||
| 6692 | dirp = (DIR *) xmalloc (sizeof (DIR)); | ||
| 6693 | if (!dirp) | ||
| 6694 | return 0; | ||
| 6695 | |||
| 6696 | /* Handle special case when dirname is "/": sets up for readir to | ||
| 6697 | get all mount volumes. */ | ||
| 6698 | if (strcmp (dirname, "/") == 0) { | ||
| 6699 | dirp->getting_volumes = 1; /* special all mounted volumes DIR struct */ | ||
| 6700 | dirp->current_index = 1; /* index for first volume */ | ||
| 6701 | return dirp; | ||
| 6702 | } | ||
| 6703 | |||
| 6704 | /* Handle typical cases: not accessing all mounted volumes. */ | ||
| 6705 | if (Unix2MacPathname (dirname, MacPathname, MAXPATHLEN+1) == 0) | ||
| 6706 | return 0; | ||
| 6707 | |||
| 6708 | /* Emacs calls opendir without the trailing '/', Mac needs trailing ':' */ | ||
| 6709 | len = strlen (MacPathname); | ||
| 6710 | if (MacPathname[len - 1] != ':' && len < MAXPATHLEN) | ||
| 6711 | strcat (MacPathname, ":"); | ||
| 6712 | |||
| 6713 | c2pstr (MacPathname); | ||
| 6714 | cipb.hFileInfo.ioNamePtr = MacPathname; /* using full pathname so vRefNum and dirID ignored */ | ||
| 6715 | cipb.hFileInfo.ioVRefNum = 0; | ||
| 6716 | cipb.hFileInfo.ioDirID = 0; | ||
| 6717 | cipb.hFileInfo.ioFDirIndex = 0; /* set to 0 to get information about specific dir or file */ | ||
| 6718 | |||
| 6719 | errno = PBGetCatInfo (&cipb, false); | ||
| 6720 | if (errno != noErr) { | ||
| 6721 | errno = ENOENT; | ||
| 6722 | return 0; | ||
| 6723 | } | ||
| 6724 | |||
| 6725 | if (!(cipb.hFileInfo.ioFlAttrib & 0x10)) /* bit 4 = 1 for directories */ | ||
| 6726 | return 0; /* not a directory */ | ||
| 6727 | |||
| 6728 | dirp->dir_id = cipb.dirInfo.ioDrDirID; /* used later in readdir */ | ||
| 6729 | dirp->getting_volumes = 0; | ||
| 6730 | dirp->current_index = 1; /* index for first file/directory */ | ||
| 6731 | |||
| 6732 | return dirp; | ||
| 6733 | } | ||
| 6734 | |||
| 6735 | int | ||
| 6736 | closedir (DIR *dp) | ||
| 6737 | { | ||
| 6738 | xfree (dp); | ||
| 6739 | return 0; | ||
| 6740 | } | ||
| 6741 | |||
| 6742 | struct dirent * | ||
| 6743 | readdir (DIR *dp) | ||
| 6744 | { | ||
| 6745 | HParamBlockRec HPBlock; | ||
| 6746 | CInfoPBRec cipb; | ||
| 6747 | static struct dirent s_dirent; | ||
| 6748 | static Str255 s_name; | ||
| 6749 | int done; | ||
| 6750 | |||
| 6751 | /* Handle the root directory containing the mounted volumes. Call | ||
| 6752 | PBHGetVInfo specifying an index to obtain the info for a volume. | ||
| 6753 | PBHGetVInfo returns an error when it receives an index beyond the | ||
| 6754 | last volume, at which time we should return a nil dirent struct | ||
| 6755 | pointer. */ | ||
| 6756 | if (dp->getting_volumes) { | ||
| 6757 | HPBlock.volumeParam.ioNamePtr = s_name; | ||
| 6758 | HPBlock.volumeParam.ioVRefNum = 0; | ||
| 6759 | HPBlock.volumeParam.ioVolIndex = dp->current_index; | ||
| 6760 | |||
| 6761 | errno = PBHGetVInfo (&HPBlock, false); | ||
| 6762 | if (errno != noErr) { | ||
| 6763 | errno = ENOENT; | ||
| 6764 | return 0; | ||
| 6765 | } | ||
| 6766 | |||
| 6767 | p2cstr (s_name); | ||
| 6768 | strcat (s_name, "/"); /* need "/" for stat to work correctly */ | ||
| 6769 | |||
| 6770 | dp->current_index++; | ||
| 6771 | |||
| 6772 | s_dirent.d_ino = cipb.dirInfo.ioDrDirID; | ||
| 6773 | s_dirent.d_name = s_name; | ||
| 6774 | |||
| 6775 | return &s_dirent; | ||
| 6776 | } | ||
| 6777 | else { | ||
| 6778 | cipb.hFileInfo.ioVRefNum = 0; | ||
| 6779 | cipb.hFileInfo.ioNamePtr = s_name; /* location to receive filename returned */ | ||
| 6780 | |||
| 6781 | /* return only visible files */ | ||
| 6782 | done = false; | ||
| 6783 | while (!done) { | ||
| 6784 | cipb.hFileInfo.ioDirID = dp->dir_id; /* directory ID found by opendir */ | ||
| 6785 | cipb.hFileInfo.ioFDirIndex = dp->current_index; | ||
| 6786 | |||
| 6787 | errno = PBGetCatInfo (&cipb, false); | ||
| 6788 | if (errno != noErr) { | ||
| 6789 | errno = ENOENT; | ||
| 6790 | return 0; | ||
| 6791 | } | ||
| 6792 | |||
| 6793 | /* insist on an visibile entry */ | ||
| 6794 | if (cipb.hFileInfo.ioFlAttrib & 0x10) /* directory? */ | ||
| 6795 | done = !(cipb.dirInfo.ioDrUsrWds.frFlags & fInvisible); | ||
| 6796 | else | ||
| 6797 | done = !(cipb.hFileInfo.ioFlFndrInfo.fdFlags & fInvisible); | ||
| 6798 | |||
| 6799 | dp->current_index++; | ||
| 6800 | } | ||
| 6801 | |||
| 6802 | p2cstr (s_name); | ||
| 6803 | |||
| 6804 | s_dirent.d_ino = cipb.dirInfo.ioDrDirID; /* value unimportant: non-zero for valid file */ | ||
| 6805 | s_dirent.d_name = s_name; | ||
| 6806 | |||
| 6807 | return &s_dirent; | ||
| 6808 | } | ||
| 6809 | } | ||
| 6810 | |||
| 6811 | char * | ||
| 6812 | getwd (char *path) | ||
| 6813 | { | ||
| 6814 | char MacPathname[MAXPATHLEN+1]; | ||
| 6815 | Str255 directoryName; | ||
| 6816 | OSErr errno; | ||
| 6817 | CInfoPBRec cipb; | ||
| 6818 | |||
| 6819 | MacPathname[0] = '\0'; | ||
| 6820 | directoryName[0] = '\0'; | ||
| 6821 | cipb.dirInfo.ioDrParID = 0; | ||
| 6822 | cipb.dirInfo.ioNamePtr = directoryName; /* empty string = default directory */ | ||
| 6823 | |||
| 6824 | do { | ||
| 6825 | cipb.dirInfo.ioVRefNum = 0; | ||
| 6826 | cipb.dirInfo.ioFDirIndex = -1; | ||
| 6827 | cipb.dirInfo.ioDrDirID = cipb.dirInfo.ioDrParID; /* go up to parent each time */ | ||
| 6828 | |||
| 6829 | errno = PBGetCatInfo (&cipb, false); | ||
| 6830 | if (errno != noErr) { | ||
| 6831 | errno = ENOENT; | ||
| 6832 | return 0; | ||
| 6833 | } | ||
| 6834 | |||
| 6835 | p2cstr (directoryName); | ||
| 6836 | strcat (directoryName, ":"); | ||
| 6837 | strcat (directoryName, MacPathname); /* attach to front since going up directory tree */ | ||
| 6838 | strcpy (MacPathname, directoryName); | ||
| 6839 | } while (cipb.dirInfo.ioDrDirID != fsRtDirID); /* until volume's root directory */ | ||
| 6840 | |||
| 6841 | if (Mac2UnixPathname (MacPathname, path, MAXPATHLEN+1) == 0) | ||
| 6842 | return 0; | ||
| 6843 | else | ||
| 6844 | return path; | ||
| 6845 | } | ||
| 6846 | 5291 | ||
| 6847 | #endif /* macintosh */ | ||
diff --git a/src/term.c b/src/term.c index e704f0db0bb..c33d0553a1a 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -51,6 +51,9 @@ extern int tgetnum P_ ((char *id)); | |||
| 51 | #ifdef HAVE_X_WINDOWS | 51 | #ifdef HAVE_X_WINDOWS |
| 52 | #include "xterm.h" | 52 | #include "xterm.h" |
| 53 | #endif | 53 | #endif |
| 54 | #ifdef macintosh | ||
| 55 | #include "macterm.h" | ||
| 56 | #endif | ||
| 54 | 57 | ||
| 55 | static void turn_on_face P_ ((struct frame *, int face_id)); | 58 | static void turn_on_face P_ ((struct frame *, int face_id)); |
| 56 | static void turn_off_face P_ ((struct frame *, int face_id)); | 59 | static void turn_off_face P_ ((struct frame *, int face_id)); |
diff --git a/src/window.c b/src/window.c index 215ceea847f..ee7a10f9806 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -42,6 +42,9 @@ Boston, MA 02111-1307, USA. */ | |||
| 42 | #ifdef MSDOS | 42 | #ifdef MSDOS |
| 43 | #include "msdos.h" | 43 | #include "msdos.h" |
| 44 | #endif | 44 | #endif |
| 45 | #ifdef macintosh | ||
| 46 | #include "macterm.h" | ||
| 47 | #endif | ||
| 45 | 48 | ||
| 46 | #ifndef max | 49 | #ifndef max |
| 47 | #define max(a, b) ((a) < (b) ? (b) : (a)) | 50 | #define max(a, b) ((a) < (b) ? (b) : (a)) |
diff --git a/src/xdisp.c b/src/xdisp.c index 12574dd5d07..97791fb5e21 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -194,13 +194,16 @@ Boston, MA 02111-1307, USA. */ | |||
| 194 | #ifdef WINDOWSNT | 194 | #ifdef WINDOWSNT |
| 195 | #include "w32term.h" | 195 | #include "w32term.h" |
| 196 | #endif | 196 | #endif |
| 197 | #ifdef macintosh | ||
| 198 | #include "macterm.h" | ||
| 199 | #endif | ||
| 197 | 200 | ||
| 198 | #define min(a, b) ((a) < (b) ? (a) : (b)) | 201 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
| 199 | #define max(a, b) ((a) > (b) ? (a) : (b)) | 202 | #define max(a, b) ((a) > (b) ? (a) : (b)) |
| 200 | 203 | ||
| 201 | #define INFINITY 10000000 | 204 | #define INFINITY 10000000 |
| 202 | 205 | ||
| 203 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 206 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 204 | extern void set_frame_menubar P_ ((struct frame *f, int, int)); | 207 | extern void set_frame_menubar P_ ((struct frame *f, int, int)); |
| 205 | extern int pending_menu_activation; | 208 | extern int pending_menu_activation; |
| 206 | #endif | 209 | #endif |
| @@ -767,7 +770,7 @@ window_text_bottom_y (w) | |||
| 767 | { | 770 | { |
| 768 | struct frame *f = XFRAME (w->frame); | 771 | struct frame *f = XFRAME (w->frame); |
| 769 | int height = XFASTINT (w->height) * CANON_Y_UNIT (f); | 772 | int height = XFASTINT (w->height) * CANON_Y_UNIT (f); |
| 770 | 773 | ||
| 771 | if (WINDOW_WANTS_MODELINE_P (w)) | 774 | if (WINDOW_WANTS_MODELINE_P (w)) |
| 772 | height -= CURRENT_MODE_LINE_HEIGHT (w); | 775 | height -= CURRENT_MODE_LINE_HEIGHT (w); |
| 773 | return height; | 776 | return height; |
| @@ -6392,6 +6395,8 @@ echo_area_display (update_frame_p) | |||
| 6392 | if (!FRAME_VISIBLE_P (f) || !f->glyphs_initialized_p) | 6395 | if (!FRAME_VISIBLE_P (f) || !f->glyphs_initialized_p) |
| 6393 | return 0; | 6396 | return 0; |
| 6394 | 6397 | ||
| 6398 | /* The terminal frame is used as the first Emacs frame on the Mac OS. */ | ||
| 6399 | #ifndef macintosh | ||
| 6395 | #ifdef HAVE_WINDOW_SYSTEM | 6400 | #ifdef HAVE_WINDOW_SYSTEM |
| 6396 | /* When Emacs starts, selected_frame may be a visible terminal | 6401 | /* When Emacs starts, selected_frame may be a visible terminal |
| 6397 | frame, even if we run under a window system. If we let this | 6402 | frame, even if we run under a window system. If we let this |
| @@ -6400,6 +6405,7 @@ echo_area_display (update_frame_p) | |||
| 6400 | && !NILP (Vwindow_system)) | 6405 | && !NILP (Vwindow_system)) |
| 6401 | return 0; | 6406 | return 0; |
| 6402 | #endif /* HAVE_WINDOW_SYSTEM */ | 6407 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 6408 | #endif | ||
| 6403 | 6409 | ||
| 6404 | /* Redraw garbaged frames. */ | 6410 | /* Redraw garbaged frames. */ |
| 6405 | if (frame_garbaged) | 6411 | if (frame_garbaged) |
| @@ -6732,7 +6738,7 @@ update_menu_bar (f, save_match_data) | |||
| 6732 | 6738 | ||
| 6733 | if (FRAME_WINDOW_P (f) | 6739 | if (FRAME_WINDOW_P (f) |
| 6734 | ? | 6740 | ? |
| 6735 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 6741 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 6736 | FRAME_EXTERNAL_MENU_BAR (f) | 6742 | FRAME_EXTERNAL_MENU_BAR (f) |
| 6737 | #else | 6743 | #else |
| 6738 | FRAME_MENU_BAR_LINES (f) > 0 | 6744 | FRAME_MENU_BAR_LINES (f) > 0 |
| @@ -6779,8 +6785,14 @@ update_menu_bar (f, save_match_data) | |||
| 6779 | FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); | 6785 | FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
| 6780 | 6786 | ||
| 6781 | /* Redisplay the menu bar in case we changed it. */ | 6787 | /* Redisplay the menu bar in case we changed it. */ |
| 6782 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 6788 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 6783 | if (FRAME_WINDOW_P (f)) | 6789 | if (FRAME_WINDOW_P (f) |
| 6790 | #if defined (macintosh) | ||
| 6791 | /* All frames on Mac OS share the same menubar. So only the | ||
| 6792 | selected frame should be allowed to set it. */ | ||
| 6793 | && f == SELECTED_FRAME () | ||
| 6794 | #endif | ||
| 6795 | ) | ||
| 6784 | set_frame_menubar (f, 0, 0); | 6796 | set_frame_menubar (f, 0, 0); |
| 6785 | else | 6797 | else |
| 6786 | /* On a terminal screen, the menu bar is an ordinary screen | 6798 | /* On a terminal screen, the menu bar is an ordinary screen |
| @@ -9666,7 +9678,7 @@ redisplay_window (window, just_this_one_p) | |||
| 9666 | 9678 | ||
| 9667 | if (FRAME_WINDOW_P (f)) | 9679 | if (FRAME_WINDOW_P (f)) |
| 9668 | { | 9680 | { |
| 9669 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 9681 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (macintosh) |
| 9670 | redisplay_menu_p = FRAME_EXTERNAL_MENU_BAR (f); | 9682 | redisplay_menu_p = FRAME_EXTERNAL_MENU_BAR (f); |
| 9671 | #else | 9683 | #else |
| 9672 | redisplay_menu_p = FRAME_MENU_BAR_LINES (f) > 0; | 9684 | redisplay_menu_p = FRAME_MENU_BAR_LINES (f) > 0; |
| @@ -12113,6 +12125,10 @@ display_menu_bar (w) | |||
| 12113 | if (FRAME_X_P (f)) | 12125 | if (FRAME_X_P (f)) |
| 12114 | return; | 12126 | return; |
| 12115 | #endif | 12127 | #endif |
| 12128 | #ifdef macintosh | ||
| 12129 | if (FRAME_MAC_P (f)) | ||
| 12130 | return; | ||
| 12131 | #endif | ||
| 12116 | 12132 | ||
| 12117 | #ifdef USE_X_TOOLKIT | 12133 | #ifdef USE_X_TOOLKIT |
| 12118 | xassert (!FRAME_WINDOW_P (f)); | 12134 | xassert (!FRAME_WINDOW_P (f)); |
diff --git a/src/xfaces.c b/src/xfaces.c index f12ec242e7f..b0c5dc01258 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -218,6 +218,33 @@ Boston, MA 02111-1307, USA. */ | |||
| 218 | #define FONT_WIDTH FONT_MAX_WIDTH | 218 | #define FONT_WIDTH FONT_MAX_WIDTH |
| 219 | #endif /* WINDOWSNT */ | 219 | #endif /* WINDOWSNT */ |
| 220 | 220 | ||
| 221 | #ifdef macintosh | ||
| 222 | #include "macterm.h" | ||
| 223 | #define x_display_info mac_display_info | ||
| 224 | #define check_x check_mac | ||
| 225 | |||
| 226 | extern XGCValues *XCreateGC (void *, WindowPtr, unsigned long, XGCValues *); | ||
| 227 | |||
| 228 | static INLINE GC | ||
| 229 | x_create_gc (f, mask, xgcv) | ||
| 230 | struct frame *f; | ||
| 231 | unsigned long mask; | ||
| 232 | XGCValues *xgcv; | ||
| 233 | { | ||
| 234 | GC gc; | ||
| 235 | gc = XCreateGC (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), mask, xgcv); | ||
| 236 | return gc; | ||
| 237 | } | ||
| 238 | |||
| 239 | static INLINE void | ||
| 240 | x_free_gc (f, gc) | ||
| 241 | struct frame *f; | ||
| 242 | GC gc; | ||
| 243 | { | ||
| 244 | XFreeGC (FRAME_MAC_DISPLAY (f), gc); | ||
| 245 | } | ||
| 246 | #endif | ||
| 247 | |||
| 221 | #include "buffer.h" | 248 | #include "buffer.h" |
| 222 | #include "dispextern.h" | 249 | #include "dispextern.h" |
| 223 | #include "blockinput.h" | 250 | #include "blockinput.h" |
| @@ -1304,7 +1331,6 @@ defined_color (f, color_name, color_def, alloc) | |||
| 1304 | #endif | 1331 | #endif |
| 1305 | #ifdef macintosh | 1332 | #ifdef macintosh |
| 1306 | else if (FRAME_MAC_P (f)) | 1333 | else if (FRAME_MAC_P (f)) |
| 1307 | /* FIXME: mac_defined_color doesn't exist! */ | ||
| 1308 | return mac_defined_color (f, color_name, color_def, alloc); | 1334 | return mac_defined_color (f, color_name, color_def, alloc); |
| 1309 | #endif | 1335 | #endif |
| 1310 | else | 1336 | else |
| @@ -1800,8 +1826,11 @@ static struct frame *font_frame; | |||
| 1800 | font height, then for weight, then for slant.' This variable can be | 1826 | font height, then for weight, then for slant.' This variable can be |
| 1801 | set via set-face-font-sort-order. */ | 1827 | set via set-face-font-sort-order. */ |
| 1802 | 1828 | ||
| 1829 | #ifdef macintosh | ||
| 1830 | static int font_sort_order[4] = { XLFD_SWIDTH, XLFD_POINT_SIZE, XLFD_WEIGHT, XLFD_SLANT }; | ||
| 1831 | #else | ||
| 1803 | static int font_sort_order[4]; | 1832 | static int font_sort_order[4]; |
| 1804 | 1833 | #endif | |
| 1805 | 1834 | ||
| 1806 | /* Look up FONT.fields[FIELD_INDEX] in TABLE which has DIM entries. | 1835 | /* Look up FONT.fields[FIELD_INDEX] in TABLE which has DIM entries. |
| 1807 | TABLE must be sorted by TABLE[i]->name in ascending order. Value | 1836 | TABLE must be sorted by TABLE[i]->name in ascending order. Value |
| @@ -2242,7 +2271,7 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, | |||
| 2242 | names = XListFonts (dpy, pattern, nfonts, &n); | 2271 | names = XListFonts (dpy, pattern, nfonts, &n); |
| 2243 | UNBLOCK_INPUT; | 2272 | UNBLOCK_INPUT; |
| 2244 | #endif /* HAVE_X_WINDOWS */ | 2273 | #endif /* HAVE_X_WINDOWS */ |
| 2245 | #ifdef WINDOWSNT | 2274 | #if defined (WINDOWSNT) || defined (macintosh) |
| 2246 | /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be | 2275 | /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be |
| 2247 | better to do it the other way around. */ | 2276 | better to do it the other way around. */ |
| 2248 | Lisp_Object lfonts; | 2277 | Lisp_Object lfonts; |
| @@ -2255,7 +2284,11 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, | |||
| 2255 | 2284 | ||
| 2256 | /* Get the list of fonts matching PATTERN. */ | 2285 | /* Get the list of fonts matching PATTERN. */ |
| 2257 | BLOCK_INPUT; | 2286 | BLOCK_INPUT; |
| 2287 | #ifdef WINDOWSNT | ||
| 2258 | lfonts = w32_list_fonts (f, lpattern, 0, nfonts); | 2288 | lfonts = w32_list_fonts (f, lpattern, 0, nfonts); |
| 2289 | #else /* macintosh */ | ||
| 2290 | lfonts = x_list_fonts (f, lpattern, 0, nfonts); | ||
| 2291 | #endif | ||
| 2259 | UNBLOCK_INPUT; | 2292 | UNBLOCK_INPUT; |
| 2260 | 2293 | ||
| 2261 | /* Count fonts returned */ | 2294 | /* Count fonts returned */ |
| @@ -2273,7 +2306,7 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, | |||
| 2273 | names[i] = XSTRING (XCAR (tem))->data; | 2306 | names[i] = XSTRING (XCAR (tem))->data; |
| 2274 | tem = XCDR (tem); | 2307 | tem = XCDR (tem); |
| 2275 | } | 2308 | } |
| 2276 | #endif /* WINDOWSNT */ | 2309 | #endif /* defined (WINDOWSNT) || defined (macintosh) */ |
| 2277 | 2310 | ||
| 2278 | if (names) | 2311 | if (names) |
| 2279 | { | 2312 | { |
| @@ -4121,6 +4154,7 @@ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, | |||
| 4121 | { | 4154 | { |
| 4122 | Lisp_Object value = Qnil; | 4155 | Lisp_Object value = Qnil; |
| 4123 | #ifndef WINDOWSNT | 4156 | #ifndef WINDOWSNT |
| 4157 | #ifndef macintosh | ||
| 4124 | CHECK_STRING (resource, 0); | 4158 | CHECK_STRING (resource, 0); |
| 4125 | CHECK_STRING (class, 1); | 4159 | CHECK_STRING (class, 1); |
| 4126 | CHECK_LIVE_FRAME (frame, 2); | 4160 | CHECK_LIVE_FRAME (frame, 2); |
| @@ -4128,6 +4162,7 @@ DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, | |||
| 4128 | value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)), | 4162 | value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)), |
| 4129 | resource, class, Qnil, Qnil); | 4163 | resource, class, Qnil, Qnil); |
| 4130 | UNBLOCK_INPUT; | 4164 | UNBLOCK_INPUT; |
| 4165 | #endif /* not macintosh */ | ||
| 4131 | #endif /* not WINDOWSNT */ | 4166 | #endif /* not WINDOWSNT */ |
| 4132 | return value; | 4167 | return value; |
| 4133 | } | 4168 | } |
| @@ -4873,6 +4908,9 @@ prepare_face_for_display (f, face) | |||
| 4873 | #ifdef WINDOWSNT | 4908 | #ifdef WINDOWSNT |
| 4874 | xgcv.font = face->font; | 4909 | xgcv.font = face->font; |
| 4875 | #endif | 4910 | #endif |
| 4911 | #ifdef macintosh | ||
| 4912 | xgcv.font = face->font; | ||
| 4913 | #endif | ||
| 4876 | mask |= GCFont; | 4914 | mask |= GCFont; |
| 4877 | } | 4915 | } |
| 4878 | 4916 | ||
| @@ -6181,6 +6219,18 @@ realize_x_face (cache, attrs, c, base_face) | |||
| 6181 | fontset = default_face->fontset; | 6219 | fontset = default_face->fontset; |
| 6182 | face->fontset = make_fontset_for_ascii_face (f, fontset); | 6220 | face->fontset = make_fontset_for_ascii_face (f, fontset); |
| 6183 | face->font = NULL; /* to force realize_face to load font */ | 6221 | face->font = NULL; /* to force realize_face to load font */ |
| 6222 | |||
| 6223 | #ifdef macintosh | ||
| 6224 | /* Load the font if it is specified in ATTRS. This fixes | ||
| 6225 | changing frame font on the Mac. */ | ||
| 6226 | if (STRINGP (attrs[LFACE_FONT_INDEX])) | ||
| 6227 | { | ||
| 6228 | struct font_info *font_info = | ||
| 6229 | FS_LOAD_FONT (f, 0, XSTRING (attrs[LFACE_FONT_INDEX])->data, -1); | ||
| 6230 | if (font_info) | ||
| 6231 | face->font = font_info->font; | ||
| 6232 | } | ||
| 6233 | #endif | ||
| 6184 | } | 6234 | } |
| 6185 | 6235 | ||
| 6186 | /* Load colors, and set remaining attributes. */ | 6236 | /* Load colors, and set remaining attributes. */ |
| @@ -7037,7 +7087,7 @@ A value of nil means don't allow any scalable fonts.\n\ | |||
| 7037 | A value of t means allow any scalable font.\n\ | 7087 | A value of t means allow any scalable font.\n\ |
| 7038 | Otherwise, value must be a list of regular expressions. A font may be\n\ | 7088 | Otherwise, value must be a list of regular expressions. A font may be\n\ |
| 7039 | scaled if its name matches a regular expression in the list."); | 7089 | scaled if its name matches a regular expression in the list."); |
| 7040 | #ifdef WINDOWSNT | 7090 | #if defined (WINDOWSNT) || defined (macintosh) |
| 7041 | /* Windows uses mainly truetype fonts, so disallowing scalable fonts | 7091 | /* Windows uses mainly truetype fonts, so disallowing scalable fonts |
| 7042 | by default limits the fonts available severely. */ | 7092 | by default limits the fonts available severely. */ |
| 7043 | Vscalable_fonts_allowed = Qt; | 7093 | Vscalable_fonts_allowed = Qt; |