Mercurial > emacs
comparison src/mac.c @ 69960:b4cb58f90f13
(init_process): Remove undef.
(select) [MAC_OSX]: Undefine before including sysselect.h.
(posix_pathname_to_fsspec, fsspec_to_posix_pathname) [MAC_OSX]:
Remove functions and prototypes.
(parse_value): Add parentheses around + inside shift.
(path_from_vol_dir_name): Make static.
(get_temp_dir_name): Remove unused variables `cpb' and `dir_name'.
[!MAC_OSX] (get_path_to_system_folder): Likewise.
(Fmac_get_file_creator, Fmac_get_file_type): Remove unused
variable `cCode'.
(Fmac_coerce_ae_data): Remove unused variables `fref' and `fs'.
(Fmac_get_preference): Add explicit braces to avoid ambiguous `else'.
| author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
|---|---|
| date | Wed, 12 Apr 2006 08:06:59 +0000 |
| parents | f95c886a6158 |
| children | e82c1fc1df38 c156f6a9e7b5 |
comparison
equal
deleted
inserted
replaced
| 69959:d1856dc3952f | 69960:b4cb58f90f13 |
|---|---|
| 26 #include <stdio.h> | 26 #include <stdio.h> |
| 27 #include <errno.h> | 27 #include <errno.h> |
| 28 | 28 |
| 29 #include "lisp.h" | 29 #include "lisp.h" |
| 30 #include "process.h" | 30 #include "process.h" |
| 31 #undef init_process | 31 #ifdef MAC_OSX |
| 32 #undef select | |
| 33 #endif | |
| 32 #include "systime.h" | 34 #include "systime.h" |
| 33 #include "sysselect.h" | 35 #include "sysselect.h" |
| 34 #include "blockinput.h" | 36 #include "blockinput.h" |
| 35 | 37 |
| 36 #include "macterm.h" | 38 #include "macterm.h" |
| 77 /* An instance of the AppleScript component. */ | 79 /* An instance of the AppleScript component. */ |
| 78 static ComponentInstance as_scripting_component; | 80 static ComponentInstance as_scripting_component; |
| 79 /* The single script context used for all script executions. */ | 81 /* The single script context used for all script executions. */ |
| 80 static OSAID as_script_context; | 82 static OSAID as_script_context; |
| 81 | 83 |
| 84 #ifndef MAC_OSX | |
| 82 static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); | 85 static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); |
| 83 static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); | 86 static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); |
| 87 #endif | |
| 84 | 88 |
| 85 /* When converting from Mac to Unix pathnames, /'s in folder names are | 89 /* When converting from Mac to Unix pathnames, /'s in folder names are |
| 86 converted to :'s. This function, used in copying folder names, | 90 converted to :'s. This function, used in copying folder names, |
| 87 performs a strncat and converts all character a to b in the copy of | 91 performs a strncat and converts all character a to b in the copy of |
| 88 the string s2 appended to the end of s1. */ | 92 the string s2 appended to the end of s1. */ |
| 1220 } | 1224 } |
| 1221 else if ('0' <= P[0] && P[0] <= '7' | 1225 else if ('0' <= P[0] && P[0] <= '7' |
| 1222 && '0' <= P[1] && P[1] <= '7' | 1226 && '0' <= P[1] && P[1] <= '7' |
| 1223 && '0' <= P[2] && P[2] <= '7') | 1227 && '0' <= P[2] && P[2] <= '7') |
| 1224 { | 1228 { |
| 1225 *q++ = (P[0] - '0' << 6) + (P[1] - '0' << 3) + (P[2] - '0'); | 1229 *q++ = ((P[0] - '0') << 6) + ((P[1] - '0') << 3) + (P[2] - '0'); |
| 1226 P += 3; | 1230 P += 3; |
| 1227 } | 1231 } |
| 1228 else | 1232 else |
| 1229 *q++ = *P++; | 1233 *q++ = *P++; |
| 1230 } | 1234 } |
| 2787 #endif /* ! MAC_OSX */ | 2791 #endif /* ! MAC_OSX */ |
| 2788 | 2792 |
| 2789 /* Determine the path name of the file specified by VREFNUM, DIRID, | 2793 /* Determine the path name of the file specified by VREFNUM, DIRID, |
| 2790 and NAME and place that in the buffer PATH of length | 2794 and NAME and place that in the buffer PATH of length |
| 2791 MAXPATHLEN. */ | 2795 MAXPATHLEN. */ |
| 2792 int | 2796 static int |
| 2793 path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, | 2797 path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, |
| 2794 long dir_id, ConstStr255Param name) | 2798 long dir_id, ConstStr255Param name) |
| 2795 { | 2799 { |
| 2796 Str255 dir_name; | 2800 Str255 dir_name; |
| 2797 CInfoPBRec cipb; | 2801 CInfoPBRec cipb; |
| 2831 /* stop when we see the volume's root directory */ | 2835 /* stop when we see the volume's root directory */ |
| 2832 | 2836 |
| 2833 return 1; /* success */ | 2837 return 1; /* success */ |
| 2834 } | 2838 } |
| 2835 | 2839 |
| 2840 | |
| 2841 #ifndef MAC_OSX | |
| 2836 | 2842 |
| 2837 static OSErr | 2843 static OSErr |
| 2838 posix_pathname_to_fsspec (ufn, fs) | 2844 posix_pathname_to_fsspec (ufn, fs) |
| 2839 const char *ufn; | 2845 const char *ufn; |
| 2840 FSSpec *fs; | 2846 FSSpec *fs; |
| 2863 && mac_to_posix_pathname (mac_pathname, ufn, ufnbuflen)) | 2869 && mac_to_posix_pathname (mac_pathname, ufn, ufnbuflen)) |
| 2864 return noErr; | 2870 return noErr; |
| 2865 else | 2871 else |
| 2866 return fnfErr; | 2872 return fnfErr; |
| 2867 } | 2873 } |
| 2868 | |
| 2869 #ifndef MAC_OSX | |
| 2870 | 2874 |
| 2871 int | 2875 int |
| 2872 readlink (const char *path, char *buf, int bufsiz) | 2876 readlink (const char *path, char *buf, int bufsiz) |
| 2873 { | 2877 { |
| 2874 char mac_sym_link_name[MAXPATHLEN+1]; | 2878 char mac_sym_link_name[MAXPATHLEN+1]; |
| 3122 { | 3126 { |
| 3123 static char *temp_dir_name = NULL; | 3127 static char *temp_dir_name = NULL; |
| 3124 short vol_ref_num; | 3128 short vol_ref_num; |
| 3125 long dir_id; | 3129 long dir_id; |
| 3126 OSErr err; | 3130 OSErr err; |
| 3127 Str255 dir_name, full_path; | 3131 Str255 full_path; |
| 3128 CInfoPBRec cpb; | |
| 3129 char unix_dir_name[MAXPATHLEN+1]; | 3132 char unix_dir_name[MAXPATHLEN+1]; |
| 3130 DIR *dir; | 3133 DIR *dir; |
| 3131 | 3134 |
| 3132 /* Cache directory name with pointer temp_dir_name. | 3135 /* Cache directory name with pointer temp_dir_name. |
| 3133 Look for it only the first time. */ | 3136 Look for it only the first time. */ |
| 3215 get_path_to_system_folder () | 3218 get_path_to_system_folder () |
| 3216 { | 3219 { |
| 3217 short vol_ref_num; | 3220 short vol_ref_num; |
| 3218 long dir_id; | 3221 long dir_id; |
| 3219 OSErr err; | 3222 OSErr err; |
| 3220 Str255 dir_name, full_path; | 3223 Str255 full_path; |
| 3221 CInfoPBRec cpb; | |
| 3222 static char system_folder_unix_name[MAXPATHLEN+1]; | 3224 static char system_folder_unix_name[MAXPATHLEN+1]; |
| 3223 DIR *dir; | 3225 DIR *dir; |
| 3224 | 3226 |
| 3225 err = FindFolder (kOnSystemDisk, kSystemFolderType, kDontCreateFolder, | 3227 err = FindFolder (kOnSystemDisk, kSystemFolderType, kDontCreateFolder, |
| 3226 &vol_ref_num, &dir_id); | 3228 &vol_ref_num, &dir_id); |
| 3945 #ifdef MAC_OSX | 3947 #ifdef MAC_OSX |
| 3946 FSRef fref; | 3948 FSRef fref; |
| 3947 #else | 3949 #else |
| 3948 FSSpec fss; | 3950 FSSpec fss; |
| 3949 #endif | 3951 #endif |
| 3950 OSType cCode; | |
| 3951 Lisp_Object result = Qnil; | 3952 Lisp_Object result = Qnil; |
| 3952 CHECK_STRING (filename); | 3953 CHECK_STRING (filename); |
| 3953 | 3954 |
| 3954 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) { | 3955 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) { |
| 3955 return Qnil; | 3956 return Qnil; |
| 4000 #ifdef MAC_OSX | 4001 #ifdef MAC_OSX |
| 4001 FSRef fref; | 4002 FSRef fref; |
| 4002 #else | 4003 #else |
| 4003 FSSpec fss; | 4004 FSSpec fss; |
| 4004 #endif | 4005 #endif |
| 4005 OSType cCode; | |
| 4006 Lisp_Object result = Qnil; | 4006 Lisp_Object result = Qnil; |
| 4007 CHECK_STRING (filename); | 4007 CHECK_STRING (filename); |
| 4008 | 4008 |
| 4009 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) { | 4009 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) { |
| 4010 return Qnil; | 4010 return Qnil; |
| 4294 { | 4294 { |
| 4295 OSErr err; | 4295 OSErr err; |
| 4296 Lisp_Object result = Qnil; | 4296 Lisp_Object result = Qnil; |
| 4297 DescType src_desc_type, dst_desc_type; | 4297 DescType src_desc_type, dst_desc_type; |
| 4298 AEDesc dst_desc; | 4298 AEDesc dst_desc; |
| 4299 #ifdef MAC_OSX | |
| 4300 FSRef fref; | |
| 4301 #else | |
| 4302 FSSpec fs; | |
| 4303 #endif | |
| 4304 | 4299 |
| 4305 CHECK_STRING (src_data); | 4300 CHECK_STRING (src_data); |
| 4306 if (EQ (src_type, Qundecoded_file_name)) | 4301 if (EQ (src_type, Qundecoded_file_name)) |
| 4307 src_desc_type = TYPE_FILE_NAME; | 4302 src_desc_type = TYPE_FILE_NAME; |
| 4308 else | 4303 else |
| 4420 if (plist == NULL) | 4415 if (plist == NULL) |
| 4421 goto out; | 4416 goto out; |
| 4422 } | 4417 } |
| 4423 | 4418 |
| 4424 if (NILP (key)) | 4419 if (NILP (key)) |
| 4425 if (EQ (format, Qxml)) | 4420 { |
| 4426 { | 4421 if (EQ (format, Qxml)) |
| 4427 CFDataRef data = CFPropertyListCreateXMLData (NULL, plist); | 4422 { |
| 4428 if (data == NULL) | 4423 CFDataRef data = CFPropertyListCreateXMLData (NULL, plist); |
| 4429 goto out; | 4424 if (data == NULL) |
| 4430 result = cfdata_to_lisp (data); | 4425 goto out; |
| 4431 CFRelease (data); | 4426 result = cfdata_to_lisp (data); |
| 4432 } | 4427 CFRelease (data); |
| 4433 else | 4428 } |
| 4434 result = | 4429 else |
| 4435 cfproperty_list_to_lisp (plist, EQ (format, Qt), | 4430 result = |
| 4436 NILP (hash_bound) ? -1 : XINT (hash_bound)); | 4431 cfproperty_list_to_lisp (plist, EQ (format, Qt), |
| 4432 NILP (hash_bound) ? -1 : XINT (hash_bound)); | |
| 4433 } | |
| 4437 | 4434 |
| 4438 out: | 4435 out: |
| 4439 if (app_plist) | 4436 if (app_plist) |
| 4440 CFRelease (app_plist); | 4437 CFRelease (app_plist); |
| 4441 CFRelease (app_id); | 4438 CFRelease (app_id); |
| 4699 return Qnil; | 4696 return Qnil; |
| 4700 } | 4697 } |
| 4701 | 4698 |
| 4702 | 4699 |
| 4703 #ifdef MAC_OSX | 4700 #ifdef MAC_OSX |
| 4704 #undef select | |
| 4705 | 4701 |
| 4706 extern int inhibit_window_system; | 4702 extern int inhibit_window_system; |
| 4707 extern int noninteractive; | 4703 extern int noninteractive; |
| 4708 | 4704 |
| 4709 /* Unlike in X11, window events in Carbon do not come from sockets. | 4705 /* Unlike in X11, window events in Carbon do not come from sockets. |
