comparison src/editfns.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 2f8bb876ab1d
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
26 26
27 /* Hacked on for Mule by Ben Wing, December 1994. */ 27 /* Hacked on for Mule by Ben Wing, December 1994. */
28 28
29 #include <config.h> 29 #include <config.h>
30 #include "lisp.h" 30 #include "lisp.h"
31 #ifdef HAVE_UNISTD_H
32 #include <unistd.h>
33 #endif
34 31
35 #include "buffer.h" 32 #include "buffer.h"
36 #include "commands.h" 33 #include "commands.h"
37 #include "events.h" /* for EVENTP */ 34 #include "events.h" /* for EVENTP */
38 #include "extents.h" 35 #include "extents.h"
604 } 601 }
605 602
606 603
607 DEFUN ("temp-directory", Ftemp_directory, 0, 0, 0, /* 604 DEFUN ("temp-directory", Ftemp_directory, 0, 0, 0, /*
608 Return the pathname to the directory to use for temporary files. 605 Return the pathname to the directory to use for temporary files.
609 On NT/MSDOS, this is obtained from the TEMP or TMP environment variables, 606 On MS Windows, this is obtained from the TEMP or TMP environment variables,
610 defaulting to / if they are both undefined. 607 defaulting to / if they are both undefined.
611 On Unix it is obtained from TMPDIR, with /tmp as the default 608 On Unix it is obtained from TMPDIR, with /tmp as the default
612 */ 609 */
613 ()) 610 ())
614 { 611 {
615 char *tmpdir; 612 char *tmpdir;
616 #if defined(WINDOWSNT) || defined(MSDOS) 613 #if defined(WIN32_NATIVE)
617 tmpdir = getenv ("TEMP"); 614 tmpdir = getenv ("TEMP");
618 if (!tmpdir) 615 if (!tmpdir)
619 tmpdir = getenv ("TMP"); 616 tmpdir = getenv ("TMP");
620 if (!tmpdir) 617 if (!tmpdir)
621 tmpdir = "/"; 618 tmpdir = "/";
622 #else /* WINDOWSNT || MSDOS */ 619 #else /* WIN32_NATIVE */
623 tmpdir = getenv ("TMPDIR"); 620 tmpdir = getenv ("TMPDIR");
624 if (!tmpdir) 621 if (!tmpdir)
625 tmpdir = "/tmp"; 622 tmpdir = "/tmp";
626 #endif 623 #endif
627 624
679 old environment (I site observed behavior on sunos and linux), so the 676 old environment (I site observed behavior on sunos and linux), so the
680 environment variables should be disregarded in that case. --Stig */ 677 environment variables should be disregarded in that case. --Stig */
681 char *user_name = getenv ("LOGNAME"); 678 char *user_name = getenv ("LOGNAME");
682 if (!user_name) 679 if (!user_name)
683 user_name = getenv ( 680 user_name = getenv (
684 #ifdef WINDOWSNT 681 #ifdef WIN32_NATIVE
685 "USERNAME" /* it's USERNAME on NT */ 682 "USERNAME" /* it's USERNAME on NT */
686 #else 683 #else
687 "USER" 684 "USER"
688 #endif 685 #endif
689 ); 686 );
690 if (user_name) 687 if (user_name)
691 return (user_name); 688 return (user_name);
692 else 689 else
693 { 690 {
694 struct passwd *pw = getpwuid (geteuid ()); 691 struct passwd *pw = getpwuid (geteuid ());
695 #ifdef __CYGWIN32__ 692 #ifdef CYGWIN
696 /* Since the Cygwin environment may not have an /etc/passwd, 693 /* Since the Cygwin environment may not have an /etc/passwd,
697 return "unknown" instead of the null if the username 694 return "unknown" instead of the null if the username
698 cannot be determined. 695 cannot be determined.
699 */ 696 */
700 return pw ? pw->pw_name : "unknown"; 697 return pw ? pw->pw_name : "unknown";
714 ()) 711 ())
715 { 712 {
716 struct passwd *pw = getpwuid (getuid ()); 713 struct passwd *pw = getpwuid (getuid ());
717 /* #### - I believe this should return nil instead of "unknown" when pw==0 */ 714 /* #### - I believe this should return nil instead of "unknown" when pw==0 */
718 715
719 #ifdef MSDOS
720 /* We let the real user name default to "root" because that's quite
721 accurate on MSDOG and because it lets Emacs find the init file.
722 (The DVX libraries override the Djgpp libraries here.) */
723 Lisp_Object tem = build_string (pw ? pw->pw_name : "root");/* no gettext */
724 #else
725 Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */ 716 Lisp_Object tem = build_string (pw ? pw->pw_name : "unknown");/* no gettext */
726 #endif
727 return tem; 717 return tem;
728 } 718 }
729 719
730 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /* 720 DEFUN ("user-uid", Fuser_uid, 0, 0, 0, /*
731 Return the effective uid of Emacs, as an integer. 721 Return the effective uid of Emacs, as an integer.
838 828
839 if (cached_home_directory == NULL) 829 if (cached_home_directory == NULL)
840 { 830 {
841 if ((cached_home_directory = (Extbyte *) getenv("HOME")) == NULL) 831 if ((cached_home_directory = (Extbyte *) getenv("HOME")) == NULL)
842 { 832 {
843 #if defined(WINDOWSNT) && !defined(__CYGWIN32__) 833 #if defined(WIN32_NATIVE)
844 char *homedrive, *homepath; 834 char *homedrive, *homepath;
845 835
846 if ((homedrive = getenv("HOMEDRIVE")) != NULL && 836 if ((homedrive = getenv("HOMEDRIVE")) != NULL &&
847 (homepath = getenv("HOMEPATH")) != NULL) 837 (homepath = getenv("HOMEPATH")) != NULL)
848 { 838 {
878 */ 868 */
879 cached_home_directory = (Extbyte *) "C:\\"; 869 cached_home_directory = (Extbyte *) "C:\\";
880 output_home_warning = 1; 870 output_home_warning = 1;
881 # endif 871 # endif
882 } 872 }
883 #else /* !WINDOWSNT */ 873 #else /* !WIN32_NATIVE */
884 /* 874 /*
885 * Unix, typically. 875 * Unix, typically.
886 * Using "/" isn't quite right, but what should we do? 876 * Using "/" isn't quite right, but what should we do?
887 * We probably should try to extract pw_dir from /etc/passwd, 877 * We probably should try to extract pw_dir from /etc/passwd,
888 * before falling back to this. 878 * before falling back to this.
889 */ 879 */
890 cached_home_directory = (Extbyte *) "/"; 880 cached_home_directory = (Extbyte *) "/";
891 output_home_warning = 1; 881 output_home_warning = 1;
892 #endif /* !WINDOWSNT */ 882 #endif /* !WIN32_NATIVE */
893 } 883 }
894 if (initialized && output_home_warning) 884 if (initialized && output_home_warning)
895 { 885 {
896 warn_when_safe (Quser_files_and_directories, Qwarning, "\n" 886 warn_when_safe (Quser_files_and_directories, Qwarning, "\n"
897 " XEmacs was unable to determine a good value for the user's $HOME\n" 887 " XEmacs was unable to determine a good value for the user's $HOME\n"