Mercurial > hg > xemacs-beta
comparison src/console-x.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 Boston, MA 02111-1307, USA. */ | 19 Boston, MA 02111-1307, USA. */ |
20 | 20 |
21 /* Synched up with: Not in FSF. */ | 21 /* Synched up with: Not in FSF. */ |
22 | 22 |
23 /* This file Mule-ized by Ben Wing, 7-10-00. */ | |
24 | |
23 /* Authorship: | 25 /* Authorship: |
24 | 26 |
25 Ben Wing: January 1996, for 19.14. | 27 Ben Wing: January 1996, for 19.14. |
26 */ | 28 */ |
27 | 29 |
28 #include <config.h> | 30 #include <config.h> |
29 #include "lisp.h" | 31 #include "lisp.h" |
30 | 32 |
31 #include "console-x.h" | 33 #include "console-x.h" |
34 #include "buffer.h" | |
32 #include "process.h" /* canonicalize_host_name */ | 35 #include "process.h" /* canonicalize_host_name */ |
33 #include "redisplay.h" /* for display_arg */ | 36 #include "redisplay.h" /* for display_arg */ |
34 | 37 |
35 DEFINE_CONSOLE_TYPE (x); | 38 DEFINE_CONSOLE_TYPE (x); |
36 | 39 |
42 | 45 |
43 static void | 46 static void |
44 split_up_display_spec (Lisp_Object display, int *hostname_length, | 47 split_up_display_spec (Lisp_Object display, int *hostname_length, |
45 int *display_length, int *screen_length) | 48 int *display_length, int *screen_length) |
46 { | 49 { |
47 char *dotptr; | 50 Bufbyte *dotptr; |
48 | 51 |
49 dotptr = strrchr ((char *) XSTRING_DATA (display), ':'); | 52 dotptr = strrchr ((char *) XSTRING_DATA (display), ':'); |
50 if (!dotptr) | 53 if (!dotptr) |
51 { | 54 { |
52 *hostname_length = XSTRING_LENGTH (display); | 55 *hostname_length = XSTRING_LENGTH (display); |
53 *display_length = 0; | 56 *display_length = 0; |
54 } | 57 } |
55 else | 58 else |
56 { | 59 { |
57 *hostname_length = dotptr - (char *) XSTRING_DATA (display); | 60 *hostname_length = dotptr - XSTRING_DATA (display); |
58 | 61 |
59 dotptr = strchr (dotptr, '.'); | 62 dotptr = strchr ((char *) dotptr, '.'); |
60 if (dotptr) | 63 if (dotptr) |
61 *display_length = (dotptr - (char *) XSTRING_DATA (display) | 64 *display_length = (dotptr - XSTRING_DATA (display) - *hostname_length); |
62 - *hostname_length); | |
63 else | 65 else |
64 *display_length = XSTRING_LENGTH (display) - *hostname_length; | 66 *display_length = XSTRING_LENGTH (display) - *hostname_length; |
65 } | 67 } |
66 | 68 |
67 *screen_length = (XSTRING_LENGTH (display) - *display_length | 69 *screen_length = (XSTRING_LENGTH (display) - *display_length |
100 } | 102 } |
101 | 103 |
102 static Lisp_Object | 104 static Lisp_Object |
103 get_display_arg_connection (void) | 105 get_display_arg_connection (void) |
104 { | 106 { |
105 CONST char *disp_name; | 107 const Extbyte *disp_name; |
106 | 108 |
107 /* If the user didn't explicitly specify a display to use when | 109 /* If the user didn't explicitly specify a display to use when |
108 they called make-x-device, then we first check to see if a | 110 they called make-x-device, then we first check to see if a |
109 display was specified on the command line with -display. If | 111 display was specified on the command line with -display. If |
110 so, we set disp_name to it. Otherwise we use XDisplayName to | 112 so, we set disp_name to it. Otherwise we use XDisplayName to |
112 both of these things, but we need to know the name to use. */ | 114 both of these things, but we need to know the name to use. */ |
113 if (display_arg) | 115 if (display_arg) |
114 { | 116 { |
115 int elt; | 117 int elt; |
116 int argc; | 118 int argc; |
117 char **argv; | 119 Extbyte **argv; |
118 Lisp_Object conn; | 120 Lisp_Object conn; |
119 | 121 |
120 make_argc_argv (Vx_initial_argv_list, &argc, &argv); | 122 make_argc_argv (Vx_initial_argv_list, &argc, &argv); |
121 | 123 |
122 disp_name = NULL; | 124 disp_name = NULL; |
125 if (!strcmp (argv[elt], "-d") || !strcmp (argv[elt], "-display")) | 127 if (!strcmp (argv[elt], "-d") || !strcmp (argv[elt], "-display")) |
126 { | 128 { |
127 if (elt + 1 == argc) | 129 if (elt + 1 == argc) |
128 { | 130 { |
129 suppress_early_error_handler_backtrace = 1; | 131 suppress_early_error_handler_backtrace = 1; |
130 error ("-display specified with no arg"); | 132 type_error (Qinvalid_argument, |
133 "-display specified with no arg"); | |
131 } | 134 } |
132 else | 135 else |
133 { | 136 { |
134 disp_name = argv[elt + 1]; | 137 disp_name = argv[elt + 1]; |
135 break; | 138 break; |
138 } | 141 } |
139 | 142 |
140 /* assert: display_arg is only set if we found the display | 143 /* assert: display_arg is only set if we found the display |
141 arg earlier so we can't fail to find it now. */ | 144 arg earlier so we can't fail to find it now. */ |
142 assert (disp_name != NULL); | 145 assert (disp_name != NULL); |
143 conn = build_ext_string (disp_name, Qctext); | 146 conn = build_ext_string (disp_name, Qcommand_argument_encoding); |
144 free_argc_argv (argv); | 147 free_argc_argv (argv); |
145 return conn; | 148 return conn; |
146 } | 149 } |
147 else | 150 else |
148 return build_ext_string (XDisplayName (0), Qctext); | 151 return build_ext_string (XDisplayName (0), Qx_display_name_encoding); |
149 } | 152 } |
150 | 153 |
151 /* "semi-canonicalize" means convert to a nicer form for printing, but | 154 /* "semi-canonicalize" means convert to a nicer form for printing, but |
152 don't completely canonicalize (into some likely ugly form) */ | 155 don't completely canonicalize (into some likely ugly form) */ |
153 | 156 |
179 connection = x_device_to_console_connection (connection, errb); | 182 connection = x_device_to_console_connection (connection, errb); |
180 | 183 |
181 /* Check for a couple of standard special cases */ | 184 /* Check for a couple of standard special cases */ |
182 if (string_byte (XSTRING (connection), 0) == ':') | 185 if (string_byte (XSTRING (connection), 0) == ':') |
183 connection = concat2 (build_string ("localhost"), connection); | 186 connection = concat2 (build_string ("localhost"), connection); |
184 else if (!strncmp ((CONST char *) XSTRING_DATA (connection), | 187 else if (!strncmp (XSTRING_DATA (connection), "unix:", 5)) |
185 "unix:", 5)) | |
186 connection = concat2 (build_string ("localhost:"), | 188 connection = concat2 (build_string ("localhost:"), |
187 Fsubstring (connection, make_int (5), Qnil)); | 189 Fsubstring (connection, make_int (5), Qnil)); |
188 | 190 |
189 RETURN_UNGCPRO (connection); | 191 RETURN_UNGCPRO (connection); |
190 } | 192 } |
258 RETURN_UNGCPRO (Qunbound); | 260 RETURN_UNGCPRO (Qunbound); |
259 | 261 |
260 split_up_display_spec (connection, &hostname_length, &display_length, | 262 split_up_display_spec (connection, &hostname_length, &display_length, |
261 &screen_length); | 263 &screen_length); |
262 | 264 |
263 screen_str = build_string ((CONST char *) XSTRING_DATA (connection) | 265 screen_str = build_string (XSTRING_DATA (connection) |
264 + hostname_length + display_length); | 266 + hostname_length + display_length); |
265 connection = x_canonicalize_console_connection (connection, errb); | 267 connection = x_canonicalize_console_connection (connection, errb); |
266 | 268 |
267 RETURN_UNGCPRO (concat2 (connection, screen_str)); | 269 RETURN_UNGCPRO (concat2 (connection, screen_str)); |
268 } | 270 } |