Mercurial > hg > xemacs-beta
diff src/editfns.c @ 365:30d2cfa1092a r21-1-12
Import from CVS: tag r21-1-12
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:00:12 +0200 |
parents | 8429d81ab209 |
children | a4f53d9b3154 |
line wrap: on
line diff
--- a/src/editfns.c Mon Aug 13 10:59:30 2007 +0200 +++ b/src/editfns.c Mon Aug 13 11:00:12 2007 +0200 @@ -602,6 +602,12 @@ return make_char (BUF_FETCH_CHAR (b, n)); } +#if !defined(WINDOWSNT) && !defined(MSDOS) +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <limits.h> +#endif DEFUN ("temp-directory", Ftemp_directory, 0, 0, 0, /* Return the pathname to the directory to use for temporary files. @@ -621,7 +627,47 @@ #else /* WINDOWSNT || MSDOS */ tmpdir = getenv ("TMPDIR"); if (!tmpdir) + { + struct stat st; + char * logname = user_login_name(NULL); + int myuid = getuid(); + static char path[1+_POSIX_PATH_MAX]; + + strcpy(path, "/tmp/"); strncat(path, logname, _POSIX_PATH_MAX); + if (lstat(path, &st) < 0 && errno == ENOENT) + { + mkdir(path, 0700); /* ignore retval -- checked next anyway. */ + } + if (lstat(path, &st) == 0 && st.st_uid == myuid && S_ISDIR(st.st_mode)) + { + tmpdir = path; + } + else + { + strcpy(path, getenv("HOME")); strncat(path, "/tmp/", _POSIX_PATH_MAX); + if (stat(path, &st) < 0 && errno == ENOENT) + { + int fd; + char warnpath[1+_POSIX_PATH_MAX]; + mkdir(path, 0700); /* ignore retvals */ + strcpy(warnpath, path); + strncat(warnpath, ".created_by_xemacs", _POSIX_PATH_MAX); + if ((fd = open(warnpath, O_WRONLY|O_CREAT, 0644)) > 0) + { + write(fd, "XEmacs created this directory because /tmp/<yourname> was unavailable -- \nPlease check !\n", 89); + close(fd); + } + } + if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) + { + tmpdir = path; + } + else + { tmpdir = "/tmp"; + } + } + } #endif return build_ext_string (tmpdir, FORMAT_FILENAME); @@ -2398,6 +2444,8 @@ See the variable `zmacs-regions'. The same effect can be achieved using the `_' interactive specification. + +`zmacs-region-stays' is reset to nil before each command is executed. */ ); zmacs_region_stays = 0;