Mercurial > hg > xemacs-beta
comparison src/console-x.c @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | abe6d1db359e |
children | 183866b06e0b |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
41 x_initially_selected_for_input (struct console *con) | 41 x_initially_selected_for_input (struct console *con) |
42 { | 42 { |
43 return 1; | 43 return 1; |
44 } | 44 } |
45 | 45 |
46 /* Parse a DISPLAY specification like "host:10.0" or ":0" */ | |
46 static void | 47 static void |
47 split_up_display_spec (Lisp_Object display, int *hostname_length, | 48 split_up_display_spec (Lisp_Object display, int *hostname_length, |
48 int *display_length, int *screen_length) | 49 int *display_length, int *screen_length) |
49 { | 50 { |
50 Bufbyte *dotptr; | 51 Bufbyte *beg = XSTRING_DATA (display); |
51 | 52 Bufbyte *end = beg + XSTRING_LENGTH (display); |
52 dotptr = strrchr ((char *) XSTRING_DATA (display), ':'); | 53 Bufbyte *p = end; |
53 if (!dotptr) | 54 |
54 { | 55 while (p > beg) |
55 *hostname_length = XSTRING_LENGTH (display); | 56 { |
56 *display_length = 0; | 57 DEC_CHARPTR (p); |
57 } | 58 if (charptr_emchar (p) == ':') |
58 else | 59 { |
59 { | 60 *hostname_length = p - beg; |
60 *hostname_length = dotptr - XSTRING_DATA (display); | 61 |
61 | 62 while (p < end - 1) |
62 dotptr = strchr ((char *) dotptr, '.'); | 63 { |
63 if (dotptr) | 64 INC_CHARPTR (p); |
64 *display_length = (dotptr - XSTRING_DATA (display) - *hostname_length); | 65 if (charptr_emchar (p) == '.') |
65 else | 66 { |
66 *display_length = XSTRING_LENGTH (display) - *hostname_length; | 67 *display_length = p - beg - *hostname_length; |
67 } | 68 *screen_length = end - p; |
68 | 69 return; |
69 *screen_length = (XSTRING_LENGTH (display) - *display_length | 70 } |
70 - *hostname_length); | 71 } |
72 /* No '.' found. */ | |
73 *display_length = XSTRING_LENGTH (display) - *hostname_length; | |
74 *screen_length = 0; | |
75 return; | |
76 } | |
77 } | |
78 | |
79 /* No ':' found. */ | |
80 *hostname_length = XSTRING_LENGTH (display); | |
81 *display_length = 0; | |
82 *screen_length = 0; | |
71 } | 83 } |
72 | 84 |
73 /* Remember, in all of the following functions, we have to verify | 85 /* Remember, in all of the following functions, we have to verify |
74 the integrity of our input, because the generic functions don't. */ | 86 the integrity of our input, because the generic functions don't. */ |
75 | 87 |
180 a console connection -- e.g. "foo:0.0" instead of "foo:0". This | 192 a console connection -- e.g. "foo:0.0" instead of "foo:0". This |
181 only happens in `find-console' and `get-console'. */ | 193 only happens in `find-console' and `get-console'. */ |
182 connection = x_device_to_console_connection (connection, errb); | 194 connection = x_device_to_console_connection (connection, errb); |
183 | 195 |
184 /* Check for a couple of standard special cases */ | 196 /* Check for a couple of standard special cases */ |
185 if (string_byte (XSTRING (connection), 0) == ':') | 197 if (string_char (XSTRING (connection), 0) == ':') |
186 connection = concat2 (build_string ("localhost"), connection); | 198 connection = concat2 (build_string ("localhost"), connection); |
187 else if (!strncmp (XSTRING_DATA (connection), "unix:", 5)) | 199 else |
188 connection = concat2 (build_string ("localhost:"), | 200 { |
189 Fsubstring (connection, make_int (5), Qnil)); | 201 /* connection =~ s/^unix:/localhost:/; */ |
202 const Bufbyte *p = XSTRING_DATA (connection); | |
203 const Bufbyte *end = XSTRING_DATA (connection) + XSTRING_LENGTH (connection); | |
204 size_t i; | |
205 | |
206 for (i = 0; i < sizeof ("unix:") - 1; i++) | |
207 { | |
208 if (p == end || charptr_emchar (p) != "unix:"[i]) | |
209 goto ok; | |
210 INC_CHARPTR (p); | |
211 } | |
212 | |
213 connection = concat2 (build_string ("localhost:"), | |
214 make_string (p, end - p)); | |
215 } | |
216 ok: | |
190 | 217 |
191 RETURN_UNGCPRO (connection); | 218 RETURN_UNGCPRO (connection); |
192 } | 219 } |
193 | 220 |
194 static Lisp_Object | 221 static Lisp_Object |
260 RETURN_UNGCPRO (Qunbound); | 287 RETURN_UNGCPRO (Qunbound); |
261 | 288 |
262 split_up_display_spec (connection, &hostname_length, &display_length, | 289 split_up_display_spec (connection, &hostname_length, &display_length, |
263 &screen_length); | 290 &screen_length); |
264 | 291 |
265 screen_str = build_string (XSTRING_DATA (connection) | 292 screen_str = make_string (XSTRING_DATA (connection) |
266 + hostname_length + display_length); | 293 + hostname_length + display_length, screen_length); |
267 connection = x_canonicalize_console_connection (connection, errb); | 294 connection = x_canonicalize_console_connection (connection, errb); |
268 | 295 |
269 RETURN_UNGCPRO (concat2 (connection, screen_str)); | 296 RETURN_UNGCPRO (concat2 (connection, screen_str)); |
270 } | 297 } |
271 | 298 |