X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fconsole-x.c;h=f7bcdfb0d1f3fcd2586017855b63c1c75255fbf3;hp=05d9ac3353526228082e96522f1a4e750bdbe1c3;hb=f94fbd3020e40c3685853c905014f2ae310b02c7;hpb=716cfba952c1dc0d2cf5c968971f3780ba728a89 diff --git a/src/console-x.c b/src/console-x.c index 05d9ac3..f7bcdfb 100644 --- a/src/console-x.c +++ b/src/console-x.c @@ -20,6 +20,8 @@ Boston, MA 02111-1307, USA. */ /* Synched up with: Not in FSF. */ +/* This file Mule-ized by Ben Wing, 7-10-00. */ + /* Authorship: Ben Wing: January 1996, for 19.14. @@ -29,6 +31,7 @@ Boston, MA 02111-1307, USA. */ #include "lisp.h" #include "console-x.h" +#include "buffer.h" #include "process.h" /* canonicalize_host_name */ #include "redisplay.h" /* for display_arg */ @@ -40,32 +43,43 @@ x_initially_selected_for_input (struct console *con) return 1; } +/* Parse a DISPLAY specification like "host:10.0" or ":0" */ static void split_up_display_spec (Lisp_Object display, int *hostname_length, int *display_length, int *screen_length) { - char *dotptr; + Bufbyte *beg = XSTRING_DATA (display); + Bufbyte *end = beg + XSTRING_LENGTH (display); + Bufbyte *p = end; - dotptr = strrchr ((char *) XSTRING_DATA (display), ':'); - if (!dotptr) + while (p > beg) { - *hostname_length = XSTRING_LENGTH (display); - *display_length = 0; - } - else - { - *hostname_length = dotptr - (char *) XSTRING_DATA (display); + DEC_CHARPTR (p); + if (charptr_emchar (p) == ':') + { + *hostname_length = p - beg; - dotptr = strchr (dotptr, '.'); - if (dotptr) - *display_length = (dotptr - (char *) XSTRING_DATA (display) - - *hostname_length); - else - *display_length = XSTRING_LENGTH (display) - *hostname_length; + while (p < end - 1) + { + INC_CHARPTR (p); + if (charptr_emchar (p) == '.') + { + *display_length = p - beg - *hostname_length; + *screen_length = end - p; + return; + } + } + /* No '.' found. */ + *display_length = XSTRING_LENGTH (display) - *hostname_length; + *screen_length = 0; + return; + } } - *screen_length = (XSTRING_LENGTH (display) - *display_length - - *hostname_length); + /* No ':' found. */ + *hostname_length = XSTRING_LENGTH (display); + *display_length = 0; + *screen_length = 0; } /* Remember, in all of the following functions, we have to verify @@ -102,7 +116,7 @@ x_device_to_console_connection (Lisp_Object connection, Error_behavior errb) static Lisp_Object get_display_arg_connection (void) { - CONST char *disp_name; + const Extbyte *disp_name; /* If the user didn't explicitly specify a display to use when they called make-x-device, then we first check to see if a @@ -114,7 +128,7 @@ get_display_arg_connection (void) { int elt; int argc; - char **argv; + Extbyte **argv; Lisp_Object conn; make_argc_argv (Vx_initial_argv_list, &argc, &argv); @@ -127,7 +141,8 @@ get_display_arg_connection (void) if (elt + 1 == argc) { suppress_early_error_handler_backtrace = 1; - error ("-display specified with no arg"); + type_error (Qinvalid_argument, + "-display specified with no arg"); } else { @@ -140,12 +155,12 @@ get_display_arg_connection (void) /* assert: display_arg is only set if we found the display arg earlier so we can't fail to find it now. */ assert (disp_name != NULL); - conn = build_ext_string (disp_name, Qctext); + conn = build_ext_string (disp_name, Qcommand_argument_encoding); free_argc_argv (argv); return conn; } else - return build_ext_string (XDisplayName (0), Qctext); + return build_ext_string (XDisplayName (0), Qx_display_name_encoding); } /* "semi-canonicalize" means convert to a nicer form for printing, but @@ -179,12 +194,26 @@ x_semi_canonicalize_console_connection (Lisp_Object connection, connection = x_device_to_console_connection (connection, errb); /* Check for a couple of standard special cases */ - if (string_byte (XSTRING (connection), 0) == ':') + if (string_char (XSTRING (connection), 0) == ':') connection = concat2 (build_string ("localhost"), connection); - else if (!strncmp ((CONST char *) XSTRING_DATA (connection), - "unix:", 5)) - connection = concat2 (build_string ("localhost:"), - Fsubstring (connection, make_int (5), Qnil)); + else + { + /* connection =~ s/^unix:/localhost:/; */ + const Bufbyte *p = XSTRING_DATA (connection); + const Bufbyte *end = XSTRING_DATA (connection) + XSTRING_LENGTH (connection); + size_t i; + + for (i = 0; i < sizeof ("unix:") - 1; i++) + { + if (p == end || charptr_emchar (p) != "unix:"[i]) + goto ok; + INC_CHARPTR (p); + } + + connection = concat2 (build_string ("localhost:"), + make_string (p, end - p)); + } + ok: RETURN_UNGCPRO (connection); } @@ -260,8 +289,8 @@ x_canonicalize_device_connection (Lisp_Object connection, Error_behavior errb) split_up_display_spec (connection, &hostname_length, &display_length, &screen_length); - screen_str = build_string ((CONST char *) XSTRING_DATA (connection) - + hostname_length + display_length); + screen_str = make_string (XSTRING_DATA (connection) + + hostname_length + display_length, screen_length); connection = x_canonicalize_console_connection (connection, errb); RETURN_UNGCPRO (concat2 (connection, screen_str));