Mercurial > hg > xemacs-beta
comparison src/editfns.c @ 288:e11d67e05968 r21-0b42
Import from CVS: tag r21-0b42
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:35:54 +0200 |
parents | c5d627a313b1 |
children | 4b85ae5eabfb |
comparison
equal
deleted
inserted
replaced
287:13a0bd77a29d | 288:e11d67e05968 |
---|---|
67 char *get_system_name (void); | 67 char *get_system_name (void); |
68 | 68 |
69 Lisp_Object Qformat; | 69 Lisp_Object Qformat; |
70 | 70 |
71 Lisp_Object Qpoint, Qmark, Qregion_beginning, Qregion_end; | 71 Lisp_Object Qpoint, Qmark, Qregion_beginning, Qregion_end; |
72 | |
73 Lisp_Object Quser_files_and_directories; | |
72 | 74 |
73 /* This holds the value of `environ' produced by the previous | 75 /* This holds the value of `environ' produced by the previous |
74 call to Fset_time_zone_rule, or 0 if Fset_time_zone_rule | 76 call to Fset_time_zone_rule, or 0 if Fset_time_zone_rule |
75 has never been called. */ | 77 has never been called. */ |
76 static char **environbuf; | 78 static char **environbuf; |
766 } | 768 } |
767 } | 769 } |
768 #endif /* AMPERSAND_FULL_NAME */ | 770 #endif /* AMPERSAND_FULL_NAME */ |
769 | 771 |
770 return tem; | 772 return tem; |
773 } | |
774 | |
775 static char *cached_home_directory; | |
776 | |
777 void | |
778 uncache_home_directory (void) | |
779 { | |
780 cached_home_directory = NULL; /* in some cases, this may cause the leaking | |
781 of a few bytes */ | |
782 } | |
783 | |
784 char * | |
785 get_home_directory (void) | |
786 { | |
787 int output_home_warning = 0; | |
788 | |
789 if (cached_home_directory == NULL) | |
790 { | |
791 if ((cached_home_directory = getenv("HOME")) == NULL) | |
792 { | |
793 #if defined(WINDOWSNT) && !defined(__CYGWIN32__) | |
794 char *homedrive, *homepath; | |
795 | |
796 if ((homedrive = getenv("HOMEDRIVE")) != NULL && | |
797 (homepath = getenv("HOMEPATH")) != NULL) | |
798 { | |
799 cached_home_directory = | |
800 (char *) xmalloc(strlen(homedrive) + strlen(homepath) + 1); | |
801 sprintf(cached_home_directory, "%s%s", homedrive, homepath); | |
802 } | |
803 else | |
804 { | |
805 # if 1 | |
806 /* | |
807 * Use the current directory. | |
808 * This preserves the existing XEmacs behavior, but is different | |
809 * from NT Emacs. | |
810 */ | |
811 if (initial_directory[0] != '\0') | |
812 { | |
813 cached_home_directory = initial_directory; | |
814 } | |
815 else | |
816 { | |
817 /* This will probably give the wrong value */ | |
818 cached_home_directory = getcwd (NULL, 0); | |
819 } | |
820 # else | |
821 /* | |
822 * This is NT Emacs behavior | |
823 */ | |
824 cached_home_directory = "C:\\"; | |
825 output_home_warning = 1; | |
826 # endif | |
827 } | |
828 #else /* !WINDOWSNT */ | |
829 /* | |
830 * Unix, typically. | |
831 * Using "/" isn't quite right, but what should we do? | |
832 * We probably should try to extract pw_dir from /etc/passwd, | |
833 * before falling back to this. | |
834 */ | |
835 cached_home_directory = "/"; | |
836 output_home_warning = 1; | |
837 #endif /* !WINDOWSNT */ | |
838 } | |
839 if (initialized && output_home_warning) | |
840 { | |
841 warn_when_safe(Quser_files_and_directories, Qwarning, "\n" | |
842 " Xemacs was unable to determine a good value for the user's $HOME\n" | |
843 " directory, and will be using the value:\n" | |
844 " %s\n" | |
845 " This is probably incorrect.", | |
846 cached_home_directory | |
847 ); | |
848 } | |
849 } | |
850 return (cached_home_directory); | |
851 } | |
852 | |
853 DEFUN ("user-home-directory", Fuser_home_directory, 0, 0, 0, /* | |
854 Return the user's home directory, as a string. | |
855 */ | |
856 ()) | |
857 { | |
858 Lisp_Object directory; | |
859 char *path; | |
860 | |
861 directory = Qnil; | |
862 path = get_home_directory (); | |
863 if (path != NULL) | |
864 { | |
865 directory = | |
866 Fexpand_file_name (Fsubstitute_in_file_name (build_string (path)), | |
867 Qnil); | |
868 } | |
869 return (directory); | |
771 } | 870 } |
772 | 871 |
773 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /* | 872 DEFUN ("system-name", Fsystem_name, 0, 0, 0, /* |
774 Return the name of the machine you are running on, as a string. | 873 Return the name of the machine you are running on, as a string. |
775 */ | 874 */ |
2114 defsymbol (&Qpoint, "point"); | 2213 defsymbol (&Qpoint, "point"); |
2115 defsymbol (&Qmark, "mark"); | 2214 defsymbol (&Qmark, "mark"); |
2116 defsymbol (&Qregion_beginning, "region-beginning"); | 2215 defsymbol (&Qregion_beginning, "region-beginning"); |
2117 defsymbol (&Qregion_end, "region-end"); | 2216 defsymbol (&Qregion_end, "region-end"); |
2118 defsymbol (&Qformat, "format"); | 2217 defsymbol (&Qformat, "format"); |
2218 defsymbol (&Quser_files_and_directories, "user-files-and-directories"); | |
2119 | 2219 |
2120 DEFSUBR (Fchar_equal); | 2220 DEFSUBR (Fchar_equal); |
2121 DEFSUBR (Fchar_Equal); | 2221 DEFSUBR (Fchar_Equal); |
2122 DEFSUBR (Fgoto_char); | 2222 DEFSUBR (Fgoto_char); |
2123 DEFSUBR (Fstring_to_char); | 2223 DEFSUBR (Fstring_to_char); |
2155 DEFSUBR (Fuser_login_name); | 2255 DEFSUBR (Fuser_login_name); |
2156 DEFSUBR (Fuser_real_login_name); | 2256 DEFSUBR (Fuser_real_login_name); |
2157 DEFSUBR (Fuser_uid); | 2257 DEFSUBR (Fuser_uid); |
2158 DEFSUBR (Fuser_real_uid); | 2258 DEFSUBR (Fuser_real_uid); |
2159 DEFSUBR (Fuser_full_name); | 2259 DEFSUBR (Fuser_full_name); |
2260 DEFSUBR (Fuser_home_directory); | |
2160 DEFSUBR (Femacs_pid); | 2261 DEFSUBR (Femacs_pid); |
2161 DEFSUBR (Fcurrent_time); | 2262 DEFSUBR (Fcurrent_time); |
2162 DEFSUBR (Fcurrent_process_time); | 2263 DEFSUBR (Fcurrent_process_time); |
2163 DEFSUBR (Fformat_time_string); | 2264 DEFSUBR (Fformat_time_string); |
2164 DEFSUBR (Fdecode_time); | 2265 DEFSUBR (Fdecode_time); |