comparison src/emacs.c @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children 57709be46d1b
comparison
equal deleted inserted replaced
283:fa3d41851a08 284:558f606b08ae
142 Lisp_Object Vdata_directory_list; 142 Lisp_Object Vdata_directory_list;
143 Lisp_Object Vinfo_directory, Vconfigure_info_directory; 143 Lisp_Object Vinfo_directory, Vconfigure_info_directory;
144 Lisp_Object Vsite_directory, Vconfigure_site_directory; 144 Lisp_Object Vsite_directory, Vconfigure_site_directory;
145 Lisp_Object Vconfigure_info_path; 145 Lisp_Object Vconfigure_info_path;
146 Lisp_Object Vinternal_error_checking; 146 Lisp_Object Vinternal_error_checking;
147 Lisp_Object Vpath_separator;
147 148
148 /* The default base directory XEmacs is installed under. */ 149 /* The default base directory XEmacs is installed under. */
149 Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory; 150 Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory;
150 151
151 /* If nonzero, set XEmacs to run at this priority. This is also used 152 /* If nonzero, set XEmacs to run at this priority. This is also used
1085 console_type_create_scrollbar_x (); 1086 console_type_create_scrollbar_x ();
1086 #endif 1087 #endif
1087 #ifdef HAVE_TOOLBARS 1088 #ifdef HAVE_TOOLBARS
1088 console_type_create_toolbar_x (); 1089 console_type_create_toolbar_x ();
1089 #endif 1090 #endif
1091 #ifdef HAVE_DIALOGS
1092 console_type_create_dialog_x ();
1093 #endif
1090 #endif /* HAVE_X_WINDOWS */ 1094 #endif /* HAVE_X_WINDOWS */
1091 1095
1092 #ifdef HAVE_MS_WINDOWS 1096 #ifdef HAVE_MS_WINDOWS
1093 console_type_create_mswindows (); 1097 console_type_create_mswindows ();
1094 console_type_create_device_mswindows (); 1098 console_type_create_device_mswindows ();
1254 #ifdef HAVE_DIALOGS 1258 #ifdef HAVE_DIALOGS
1255 vars_of_dialog (); 1259 vars_of_dialog ();
1256 #endif 1260 #endif
1257 vars_of_dired (); 1261 vars_of_dired ();
1258 vars_of_doc (); 1262 vars_of_doc ();
1263 #ifdef HAVE_DRAGNDROP
1264 vars_of_dragdrop ();
1265 #endif
1259 vars_of_editfns (); 1266 vars_of_editfns ();
1260 vars_of_elhash (); 1267 vars_of_elhash ();
1261 vars_of_emacs (); 1268 vars_of_emacs ();
1262 vars_of_eval (); 1269 vars_of_eval ();
1263 vars_of_event_stream (); 1270 vars_of_event_stream ();
2446 2453
2447 #ifndef SEPCHAR 2454 #ifndef SEPCHAR
2448 #define SEPCHAR ':' 2455 #define SEPCHAR ':'
2449 #endif 2456 #endif
2450 2457
2451 DEFUN ("decode-path-internal", Fdecode_path_internal, 1, 1, 0, /* 2458 /* Split STRING into a list of substrings. The substrings are the
2452 Explode a colon-separated list of paths into a list of strings. 2459 parts of original STRING separated by SEPCHAR. */
2453 */ 2460 static Lisp_Object
2454 (cd_path)) 2461 split_string_by_emchar_1 (CONST Bufbyte *string, Bytecount size,
2455 { 2462 Emchar sepchar)
2456 if (NILP (cd_path)) 2463 {
2457 return Qnil; 2464 Lisp_Object result = Qnil;
2458 2465 CONST Bufbyte *end = string + size;
2459 CHECK_STRING (cd_path);
2460
2461 return !XSTRING_LENGTH (cd_path) ?
2462 list1 (Qnil) :
2463 decode_path ((char *) XSTRING_DATA (cd_path));
2464 }
2465
2466 Lisp_Object
2467 decode_path (CONST char *path)
2468 {
2469 REGISTER CONST char *p;
2470 Lisp_Object lpath = Qnil;
2471
2472 if (!path || !strlen (path)) return Qnil;
2473
2474 #if defined (MSDOS) || defined (WIN32)
2475 dostounix_filename (path);
2476 #endif
2477 2466
2478 while (1) 2467 while (1)
2479 { 2468 {
2480 p = strchr (path, SEPCHAR); 2469 CONST Bufbyte *p = string;
2481 if (!p) p = path + strlen (path); 2470 while (p < end)
2482 lpath = Fcons (make_string ((CONST Bufbyte *) path, p - path), 2471 {
2483 lpath); 2472 if (charptr_emchar (p) == sepchar)
2484 if (*p) 2473 break;
2485 path = p + 1; 2474 INC_CHARPTR (p);
2475 }
2476 result = Fcons (make_string (string, p - string), result);
2477 if (p < end)
2478 {
2479 string = p;
2480 INC_CHARPTR (string); /* skip sepchar */
2481 }
2486 else 2482 else
2487 break; 2483 break;
2488 } 2484 }
2489 return Fnreverse (lpath); 2485 return Fnreverse (result);
2486 }
2487
2488 /* The same as the above, except PATH is an external C string (it is
2489 converted as FORMAT_FILENAME), and sepchar is hardcoded to SEPCHAR
2490 (':' or whatever). */
2491 Lisp_Object
2492 decode_path (CONST char *path)
2493 {
2494 int len;
2495 Bufbyte *newpath;
2496 if (!path)
2497 return Qnil;
2498
2499 GET_C_CHARPTR_INT_FILENAME_DATA_ALLOCA (path, newpath);
2500
2501 len = strlen (newpath);
2502 /* #### Does this make sense? It certainly does for
2503 decode_env_path(), but it looks dubious here. Does any code
2504 depend on decode_path("") returning nil instead of an empty
2505 string? */
2506 if (!len)
2507 return Qnil;
2508
2509 return split_string_by_emchar_1 (newpath, (Bytecount)len, SEPCHAR);
2490 } 2510 }
2491 2511
2492 Lisp_Object 2512 Lisp_Object
2493 decode_env_path (CONST char *evarname, CONST char *default_) 2513 decode_env_path (CONST char *evarname, CONST char *default_)
2494 { 2514 {
2495 REGISTER CONST char *path = 0; 2515 CONST char *path = 0;
2496 if (evarname) 2516 if (evarname)
2497 path = (char *) egetenv (evarname); 2517 path = egetenv (evarname);
2498 if (!path) 2518 if (!path)
2499 path = default_; 2519 path = default_;
2500 if (!path) 2520 return decode_path (path);
2501 return Qnil; 2521 }
2502 else 2522
2503 return decode_path(path); 2523 /* Ben thinks this function should not exist or be exported to Lisp.
2504 } 2524 We use it to define split-path-string in subr.el (not!). */
2505 2525
2526 DEFUN ("split-string-by-char", Fsplit_string_by_char, 1, 2, 0, /*
2527 Split STRING into a list of substrings originally separated by SEPCHAR.
2528 */
2529 (string, sepchar))
2530 {
2531 CHECK_STRING (string);
2532 CHECK_CHAR (sepchar);
2533 return split_string_by_emchar_1 (XSTRING_DATA (string),
2534 XSTRING_LENGTH (string),
2535 XCHAR (sepchar));
2536 }
2537
2538 /* #### This was supposed to be in subr.el, but is used VERY early in
2539 the bootstrap process, so it goes here. Damn. */
2540
2541 DEFUN ("split-path", Fsplit_path, 1, 1, 0, /*
2542 Explode a search path into a list of strings.
2543 The path components are separated with the characters specified
2544 with `path-separator'.
2545 */
2546 (path))
2547 {
2548 CHECK_STRING (path);
2549
2550 while (!STRINGP (Vpath_separator)
2551 || (XSTRING_CHAR_LENGTH (Vpath_separator) != 1))
2552 Vpath_separator = signal_simple_continuable_error
2553 ("`path-separator' should be set to a single-character string",
2554 Vpath_separator);
2555
2556 return (split_string_by_emchar_1
2557 (XSTRING_DATA (path), XSTRING_LENGTH (path),
2558 charptr_emchar (XSTRING_DATA (Vpath_separator))));
2559 }
2560
2506 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /* 2561 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /*
2507 Non-nil return value means XEmacs is running without interactive terminal. 2562 Non-nil return value means XEmacs is running without interactive terminal.
2508 */ 2563 */
2509 ()) 2564 ())
2510 { 2565 {
2586 DEFSUBR (Fquantify_start_recording_data); 2641 DEFSUBR (Fquantify_start_recording_data);
2587 DEFSUBR (Fquantify_stop_recording_data); 2642 DEFSUBR (Fquantify_stop_recording_data);
2588 DEFSUBR (Fquantify_clear_data); 2643 DEFSUBR (Fquantify_clear_data);
2589 #endif /* QUANTIFY */ 2644 #endif /* QUANTIFY */
2590 2645
2591 DEFSUBR (Fdecode_path_internal); 2646 DEFSUBR (Fsplit_string_by_char);
2647 DEFSUBR (Fsplit_path); /* #### */
2592 2648
2593 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook"); 2649 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
2594 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs"); 2650 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
2595 } 2651 }
2596 2652
2770 #ifdef ERROR_CHECK_BUFPOS 2826 #ifdef ERROR_CHECK_BUFPOS
2771 Vinternal_error_checking = Fcons (intern ("bufpos"), 2827 Vinternal_error_checking = Fcons (intern ("bufpos"),
2772 Vinternal_error_checking); 2828 Vinternal_error_checking);
2773 #endif 2829 #endif
2774 Vinternal_error_checking = Fpurecopy (Vinternal_error_checking); 2830 Vinternal_error_checking = Fpurecopy (Vinternal_error_checking);
2831
2832 DEFVAR_LISP ("path-separator", &Vpath_separator /*
2833 The directory separator in search paths, as a string.
2834 */ );
2835 {
2836 char c = SEPCHAR;
2837 Vpath_separator = make_string ((Bufbyte *)&c, 1);
2838 }
2775 } 2839 }
2776 2840
2777 void 2841 void
2778 complex_vars_of_emacs (void) 2842 complex_vars_of_emacs (void)
2779 { 2843 {