Mercurial > emacs
annotate src/mac.c @ 62242:cce9501aab6e
(sh-mode-default-syntax-table): Set the
syntax of $ to "'" (quote).
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Wed, 11 May 2005 22:57:25 +0000 |
parents | fd9250f00dae |
children | 988827be383c 08185296b491 |
rev | line source |
---|---|
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1 /* Unix emulation routines for GNU Emacs on the Mac OS. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4 This file is part of GNU Emacs. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
5 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
9 any later version. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
10 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
14 GNU General Public License for more details. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
15 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
20 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
21 /* Contributed by Andrew Choi (akochoi@mac.com). */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
22 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
23 #include <config.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
24 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
25 #include <stdio.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
26 #include <errno.h> |
60360
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
27 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
28 #include "lisp.h" |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
29 #include "process.h" |
62054
fd9250f00dae
* mac.c: #undef init_process so not to conflict with system headers.
Jan Djärv <jan.h.d@swipnet.se>
parents:
61925
diff
changeset
|
30 #undef init_process |
61925
e3bedede9b3f
Don't include time.h. Include sysselect.h after systime.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61785
diff
changeset
|
31 #include "systime.h" |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
32 #include "sysselect.h" |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
33 #include "blockinput.h" |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
34 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
35 #include "macterm.h" |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
36 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
37 #if TARGET_API_MAC_CARBON |
61572
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
38 #include "charset.h" |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
39 #include "coding.h" |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
40 #else /* not TARGET_API_MAC_CARBON */ |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
41 #include <Files.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
42 #include <MacTypes.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
43 #include <TextUtils.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
44 #include <Folders.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
45 #include <Resources.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
46 #include <Aliases.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
47 #include <FixMath.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
48 #include <Timer.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
49 #include <OSA.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
50 #include <AppleScript.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
51 #include <Scrap.h> |
60360
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
52 #include <Events.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
53 #include <Processes.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
54 #include <EPPC.h> |
61553
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
55 #include <MacLocales.h> |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
56 #endif /* not TARGET_API_MAC_CARBON */ |
60360
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
57 |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
58 #include <utime.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
59 #include <dirent.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
60 #include <sys/types.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
61 #include <sys/stat.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
62 #include <string.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
63 #include <pwd.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
64 #include <grp.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
65 #include <sys/param.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
66 #include <stdlib.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
67 #include <fcntl.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
68 #if __MWERKS__ |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
69 #include <unistd.h> |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
70 #endif |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
71 |
61553
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
72 /* The system script code. */ |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
73 static int mac_system_script_code; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
74 |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
75 /* The system locale identifier string. */ |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
76 static Lisp_Object Vmac_system_locale; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
77 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
78 /* An instance of the AppleScript component. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
79 static ComponentInstance as_scripting_component; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
80 /* The single script context used for all script executions. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
81 static OSAID as_script_context; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
82 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
83 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
84 /* When converting from Mac to Unix pathnames, /'s in folder names are |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
85 converted to :'s. This function, used in copying folder names, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
86 performs a strncat and converts all character a to b in the copy of |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
87 the string s2 appended to the end of s1. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
88 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
89 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
90 string_cat_and_replace (char *s1, const char *s2, int n, char a, char b) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
91 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
92 int l1 = strlen (s1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
93 int l2 = strlen (s2); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
94 char *p = s1 + l1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
95 int i; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
96 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
97 strncat (s1, s2, n); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
98 for (i = 0; i < l2; i++) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
99 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
100 if (*p == a) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
101 *p = b; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
102 p++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
103 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
104 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
105 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
106 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
107 /* Convert a Mac pathname to Posix form. A Mac full pathname is one |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
108 that does not begin with a ':' and contains at least one ':'. A Mac |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
109 full pathname causes a '/' to be prepended to the Posix pathname. |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
110 The algorithm for the rest of the pathname is as follows: |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
111 For each segment between two ':', |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
112 if it is non-null, copy as is and then add a '/' at the end, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
113 otherwise, insert a "../" into the Posix pathname. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
114 Returns 1 if successful; 0 if fails. */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
115 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
116 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
117 mac_to_posix_pathname (const char *mfn, char *ufn, int ufnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
118 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
119 const char *p, *q, *pe; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
120 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
121 strcpy (ufn, ""); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
122 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
123 if (*mfn == '\0') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
124 return 1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
125 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
126 p = strchr (mfn, ':'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
127 if (p != 0 && p != mfn) /* full pathname */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
128 strcat (ufn, "/"); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
129 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
130 p = mfn; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
131 if (*p == ':') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
132 p++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
133 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
134 pe = mfn + strlen (mfn); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
135 while (p < pe) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
136 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
137 q = strchr (p, ':'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
138 if (q) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
139 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
140 if (q == p) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
141 { /* two consecutive ':' */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
142 if (strlen (ufn) + 3 >= ufnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
143 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
144 strcat (ufn, "../"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
145 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
146 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
147 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
148 if (strlen (ufn) + (q - p) + 1 >= ufnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
149 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
150 string_cat_and_replace (ufn, p, q - p, '/', ':'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
151 strcat (ufn, "/"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
152 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
153 p = q + 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
154 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
155 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
156 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
157 if (strlen (ufn) + (pe - p) >= ufnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
158 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
159 string_cat_and_replace (ufn, p, pe - p, '/', ':'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
160 /* no separator for last one */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
161 p = pe; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
162 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
163 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
164 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
165 return 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
166 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
167 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
168 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
169 extern char *get_temp_dir_name (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
170 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
171 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
172 /* Convert a Posix pathname to Mac form. Approximately reverse of the |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
173 above in algorithm. */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
174 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
175 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
176 posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
177 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
178 const char *p, *q, *pe; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
179 char expanded_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
180 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
181 strcpy (mfn, ""); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
182 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
183 if (*ufn == '\0') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
184 return 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
185 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
186 p = ufn; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
187 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
188 /* Check for and handle volume names. Last comparison: strangely |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
189 somewhere "/.emacs" is passed. A temporary fix for now. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
190 if (*p == '/' && strchr (p+1, '/') == NULL && strcmp (p, "/.emacs") != 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
191 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
192 if (strlen (p) + 1 > mfnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
193 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
194 strcpy (mfn, p+1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
195 strcat (mfn, ":"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
196 return 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
197 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
198 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
199 /* expand to emacs dir found by init_emacs_passwd_dir */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
200 if (strncmp (p, "~emacs/", 7) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
201 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
202 struct passwd *pw = getpwnam ("emacs"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
203 p += 7; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
204 if (strlen (pw->pw_dir) + strlen (p) > MAXPATHLEN) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
205 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
206 strcpy (expanded_pathname, pw->pw_dir); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
207 strcat (expanded_pathname, p); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
208 p = expanded_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
209 /* now p points to the pathname with emacs dir prefix */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
210 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
211 else if (strncmp (p, "/tmp/", 5) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
212 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
213 char *t = get_temp_dir_name (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
214 p += 5; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
215 if (strlen (t) + strlen (p) > MAXPATHLEN) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
216 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
217 strcpy (expanded_pathname, t); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
218 strcat (expanded_pathname, p); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
219 p = expanded_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
220 /* now p points to the pathname with emacs dir prefix */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
221 } |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
222 else if (*p != '/') /* relative pathname */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
223 strcat (mfn, ":"); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
224 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
225 if (*p == '/') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
226 p++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
227 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
228 pe = p + strlen (p); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
229 while (p < pe) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
230 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
231 q = strchr (p, '/'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
232 if (q) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
233 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
234 if (q - p == 2 && *p == '.' && *(p+1) == '.') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
235 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
236 if (strlen (mfn) + 1 >= mfnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
237 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
238 strcat (mfn, ":"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
239 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
240 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
241 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
242 if (strlen (mfn) + (q - p) + 1 >= mfnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
243 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
244 string_cat_and_replace (mfn, p, q - p, ':', '/'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
245 strcat (mfn, ":"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
246 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
247 p = q + 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
248 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
249 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
250 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
251 if (strlen (mfn) + (pe - p) >= mfnbuflen) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
252 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
253 string_cat_and_replace (mfn, p, pe - p, ':', '/'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
254 p = pe; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
255 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
256 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
257 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
258 return 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
259 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
260 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
261 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
262 /*********************************************************************** |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
263 Conversion between Lisp and Core Foundation objects |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
264 ***********************************************************************/ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
265 |
58752
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
266 #if TARGET_API_MAC_CARBON |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
267 static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
268 static Lisp_Object Qarray, Qdictionary; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
269 #define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
270 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
271 struct cfdict_context |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
272 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
273 Lisp_Object *result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
274 int with_tag, hash_bound; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
275 }; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
276 |
61572
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
277 /* C string to CFString. */ |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
278 |
58752
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
279 CFStringRef |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
280 cfstring_create_with_utf8_cstring (c_str) |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
281 const char *c_str; |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
282 { |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
283 CFStringRef str; |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
284 |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
285 str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingUTF8); |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
286 if (str == NULL) |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
287 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */ |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
288 str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingMacRoman); |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
289 |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
290 return str; |
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
291 } |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
292 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
293 |
61572
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
294 /* Lisp string to CFString. */ |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
295 |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
296 CFStringRef |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
297 cfstring_create_with_string (s) |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
298 Lisp_Object s; |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
299 { |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
300 CFStringRef string = NULL; |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
301 |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
302 if (STRING_MULTIBYTE (s)) |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
303 { |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
304 char *p, *end = SDATA (s) + SBYTES (s); |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
305 |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
306 for (p = SDATA (s); p < end; p++) |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
307 if (!isascii (*p)) |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
308 { |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
309 s = ENCODE_UTF_8 (s); |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
310 break; |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
311 } |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
312 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s), |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
313 kCFStringEncodingUTF8, false); |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
314 } |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
315 |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
316 if (string == NULL) |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
317 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */ |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
318 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s), |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
319 kCFStringEncodingMacRoman, false); |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
320 |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
321 return string; |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
322 } |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
323 |
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
324 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
325 /* From CFData to a lisp string. Always returns a unibyte string. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
326 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
327 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
328 cfdata_to_lisp (data) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
329 CFDataRef data; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
330 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
331 CFIndex len = CFDataGetLength (data); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
332 Lisp_Object result = make_uninit_string (len); |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
333 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
334 CFDataGetBytes (data, CFRangeMake (0, len), SDATA (result)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
335 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
336 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
337 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
338 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
339 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
340 /* From CFString to a lisp string. Never returns a unibyte string |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
341 (even if it only contains ASCII characters). |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
342 This may cause GC during code conversion. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
343 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
344 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
345 cfstring_to_lisp (string) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
346 CFStringRef string; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
347 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
348 Lisp_Object result = Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
349 const char *s = CFStringGetCStringPtr (string, kCFStringEncodingUTF8); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
350 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
351 if (s) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
352 result = make_unibyte_string (s, strlen (s)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
353 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
354 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
355 CFDataRef data = |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
356 CFStringCreateExternalRepresentation (NULL, string, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
357 kCFStringEncodingUTF8, '?'); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
358 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
359 if (data) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
360 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
361 result = cfdata_to_lisp (data); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
362 CFRelease (data); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
363 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
364 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
365 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
366 if (!NILP (result)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
367 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
368 result = DECODE_UTF_8 (result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
369 /* This may be superfluous. Just to make sure that the result |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
370 is a multibyte string. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
371 result = string_to_multibyte (result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
372 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
373 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
374 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
375 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
376 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
377 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
378 /* CFNumber to a lisp integer or a lisp float. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
379 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
380 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
381 cfnumber_to_lisp (number) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
382 CFNumberRef number; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
383 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
384 Lisp_Object result = Qnil; |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
385 #if BITS_PER_EMACS_INT > 32 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
386 SInt64 int_val; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
387 CFNumberType emacs_int_type = kCFNumberSInt64Type; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
388 #else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
389 SInt32 int_val; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
390 CFNumberType emacs_int_type = kCFNumberSInt32Type; |
58752
4ad0594e1ac4
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents:
57425
diff
changeset
|
391 #endif |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
392 double float_val; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
393 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
394 if (CFNumberGetValue (number, emacs_int_type, &int_val) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
395 && !FIXNUM_OVERFLOW_P (int_val)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
396 result = make_number (int_val); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
397 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
398 if (CFNumberGetValue (number, kCFNumberDoubleType, &float_val)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
399 result = make_float (float_val); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
400 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
401 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
402 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
403 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
404 /* CFDate to a list of three integers as in a return value of |
61338
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
405 `current-time'. */ |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
406 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
407 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
408 cfdate_to_lisp (date) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
409 CFDateRef date; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
410 { |
61338
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
411 static const CFGregorianDate epoch_gdate = {1970, 1, 1, 0, 0, 0.0}; |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
412 static CFAbsoluteTime epoch = 0.0, sec; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
413 int high, low; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
414 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
415 if (epoch == 0.0) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
416 epoch = CFGregorianDateGetAbsoluteTime (epoch_gdate, NULL); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
417 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
418 sec = CFDateGetAbsoluteTime (date) - epoch; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
419 high = sec / 65536.0; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
420 low = sec - high * 65536.0; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
421 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
422 return list3 (make_number (high), make_number (low), make_number (0)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
423 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
424 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
425 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
426 /* CFBoolean to a lisp symbol, `t' or `nil'. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
427 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
428 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
429 cfboolean_to_lisp (boolean) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
430 CFBooleanRef boolean; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
431 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
432 return CFBooleanGetValue (boolean) ? Qt : Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
433 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
434 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
435 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
436 /* Any Core Foundation object to a (lengthy) lisp string. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
437 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
438 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
439 cfobject_desc_to_lisp (object) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
440 CFTypeRef object; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
441 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
442 Lisp_Object result = Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
443 CFStringRef desc = CFCopyDescription (object); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
444 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
445 if (desc) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
446 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
447 result = cfstring_to_lisp (desc); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
448 CFRelease (desc); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
449 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
450 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
451 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
452 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
453 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
454 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
455 /* Callback functions for cfproperty_list_to_lisp. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
456 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
457 static void |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
458 cfdictionary_add_to_list (key, value, context) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
459 const void *key; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
460 const void *value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
461 void *context; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
462 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
463 struct cfdict_context *cxt = (struct cfdict_context *)context; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
464 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
465 *cxt->result = |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
466 Fcons (Fcons (cfstring_to_lisp (key), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
467 cfproperty_list_to_lisp (value, cxt->with_tag, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
468 cxt->hash_bound)), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
469 *cxt->result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
470 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
471 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
472 static void |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
473 cfdictionary_puthash (key, value, context) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
474 const void *key; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
475 const void *value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
476 void *context; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
477 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
478 Lisp_Object lisp_key = cfstring_to_lisp (key); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
479 struct cfdict_context *cxt = (struct cfdict_context *)context; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
480 struct Lisp_Hash_Table *h = XHASH_TABLE (*(cxt->result)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
481 unsigned hash_code; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
482 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
483 hash_lookup (h, lisp_key, &hash_code); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
484 hash_put (h, lisp_key, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
485 cfproperty_list_to_lisp (value, cxt->with_tag, cxt->hash_bound), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
486 hash_code); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
487 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
488 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
489 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
490 /* Convert CFPropertyList PLIST to a lisp object. If WITH_TAG is |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
491 non-zero, a symbol that represents the type of the original Core |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
492 Foundation object is prepended. HASH_BOUND specifies which kinds |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
493 of the lisp objects, alists or hash tables, are used as the targets |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
494 of the conversion from CFDictionary. If HASH_BOUND is negative, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
495 always generate alists. If HASH_BOUND >= 0, generate an alist if |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
496 the number of keys in the dictionary is smaller than HASH_BOUND, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
497 and a hash table otherwise. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
498 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
499 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
500 cfproperty_list_to_lisp (plist, with_tag, hash_bound) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
501 CFPropertyListRef plist; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
502 int with_tag, hash_bound; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
503 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
504 CFTypeID type_id = CFGetTypeID (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
505 Lisp_Object tag = Qnil, result = Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
506 struct gcpro gcpro1, gcpro2; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
507 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
508 GCPRO2 (tag, result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
509 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
510 if (type_id == CFStringGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
511 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
512 tag = Qstring; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
513 result = cfstring_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
514 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
515 else if (type_id == CFNumberGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
516 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
517 tag = Qnumber; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
518 result = cfnumber_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
519 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
520 else if (type_id == CFBooleanGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
521 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
522 tag = Qboolean; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
523 result = cfboolean_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
524 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
525 else if (type_id == CFDateGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
526 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
527 tag = Qdate; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
528 result = cfdate_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
529 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
530 else if (type_id == CFDataGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
531 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
532 tag = Qdata; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
533 result = cfdata_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
534 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
535 else if (type_id == CFArrayGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
536 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
537 CFIndex index, count = CFArrayGetCount (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
538 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
539 tag = Qarray; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
540 result = Fmake_vector (make_number (count), Qnil); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
541 for (index = 0; index < count; index++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
542 XVECTOR (result)->contents[index] = |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
543 cfproperty_list_to_lisp (CFArrayGetValueAtIndex (plist, index), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
544 with_tag, hash_bound); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
545 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
546 else if (type_id == CFDictionaryGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
547 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
548 struct cfdict_context context; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
549 CFIndex count = CFDictionaryGetCount (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
550 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
551 tag = Qdictionary; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
552 context.result = &result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
553 context.with_tag = with_tag; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
554 context.hash_bound = hash_bound; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
555 if (hash_bound < 0 || count < hash_bound) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
556 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
557 result = Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
558 CFDictionaryApplyFunction (plist, cfdictionary_add_to_list, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
559 &context); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
560 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
561 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
562 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
563 result = make_hash_table (Qequal, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
564 make_number (count), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
565 make_float (DEFAULT_REHASH_SIZE), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
566 make_float (DEFAULT_REHASH_THRESHOLD), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
567 Qnil, Qnil, Qnil); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
568 CFDictionaryApplyFunction (plist, cfdictionary_puthash, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
569 &context); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
570 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
571 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
572 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
573 abort (); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
574 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
575 UNGCPRO; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
576 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
577 if (with_tag) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
578 result = Fcons (tag, result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
579 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
580 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
581 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
582 #endif |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
583 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
584 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
585 /*********************************************************************** |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
586 Emulation of the X Resource Manager |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
587 ***********************************************************************/ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
588 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
589 /* Parser functions for resource lines. Each function takes an |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
590 address of a variable whose value points to the head of a string. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
591 The value will be advanced so that it points to the next character |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
592 of the parsed part when the function returns. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
593 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
594 A resource name such as "Emacs*font" is parsed into a non-empty |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
595 list called `quarks'. Each element is either a Lisp string that |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
596 represents a concrete component, a Lisp symbol LOOSE_BINDING |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
597 (actually Qlambda) that represents any number (>=0) of intervening |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
598 components, or a Lisp symbol SINGLE_COMPONENT (actually Qquote) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
599 that represents as any single component. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
600 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
601 #define P (*p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
602 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
603 #define LOOSE_BINDING Qlambda /* '*' ("L"oose) */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
604 #define SINGLE_COMPONENT Qquote /* '?' ("Q"uestion) */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
605 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
606 static void |
60640
7dd25916c6bb
Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60632
diff
changeset
|
607 skip_white_space (p) |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
608 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
609 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
610 /* WhiteSpace = {<space> | <horizontal tab>} */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
611 while (*P == ' ' || *P == '\t') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
612 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
613 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
614 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
615 static int |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
616 parse_comment (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
617 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
618 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
619 /* Comment = "!" {<any character except null or newline>} */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
620 if (*P == '!') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
621 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
622 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
623 while (*P) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
624 if (*P++ == '\n') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
625 break; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
626 return 1; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
627 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
628 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
629 return 0; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
630 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
631 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
632 /* Don't interpret filename. Just skip until the newline. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
633 static int |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
634 parse_include_file (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
635 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
636 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
637 /* IncludeFile = "#" WhiteSpace "include" WhiteSpace FileName WhiteSpace */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
638 if (*P == '#') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
639 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
640 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
641 while (*P) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
642 if (*P++ == '\n') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
643 break; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
644 return 1; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
645 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
646 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
647 return 0; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
648 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
649 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
650 static char |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
651 parse_binding (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
652 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
653 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
654 /* Binding = "." | "*" */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
655 if (*P == '.' || *P == '*') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
656 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
657 char binding = *P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
658 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
659 while (*P == '.' || *P == '*') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
660 if (*P++ == '*') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
661 binding = '*'; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
662 return binding; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
663 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
664 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
665 return '\0'; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
666 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
667 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
668 static Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
669 parse_component (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
670 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
671 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
672 /* Component = "?" | ComponentName |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
673 ComponentName = NameChar {NameChar} |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
674 NameChar = "a"-"z" | "A"-"Z" | "0"-"9" | "_" | "-" */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
675 if (*P == '?') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
676 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
677 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
678 return SINGLE_COMPONENT; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
679 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
680 else if (isalnum (*P) || *P == '_' || *P == '-') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
681 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
682 char *start = P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
683 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
684 while (isalnum (*P) || *P == '_' || *P == '-') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
685 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
686 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
687 return make_unibyte_string (start, P - start); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
688 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
689 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
690 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
691 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
692 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
693 static Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
694 parse_resource_name (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
695 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
696 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
697 Lisp_Object result = Qnil, component; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
698 char binding; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
699 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
700 /* ResourceName = [Binding] {Component Binding} ComponentName */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
701 if (parse_binding (p) == '*') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
702 result = Fcons (LOOSE_BINDING, result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
703 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
704 component = parse_component (p); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
705 if (NILP (component)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
706 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
707 |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
708 result = Fcons (component, result); |
61338
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
709 while ((binding = parse_binding (p)) != '\0') |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
710 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
711 if (binding == '*') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
712 result = Fcons (LOOSE_BINDING, result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
713 component = parse_component (p); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
714 if (NILP (component)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
715 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
716 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
717 result = Fcons (component, result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
718 } |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
719 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
720 /* The final component should not be '?'. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
721 if (EQ (component, SINGLE_COMPONENT)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
722 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
723 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
724 return Fnreverse (result); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
725 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
726 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
727 static Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
728 parse_value (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
729 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
730 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
731 char *q, *buf; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
732 Lisp_Object seq = Qnil, result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
733 int buf_len, total_len = 0, len, continue_p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
734 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
735 q = strchr (P, '\n'); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
736 buf_len = q ? q - P : strlen (P); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
737 buf = xmalloc (buf_len); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
738 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
739 while (1) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
740 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
741 q = buf; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
742 continue_p = 0; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
743 while (*P) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
744 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
745 if (*P == '\n') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
746 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
747 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
748 break; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
749 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
750 else if (*P == '\\') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
751 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
752 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
753 if (*P == '\0') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
754 break; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
755 else if (*P == '\n') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
756 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
757 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
758 continue_p = 1; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
759 break; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
760 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
761 else if (*P == 'n') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
762 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
763 *q++ = '\n'; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
764 P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
765 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
766 else if ('0' <= P[0] && P[0] <= '7' |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
767 && '0' <= P[1] && P[1] <= '7' |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
768 && '0' <= P[2] && P[2] <= '7') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
769 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
770 *q++ = (P[0] - '0' << 6) + (P[1] - '0' << 3) + (P[2] - '0'); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
771 P += 3; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
772 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
773 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
774 *q++ = *P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
775 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
776 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
777 *q++ = *P++; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
778 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
779 len = q - buf; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
780 seq = Fcons (make_unibyte_string (buf, len), seq); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
781 total_len += len; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
782 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
783 if (continue_p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
784 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
785 q = strchr (P, '\n'); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
786 len = q ? q - P : strlen (P); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
787 if (len > buf_len) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
788 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
789 xfree (buf); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
790 buf_len = len; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
791 buf = xmalloc (buf_len); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
792 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
793 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
794 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
795 break; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
796 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
797 xfree (buf); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
798 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
799 if (SBYTES (XCAR (seq)) == total_len) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
800 return make_string (SDATA (XCAR (seq)), total_len); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
801 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
802 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
803 buf = xmalloc (total_len); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
804 q = buf + total_len; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
805 for (; CONSP (seq); seq = XCDR (seq)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
806 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
807 len = SBYTES (XCAR (seq)); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
808 q -= len; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
809 memcpy (q, SDATA (XCAR (seq)), len); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
810 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
811 result = make_string (buf, total_len); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
812 xfree (buf); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
813 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
814 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
815 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
816 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
817 static Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
818 parse_resource_line (p) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
819 char **p; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
820 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
821 Lisp_Object quarks, value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
822 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
823 /* ResourceLine = Comment | IncludeFile | ResourceSpec | <empty line> */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
824 if (parse_comment (p) || parse_include_file (p)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
825 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
826 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
827 /* ResourceSpec = WhiteSpace ResourceName WhiteSpace ":" WhiteSpace Value */ |
60640
7dd25916c6bb
Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60632
diff
changeset
|
828 skip_white_space (p); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
829 quarks = parse_resource_name (p); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
830 if (NILP (quarks)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
831 goto cleanup; |
60640
7dd25916c6bb
Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60632
diff
changeset
|
832 skip_white_space (p); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
833 if (*P != ':') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
834 goto cleanup; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
835 P++; |
60640
7dd25916c6bb
Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60632
diff
changeset
|
836 skip_white_space (p); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
837 value = parse_value (p); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
838 return Fcons (quarks, value); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
839 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
840 cleanup: |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
841 /* Skip the remaining data as a dummy value. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
842 parse_value (p); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
843 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
844 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
845 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
846 #undef P |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
847 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
848 /* Equivalents of X Resource Manager functions. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
849 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
850 An X Resource Database acts as a collection of resource names and |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
851 associated values. It is implemented as a trie on quarks. Namely, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
852 each edge is labeled by either a string, LOOSE_BINDING, or |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
853 SINGLE_COMPONENT. Each node has a node id, which is a unique |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
854 nonnegative integer, and the root node id is 0. A database is |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
855 implemented as a hash table that maps a pair (SRC-NODE-ID . |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
856 EDGE-LABEL) to DEST-NODE-ID. It also holds a maximum node id used |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
857 in the table as a value for HASHKEY_MAX_NID. A value associated to |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
858 a node is recorded as a value for the node id. */ |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
859 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
860 #define HASHKEY_MAX_NID (make_number (0)) |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
861 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
862 static XrmDatabase |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
863 xrm_create_database () |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
864 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
865 XrmDatabase database; |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
866 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
867 database = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
868 make_float (DEFAULT_REHASH_SIZE), |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
869 make_float (DEFAULT_REHASH_THRESHOLD), |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
870 Qnil, Qnil, Qnil); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
871 Fputhash (HASHKEY_MAX_NID, make_number (0), database); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
872 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
873 return database; |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
874 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
875 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
876 static void |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
877 xrm_q_put_resource (database, quarks, value) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
878 XrmDatabase database; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
879 Lisp_Object quarks, value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
880 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
881 struct Lisp_Hash_Table *h = XHASH_TABLE (database); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
882 unsigned hash_code; |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
883 int max_nid, i; |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
884 Lisp_Object node_id, key; |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
885 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
886 max_nid = XINT (Fgethash (HASHKEY_MAX_NID, database, Qnil)); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
887 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
888 XSETINT (node_id, 0); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
889 for (; CONSP (quarks); quarks = XCDR (quarks)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
890 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
891 key = Fcons (node_id, XCAR (quarks)); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
892 i = hash_lookup (h, key, &hash_code); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
893 if (i < 0) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
894 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
895 max_nid++; |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
896 XSETINT (node_id, max_nid); |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
897 hash_put (h, key, node_id, hash_code); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
898 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
899 else |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
900 node_id = HASH_VALUE (h, i); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
901 } |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
902 Fputhash (node_id, value, database); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
903 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
904 Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
905 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
906 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
907 /* Merge multiple resource entries specified by DATA into a resource |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
908 database DATABASE. DATA points to the head of a null-terminated |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
909 string consisting of multiple resource lines. It's like a |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
910 combination of XrmGetStringDatabase and XrmMergeDatabases. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
911 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
912 void |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
913 xrm_merge_string_database (database, data) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
914 XrmDatabase database; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
915 char *data; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
916 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
917 Lisp_Object quarks_value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
918 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
919 while (*data) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
920 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
921 quarks_value = parse_resource_line (&data); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
922 if (!NILP (quarks_value)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
923 xrm_q_put_resource (database, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
924 XCAR (quarks_value), XCDR (quarks_value)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
925 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
926 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
927 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
928 static Lisp_Object |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
929 xrm_q_get_resource_1 (database, node_id, quark_name, quark_class) |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
930 XrmDatabase database; |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
931 Lisp_Object node_id, quark_name, quark_class; |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
932 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
933 struct Lisp_Hash_Table *h = XHASH_TABLE (database); |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
934 Lisp_Object key, labels[3], value; |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
935 int i, k; |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
936 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
937 if (!CONSP (quark_name)) |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
938 return Fgethash (node_id, database, Qnil); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
939 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
940 /* First, try tight bindings */ |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
941 labels[0] = XCAR (quark_name); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
942 labels[1] = XCAR (quark_class); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
943 labels[2] = SINGLE_COMPONENT; |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
944 |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
945 key = Fcons (node_id, Qnil); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
946 for (k = 0; k < sizeof (labels) / sizeof (*labels); k++) |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
947 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
948 XSETCDR (key, labels[k]); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
949 i = hash_lookup (h, key, NULL); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
950 if (i >= 0) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
951 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
952 value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i), |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
953 XCDR (quark_name), XCDR (quark_class)); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
954 if (!NILP (value)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
955 return value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
956 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
957 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
958 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
959 /* Then, try loose bindings */ |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
960 XSETCDR (key, LOOSE_BINDING); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
961 i = hash_lookup (h, key, NULL); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
962 if (i >= 0) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
963 { |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
964 value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i), |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
965 quark_name, quark_class); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
966 if (!NILP (value)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
967 return value; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
968 else |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
969 return xrm_q_get_resource_1 (database, node_id, |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
970 XCDR (quark_name), XCDR (quark_class)); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
971 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
972 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
973 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
974 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
975 |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
976 static Lisp_Object |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
977 xrm_q_get_resource (database, quark_name, quark_class) |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
978 XrmDatabase database; |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
979 Lisp_Object quark_name, quark_class; |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
980 { |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
981 return xrm_q_get_resource_1 (database, make_number (0), |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
982 quark_name, quark_class); |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
983 } |
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
984 |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
985 /* Retrieve a resource value for the specified NAME and CLASS from the |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
986 resource database DATABASE. It corresponds to XrmGetResource. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
987 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
988 Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
989 xrm_get_resource (database, name, class) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
990 XrmDatabase database; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
991 char *name, *class; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
992 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
993 Lisp_Object quark_name, quark_class, tmp; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
994 int nn, nc; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
995 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
996 quark_name = parse_resource_name (&name); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
997 if (*name != '\0') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
998 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
999 for (tmp = quark_name, nn = 0; CONSP (tmp); tmp = XCDR (tmp), nn++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1000 if (!STRINGP (XCAR (tmp))) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1001 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1002 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1003 quark_class = parse_resource_name (&class); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1004 if (*class != '\0') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1005 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1006 for (tmp = quark_class, nc = 0; CONSP (tmp); tmp = XCDR (tmp), nc++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1007 if (!STRINGP (XCAR (tmp))) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1008 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1009 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1010 if (nn != nc) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1011 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1012 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1013 return xrm_q_get_resource (database, quark_name, quark_class); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1014 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1015 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1016 #if TARGET_API_MAC_CARBON |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1017 static Lisp_Object |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1018 xrm_cfproperty_list_to_value (plist) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1019 CFPropertyListRef plist; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1020 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1021 CFTypeID type_id = CFGetTypeID (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1022 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1023 if (type_id == CFStringGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1024 return cfstring_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1025 else if (type_id == CFNumberGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1026 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1027 CFStringRef string; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1028 Lisp_Object result = Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1029 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1030 string = CFStringCreateWithFormat (NULL, NULL, CFSTR ("%@"), plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1031 if (string) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1032 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1033 result = cfstring_to_lisp (string); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1034 CFRelease (string); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1035 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1036 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1037 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1038 else if (type_id == CFBooleanGetTypeID ()) |
60660
40fe172d199c
(HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60640
diff
changeset
|
1039 return build_string (CFBooleanGetValue (plist) ? "true" : "false"); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1040 else if (type_id == CFDataGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1041 return cfdata_to_lisp (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1042 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1043 return Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1044 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1045 #endif |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1046 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1047 /* Create a new resource database from the preferences for the |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1048 application APPLICATION. APPLICATION is either a string that |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1049 specifies an application ID, or NULL that represents the current |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1050 application. */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1051 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1052 XrmDatabase |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1053 xrm_get_preference_database (application) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1054 char *application; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1055 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1056 #if TARGET_API_MAC_CARBON |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1057 CFStringRef app_id, *keys, user_doms[2], host_doms[2]; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1058 CFMutableSetRef key_set = NULL; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1059 CFArrayRef key_array; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1060 CFIndex index, count; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1061 char *res_name; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1062 XrmDatabase database; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1063 Lisp_Object quarks = Qnil, value = Qnil; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1064 CFPropertyListRef plist; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1065 int iu, ih; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1066 struct gcpro gcpro1, gcpro2, gcpro3; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1067 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1068 user_doms[0] = kCFPreferencesCurrentUser; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1069 user_doms[1] = kCFPreferencesAnyUser; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1070 host_doms[0] = kCFPreferencesCurrentHost; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1071 host_doms[1] = kCFPreferencesAnyHost; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1072 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1073 database = xrm_create_database (); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1074 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1075 GCPRO3 (database, quarks, value); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1076 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1077 BLOCK_INPUT; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1078 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1079 app_id = kCFPreferencesCurrentApplication; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1080 if (application) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1081 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1082 app_id = cfstring_create_with_utf8_cstring (application); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1083 if (app_id == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1084 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1085 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1086 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1087 key_set = CFSetCreateMutable (NULL, 0, &kCFCopyStringSetCallBacks); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1088 if (key_set == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1089 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1090 for (iu = 0; iu < sizeof (user_doms) / sizeof (*user_doms) ; iu++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1091 for (ih = 0; ih < sizeof (host_doms) / sizeof (*host_doms); ih++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1092 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1093 key_array = CFPreferencesCopyKeyList (app_id, user_doms[iu], |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1094 host_doms[ih]); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1095 if (key_array) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1096 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1097 count = CFArrayGetCount (key_array); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1098 for (index = 0; index < count; index++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1099 CFSetAddValue (key_set, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1100 CFArrayGetValueAtIndex (key_array, index)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1101 CFRelease (key_array); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1102 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1103 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1104 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1105 count = CFSetGetCount (key_set); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1106 keys = xmalloc (sizeof (CFStringRef) * count); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1107 if (keys == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1108 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1109 CFSetGetValues (key_set, (const void **)keys); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1110 for (index = 0; index < count; index++) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1111 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1112 res_name = SDATA (cfstring_to_lisp (keys[index])); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1113 quarks = parse_resource_name (&res_name); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1114 if (!(NILP (quarks) || *res_name)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1115 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1116 plist = CFPreferencesCopyAppValue (keys[index], app_id); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1117 value = xrm_cfproperty_list_to_value (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1118 CFRelease (plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1119 if (!NILP (value)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1120 xrm_q_put_resource (database, quarks, value); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1121 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1122 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1123 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1124 xfree (keys); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1125 out: |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1126 if (key_set) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1127 CFRelease (key_set); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1128 CFRelease (app_id); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1129 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1130 UNBLOCK_INPUT; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1131 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1132 UNGCPRO; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1133 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1134 return database; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1135 #else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1136 return xrm_create_database (); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1137 #endif |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1138 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1139 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
1140 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1141 #ifndef MAC_OSX |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1142 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1143 /* The following functions with "sys_" prefix are stubs to Unix |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1144 functions that have already been implemented by CW or MPW. The |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1145 calls to them in Emacs source course are #define'd to call the sys_ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1146 versions by the header files s-mac.h. In these stubs pathnames are |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1147 converted between their Unix and Mac forms. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1148 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1149 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1150 /* Unix epoch is Jan 1, 1970 while Mac epoch is Jan 1, 1904: 66 years |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1151 + 17 leap days. These are for adjusting time values returned by |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1152 MacOS Toolbox functions. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1153 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1154 #define MAC_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1155 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1156 #ifdef __MWERKS__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1157 #if __MSL__ < 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1158 /* CW Pro 5 epoch is Jan 1, 1900 (aaarghhhhh!); remember, 1900 is not |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1159 a leap year! This is for adjusting time_t values returned by MSL |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1160 functions. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1161 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 70 + 17) * 24 * 60 * 60) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1162 #else /* __MSL__ >= 0x6000 */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1163 /* CW changes Pro 6 to follow Unix! */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1164 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1165 #endif /* __MSL__ >= 0x6000 */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1166 #elif __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1167 /* MPW library functions follow Unix (confused?). */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1168 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1169 #else /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1170 You lose!!! |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1171 #endif /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1172 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1173 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1174 /* Define our own stat function for both MrC and CW. The reason for |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1175 doing this: "stat" is both the name of a struct and function name: |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1176 can't use the same trick like that for sys_open, sys_close, etc. to |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1177 redirect Emacs's calls to our own version that converts Unix style |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1178 filenames to Mac style filename because all sorts of compilation |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1179 errors will be generated if stat is #define'd to be sys_stat. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1180 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1181 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1182 stat_noalias (const char *path, struct stat *buf) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1183 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1184 char mac_pathname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1185 CInfoPBRec cipb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1186 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1187 if (posix_to_mac_pathname (path, mac_pathname, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1188 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1189 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1190 c2pstr (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1191 cipb.hFileInfo.ioNamePtr = mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1192 cipb.hFileInfo.ioVRefNum = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1193 cipb.hFileInfo.ioDirID = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1194 cipb.hFileInfo.ioFDirIndex = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1195 /* set to 0 to get information about specific dir or file */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1196 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1197 errno = PBGetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1198 if (errno == -43) /* -43: fnfErr defined in Errors.h */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1199 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1200 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1201 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1202 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1203 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* bit 4 = 1 for directories */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1204 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1205 buf->st_mode = S_IFDIR | S_IREAD | S_IEXEC; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1206 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1207 if (!(cipb.hFileInfo.ioFlAttrib & 0x1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1208 buf->st_mode |= S_IWRITE; /* bit 1 = 1 for locked files/directories */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1209 buf->st_ino = cipb.dirInfo.ioDrDirID; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1210 buf->st_dev = cipb.dirInfo.ioVRefNum; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1211 buf->st_size = cipb.dirInfo.ioDrNmFls; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1212 /* size of dir = number of files and dirs */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1213 buf->st_atime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1214 = buf->st_mtime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1215 = cipb.dirInfo.ioDrMdDat - MAC_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1216 buf->st_ctime = cipb.dirInfo.ioDrCrDat - MAC_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1217 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1218 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1219 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1220 buf->st_mode = S_IFREG | S_IREAD; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1221 if (!(cipb.hFileInfo.ioFlAttrib & 0x1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1222 buf->st_mode |= S_IWRITE; /* bit 1 = 1 for locked files/directories */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1223 if (cipb.hFileInfo.ioFlFndrInfo.fdType == 'APPL') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1224 buf->st_mode |= S_IEXEC; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1225 buf->st_ino = cipb.hFileInfo.ioDirID; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1226 buf->st_dev = cipb.hFileInfo.ioVRefNum; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1227 buf->st_size = cipb.hFileInfo.ioFlLgLen; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1228 buf->st_atime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1229 = buf->st_mtime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1230 = cipb.hFileInfo.ioFlMdDat - MAC_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1231 buf->st_ctime = cipb.hFileInfo.ioFlCrDat - MAC_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1232 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1233 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1234 if (cipb.hFileInfo.ioFlFndrInfo.fdFlags & 0x8000) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1235 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1236 /* identify alias files as symlinks */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1237 buf->st_mode &= ~S_IFREG; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1238 buf->st_mode |= S_IFLNK; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1239 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1240 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1241 buf->st_nlink = 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1242 buf->st_uid = getuid (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1243 buf->st_gid = getgid (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1244 buf->st_rdev = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1245 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1246 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1247 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1248 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1249 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1250 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1251 lstat (const char *path, struct stat *buf) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1252 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1253 int result; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1254 char true_pathname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1255 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1256 /* Try looking for the file without resolving aliases first. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1257 if ((result = stat_noalias (path, buf)) >= 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1258 return result; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1259 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1260 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1261 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1262 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1263 return stat_noalias (true_pathname, buf); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1264 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1265 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1266 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1267 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1268 stat (const char *path, struct stat *sb) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1269 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1270 int result; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1271 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1272 int len; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1273 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1274 if ((result = stat_noalias (path, sb)) >= 0 && |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1275 ! (sb->st_mode & S_IFLNK)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1276 return result; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1277 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1278 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1279 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1280 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1281 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1282 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1283 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1284 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1285 /* in fact our readlink terminates strings */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1286 return lstat (fully_resolved_name, sb); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1287 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1288 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1289 return lstat (true_pathname, sb); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1290 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1291 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1292 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1293 #if __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1294 /* CW defines fstat in stat.mac.c while MPW does not provide this |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1295 function. Without the information of how to get from a file |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1296 descriptor in MPW StdCLib to a Mac OS file spec, it should be hard |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1297 to implement this function. Fortunately, there is only one place |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1298 where this function is called in our configuration: in fileio.c, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1299 where only the st_dev and st_ino fields are used to determine |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1300 whether two fildes point to different i-nodes to prevent copying |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1301 a file onto itself equal. What we have here probably needs |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1302 improvement. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1303 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1304 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1305 fstat (int fildes, struct stat *buf) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1306 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1307 buf->st_dev = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1308 buf->st_ino = fildes; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1309 buf->st_mode = S_IFREG; /* added by T.I. for the copy-file */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1310 return 0; /* success */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1311 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1312 #endif /* __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1313 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1314 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1315 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1316 mkdir (const char *dirname, int mode) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1317 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1318 #pragma unused(mode) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1319 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1320 HFileParam hfpb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1321 char true_pathname[MAXPATHLEN+1], mac_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1322 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1323 if (find_true_pathname (dirname, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1324 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1325 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1326 if (posix_to_mac_pathname (true_pathname, mac_pathname, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1327 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1328 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1329 c2pstr (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1330 hfpb.ioNamePtr = mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1331 hfpb.ioVRefNum = 0; /* ignored unless name is invalid */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1332 hfpb.ioDirID = 0; /* parent is the root */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1333 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1334 errno = PBDirCreate ((HParmBlkPtr) &hfpb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1335 /* just return the Mac OSErr code for now */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1336 return errno == noErr ? 0 : -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1337 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1338 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1339 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1340 #undef rmdir |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1341 sys_rmdir (const char *dirname) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1342 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1343 HFileParam hfpb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1344 char mac_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1345 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1346 if (posix_to_mac_pathname (dirname, mac_pathname, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1347 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1348 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1349 c2pstr (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1350 hfpb.ioNamePtr = mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1351 hfpb.ioVRefNum = 0; /* ignored unless name is invalid */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1352 hfpb.ioDirID = 0; /* parent is the root */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1353 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1354 errno = PBHDelete ((HParmBlkPtr) &hfpb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1355 return errno == noErr ? 0 : -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1356 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1357 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1358 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1359 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1360 /* No implementation yet. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1361 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1362 execvp (const char *path, ...) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1363 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1364 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1365 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1366 #endif /* __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1367 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1368 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1369 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1370 utime (const char *path, const struct utimbuf *times) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1371 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1372 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1373 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1374 char mac_pathname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1375 CInfoPBRec cipb; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1376 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1377 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1378 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1379 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1380 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1381 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1382 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1383 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1384 strcpy (fully_resolved_name, true_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1385 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1386 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1387 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1388 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1389 c2pstr (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1390 cipb.hFileInfo.ioNamePtr = mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1391 cipb.hFileInfo.ioVRefNum = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1392 cipb.hFileInfo.ioDirID = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1393 cipb.hFileInfo.ioFDirIndex = 0; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1394 /* set to 0 to get information about specific dir or file */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1395 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1396 errno = PBGetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1397 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1398 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1399 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1400 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* bit 4 = 1 for directories */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1401 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1402 if (times) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1403 cipb.dirInfo.ioDrMdDat = times->modtime + MAC_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1404 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1405 GetDateTime (&cipb.dirInfo.ioDrMdDat); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1406 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1407 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1408 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1409 if (times) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1410 cipb.hFileInfo.ioFlMdDat = times->modtime + MAC_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1411 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1412 GetDateTime (&cipb.hFileInfo.ioFlMdDat); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1413 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1414 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1415 errno = PBSetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1416 return errno == noErr ? 0 : -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1417 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1418 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1419 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1420 #ifndef F_OK |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1421 #define F_OK 0 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1422 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1423 #ifndef X_OK |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1424 #define X_OK 1 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1425 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1426 #ifndef W_OK |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1427 #define W_OK 2 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1428 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1429 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1430 /* Like stat, but test for access mode in hfpb.ioFlAttrib */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1431 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1432 access (const char *path, int mode) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1433 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1434 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1435 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1436 char mac_pathname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1437 CInfoPBRec cipb; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1438 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1439 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1440 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1441 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1442 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1443 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1444 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1445 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1446 strcpy (fully_resolved_name, true_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1447 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1448 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1449 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1450 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1451 c2pstr (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1452 cipb.hFileInfo.ioNamePtr = mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1453 cipb.hFileInfo.ioVRefNum = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1454 cipb.hFileInfo.ioDirID = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1455 cipb.hFileInfo.ioFDirIndex = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1456 /* set to 0 to get information about specific dir or file */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1457 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1458 errno = PBGetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1459 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1460 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1461 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1462 if (mode == F_OK) /* got this far, file exists */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1463 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1464 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1465 if (mode & X_OK) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1466 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* path refers to a directory */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1467 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1468 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1469 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1470 if (cipb.hFileInfo.ioFlFndrInfo.fdType == 'APPL') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1471 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1472 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1473 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1474 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1475 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1476 if (mode & W_OK) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1477 return (cipb.hFileInfo.ioFlAttrib & 0x1) ? -1 : 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1478 /* don't allow if lock bit is on */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1479 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1480 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1481 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1482 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1483 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1484 #define DEV_NULL_FD 0x10000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1485 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1486 #undef open |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1487 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1488 sys_open (const char *path, int oflag) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1489 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1490 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1491 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1492 char mac_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1493 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1494 if (strcmp (path, "/dev/null") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1495 return DEV_NULL_FD; /* some bogus fd to be ignored in write */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1496 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1497 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1498 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1499 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1500 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1501 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1502 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1503 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1504 strcpy (fully_resolved_name, true_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1505 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1506 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1507 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1508 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1509 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1510 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1511 int res = open (mac_pathname, oflag); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1512 /* if (oflag == O_WRONLY || oflag == O_RDWR) */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1513 if (oflag & O_CREAT) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1514 fsetfileinfo (mac_pathname, 'EMAx', 'TEXT'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1515 return res; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1516 #else /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1517 return open (mac_pathname, oflag); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1518 #endif /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1519 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1520 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1521 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1522 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1523 #undef creat |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1524 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1525 sys_creat (const char *path, mode_t mode) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1526 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1527 char true_pathname[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1528 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1529 char mac_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1530 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1531 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1532 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1533 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1534 if (!posix_to_mac_pathname (true_pathname, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1535 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1536 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1537 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1538 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1539 int result = creat (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1540 fsetfileinfo (mac_pathname, 'EMAx', 'TEXT'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1541 return result; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1542 #else /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1543 return creat (mac_pathname, mode); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1544 #endif /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1545 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1546 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1547 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1548 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1549 #undef unlink |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1550 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1551 sys_unlink (const char *path) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1552 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1553 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1554 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1555 char mac_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1556 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1557 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1558 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1559 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1560 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1561 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1562 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1563 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1564 strcpy (fully_resolved_name, true_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1565 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1566 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1567 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1568 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1569 return unlink (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1570 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1571 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1572 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1573 #undef read |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1574 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1575 sys_read (int fildes, char *buf, int count) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1576 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1577 if (fildes == 0) /* this should not be used for console input */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1578 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1579 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1580 #if __MSL__ >= 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1581 return _read (fildes, buf, count); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1582 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1583 return read (fildes, buf, count); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1584 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1585 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1586 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1587 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1588 #undef write |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1589 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1590 sys_write (int fildes, const char *buf, int count) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1591 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1592 if (fildes == DEV_NULL_FD) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1593 return count; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1594 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1595 #if __MSL__ >= 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1596 return _write (fildes, buf, count); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1597 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1598 return write (fildes, buf, count); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1599 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1600 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1601 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1602 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1603 #undef rename |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1604 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1605 sys_rename (const char * old_name, const char * new_name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1606 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1607 char true_old_pathname[MAXPATHLEN+1], true_new_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1608 char fully_resolved_old_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1609 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1610 char mac_old_name[MAXPATHLEN+1], mac_new_name[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1611 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1612 if (find_true_pathname (old_name, true_old_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1613 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1614 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1615 len = readlink (true_old_pathname, fully_resolved_old_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1616 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1617 fully_resolved_old_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1618 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1619 strcpy (fully_resolved_old_name, true_old_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1620 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1621 if (find_true_pathname (new_name, true_new_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1622 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1623 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1624 if (strcmp (fully_resolved_old_name, true_new_pathname) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1625 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1626 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1627 if (!posix_to_mac_pathname (fully_resolved_old_name, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1628 mac_old_name, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1629 MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1630 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1631 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1632 if (!posix_to_mac_pathname(true_new_pathname, mac_new_name, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1633 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1634 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1635 /* If a file with new_name already exists, rename deletes the old |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1636 file in Unix. CW version fails in these situation. So we add a |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1637 call to unlink here. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1638 (void) unlink (mac_new_name); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1639 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1640 return rename (mac_old_name, mac_new_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1641 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1642 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1643 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1644 #undef fopen |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1645 extern FILE *fopen (const char *name, const char *mode); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1646 FILE * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1647 sys_fopen (const char *name, const char *mode) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1648 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1649 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1650 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1651 char mac_pathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1652 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1653 if (find_true_pathname (name, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1654 return 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1655 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1656 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1657 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1658 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1659 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1660 strcpy (fully_resolved_name, true_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1661 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1662 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1663 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1664 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1665 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1666 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1667 if (mode[0] == 'w' || mode[0] == 'a') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1668 fsetfileinfo (mac_pathname, 'EMAx', 'TEXT'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1669 #endif /* not __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1670 return fopen (mac_pathname, mode); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1671 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1672 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1673 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1674 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1675 long target_ticks = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1676 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1677 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1678 __sigfun alarm_signal_func = (__sigfun) 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1679 #elif __MWERKS__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1680 __signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1681 #else /* not __MRC__ and not __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1682 You lose!!! |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1683 #endif /* not __MRC__ and not __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1684 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1685 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1686 /* These functions simulate SIG_ALRM. The stub for function signal |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1687 stores the signal handler function in alarm_signal_func if a |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1688 SIG_ALRM is encountered. check_alarm is called in XTread_socket, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1689 which emacs calls periodically. A pending alarm is represented by |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1690 a non-zero target_ticks value. check_alarm calls the handler |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1691 function pointed to by alarm_signal_func if one has been set up and |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1692 an alarm is pending. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1693 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1694 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1695 check_alarm () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1696 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1697 if (target_ticks && TickCount () > target_ticks) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1698 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1699 target_ticks = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1700 if (alarm_signal_func) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1701 (*alarm_signal_func)(SIGALRM); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1702 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1703 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1704 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1705 |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1706 extern Boolean mac_wait_next_event (EventRecord *, UInt32, Boolean); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1707 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1708 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1709 select (n, rfds, wfds, efds, timeout) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1710 int n; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1711 SELECT_TYPE *rfds; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1712 SELECT_TYPE *wfds; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1713 SELECT_TYPE *efds; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1714 struct timeval *timeout; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1715 { |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1716 #if TARGET_API_MAC_CARBON |
60360
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1717 OSErr err; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1718 EventTimeout timeout_sec = |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1719 (timeout |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1720 ? (EMACS_SECS (*timeout) * kEventDurationSecond |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1721 + EMACS_USECS (*timeout) * kEventDurationMicrosecond) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1722 : kEventDurationForever); |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1723 |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1724 if (FD_ISSET (0, rfds)) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1725 { |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1726 BLOCK_INPUT; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1727 err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL); |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1728 UNBLOCK_INPUT; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1729 if (err == noErr) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1730 return 1; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1731 else |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1732 FD_ZERO (rfds); |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1733 } |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
1734 return 0; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1735 #else /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1736 EventRecord e; |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1737 UInt32 sleep_time = EMACS_SECS (*timeout) * 60 + |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1738 ((EMACS_USECS (*timeout) * 60) / 1000000); |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1739 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1740 /* Can only handle wait for keyboard input. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1741 if (n > 1 || wfds || efds) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1742 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1743 |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1744 /* Also return true if an event other than a keyDown has occurred. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1745 This causes kbd_buffer_get_event in keyboard.c to call |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1746 read_avail_input which in turn calls XTread_socket to poll for |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1747 these events. Otherwise these never get processed except but a |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1748 very slow poll timer. */ |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1749 if (FD_ISSET (0, rfds) && mac_wait_next_event (&e, sleep_time, false)) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
1750 return 1; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1751 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1752 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1753 #endif /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1754 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1755 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1756 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1757 /* Called in sys_select to wait for an alarm signal to arrive. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1758 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1759 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1760 pause () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1761 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1762 EventRecord e; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1763 unsigned long tick; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1764 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1765 if (!target_ticks) /* no alarm pending */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1766 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1767 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1768 if ((tick = TickCount ()) < target_ticks) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1769 WaitNextEvent (0, &e, target_ticks - tick, NULL); /* Accept no event; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1770 just wait. by T.I. */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1771 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1772 target_ticks = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1773 if (alarm_signal_func) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1774 (*alarm_signal_func)(SIGALRM); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1775 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1776 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1777 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1778 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1779 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1780 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1781 alarm (int seconds) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1782 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1783 long remaining = target_ticks ? (TickCount () - target_ticks) / 60 : 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1784 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1785 target_ticks = seconds ? TickCount () + 60 * seconds : 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1786 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1787 return (remaining < 0) ? 0 : (unsigned int) remaining; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1788 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1789 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1790 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1791 #undef signal |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1792 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1793 extern __sigfun signal (int signal, __sigfun signal_func); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1794 __sigfun |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1795 sys_signal (int signal_num, __sigfun signal_func) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1796 #elif __MWERKS__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1797 extern __signal_func_ptr signal (int signal, __signal_func_ptr signal_func); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1798 __signal_func_ptr |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1799 sys_signal (int signal_num, __signal_func_ptr signal_func) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1800 #else /* not __MRC__ and not __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1801 You lose!!! |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1802 #endif /* not __MRC__ and not __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1803 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1804 if (signal_num != SIGALRM) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1805 return signal (signal_num, signal_func); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1806 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1807 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1808 #ifdef __MRC__ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1809 __sigfun old_signal_func; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1810 #elif __MWERKS__ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1811 __signal_func_ptr old_signal_func; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1812 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1813 You lose!!! |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1814 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1815 old_signal_func = alarm_signal_func; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1816 alarm_signal_func = signal_func; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1817 return old_signal_func; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1818 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1819 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1820 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1821 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1822 /* gettimeofday should return the amount of time (in a timeval |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1823 structure) since midnight today. The toolbox function Microseconds |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1824 returns the number of microseconds (in a UnsignedWide value) since |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1825 the machine was booted. Also making this complicated is WideAdd, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1826 WideSubtract, etc. take wide values. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1827 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1828 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1829 gettimeofday (tp) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1830 struct timeval *tp; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1831 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1832 static inited = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1833 static wide wall_clock_at_epoch, clicks_at_epoch; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1834 UnsignedWide uw_microseconds; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1835 wide w_microseconds; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1836 time_t sys_time (time_t *); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1837 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1838 /* If this function is called for the first time, record the number |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1839 of seconds since midnight and the number of microseconds since |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1840 boot at the time of this first call. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1841 if (!inited) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1842 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1843 time_t systime; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1844 inited = 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1845 systime = sys_time (NULL); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1846 /* Store microseconds since midnight in wall_clock_at_epoch. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1847 WideMultiply (systime, 1000000L, &wall_clock_at_epoch); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1848 Microseconds (&uw_microseconds); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1849 /* Store microseconds since boot in clicks_at_epoch. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1850 clicks_at_epoch.hi = uw_microseconds.hi; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1851 clicks_at_epoch.lo = uw_microseconds.lo; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1852 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1853 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1854 /* Get time since boot */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1855 Microseconds (&uw_microseconds); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1856 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1857 /* Convert to time since midnight*/ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1858 w_microseconds.hi = uw_microseconds.hi; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1859 w_microseconds.lo = uw_microseconds.lo; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1860 WideSubtract (&w_microseconds, &clicks_at_epoch); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1861 WideAdd (&w_microseconds, &wall_clock_at_epoch); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1862 tp->tv_sec = WideDivide (&w_microseconds, 1000000L, &tp->tv_usec); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1863 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1864 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1865 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1866 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1867 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1868 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1869 unsigned int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1870 sleep (unsigned int seconds) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1871 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1872 unsigned long time_up; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1873 EventRecord e; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1874 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1875 time_up = TickCount () + seconds * 60; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1876 while (TickCount () < time_up) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1877 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1878 /* Accept no event; just wait. by T.I. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1879 WaitNextEvent (0, &e, 30, NULL); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1880 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1881 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1882 return (0); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1883 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1884 #endif /* __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1885 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1886 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1887 /* The time functions adjust time values according to the difference |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1888 between the Unix and CW epoches. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1889 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1890 #undef gmtime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1891 extern struct tm *gmtime (const time_t *); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1892 struct tm * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1893 sys_gmtime (const time_t *timer) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1894 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1895 time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1896 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1897 return gmtime (&unix_time); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1898 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1899 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1900 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1901 #undef localtime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1902 extern struct tm *localtime (const time_t *); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1903 struct tm * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1904 sys_localtime (const time_t *timer) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1905 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1906 #if __MSL__ >= 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1907 time_t unix_time = *timer; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1908 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1909 time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1910 #endif |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1911 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1912 return localtime (&unix_time); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1913 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1914 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1915 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1916 #undef ctime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1917 extern char *ctime (const time_t *); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1918 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1919 sys_ctime (const time_t *timer) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1920 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1921 #if __MSL__ >= 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1922 time_t unix_time = *timer; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1923 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1924 time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1925 #endif |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1926 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1927 return ctime (&unix_time); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1928 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1929 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1930 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1931 #undef time |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1932 extern time_t time (time_t *); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1933 time_t |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1934 sys_time (time_t *timer) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1935 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1936 #if __MSL__ >= 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1937 time_t mac_time = time (NULL); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1938 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1939 time_t mac_time = time (NULL) - CW_OR_MPW_UNIX_EPOCH_DIFF; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1940 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1941 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1942 if (timer) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1943 *timer = mac_time; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
1944 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1945 return mac_time; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1946 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1947 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1948 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1949 /* MPW strftime broken for "%p" format */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1950 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1951 #undef strftime |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1952 #include <time.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1953 size_t |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1954 sys_strftime (char * s, size_t maxsize, const char * format, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1955 const struct tm * timeptr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1956 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1957 if (strcmp (format, "%p") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1958 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1959 if (maxsize < 3) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1960 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1961 if (timeptr->tm_hour < 12) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1962 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1963 strcpy (s, "AM"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1964 return 2; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1965 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1966 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1967 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1968 strcpy (s, "PM"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1969 return 2; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1970 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1971 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1972 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1973 return strftime (s, maxsize, format, timeptr); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1974 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1975 #endif /* __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1976 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1977 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1978 /* no subprocesses, empty wait */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1979 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1980 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1981 wait (int pid) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1982 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1983 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1984 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1985 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1986 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1987 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1988 croak (char *badfunc) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1989 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1990 printf ("%s not yet implemented\r\n", badfunc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1991 exit (1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1992 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1993 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1994 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1995 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1996 index (const char * str, int chr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1997 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1998 return strchr (str, chr); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
1999 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2001 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2002 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2003 mktemp (char *template) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2004 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2005 int len, k; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2006 static seqnum = 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2007 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2008 len = strlen (template); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2009 k = len - 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2010 while (k >= 0 && template[k] == 'X') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2011 k--; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2012 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2013 k++; /* make k index of first 'X' */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2014 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2015 if (k < len) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2016 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2017 /* Zero filled, number of digits equal to the number of X's. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2018 sprintf (&template[k], "%0*d", len-k, seqnum++); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2019 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2020 return template; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2021 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2022 else |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2023 return 0; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2024 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2025 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2026 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2027 /* Emulate getpwuid, getpwnam and others. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2028 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2029 #define PASSWD_FIELD_SIZE 256 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2030 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2031 static char my_passwd_name[PASSWD_FIELD_SIZE]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2032 static char my_passwd_dir[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2033 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2034 static struct passwd my_passwd = |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2035 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2036 my_passwd_name, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2037 my_passwd_dir, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2038 }; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2039 |
53122 | 2040 static struct group my_group = |
2041 { | |
2042 /* There are no groups on the mac, so we just return "root" as the | |
2043 group name. */ | |
2044 "root", | |
2045 }; | |
2046 | |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2047 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2048 /* Initialized by main () in macterm.c to pathname of emacs directory. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2049 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2050 char emacs_passwd_dir[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2051 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2052 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2053 getwd (char *); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2054 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2055 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2056 init_emacs_passwd_dir () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2057 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2058 int found = false; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2059 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2060 if (getwd (emacs_passwd_dir) && getwd (my_passwd_dir)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2061 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2062 /* Need pathname of first ancestor that begins with "emacs" |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2063 since Mac emacs application is somewhere in the emacs-* |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2064 tree. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2065 int len = strlen (emacs_passwd_dir); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2066 int j = len - 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2067 /* j points to the "/" following the directory name being |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2068 compared. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2069 int i = j - 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2070 while (i >= 0 && !found) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2071 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2072 while (i >= 0 && emacs_passwd_dir[i] != '/') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2073 i--; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2074 if (emacs_passwd_dir[i] == '/' && i+5 < len) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2075 found = (strncmp (&(emacs_passwd_dir[i+1]), "emacs", 5) == 0); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2076 if (found) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2077 emacs_passwd_dir[j+1] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2078 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2079 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2080 j = i; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2081 i = j - 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2082 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2083 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2084 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2085 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2086 if (!found) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2087 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2088 /* Setting to "/" probably won't work but set it to something |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2089 anyway. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2090 strcpy (emacs_passwd_dir, "/"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2091 strcpy (my_passwd_dir, "/"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2092 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2093 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2094 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2095 |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2096 static struct passwd emacs_passwd = |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2097 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2098 "emacs", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2099 emacs_passwd_dir, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2100 }; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2101 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2102 static int my_passwd_inited = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2103 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2104 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2105 static void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2106 init_my_passwd () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2107 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2108 char **owner_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2109 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2110 /* Note: my_passwd_dir initialized in int_emacs_passwd_dir to |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2111 directory where Emacs was started. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2112 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2113 owner_name = (char **) GetResource ('STR ',-16096); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2114 if (owner_name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2115 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2116 HLock (owner_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2117 BlockMove ((unsigned char *) *owner_name, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2118 (unsigned char *) my_passwd_name, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2119 *owner_name[0]+1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2120 HUnlock (owner_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2121 p2cstr ((unsigned char *) my_passwd_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2122 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2123 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2124 my_passwd_name[0] = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2125 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2126 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2127 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2128 struct passwd * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2129 getpwuid (uid_t uid) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2130 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2131 if (!my_passwd_inited) |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2132 { |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2133 init_my_passwd (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2134 my_passwd_inited = 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2135 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2136 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2137 return &my_passwd; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2138 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2139 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2140 |
53122 | 2141 struct group * |
2142 getgrgid (gid_t gid) | |
2143 { | |
2144 return &my_group; | |
2145 } | |
2146 | |
2147 | |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2148 struct passwd * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2149 getpwnam (const char *name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2150 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2151 if (strcmp (name, "emacs") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2152 return &emacs_passwd; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2153 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2154 if (!my_passwd_inited) |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2155 { |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2156 init_my_passwd (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2157 my_passwd_inited = 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2158 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2159 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2160 return &my_passwd; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2161 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2162 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2163 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2164 /* The functions fork, kill, sigsetmask, sigblock, request_sigio, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2165 setpgrp, setpriority, and unrequest_sigio are defined to be empty |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2166 as in msdos.c. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2167 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2168 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2169 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2170 fork () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2171 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2172 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2173 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2174 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2175 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2176 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2177 kill (int x, int y) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2178 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2179 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2180 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2181 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2182 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2183 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2184 sys_subshell () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2185 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2186 error ("Can't spawn subshell"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2187 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2188 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2189 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2190 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2191 sigsetmask (int x) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2192 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2193 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2194 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2195 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2196 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2197 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2198 sigblock (int mask) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2199 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2200 return 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2201 } |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2202 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2203 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2204 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2205 request_sigio (void) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2206 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2207 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2208 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2209 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2210 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2211 unrequest_sigio (void) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2212 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2213 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2214 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2215 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2216 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2217 setpgrp () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2218 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2219 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2220 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2221 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2222 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2223 /* No pipes yet. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2224 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2225 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2226 pipe (int _fildes[2]) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2227 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2228 errno = EACCES; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2229 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2230 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2231 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2232 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2233 /* Hard and symbolic links. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2234 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2235 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2236 symlink (const char *name1, const char *name2) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2237 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2238 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2239 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2240 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2241 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2242 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2243 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2244 link (const char *name1, const char *name2) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2245 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2246 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2247 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2248 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2249 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2250 #endif /* ! MAC_OSX */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2251 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2252 /* Determine the path name of the file specified by VREFNUM, DIRID, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2253 and NAME and place that in the buffer PATH of length |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2254 MAXPATHLEN. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2255 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2256 path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2257 long dir_id, ConstStr255Param name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2258 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2259 Str255 dir_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2260 CInfoPBRec cipb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2261 OSErr err; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2262 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2263 if (strlen (name) > man_path_len) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2264 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2265 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2266 memcpy (dir_name, name, name[0]+1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2267 memcpy (path, name, name[0]+1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2268 p2cstr (path); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2269 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2270 cipb.dirInfo.ioDrParID = dir_id; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2271 cipb.dirInfo.ioNamePtr = dir_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2272 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2273 do |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2274 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2275 cipb.dirInfo.ioVRefNum = vol_ref_num; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2276 cipb.dirInfo.ioFDirIndex = -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2277 cipb.dirInfo.ioDrDirID = cipb.dirInfo.ioDrParID; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2278 /* go up to parent each time */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2279 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2280 err = PBGetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2281 if (err != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2282 return 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2283 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2284 p2cstr (dir_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2285 if (strlen (dir_name) + strlen (path) + 1 >= man_path_len) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2286 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2287 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2288 strcat (dir_name, ":"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2289 strcat (dir_name, path); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2290 /* attach to front since we're going up directory tree */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2291 strcpy (path, dir_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2292 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2293 while (cipb.dirInfo.ioDrDirID != fsRtDirID); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2294 /* stop when we see the volume's root directory */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2295 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2296 return 1; /* success */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2297 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2298 |
60360
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2299 |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2300 OSErr |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2301 posix_pathname_to_fsspec (ufn, fs) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2302 const char *ufn; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2303 FSSpec *fs; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2304 { |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2305 Str255 mac_pathname; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2306 |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2307 if (posix_to_mac_pathname (ufn, mac_pathname, sizeof (mac_pathname)) == 0) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2308 return fnfErr; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2309 else |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2310 { |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2311 c2pstr (mac_pathname); |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2312 return FSMakeFSSpec (0, 0, mac_pathname, fs); |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2313 } |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2314 } |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2315 |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2316 OSErr |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2317 fsspec_to_posix_pathname (fs, ufn, ufnbuflen) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2318 const FSSpec *fs; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2319 char *ufn; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2320 int ufnbuflen; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2321 { |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2322 char mac_pathname[MAXPATHLEN]; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2323 |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2324 if (path_from_vol_dir_name (mac_pathname, sizeof (mac_pathname) - 1, |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2325 fs->vRefNum, fs->parID, fs->name) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2326 && mac_to_posix_pathname (mac_pathname, ufn, ufnbuflen)) |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2327 return noErr; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2328 else |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2329 return fnfErr; |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2330 } |
86edfe26d552
[!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59897
diff
changeset
|
2331 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2332 #ifndef MAC_OSX |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2333 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2334 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2335 readlink (const char *path, char *buf, int bufsiz) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2336 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2337 char mac_sym_link_name[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2338 OSErr err; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2339 FSSpec fsspec; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2340 Boolean target_is_folder, was_aliased; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2341 Str255 directory_name, mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2342 CInfoPBRec cipb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2343 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2344 if (posix_to_mac_pathname (path, mac_sym_link_name, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2345 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2346 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2347 c2pstr (mac_sym_link_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2348 err = FSMakeFSSpec (0, 0, mac_sym_link_name, &fsspec); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2349 if (err != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2350 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2351 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2352 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2353 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2354 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2355 err = ResolveAliasFile (&fsspec, true, &target_is_folder, &was_aliased); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2356 if (err != noErr || !was_aliased) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2357 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2358 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2359 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2360 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2361 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2362 if (path_from_vol_dir_name (mac_pathname, 255, fsspec.vRefNum, fsspec.parID, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2363 fsspec.name) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2364 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2365 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2366 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2367 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2368 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2369 if (mac_to_posix_pathname (mac_pathname, buf, bufsiz) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2370 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2371 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2372 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2373 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2374 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2375 return strlen (buf); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2376 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2377 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2378 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2379 /* Convert a path to one with aliases fully expanded. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2380 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2381 static int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2382 find_true_pathname (const char *path, char *buf, int bufsiz) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2383 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2384 char *q, temp[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2385 const char *p; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2386 int len; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2387 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2388 if (bufsiz <= 0 || path == 0 || path[0] == '\0') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2389 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2390 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2391 buf[0] = '\0'; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2392 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2393 p = path; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2394 if (*p == '/') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2395 q = strchr (p + 1, '/'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2396 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2397 q = strchr (p, '/'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2398 len = 0; /* loop may not be entered, e.g., for "/" */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2399 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2400 while (q) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2401 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2402 strcpy (temp, buf); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2403 strncat (temp, p, q - p); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2404 len = readlink (temp, buf, bufsiz); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2405 if (len <= -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2406 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2407 if (strlen (temp) + 1 > bufsiz) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2408 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2409 strcpy (buf, temp); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2410 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2411 strcat (buf, "/"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2412 len++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2413 p = q + 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2414 q = strchr(p, '/'); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2415 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2416 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2417 if (len + strlen (p) + 1 >= bufsiz) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2418 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2419 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2420 strcat (buf, p); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2421 return len + strlen (p); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2422 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2423 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2424 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2425 mode_t |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2426 umask (mode_t numask) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2427 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2428 static mode_t mask = 022; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2429 mode_t oldmask = mask; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2430 mask = numask; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2431 return oldmask; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2432 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2433 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2434 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2435 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2436 chmod (const char *path, mode_t mode) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2437 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2438 /* say it always succeed for now */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2439 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2440 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2441 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2442 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2443 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2444 dup (int oldd) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2445 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2446 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2447 return fcntl (oldd, F_DUPFD, 0); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2448 #elif __MWERKS__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2449 /* current implementation of fcntl in fcntl.mac.c simply returns old |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2450 descriptor */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2451 return fcntl (oldd, F_DUPFD); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2452 #else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2453 You lose!!! |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2454 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2455 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2456 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2457 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2458 /* This is from the original sysdep.c. Emulate BSD dup2. First close |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2459 newd if it already exists. Then, attempt to dup oldd. If not |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2460 successful, call dup2 recursively until we are, then close the |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2461 unsuccessful ones. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2462 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2463 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2464 dup2 (int oldd, int newd) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2465 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2466 int fd, ret; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2467 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2468 close (newd); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2469 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2470 fd = dup (oldd); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2471 if (fd == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2472 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2473 if (fd == newd) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2474 return newd; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2475 ret = dup2 (oldd, newd); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2476 close (fd); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2477 return ret; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2478 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2479 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2480 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2481 /* let it fail for now */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2482 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2483 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2484 sbrk (int incr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2485 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2486 return (char *) -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2487 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2488 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2489 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2490 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2491 fsync (int fd) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2492 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2493 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2494 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2495 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2496 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2497 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2498 ioctl (int d, int request, void *argp) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2499 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2500 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2501 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2502 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2503 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2504 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2505 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2506 isatty (int fildes) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2507 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2508 if (fildes >=0 && fildes <= 2) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2509 return 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2510 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2511 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2512 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2513 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2514 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2515 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2516 getgid () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2517 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2518 return 100; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2519 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2520 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2521 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2522 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2523 getegid () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2524 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2525 return 100; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2526 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2527 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2528 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2529 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2530 getuid () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2531 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2532 return 200; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2533 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2534 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2535 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2536 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2537 geteuid () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2538 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2539 return 200; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2540 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2541 #endif /* __MRC__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2542 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2543 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2544 #ifdef __MWERKS__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2545 #if __MSL__ < 0x6000 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2546 #undef getpid |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2547 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2548 getpid () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2549 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2550 return 9999; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2551 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2552 #endif |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2553 #endif /* __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2554 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2555 #endif /* ! MAC_OSX */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2556 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2557 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2558 /* Return the path to the directory in which Emacs can create |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2559 temporary files. The MacOS "temporary items" directory cannot be |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2560 used because it removes the file written by a process when it |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2561 exits. In that sense it's more like "/dev/null" than "/tmp" (but |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2562 again not exactly). And of course Emacs needs to read back the |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2563 files written by its subprocesses. So here we write the files to a |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2564 directory "Emacs" in the Preferences Folder. This directory is |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2565 created if it does not exist. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2566 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2567 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2568 get_temp_dir_name () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2569 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2570 static char *temp_dir_name = NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2571 short vol_ref_num; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2572 long dir_id; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2573 OSErr err; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2574 Str255 dir_name, full_path; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2575 CInfoPBRec cpb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2576 char unix_dir_name[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2577 DIR *dir; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2578 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2579 /* Cache directory name with pointer temp_dir_name. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2580 Look for it only the first time. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2581 if (!temp_dir_name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2582 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2583 err = FindFolder (kOnSystemDisk, kPreferencesFolderType, kCreateFolder, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2584 &vol_ref_num, &dir_id); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2585 if (err != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2586 return NULL; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2587 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2588 if (!path_from_vol_dir_name (full_path, 255, vol_ref_num, dir_id, "\p")) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2589 return NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2590 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2591 if (strlen (full_path) + 6 <= MAXPATHLEN) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2592 strcat (full_path, "Emacs:"); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2593 else |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2594 return NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2595 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2596 if (!mac_to_posix_pathname (full_path, unix_dir_name, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2597 return NULL; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2598 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2599 dir = opendir (unix_dir_name); /* check whether temp directory exists */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2600 if (dir) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2601 closedir (dir); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2602 else if (mkdir (unix_dir_name, 0700) != 0) /* create it if not */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2603 return NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2604 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2605 temp_dir_name = (char *) malloc (strlen (unix_dir_name) + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2606 strcpy (temp_dir_name, unix_dir_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2607 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2608 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2609 return temp_dir_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2610 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2611 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2612 #ifndef MAC_OSX |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2613 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2614 /* Allocate and construct an array of pointers to strings from a list |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2615 of strings stored in a 'STR#' resource. The returned pointer array |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2616 is stored in the style of argv and environ: if the 'STR#' resource |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2617 contains numString strings, a pointer array with numString+1 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2618 elements is returned in which the last entry contains a null |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2619 pointer. The pointer to the pointer array is passed by pointer in |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2620 parameter t. The resource ID of the 'STR#' resource is passed in |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2621 parameter StringListID. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2622 */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2623 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2624 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2625 get_string_list (char ***t, short string_list_id) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2626 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2627 Handle h; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2628 Ptr p; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2629 int i, num_strings; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2630 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2631 h = GetResource ('STR#', string_list_id); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2632 if (h) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2633 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2634 HLock (h); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2635 p = *h; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2636 num_strings = * (short *) p; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2637 p += sizeof(short); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2638 *t = (char **) malloc (sizeof (char *) * (num_strings + 1)); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2639 for (i = 0; i < num_strings; i++) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2640 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2641 short length = *p++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2642 (*t)[i] = (char *) malloc (length + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2643 strncpy ((*t)[i], p, length); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2644 (*t)[i][length] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2645 p += length; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2646 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2647 (*t)[num_strings] = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2648 HUnlock (h); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2649 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2650 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2651 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2652 /* Return no string in case GetResource fails. Bug fixed by |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2653 Ikegami Tsutomu. Caused MPW build to crash without sym -on |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2654 option (no sym -on implies -opt local). */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2655 *t = (char **) malloc (sizeof (char *)); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2656 (*t)[0] = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2657 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2658 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2659 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2660 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2661 static char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2662 get_path_to_system_folder () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2663 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2664 short vol_ref_num; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2665 long dir_id; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2666 OSErr err; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2667 Str255 dir_name, full_path; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2668 CInfoPBRec cpb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2669 static char system_folder_unix_name[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2670 DIR *dir; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2671 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2672 err = FindFolder (kOnSystemDisk, kSystemFolderType, kDontCreateFolder, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2673 &vol_ref_num, &dir_id); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2674 if (err != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2675 return NULL; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2676 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2677 if (!path_from_vol_dir_name (full_path, 255, vol_ref_num, dir_id, "\p")) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2678 return NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2679 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2680 if (!mac_to_posix_pathname (full_path, system_folder_unix_name, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2681 MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2682 return NULL; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2683 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2684 return system_folder_unix_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2685 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2686 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2687 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2688 char **environ; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2689 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2690 #define ENVIRON_STRING_LIST_ID 128 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2691 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2692 /* Get environment variable definitions from STR# resource. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2693 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2694 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2695 init_environ () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2696 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2697 int i; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2698 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2699 get_string_list (&environ, ENVIRON_STRING_LIST_ID); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2700 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2701 i = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2702 while (environ[i]) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2703 i++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2704 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2705 /* Make HOME directory the one Emacs starts up in if not specified |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2706 by resource. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2707 if (getenv ("HOME") == NULL) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2708 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2709 environ = (char **) realloc (environ, sizeof (char *) * (i + 2)); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2710 if (environ) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2711 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2712 environ[i] = (char *) malloc (strlen (my_passwd_dir) + 6); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2713 if (environ[i]) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2714 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2715 strcpy (environ[i], "HOME="); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2716 strcat (environ[i], my_passwd_dir); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2717 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2718 environ[i+1] = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2719 i++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2720 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2721 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2722 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2723 /* Make HOME directory the one Emacs starts up in if not specified |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2724 by resource. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2725 if (getenv ("MAIL") == NULL) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2726 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2727 environ = (char **) realloc (environ, sizeof (char *) * (i + 2)); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2728 if (environ) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2729 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2730 char * path_to_system_folder = get_path_to_system_folder (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2731 environ[i] = (char *) malloc (strlen (path_to_system_folder) + 22); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2732 if (environ[i]) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2733 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2734 strcpy (environ[i], "MAIL="); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2735 strcat (environ[i], path_to_system_folder); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2736 strcat (environ[i], "Eudora Folder/In"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2737 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2738 environ[i+1] = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2739 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2740 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2741 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2742 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2743 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2744 /* Return the value of the environment variable NAME. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2745 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2746 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2747 getenv (const char *name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2748 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2749 int length = strlen(name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2750 char **e; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2751 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2752 for (e = environ; *e != 0; e++) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2753 if (strncmp(*e, name, length) == 0 && (*e)[length] == '=') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2754 return &(*e)[length + 1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2755 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2756 if (strcmp (name, "TMPDIR") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2757 return get_temp_dir_name (); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2758 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2759 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2760 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2761 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2762 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2763 #ifdef __MRC__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2764 /* see Interfaces&Libraries:Interfaces:CIncludes:signal.h */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2765 char *sys_siglist[] = |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2766 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2767 "Zero is not a signal!!!", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2768 "Abort", /* 1 */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2769 "Interactive user interrupt", /* 2 */ "?", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2770 "Floating point exception", /* 4 */ "?", "?", "?", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2771 "Illegal instruction", /* 8 */ "?", "?", "?", "?", "?", "?", "?", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2772 "Segment violation", /* 16 */ "?", "?", "?", "?", "?", "?", "?", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2773 "?", "?", "?", "?", "?", "?", "?", "?", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2774 "Terminal" /* 32 */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2775 }; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2776 #elif __MWERKS__ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2777 char *sys_siglist[] = |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2778 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2779 "Zero is not a signal!!!", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2780 "Abort", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2781 "Floating point exception", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2782 "Illegal instruction", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2783 "Interactive user interrupt", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2784 "Segment violation", |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2785 "Terminal" |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2786 }; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2787 #else /* not __MRC__ and not __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2788 You lose!!! |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2789 #endif /* not __MRC__ and not __MWERKS__ */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2790 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2791 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2792 #include <utsname.h> |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2793 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2794 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2795 uname (struct utsname *name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2796 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2797 char **system_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2798 system_name = GetString (-16413); /* IM - Resource Manager Reference */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2799 if (system_name) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2800 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2801 BlockMove (*system_name, name->nodename, (*system_name)[0]+1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2802 p2cstr (name->nodename); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2803 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2804 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2805 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2806 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2807 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2808 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2809 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2810 /* Event class of HLE sent to subprocess. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2811 const OSType kEmacsSubprocessSend = 'ESND'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2812 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2813 /* Event class of HLE sent back from subprocess. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2814 const OSType kEmacsSubprocessReply = 'ERPY'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2815 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2816 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2817 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2818 mystrchr (char *s, char c) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2819 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2820 while (*s && *s != c) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2821 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2822 if (*s == '\\') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2823 s++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2824 s++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2825 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2826 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2827 if (*s) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2828 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2829 *s = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2830 return s; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2831 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2832 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2833 return NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2834 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2835 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2836 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2837 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2838 mystrtok (char *s) |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2839 { |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2840 while (*s) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2841 s++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2842 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2843 return s + 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2844 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2845 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2846 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2847 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2848 mystrcpy (char *to, char *from) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2849 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2850 while (*from) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2851 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2852 if (*from == '\\') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2853 from++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2854 *to++ = *from++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2855 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2856 *to = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2857 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2858 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2859 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2860 /* Start a Mac subprocess. Arguments for it is passed in argv (null |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2861 terminated). The process should run with the default directory |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2862 "workdir", read input from "infn", and write output and error to |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2863 "outfn" and "errfn", resp. The Process Manager call |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2864 LaunchApplication is used to start the subprocess. We use high |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2865 level events as the mechanism to pass arguments to the subprocess |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2866 and to make Emacs wait for the subprocess to terminate and pass |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2867 back a result code. The bulk of the code here packs the arguments |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2868 into one message to be passed together with the high level event. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2869 Emacs also sometimes starts a subprocess using a shell to perform |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2870 wildcard filename expansion. Since we don't really have a shell on |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2871 the Mac, this case is detected and the starting of the shell is |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2872 by-passed. We really need to add code here to do filename |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2873 expansion to support such functionality. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2874 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2875 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2876 run_mac_command (argv, workdir, infn, outfn, errfn) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2877 unsigned char **argv; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2878 const char *workdir; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2879 const char *infn, *outfn, *errfn; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2880 { |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
2881 #if TARGET_API_MAC_CARBON |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2882 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2883 #else /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2884 char macappname[MAXPATHLEN+1], macworkdir[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2885 char macinfn[MAXPATHLEN+1], macoutfn[MAXPATHLEN+1], macerrfn[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2886 int paramlen, argc, newargc, j, retries; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2887 char **newargv, *param, *p; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2888 OSErr iErr; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2889 FSSpec spec; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2890 LaunchParamBlockRec lpbr; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2891 EventRecord send_event, reply_event; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2892 RgnHandle cursor_region_handle; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2893 TargetID targ; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2894 unsigned long ref_con, len; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2895 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2896 if (posix_to_mac_pathname (workdir, macworkdir, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2897 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2898 if (posix_to_mac_pathname (infn, macinfn, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2899 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2900 if (posix_to_mac_pathname (outfn, macoutfn, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2901 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2902 if (posix_to_mac_pathname (errfn, macerrfn, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2903 return -1; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2904 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2905 paramlen = strlen (macworkdir) + strlen (macinfn) + strlen (macoutfn) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2906 + strlen (macerrfn) + 4; /* count nulls at end of strings */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2907 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2908 argc = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2909 while (argv[argc]) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2910 argc++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2911 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2912 if (argc == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2913 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2914 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2915 /* If a subprocess is invoked with a shell, we receive 3 arguments |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2916 of the form: "<path to emacs bins>/sh" "-c" "<path to emacs |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2917 bins>/<command> <command args>" */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2918 j = strlen (argv[0]); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2919 if (j >= 3 && strcmp (argv[0]+j-3, "/sh") == 0 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2920 && argc == 3 && strcmp (argv[1], "-c") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2921 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2922 char *command, *t, tempmacpathname[MAXPATHLEN+1]; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2923 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2924 /* The arguments for the command in argv[2] are separated by |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2925 spaces. Count them and put the count in newargc. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2926 command = (char *) alloca (strlen (argv[2])+2); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2927 strcpy (command, argv[2]); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2928 if (command[strlen (command) - 1] != ' ') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2929 strcat (command, " "); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2930 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2931 t = command; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2932 newargc = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2933 t = mystrchr (t, ' '); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2934 while (t) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2935 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2936 newargc++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2937 t = mystrchr (t+1, ' '); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2938 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2939 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2940 newargv = (char **) alloca (sizeof (char *) * newargc); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2941 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2942 t = command; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2943 for (j = 0; j < newargc; j++) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2944 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2945 newargv[j] = (char *) alloca (strlen (t) + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2946 mystrcpy (newargv[j], t); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2947 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2948 t = mystrtok (t); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2949 paramlen += strlen (newargv[j]) + 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2950 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2951 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2952 if (strncmp (newargv[0], "~emacs/", 7) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2953 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2954 if (posix_to_mac_pathname (newargv[0], tempmacpathname, MAXPATHLEN+1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2955 == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2956 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2957 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2958 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2959 { /* sometimes Emacs call "sh" without a path for the command */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2960 #if 0 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2961 char *t = (char *) alloca (strlen (newargv[0]) + 7 + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2962 strcpy (t, "~emacs/"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2963 strcat (t, newargv[0]); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2964 #endif /* 0 */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2965 Lisp_Object path; |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
2966 openp (Vexec_path, build_string (newargv[0]), Vexec_suffixes, &path, |
45004
303384b6edc4
(run_mac_command): Update call to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44890
diff
changeset
|
2967 make_number (X_OK)); |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2968 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2969 if (NILP (path)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2970 return -1; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45851
diff
changeset
|
2971 if (posix_to_mac_pathname (SDATA (path), tempmacpathname, |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2972 MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2973 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2974 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2975 strcpy (macappname, tempmacpathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2976 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2977 else |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2978 { |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2979 if (posix_to_mac_pathname (argv[0], macappname, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2980 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2981 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2982 newargv = (char **) alloca (sizeof (char *) * argc); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
2983 newargc = argc; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2984 for (j = 1; j < argc; j++) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2985 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2986 if (strncmp (argv[j], "~emacs/", 7) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2987 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2988 char *t = strchr (argv[j], ' '); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2989 if (t) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2990 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2991 char tempcmdname[MAXPATHLEN+1], tempmaccmdname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2992 strncpy (tempcmdname, argv[j], t-argv[j]); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2993 tempcmdname[t-argv[j]] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2994 if (posix_to_mac_pathname (tempcmdname, tempmaccmdname, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2995 MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2996 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2997 newargv[j] = (char *) alloca (strlen (tempmaccmdname) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2998 + strlen (t) + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
2999 strcpy (newargv[j], tempmaccmdname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3000 strcat (newargv[j], t); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3001 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3002 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3003 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3004 char tempmaccmdname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3005 if (posix_to_mac_pathname (argv[j], tempmaccmdname, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3006 MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3007 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3008 newargv[j] = (char *) alloca (strlen (tempmaccmdname)+1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3009 strcpy (newargv[j], tempmaccmdname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3010 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3011 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3012 else |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3013 newargv[j] = argv[j]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3014 paramlen += strlen (newargv[j]) + 1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3015 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3016 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3017 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3018 /* After expanding all the arguments, we now know the length of the |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3019 parameter block to be sent to the subprocess as a message |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3020 attached to the HLE. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3021 param = (char *) malloc (paramlen + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3022 if (!param) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3023 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3024 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3025 p = param; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3026 *p++ = newargc; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3027 /* first byte of message contains number of arguments for command */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3028 strcpy (p, macworkdir); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3029 p += strlen (macworkdir); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3030 *p++ = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3031 /* null terminate strings sent so it's possible to use strcpy over there */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3032 strcpy (p, macinfn); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3033 p += strlen (macinfn); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3034 *p++ = '\0'; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3035 strcpy (p, macoutfn); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3036 p += strlen (macoutfn); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3037 *p++ = '\0'; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3038 strcpy (p, macerrfn); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3039 p += strlen (macerrfn); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3040 *p++ = '\0'; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3041 for (j = 1; j < newargc; j++) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3042 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3043 strcpy (p, newargv[j]); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3044 p += strlen (newargv[j]); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3045 *p++ = '\0'; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3046 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3047 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3048 c2pstr (macappname); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3049 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3050 iErr = FSMakeFSSpec (0, 0, macappname, &spec); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3051 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3052 if (iErr != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3053 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3054 free (param); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3055 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3056 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3057 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3058 lpbr.launchBlockID = extendedBlock; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3059 lpbr.launchEPBLength = extendedBlockLen; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3060 lpbr.launchControlFlags = launchContinue + launchNoFileFlags; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3061 lpbr.launchAppSpec = &spec; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3062 lpbr.launchAppParameters = NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3063 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3064 iErr = LaunchApplication (&lpbr); /* call the subprocess */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3065 if (iErr != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3066 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3067 free (param); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3068 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3069 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3070 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3071 send_event.what = kHighLevelEvent; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3072 send_event.message = kEmacsSubprocessSend; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3073 /* Event ID stored in "where" unused */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3074 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3075 retries = 3; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3076 /* OS may think current subprocess has terminated if previous one |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3077 terminated recently. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3078 do |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3079 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3080 iErr = PostHighLevelEvent (&send_event, &lpbr.launchProcessSN, 0, param, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3081 paramlen + 1, receiverIDisPSN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3082 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3083 while (iErr == sessClosedErr && retries-- > 0); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3084 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3085 if (iErr != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3086 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3087 free (param); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3088 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3089 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3090 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3091 cursor_region_handle = NewRgn (); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3092 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3093 /* Wait for the subprocess to finish, when it will send us a ERPY |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3094 high level event. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3095 while (1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3096 if (WaitNextEvent (highLevelEventMask, &reply_event, 180, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3097 cursor_region_handle) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3098 && reply_event.message == kEmacsSubprocessReply) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3099 break; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3100 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3101 /* The return code is sent through the refCon */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3102 iErr = AcceptHighLevelEvent (&targ, &ref_con, NULL, &len); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3103 if (iErr != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3104 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3105 DisposeHandle ((Handle) cursor_region_handle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3106 free (param); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3107 return -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3108 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3109 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3110 DisposeHandle ((Handle) cursor_region_handle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3111 free (param); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3112 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3113 return ref_con; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3114 #endif /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3115 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3116 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3117 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3118 DIR * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3119 opendir (const char *dirname) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3120 { |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3121 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1]; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3122 char mac_pathname[MAXPATHLEN+1], vol_name[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3123 DIR *dirp; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3124 CInfoPBRec cipb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3125 HVolumeParam vpb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3126 int len, vol_name_len; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3127 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3128 if (find_true_pathname (dirname, true_pathname, MAXPATHLEN+1) == -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3129 return 0; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3130 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3131 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3132 if (len > -1) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3133 fully_resolved_name[len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3134 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3135 strcpy (fully_resolved_name, true_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3136 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3137 dirp = (DIR *) malloc (sizeof(DIR)); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3138 if (!dirp) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3139 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3140 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3141 /* Handle special case when dirname is "/": sets up for readir to |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3142 get all mount volumes. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3143 if (strcmp (fully_resolved_name, "/") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3144 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3145 dirp->getting_volumes = 1; /* special all mounted volumes DIR struct */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3146 dirp->current_index = 1; /* index for first volume */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3147 return dirp; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3148 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3149 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3150 /* Handle typical cases: not accessing all mounted volumes. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3151 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3152 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3153 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3154 /* Emacs calls opendir without the trailing '/', Mac needs trailing ':' */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3155 len = strlen (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3156 if (mac_pathname[len - 1] != ':' && len < MAXPATHLEN) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3157 strcat (mac_pathname, ":"); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3158 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3159 /* Extract volume name */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3160 vol_name_len = strchr (mac_pathname, ':') - mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3161 strncpy (vol_name, mac_pathname, vol_name_len); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3162 vol_name[vol_name_len] = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3163 strcat (vol_name, ":"); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3164 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3165 c2pstr (mac_pathname); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3166 cipb.hFileInfo.ioNamePtr = mac_pathname; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3167 /* using full pathname so vRefNum and DirID ignored */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3168 cipb.hFileInfo.ioVRefNum = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3169 cipb.hFileInfo.ioDirID = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3170 cipb.hFileInfo.ioFDirIndex = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3171 /* set to 0 to get information about specific dir or file */ |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3172 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3173 errno = PBGetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3174 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3175 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3176 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3177 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3178 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3179 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3180 if (!(cipb.hFileInfo.ioFlAttrib & 0x10)) /* bit 4 = 1 for directories */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3181 return 0; /* not a directory */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3182 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3183 dirp->dir_id = cipb.dirInfo.ioDrDirID; /* used later in readdir */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3184 dirp->getting_volumes = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3185 dirp->current_index = 1; /* index for first file/directory */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3186 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3187 c2pstr (vol_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3188 vpb.ioNamePtr = vol_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3189 /* using full pathname so vRefNum and DirID ignored */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3190 vpb.ioVRefNum = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3191 vpb.ioVolIndex = -1; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3192 errno = PBHGetVInfo ((union HParamBlockRec *) &vpb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3193 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3194 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3195 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3196 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3197 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3198 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3199 dirp->vol_ref_num = vpb.ioVRefNum; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3200 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3201 return dirp; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3202 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3203 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3204 int |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3205 closedir (DIR *dp) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3206 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3207 free (dp); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3208 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3209 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3210 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3211 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3212 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3213 struct dirent * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3214 readdir (DIR *dp) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3215 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3216 HParamBlockRec hpblock; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3217 CInfoPBRec cipb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3218 static struct dirent s_dirent; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3219 static Str255 s_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3220 int done; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3221 char *p; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3222 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3223 /* Handle the root directory containing the mounted volumes. Call |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3224 PBHGetVInfo specifying an index to obtain the info for a volume. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3225 PBHGetVInfo returns an error when it receives an index beyond the |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3226 last volume, at which time we should return a nil dirent struct |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3227 pointer. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3228 if (dp->getting_volumes) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3229 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3230 hpblock.volumeParam.ioNamePtr = s_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3231 hpblock.volumeParam.ioVRefNum = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3232 hpblock.volumeParam.ioVolIndex = dp->current_index; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3233 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3234 errno = PBHGetVInfo (&hpblock, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3235 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3236 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3237 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3238 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3239 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3240 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3241 p2cstr (s_name); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3242 strcat (s_name, "/"); /* need "/" for stat to work correctly */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3243 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3244 dp->current_index++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3245 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3246 s_dirent.d_ino = hpblock.volumeParam.ioVRefNum; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3247 s_dirent.d_name = s_name; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3248 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3249 return &s_dirent; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3250 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3251 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3252 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3253 cipb.hFileInfo.ioVRefNum = dp->vol_ref_num; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3254 cipb.hFileInfo.ioNamePtr = s_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3255 /* location to receive filename returned */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3256 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3257 /* return only visible files */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3258 done = false; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3259 while (!done) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3260 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3261 cipb.hFileInfo.ioDirID = dp->dir_id; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3262 /* directory ID found by opendir */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3263 cipb.hFileInfo.ioFDirIndex = dp->current_index; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3264 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3265 errno = PBGetCatInfo (&cipb, false); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3266 if (errno != noErr) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3267 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3268 errno = ENOENT; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3269 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3270 } |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3271 |
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3272 /* insist on a visible entry */ |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3273 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* directory? */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3274 done = !(cipb.dirInfo.ioDrUsrWds.frFlags & fInvisible); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3275 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3276 done = !(cipb.hFileInfo.ioFlFndrInfo.fdFlags & fInvisible); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3277 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3278 dp->current_index++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3279 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3280 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3281 p2cstr (s_name); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3282 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3283 p = s_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3284 while (*p) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3285 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3286 if (*p == '/') |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3287 *p = ':'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3288 p++; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3289 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3290 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3291 s_dirent.d_ino = cipb.dirInfo.ioDrDirID; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3292 /* value unimportant: non-zero for valid file */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3293 s_dirent.d_name = s_name; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3294 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3295 return &s_dirent; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3296 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3297 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3298 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3299 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3300 char * |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3301 getwd (char *path) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3302 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3303 char mac_pathname[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3304 Str255 directory_name; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3305 OSErr errno; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3306 CInfoPBRec cipb; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3307 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3308 if (path_from_vol_dir_name (mac_pathname, 255, 0, 0, "\p") == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3309 return NULL; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3310 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3311 if (mac_to_posix_pathname (mac_pathname, path, MAXPATHLEN+1) == 0) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3312 return 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3313 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3314 return path; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3315 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3316 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3317 #endif /* ! MAC_OSX */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3318 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3319 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3320 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3321 initialize_applescript () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3322 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3323 AEDesc null_desc; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3324 OSAError osaerror; |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3325 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3326 /* if open fails, as_scripting_component is set to NULL. Its |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3327 subsequent use in OSA calls will fail with badComponentInstance |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3328 error. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3329 as_scripting_component = OpenDefaultComponent (kOSAComponentType, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3330 kAppleScriptSubtype); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3331 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3332 null_desc.descriptorType = typeNull; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3333 null_desc.dataHandle = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3334 osaerror = OSAMakeContext (as_scripting_component, &null_desc, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3335 kOSANullScript, &as_script_context); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3336 if (osaerror) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3337 as_script_context = kOSANullScript; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3338 /* use default context if create fails */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3339 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3340 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3341 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3342 void terminate_applescript() |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3343 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3344 OSADispose (as_scripting_component, as_script_context); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3345 CloseComponent (as_scripting_component); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3346 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3347 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3348 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3349 /* Compile and execute the AppleScript SCRIPT and return the error |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3350 status as function value. A zero is returned if compilation and |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3351 execution is successful, in which case RESULT returns a pointer to |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3352 a string containing the resulting script value. Otherwise, the Mac |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3353 error code is returned and RESULT returns a pointer to an error |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3354 string. In both cases the caller should deallocate the storage |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3355 used by the string pointed to by RESULT if it is non-NULL. For |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3356 documentation on the MacOS scripting architecture, see Inside |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3357 Macintosh - Interapplication Communications: Scripting Components. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3358 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3359 static long |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3360 do_applescript (char *script, char **result) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3361 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3362 AEDesc script_desc, result_desc, error_desc; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3363 OSErr error; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3364 OSAError osaerror; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3365 long length; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3366 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3367 *result = 0; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3368 |
45851
7b1f766314f6
2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
45848
diff
changeset
|
3369 if (!as_scripting_component) |
7b1f766314f6
2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
45848
diff
changeset
|
3370 initialize_applescript(); |
7b1f766314f6
2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
45848
diff
changeset
|
3371 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3372 error = AECreateDesc (typeChar, script, strlen(script), &script_desc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3373 if (error) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3374 return error; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3375 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3376 osaerror = OSADoScript (as_scripting_component, &script_desc, kOSANullScript, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3377 typeChar, kOSAModeNull, &result_desc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3378 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3379 if (osaerror == errOSAScriptError) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3380 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3381 /* error executing AppleScript: retrieve error message */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3382 if (!OSAScriptError (as_scripting_component, kOSAErrorMessage, typeChar, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3383 &error_desc)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3384 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3385 #if TARGET_API_MAC_CARBON |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3386 length = AEGetDescDataSize (&error_desc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3387 *result = (char *) xmalloc (length + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3388 if (*result) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3389 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3390 AEGetDescData (&error_desc, *result, length); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3391 *(*result + length) = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3392 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3393 #else /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3394 HLock (error_desc.dataHandle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3395 length = GetHandleSize(error_desc.dataHandle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3396 *result = (char *) xmalloc (length + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3397 if (*result) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3398 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3399 memcpy (*result, *(error_desc.dataHandle), length); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3400 *(*result + length) = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3401 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3402 HUnlock (error_desc.dataHandle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3403 #endif /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3404 AEDisposeDesc (&error_desc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3405 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3406 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3407 else if (osaerror == noErr) /* success: retrieve resulting script value */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3408 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3409 #if TARGET_API_MAC_CARBON |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3410 length = AEGetDescDataSize (&result_desc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3411 *result = (char *) xmalloc (length + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3412 if (*result) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3413 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3414 AEGetDescData (&result_desc, *result, length); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3415 *(*result + length) = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3416 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3417 #else /* not TARGET_API_MAC_CARBON */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3418 HLock (result_desc.dataHandle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3419 length = GetHandleSize(result_desc.dataHandle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3420 *result = (char *) xmalloc (length + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3421 if (*result) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3422 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3423 memcpy (*result, *(result_desc.dataHandle), length); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3424 *(*result + length) = '\0'; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3425 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3426 HUnlock (result_desc.dataHandle); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3427 #endif /* not TARGET_API_MAC_CARBON */ |
45851
7b1f766314f6
2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
45848
diff
changeset
|
3428 AEDisposeDesc (&result_desc); |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3429 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3430 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3431 AEDisposeDesc (&script_desc); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3432 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3433 return osaerror; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3434 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3435 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3436 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3437 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3438 doc: /* Compile and execute AppleScript SCRIPT and retrieve and return the result. |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3439 If compilation and execution are successful, the resulting script |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3440 value is returned as a string. Otherwise the function aborts and |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3441 displays the error message returned by the AppleScript scripting |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3442 component. */) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3443 (script) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3444 Lisp_Object script; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3445 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3446 char *result, *temp; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3447 Lisp_Object lisp_result; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3448 long status; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3449 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3450 CHECK_STRING (script); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3451 |
57425
0867872551d9
macterm.c (x_raise_frame): Add BLOCK_INPUT around SelectWindow
Steven Tamm <steventamm@mac.com>
parents:
57397
diff
changeset
|
3452 BLOCK_INPUT; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45851
diff
changeset
|
3453 status = do_applescript (SDATA (script), &result); |
57425
0867872551d9
macterm.c (x_raise_frame): Add BLOCK_INPUT around SelectWindow
Steven Tamm <steventamm@mac.com>
parents:
57397
diff
changeset
|
3454 UNBLOCK_INPUT; |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3455 if (status) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3456 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3457 if (!result) |
45851
7b1f766314f6
2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
45848
diff
changeset
|
3458 error ("AppleScript error %d", status); |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3459 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3460 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3461 /* Unfortunately only OSADoScript in do_applescript knows how |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3462 how large the resulting script value or error message is |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3463 going to be and therefore as caller memory must be |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3464 deallocated here. It is necessary to free the error |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3465 message before calling error to avoid a memory leak. */ |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3466 temp = (char *) alloca (strlen (result) + 1); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3467 strcpy (temp, result); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3468 xfree (result); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3469 error (temp); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3470 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3471 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3472 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3473 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3474 lisp_result = build_string (result); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3475 xfree (result); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3476 return lisp_result; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3477 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3478 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3479 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3480 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3481 DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3482 Smac_file_name_to_posix, 1, 1, 0, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3483 doc: /* Convert Macintosh filename to Posix form. */) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3484 (mac_filename) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3485 Lisp_Object mac_filename; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3486 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3487 char posix_filename[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3488 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3489 CHECK_STRING (mac_filename); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3490 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45851
diff
changeset
|
3491 if (mac_to_posix_pathname (SDATA (mac_filename), posix_filename, |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3492 MAXPATHLEN)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3493 return build_string (posix_filename); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3494 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3495 return Qnil; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3496 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3497 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3498 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3499 DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3500 Sposix_file_name_to_mac, 1, 1, 0, |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3501 doc: /* Convert Posix filename to Mac form. */) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3502 (posix_filename) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3503 Lisp_Object posix_filename; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3504 { |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3505 char mac_filename[MAXPATHLEN+1]; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3506 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3507 CHECK_STRING (posix_filename); |
47942
080b4586492b
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46916
diff
changeset
|
3508 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45851
diff
changeset
|
3509 if (posix_to_mac_pathname (SDATA (posix_filename), mac_filename, |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3510 MAXPATHLEN)) |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3511 return build_string (mac_filename); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3512 else |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3513 return Qnil; |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3514 } |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3515 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3516 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
3517 #if TARGET_API_MAC_CARBON |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3518 static Lisp_Object Qxml, Qmime_charset; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3519 static Lisp_Object QNFD, QNFKD, QNFC, QNFKC, QHFS_plus_D, QHFS_plus_C; |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3520 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3521 DEFUN ("mac-get-preference", Fmac_get_preference, Smac_get_preference, 1, 4, 0, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3522 doc: /* Return the application preference value for KEY. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3523 KEY is either a string specifying a preference key, or a list of key |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3524 strings. If it is a list, the (i+1)-th element is used as a key for |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3525 the CFDictionary value obtained by the i-th element. If lookup is |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3526 failed at some stage, nil is returned. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3527 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3528 Optional arg APPLICATION is an application ID string. If omitted or |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3529 nil, that stands for the current application. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3530 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3531 Optional arg FORMAT specifies the data format of the return value. If |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3532 omitted or nil, each Core Foundation object is converted into a |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3533 corresponding Lisp object as follows: |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3534 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3535 Core Foundation Lisp Tag |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3536 ------------------------------------------------------------ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3537 CFString Multibyte string string |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3538 CFNumber Integer or float number |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3539 CFBoolean Symbol (t or nil) boolean |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3540 CFDate List of three integers date |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3541 (cf. `current-time') |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3542 CFData Unibyte string data |
61338
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
3543 CFArray Vector array |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3544 CFDictionary Alist or hash table dictionary |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3545 (depending on HASH-BOUND) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3546 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3547 If it is t, a symbol that represents the type of the original Core |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3548 Foundation object is prepended. If it is `xml', the value is returned |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3549 as an XML representation. |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3550 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3551 Optional arg HASH-BOUND specifies which kinds of the list objects, |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3552 alists or hash tables, are used as the targets of the conversion from |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3553 CFDictionary. If HASH-BOUND is a negative integer or nil, always |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3554 generate alists. If HASH-BOUND >= 0, generate an alist if the number |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3555 of keys in the dictionary is smaller than HASH-BOUND, and a hash table |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3556 otherwise. */) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3557 (key, application, format, hash_bound) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3558 Lisp_Object key, application, format, hash_bound; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3559 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3560 CFStringRef app_id, key_str; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3561 CFPropertyListRef app_plist = NULL, plist; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3562 Lisp_Object result = Qnil, tmp; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3563 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3564 if (STRINGP (key)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3565 key = Fcons (key, Qnil); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3566 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3567 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3568 CHECK_CONS (key); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3569 for (tmp = key; CONSP (tmp); tmp = XCDR (tmp)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3570 CHECK_STRING_CAR (tmp); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3571 if (!NILP (tmp)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3572 wrong_type_argument (Qlistp, key); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3573 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3574 if (!NILP (application)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3575 CHECK_STRING (application); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3576 CHECK_SYMBOL (format); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3577 if (!NILP (hash_bound)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3578 CHECK_NUMBER (hash_bound); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3579 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3580 BLOCK_INPUT; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3581 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3582 app_id = kCFPreferencesCurrentApplication; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3583 if (!NILP (application)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3584 { |
61572
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
3585 app_id = cfstring_create_with_string (application); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3586 if (app_id == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3587 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3588 } |
61572
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
3589 key_str = cfstring_create_with_string (XCAR (key)); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3590 if (key_str == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3591 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3592 app_plist = CFPreferencesCopyAppValue (key_str, app_id); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3593 CFRelease (key_str); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3594 if (app_plist == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3595 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3596 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3597 plist = app_plist; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3598 for (key = XCDR (key); CONSP (key); key = XCDR (key)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3599 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3600 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ()) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3601 break; |
61572
4fdfaa49202b
Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61553
diff
changeset
|
3602 key_str = cfstring_create_with_string (XCAR (key)); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3603 if (key_str == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3604 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3605 plist = CFDictionaryGetValue (plist, key_str); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3606 CFRelease (key_str); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3607 if (plist == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3608 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3609 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3610 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3611 if (NILP (key)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3612 if (EQ (format, Qxml)) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3613 { |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3614 CFDataRef data = CFPropertyListCreateXMLData (NULL, plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3615 if (data == NULL) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3616 goto out; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3617 result = cfdata_to_lisp (data); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3618 CFRelease (data); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3619 } |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3620 else |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3621 result = |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3622 cfproperty_list_to_lisp (plist, EQ (format, Qt), |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3623 NILP (hash_bound) ? -1 : XINT (hash_bound)); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3624 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3625 out: |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3626 if (app_plist) |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3627 CFRelease (app_plist); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3628 CFRelease (app_id); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3629 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3630 UNBLOCK_INPUT; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3631 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3632 return result; |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3633 } |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3634 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3635 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3636 static CFStringEncoding |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3637 get_cfstring_encoding_from_lisp (obj) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3638 Lisp_Object obj; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3639 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3640 CFStringRef iana_name; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3641 CFStringEncoding encoding = kCFStringEncodingInvalidId; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3642 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3643 if (INTEGERP (obj)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3644 return XINT (obj); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3645 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3646 if (SYMBOLP (obj) && !NILP (obj) && !NILP (Fcoding_system_p (obj))) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3647 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3648 Lisp_Object coding_spec, plist; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3649 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3650 coding_spec = Fget (obj, Qcoding_system); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3651 plist = XVECTOR (coding_spec)->contents[3]; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3652 obj = Fplist_get (XVECTOR (coding_spec)->contents[3], Qmime_charset); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3653 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3654 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3655 if (SYMBOLP (obj)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3656 obj = SYMBOL_NAME (obj); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3657 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3658 if (STRINGP (obj)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3659 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3660 iana_name = cfstring_create_with_string (obj); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3661 if (iana_name) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3662 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3663 encoding = CFStringConvertIANACharSetNameToEncoding (iana_name); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3664 CFRelease (iana_name); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3665 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3666 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3667 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3668 return encoding; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3669 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3670 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3671 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3672 static CFStringRef |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3673 cfstring_create_normalized (str, symbol) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3674 CFStringRef str; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3675 Lisp_Object symbol; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3676 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3677 int form = -1; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3678 TextEncodingVariant variant; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3679 float initial_mag = 0.0; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3680 CFStringRef result = NULL; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3681 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3682 if (EQ (symbol, QNFD)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3683 form = kCFStringNormalizationFormD; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3684 else if (EQ (symbol, QNFKD)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3685 form = kCFStringNormalizationFormKD; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3686 else if (EQ (symbol, QNFC)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3687 form = kCFStringNormalizationFormC; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3688 else if (EQ (symbol, QNFKC)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3689 form = kCFStringNormalizationFormKC; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3690 else if (EQ (symbol, QHFS_plus_D)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3691 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3692 variant = kUnicodeHFSPlusDecompVariant; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3693 initial_mag = 1.5; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3694 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3695 else if (EQ (symbol, QHFS_plus_C)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3696 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3697 variant = kUnicodeHFSPlusCompVariant; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3698 initial_mag = 1.0; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3699 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3700 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3701 if (form >= 0) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3702 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3703 CFMutableStringRef mut_str = CFStringCreateMutableCopy (NULL, 0, str); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3704 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3705 if (mut_str) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3706 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3707 CFStringNormalize (mut_str, form); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3708 result = mut_str; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3709 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3710 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3711 else if (initial_mag > 0.0) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3712 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3713 UnicodeToTextInfo uni = NULL; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3714 UnicodeMapping map; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3715 CFIndex length; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3716 UniChar *in_text, *buffer = NULL, *out_buf = NULL; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3717 OSErr err = noErr; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3718 ByteCount out_read, out_size, out_len; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3719 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3720 map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3721 kUnicodeNoSubset, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3722 kTextEncodingDefaultFormat); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3723 map.otherEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3724 variant, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3725 kTextEncodingDefaultFormat); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3726 map.mappingVersion = kUnicodeUseLatestMapping; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3727 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3728 length = CFStringGetLength (str); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3729 out_size = (int)((float)length * initial_mag) * sizeof (UniChar); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3730 if (out_size < 32) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3731 out_size = 32; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3732 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3733 in_text = (UniChar *)CFStringGetCharactersPtr (str); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3734 if (in_text == NULL) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3735 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3736 buffer = xmalloc (sizeof (UniChar) * length); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3737 if (buffer) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3738 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3739 CFStringGetCharacters (str, CFRangeMake (0, length), buffer); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3740 in_text = buffer; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3741 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3742 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3743 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3744 if (in_text) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3745 err = CreateUnicodeToTextInfo(&map, &uni); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3746 while (err == noErr) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3747 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3748 out_buf = xmalloc (out_size); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3749 if (out_buf == NULL) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3750 err = mFulErr; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3751 else |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3752 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3753 in_text, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3754 kUnicodeDefaultDirectionMask, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3755 0, NULL, NULL, NULL, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3756 out_size, &out_read, &out_len, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3757 out_buf); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3758 if (err == noErr && out_read < length * sizeof (UniChar)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3759 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3760 xfree (out_buf); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3761 out_size += length; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3762 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3763 else |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3764 break; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3765 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3766 if (err == noErr) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3767 result = CFStringCreateWithCharacters (NULL, out_buf, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3768 out_len / sizeof (UniChar)); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3769 if (uni) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3770 DisposeUnicodeToTextInfo (&uni); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3771 if (out_buf) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3772 xfree (out_buf); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3773 if (buffer) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3774 xfree (buffer); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3775 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3776 else |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3777 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3778 result = str; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3779 CFRetain (result); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3780 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3781 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3782 return result; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3783 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3784 #endif |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3785 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3786 DEFUN ("mac-code-convert-string", Fmac_code_convert_string, Smac_code_convert_string, 3, 4, 0, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3787 doc: /* Convert STRING from SOURCE encoding to TARGET encoding. |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3788 The conversion is performed using the converter provided by the system. |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3789 Each encoding is specified by either a coding system symbol, a mime |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3790 charset string, or an integer as a CFStringEncoding value. |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3791 On Mac OS X 10.2 and later, you can do Unicode Normalization by |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3792 specifying the optional argument NORMALIZATION-FORM with a symbol NFD, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3793 NFKD, NFC, NFKC, HFS+D, or HFS+C. |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3794 On successful conversion, returns the result string, else returns |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3795 nil. */) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3796 (string, source, target, normalization_form) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3797 Lisp_Object string, source, target, normalization_form; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3798 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3799 Lisp_Object result = Qnil; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3800 CFStringEncoding src_encoding, tgt_encoding; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3801 CFStringRef str = NULL; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3802 CFDataRef data = NULL; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3803 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3804 CHECK_STRING (string); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3805 if (!INTEGERP (source) && !STRINGP (source)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3806 CHECK_SYMBOL (source); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3807 if (!INTEGERP (target) && !STRINGP (target)) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3808 CHECK_SYMBOL (target); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3809 CHECK_SYMBOL (normalization_form); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3810 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3811 BLOCK_INPUT; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3812 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3813 src_encoding = get_cfstring_encoding_from_lisp (source); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3814 tgt_encoding = get_cfstring_encoding_from_lisp (target); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3815 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3816 string = string_make_unibyte (string); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3817 if (src_encoding != kCFStringEncodingInvalidId |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3818 && tgt_encoding != kCFStringEncodingInvalidId) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3819 str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string), |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3820 src_encoding, true); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3821 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3822 if (str) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3823 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3824 CFStringRef saved_str = str; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3825 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3826 str = cfstring_create_normalized (saved_str, normalization_form); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3827 CFRelease (saved_str); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3828 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3829 #endif |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3830 if (str) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3831 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3832 data = CFStringCreateExternalRepresentation (NULL, str, |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3833 tgt_encoding, '\0'); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3834 CFRelease (str); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3835 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3836 if (data) |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3837 { |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3838 result = cfdata_to_lisp (data); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3839 CFRelease (data); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3840 } |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3841 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3842 UNBLOCK_INPUT; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3843 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3844 return result; |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
3845 } |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3846 #endif /* TARGET_API_MAC_CARBON */ |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
3847 |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3848 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3849 DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0, |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3850 doc: /* Clear the font name table. */) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3851 () |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3852 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3853 check_mac (); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3854 mac_clear_font_name_table (); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3855 return Qnil; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3856 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3857 |
46856
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3858 #ifdef MAC_OSX |
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3859 #undef select |
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3860 |
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3861 extern int inhibit_window_system; |
48740
b45c19284d24
sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents:
47942
diff
changeset
|
3862 extern int noninteractive; |
46856
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3863 |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3864 /* Unlike in X11, window events in Carbon do not come from sockets. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3865 So we cannot simply use `select' to monitor two kinds of inputs: |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3866 window events and process outputs. We emulate such functionality |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3867 by regarding fd 0 as the window event channel and simultaneously |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3868 monitoring both kinds of input channels. It is implemented by |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3869 dividing into some cases: |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3870 1. The window event channel is not involved. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3871 -> Use `select'. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3872 2. Sockets are not involved. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3873 -> Use ReceiveNextEvent. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3874 3. [If SELECT_USE_CFSOCKET is defined] |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3875 Only the window event channel and socket read channels are |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3876 involved, and timeout is not too short (greater than |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3877 SELECT_TIMEOUT_THRESHHOLD_RUNLOOP seconds). |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3878 -> Create CFSocket for each socket and add it into the current |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3879 event RunLoop so that an `ready-to-read' event can be posted |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3880 to the event queue that is also used for window events. Then |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3881 ReceiveNextEvent can wait for both kinds of inputs. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3882 4. Otherwise. |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3883 -> Periodically poll the window input channel while repeatedly |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3884 executing `select' with a short timeout |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3885 (SELECT_POLLING_PERIOD_USEC microseconds). */ |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3886 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3887 #define SELECT_POLLING_PERIOD_USEC 20000 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3888 #ifdef SELECT_USE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3889 #define SELECT_TIMEOUT_THRESHOLD_RUNLOOP 0.2 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3890 #define EVENT_CLASS_SOCK 'Sock' |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3891 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3892 static void |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3893 socket_callback (s, type, address, data, info) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3894 CFSocketRef s; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3895 CFSocketCallBackType type; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3896 CFDataRef address; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3897 const void *data; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3898 void *info; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3899 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3900 EventRef event; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3901 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3902 CreateEvent (NULL, EVENT_CLASS_SOCK, 0, 0, kEventAttributeNone, &event); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3903 PostEventToQueue (GetCurrentEventQueue (), event, kEventPriorityStandard); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3904 ReleaseEvent (event); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3905 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3906 #endif /* SELECT_USE_CFSOCKET */ |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3907 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3908 static int |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3909 select_and_poll_event (n, rfds, wfds, efds, timeout) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3910 int n; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3911 SELECT_TYPE *rfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3912 SELECT_TYPE *wfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3913 SELECT_TYPE *efds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3914 struct timeval *timeout; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3915 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3916 int r; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3917 OSErr err; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3918 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3919 r = select (n, rfds, wfds, efds, timeout); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3920 if (r != -1) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3921 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3922 BLOCK_INPUT; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3923 err = ReceiveNextEvent (0, NULL, kEventDurationNoWait, |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3924 kEventLeaveInQueue, NULL); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3925 UNBLOCK_INPUT; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3926 if (err == noErr) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3927 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3928 FD_SET (0, rfds); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3929 r++; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3930 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3931 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3932 return r; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3933 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3934 |
59897
5ae033db673f
Use MAC_OS_X_VERSION_MAX_ALLOWED to conditionalize by the compiling OS
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
59146
diff
changeset
|
3935 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1020 |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3936 #undef SELECT_INVALIDATE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3937 #endif |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3938 |
46856
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3939 int |
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3940 sys_select (n, rfds, wfds, efds, timeout) |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3941 int n; |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3942 SELECT_TYPE *rfds; |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3943 SELECT_TYPE *wfds; |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3944 SELECT_TYPE *efds; |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3945 struct timeval *timeout; |
46856
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
3946 { |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3947 OSErr err; |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3948 int i, r; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3949 EMACS_TIME select_timeout; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3950 |
56477
59a86f6ee1fb
Fixes for Ctrl-G support on carbon, replacing old timeout based polling
Steven Tamm <steventamm@mac.com>
parents:
53122
diff
changeset
|
3951 if (inhibit_window_system || noninteractive |
59a86f6ee1fb
Fixes for Ctrl-G support on carbon, replacing old timeout based polling
Steven Tamm <steventamm@mac.com>
parents:
53122
diff
changeset
|
3952 || rfds == NULL || !FD_ISSET (0, rfds)) |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3953 return select (n, rfds, wfds, efds, timeout); |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3954 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3955 FD_CLR (0, rfds); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3956 |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3957 if (wfds == NULL && efds == NULL) |
48740
b45c19284d24
sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents:
47942
diff
changeset
|
3958 { |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3959 int nsocks = 0; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3960 SELECT_TYPE orfds = *rfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3961 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3962 EventTimeout timeout_sec = |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3963 (timeout |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3964 ? (EMACS_SECS (*timeout) * kEventDurationSecond |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3965 + EMACS_USECS (*timeout) * kEventDurationMicrosecond) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3966 : kEventDurationForever); |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3967 |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3968 for (i = 1; i < n; i++) |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3969 if (FD_ISSET (i, rfds)) |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3970 nsocks++; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3971 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3972 if (nsocks == 0) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3973 { |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3974 BLOCK_INPUT; |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3975 err = ReceiveNextEvent (0, NULL, timeout_sec, |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3976 kEventLeaveInQueue, NULL); |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3977 UNBLOCK_INPUT; |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3978 if (err == noErr) |
48818
5030a4c296d2
* macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents:
48793
diff
changeset
|
3979 { |
56477
59a86f6ee1fb
Fixes for Ctrl-G support on carbon, replacing old timeout based polling
Steven Tamm <steventamm@mac.com>
parents:
53122
diff
changeset
|
3980 FD_SET (0, rfds); |
59a86f6ee1fb
Fixes for Ctrl-G support on carbon, replacing old timeout based polling
Steven Tamm <steventamm@mac.com>
parents:
53122
diff
changeset
|
3981 return 1; |
48818
5030a4c296d2
* macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents:
48793
diff
changeset
|
3982 } |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3983 else |
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
3984 return 0; |
48740
b45c19284d24
sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents:
47942
diff
changeset
|
3985 } |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3986 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3987 /* Avoid initial overhead of RunLoop setup for the case that |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3988 some input is already available. */ |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3989 EMACS_SET_SECS_USECS (select_timeout, 0, 0); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3990 r = select_and_poll_event (n, rfds, wfds, efds, &select_timeout); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3991 if (r != 0 || timeout_sec == 0.0) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3992 return r; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3993 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3994 *rfds = orfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3995 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3996 #ifdef SELECT_USE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3997 if (timeout_sec > 0 && timeout_sec <= SELECT_TIMEOUT_THRESHOLD_RUNLOOP) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3998 goto poll_periodically; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
3999 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4000 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4001 CFRunLoopRef runloop = |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4002 (CFRunLoopRef) GetCFRunLoopFromEventLoop (GetCurrentEventLoop ()); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4003 EventTypeSpec specs[] = {{EVENT_CLASS_SOCK, 0}}; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4004 #ifdef SELECT_INVALIDATE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4005 CFSocketRef *shead, *s; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4006 #else |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4007 CFRunLoopSourceRef *shead, *s; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4008 #endif |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4009 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4010 BLOCK_INPUT; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4011 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4012 #ifdef SELECT_INVALIDATE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4013 shead = xmalloc (sizeof (CFSocketRef) * nsocks); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4014 #else |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4015 shead = xmalloc (sizeof (CFRunLoopSourceRef) * nsocks); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4016 #endif |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4017 s = shead; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4018 for (i = 1; i < n; i++) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4019 if (FD_ISSET (i, rfds)) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4020 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4021 CFSocketRef socket = |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4022 CFSocketCreateWithNative (NULL, i, kCFSocketReadCallBack, |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4023 socket_callback, NULL); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4024 CFRunLoopSourceRef source = |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4025 CFSocketCreateRunLoopSource (NULL, socket, 0); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4026 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4027 #ifdef SELECT_INVALIDATE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4028 CFSocketSetSocketFlags (socket, 0); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4029 #endif |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4030 CFRunLoopAddSource (runloop, source, kCFRunLoopDefaultMode); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4031 #ifdef SELECT_INVALIDATE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4032 CFRelease (source); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4033 *s = socket; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4034 #else |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4035 CFRelease (socket); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4036 *s = source; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4037 #endif |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4038 s++; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4039 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4040 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4041 err = ReceiveNextEvent (0, NULL, timeout_sec, kEventLeaveInQueue, NULL); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4042 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4043 do |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4044 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4045 --s; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4046 #ifdef SELECT_INVALIDATE_CFSOCKET |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4047 CFSocketInvalidate (*s); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4048 #else |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4049 CFRunLoopRemoveSource (runloop, *s, kCFRunLoopDefaultMode); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4050 #endif |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4051 CFRelease (*s); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4052 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4053 while (s != shead); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4054 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4055 xfree (shead); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4056 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4057 if (err) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4058 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4059 FD_ZERO (rfds); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4060 r = 0; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4061 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4062 else |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4063 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4064 FlushEventsMatchingListFromQueue (GetCurrentEventQueue (), |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4065 GetEventTypeCount (specs), |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4066 specs); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4067 EMACS_SET_SECS_USECS (select_timeout, 0, 0); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4068 r = select_and_poll_event (n, rfds, wfds, efds, &select_timeout); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4069 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4070 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4071 UNBLOCK_INPUT; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4072 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4073 return r; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4074 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4075 #endif /* SELECT_USE_CFSOCKET */ |
48740
b45c19284d24
sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents:
47942
diff
changeset
|
4076 } |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4077 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4078 poll_periodically: |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4079 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4080 EMACS_TIME end_time, now, remaining_time; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4081 SELECT_TYPE orfds = *rfds, owfds, oefds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4082 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4083 if (wfds) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4084 owfds = *wfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4085 if (efds) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4086 oefds = *efds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4087 if (timeout) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4088 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4089 remaining_time = *timeout; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4090 EMACS_GET_TIME (now); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4091 EMACS_ADD_TIME (end_time, now, remaining_time); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4092 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4093 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4094 do |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4095 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4096 EMACS_SET_SECS_USECS (select_timeout, 0, SELECT_POLLING_PERIOD_USEC); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4097 if (timeout && EMACS_TIME_LT (remaining_time, select_timeout)) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4098 select_timeout = remaining_time; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4099 r = select_and_poll_event (n, rfds, wfds, efds, &select_timeout); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4100 if (r != 0) |
56479
45d805d79d29
mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents:
56478
diff
changeset
|
4101 return r; |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4102 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4103 *rfds = orfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4104 if (wfds) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4105 *wfds = owfds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4106 if (efds) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4107 *efds = oefds; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4108 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4109 if (timeout) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4110 { |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4111 EMACS_GET_TIME (now); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4112 EMACS_SUB_TIME (remaining_time, end_time, now); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4113 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4114 } |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4115 while (!timeout || EMACS_TIME_LT (now, end_time)); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4116 |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4117 FD_ZERO (rfds); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4118 if (wfds) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4119 FD_ZERO (wfds); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4120 if (efds) |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4121 FD_ZERO (efds); |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4122 return 0; |
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4123 } |
48740
b45c19284d24
sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents:
47942
diff
changeset
|
4124 } |
b45c19284d24
sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents:
47942
diff
changeset
|
4125 |
46916
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4126 /* Set up environment variables so that Emacs can correctly find its |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4127 support files when packaged as an application bundle. Directories |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4128 placed in /usr/local/share/emacs/<emacs-version>/, /usr/local/bin, |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4129 and /usr/local/libexec/emacs/<emacs-version>/<system-configuration> |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4130 by `make install' by default can instead be placed in |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4131 .../Emacs.app/Contents/Resources/ and |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4132 .../Emacs.app/Contents/MacOS/. Each of these environment variables |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4133 is changed only if it is not already set. Presumably if the user |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4134 sets an environment variable, he will want to use files in his path |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4135 instead of ones in the application bundle. */ |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4136 void |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4137 init_mac_osx_environment () |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4138 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4139 CFBundleRef bundle; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4140 CFURLRef bundleURL; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4141 CFStringRef cf_app_bundle_pathname; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4142 int app_bundle_pathname_len; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4143 char *app_bundle_pathname; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4144 char *p, *q; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4145 struct stat st; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4146 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4147 /* Fetch the pathname of the application bundle as a C string into |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4148 app_bundle_pathname. */ |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4149 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4150 bundle = CFBundleGetMainBundle (); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4151 if (!bundle) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4152 return; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4153 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4154 bundleURL = CFBundleCopyBundleURL (bundle); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4155 if (!bundleURL) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4156 return; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4157 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4158 cf_app_bundle_pathname = CFURLCopyFileSystemPath (bundleURL, |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4159 kCFURLPOSIXPathStyle); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4160 app_bundle_pathname_len = CFStringGetLength (cf_app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4161 app_bundle_pathname = (char *) alloca (app_bundle_pathname_len + 1); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4162 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4163 if (!CFStringGetCString (cf_app_bundle_pathname, |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4164 app_bundle_pathname, |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4165 app_bundle_pathname_len + 1, |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4166 kCFStringEncodingISOLatin1)) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4167 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4168 CFRelease (cf_app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4169 return; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4170 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4171 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4172 CFRelease (cf_app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4173 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4174 /* P should have sufficient room for the pathname of the bundle plus |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4175 the subpath in it leading to the respective directories. Q |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4176 should have three times that much room because EMACSLOADPATH can |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4177 have the value "<path to lisp dir>:<path to leim dir>:<path to |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4178 site-lisp dir>". */ |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4179 p = (char *) alloca (app_bundle_pathname_len + 50); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4180 q = (char *) alloca (3 * app_bundle_pathname_len + 150); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4181 if (!getenv ("EMACSLOADPATH")) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4182 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4183 q[0] = '\0'; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4184 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4185 strcpy (p, app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4186 strcat (p, "/Contents/Resources/lisp"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4187 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4188 strcat (q, p); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4189 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4190 strcpy (p, app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4191 strcat (p, "/Contents/Resources/leim"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4192 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4193 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4194 if (q[0] != '\0') |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4195 strcat (q, ":"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4196 strcat (q, p); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4197 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4198 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4199 strcpy (p, app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4200 strcat (p, "/Contents/Resources/site-lisp"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4201 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4202 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4203 if (q[0] != '\0') |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4204 strcat (q, ":"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4205 strcat (q, p); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4206 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4207 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4208 if (q[0] != '\0') |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4209 setenv ("EMACSLOADPATH", q, 1); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4210 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4211 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4212 if (!getenv ("EMACSPATH")) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4213 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4214 q[0] = '\0'; |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4215 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4216 strcpy (p, app_bundle_pathname); |
50490
52dcc63018da
mac.c (init_mac_osx_environment): Switch libexec and bin so that self-
Steven Tamm <steventamm@mac.com>
parents:
49600
diff
changeset
|
4217 strcat (p, "/Contents/MacOS/libexec"); |
46916
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4218 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4219 strcat (q, p); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4220 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4221 strcpy (p, app_bundle_pathname); |
50490
52dcc63018da
mac.c (init_mac_osx_environment): Switch libexec and bin so that self-
Steven Tamm <steventamm@mac.com>
parents:
49600
diff
changeset
|
4222 strcat (p, "/Contents/MacOS/bin"); |
46916
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4223 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4224 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4225 if (q[0] != '\0') |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4226 strcat (q, ":"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4227 strcat (q, p); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4228 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4229 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4230 if (q[0] != '\0') |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4231 setenv ("EMACSPATH", q, 1); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4232 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4233 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4234 if (!getenv ("EMACSDATA")) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4235 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4236 strcpy (p, app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4237 strcat (p, "/Contents/Resources/etc"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4238 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4239 setenv ("EMACSDATA", p, 1); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4240 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4241 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4242 if (!getenv ("EMACSDOC")) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4243 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4244 strcpy (p, app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4245 strcat (p, "/Contents/Resources/etc"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4246 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4247 setenv ("EMACSDOC", p, 1); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4248 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4249 |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4250 if (!getenv ("INFOPATH")) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4251 { |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4252 strcpy (p, app_bundle_pathname); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4253 strcat (p, "/Contents/Resources/info"); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4254 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4255 setenv ("INFOPATH", p, 1); |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4256 } |
aff9c7fcedb0
2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46856
diff
changeset
|
4257 } |
46856
eba75fedd593
2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents:
46788
diff
changeset
|
4258 #endif /* MAC_OSX */ |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4259 |
61553
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4260 |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4261 static Lisp_Object |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4262 mac_get_system_locale () |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4263 { |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4264 OSErr err; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4265 LangCode lang; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4266 RegionCode region; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4267 LocaleRef locale; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4268 Str255 str; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4269 |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4270 lang = GetScriptVariable (smSystemScript, smScriptLang); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4271 region = GetScriptManagerVariable (smRegionCode); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4272 err = LocaleRefFromLangOrRegionCode (lang, region, &locale); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4273 if (err == noErr) |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4274 err = LocaleRefGetPartString (locale, kLocaleAllPartsMask, |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4275 sizeof (str), str); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4276 if (err == noErr) |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4277 return build_string (str); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4278 else |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4279 return Qnil; |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4280 } |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4281 |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4282 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4283 void |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4284 syms_of_mac () |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4285 { |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4286 #if TARGET_API_MAC_CARBON |
61338
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4287 Qstring = intern ("string"); staticpro (&Qstring); |
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4288 Qnumber = intern ("number"); staticpro (&Qnumber); |
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4289 Qboolean = intern ("boolean"); staticpro (&Qboolean); |
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4290 Qdate = intern ("date"); staticpro (&Qdate); |
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4291 Qdata = intern ("data"); staticpro (&Qdata); |
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4292 Qarray = intern ("array"); staticpro (&Qarray); |
b44917251d3a
(cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60660
diff
changeset
|
4293 Qdictionary = intern ("dictionary"); staticpro (&Qdictionary); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4294 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4295 Qxml = intern ("xml"); |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4296 staticpro (&Qxml); |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4297 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4298 Qmime_charset = intern ("mime-charset"); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4299 staticpro (&Qmime_charset); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4300 |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4301 QNFD = intern ("NFD"); staticpro (&QNFD); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4302 QNFKD = intern ("NFKD"); staticpro (&QNFKD); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4303 QNFC = intern ("NFC"); staticpro (&QNFC); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4304 QNFKC = intern ("NFKC"); staticpro (&QNFKC); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4305 QHFS_plus_D = intern ("HFS+D"); staticpro (&QHFS_plus_D); |
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4306 QHFS_plus_C = intern ("HFS+C"); staticpro (&QHFS_plus_C); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4307 #endif |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4308 |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4309 #if TARGET_API_MAC_CARBON |
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4310 defsubr (&Smac_get_preference); |
61785
6e608d2306b0
[!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61572
diff
changeset
|
4311 defsubr (&Smac_code_convert_string); |
60632
fa8be36e244d
Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
60360
diff
changeset
|
4312 #endif |
59146
9bde7721ad0f
* dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents:
58752
diff
changeset
|
4313 defsubr (&Smac_clear_font_name_table); |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4314 |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4315 defsubr (&Sdo_applescript); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4316 defsubr (&Smac_file_name_to_posix); |
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4317 defsubr (&Sposix_file_name_to_mac); |
61553
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4318 |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4319 DEFVAR_INT ("mac-system-script-code", &mac_system_script_code, |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4320 doc: /* The system script code. */); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4321 mac_system_script_code = (ScriptCode) GetScriptManagerVariable (smSysScript); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4322 |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4323 DEFVAR_LISP ("mac-system-locale", &Vmac_system_locale, |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4324 doc: /* The system locale identifier string. |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4325 This is not a POSIX locale ID, but an ICU locale ID. So encoding |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4326 information is not included. */); |
72c95a1c84c6
[!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61338
diff
changeset
|
4327 Vmac_system_locale = mac_get_system_locale (); |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff
changeset
|
4328 } |
52401 | 4329 |
4330 /* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff | |
4331 (do not change this comment) */ |