summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-10-26 15:14:33 +0300
committerEli Zaretskii <eliz@gnu.org>2013-10-26 15:14:33 +0300
commit5c4a19a90f803ed46629c2bdc1ac3d3563caa738 (patch)
treed9e33430f67ad451d7777a819273a615a0f662f7
parentc3e9160b8c375760d6bc53602caeed211e91389d (diff)
downloademacs-5c4a19a90f803ed46629c2bdc1ac3d3563caa738.tar.gz
getcwd and dflt_passwd stuff is done.
-rw-r--r--src/fileio.c9
-rw-r--r--src/sysdep.c4
-rw-r--r--src/w32.c56
3 files changed, 55 insertions, 14 deletions
diff --git a/src/fileio.c b/src/fileio.c
index a1dcb72b4e4..dc6d80932c4 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1267,6 +1267,11 @@ filesystem tree, not (expand-file-name ".." dirname). */)
indirectly by prepending newdir to nm if necessary, and using
cwd (or the wd of newdir's drive) as the new newdir. */
char *adir;
+#ifdef WINDOWSNT
+ const int adir_size = MAX_UTF8_PATH;
+#else
+ const int adir_size = MAXPATHLEN + 1;
+#endif
if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
{
@@ -1282,14 +1287,14 @@ filesystem tree, not (expand-file-name ".." dirname). */)
strcat (tmp, nm);
nm = tmp;
}
- adir = alloca (MAXPATHLEN + 1);
+ adir = alloca (adir_size);
if (drive)
{
if (!getdefdir (c_toupper (drive) - 'A' + 1, adir))
strcpy (adir, "/");
}
else
- getcwd (adir, MAXPATHLEN + 1);
+ getcwd (adir, adir_size);
if (multibyte)
{
Lisp_Object tem = build_string (adir);
diff --git a/src/sysdep.c b/src/sysdep.c
index f78a8fbb2ef..7af4254fcc7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -464,7 +464,11 @@ sys_subshell (void)
{
#ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */
int st;
+#ifdef MSDOS
char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */
+#else
+ char oldwd[MAX_UTF8_PATH];
+#endif
#endif
pid_t pid;
int status;
diff --git a/src/w32.c b/src/w32.c
index 993d598ff54..09d78141e14 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1367,6 +1367,7 @@ filename_from_ansi (const char *fn_in, char *fn_out)
+/* The directory where we started, in UTF-8. */
static char startup_dir[MAX_UTF8_PATH];
/* Get the current working directory. */
@@ -1559,8 +1560,8 @@ getloadavg (double loadavg[], int nelem)
static char dflt_passwd_name[PASSWD_FIELD_SIZE];
static char dflt_passwd_passwd[PASSWD_FIELD_SIZE];
static char dflt_passwd_gecos[PASSWD_FIELD_SIZE];
-static char dflt_passwd_dir[PASSWD_FIELD_SIZE];
-static char dflt_passwd_shell[PASSWD_FIELD_SIZE];
+static char dflt_passwd_dir[MAX_UTF8_PATH];
+static char dflt_passwd_shell[MAX_UTF8_PATH];
static struct passwd dflt_passwd =
{
@@ -1741,15 +1742,32 @@ init_user_info (void)
}
dflt_group.gr_gid = dflt_passwd.pw_gid;
- /* Ensure HOME and SHELL are defined. */
- if (getenv ("HOME") == NULL)
- emacs_abort ();
- if (getenv ("SHELL") == NULL)
- emacs_abort ();
-
/* Set dir and shell from environment variables. */
- strcpy (dflt_passwd.pw_dir, getenv ("HOME"));
- strcpy (dflt_passwd.pw_shell, getenv ("SHELL"));
+ if (w32_unicode_filenames)
+ {
+ wchar_t *home = _wgetenv (L"HOME");
+ wchar_t *shell = _wgetenv (L"SHELL");
+
+ /* Ensure HOME and SHELL are defined. */
+ if (home == NULL)
+ emacs_abort ();
+ if (shell == NULL)
+ emacs_abort ();
+ filename_from_utf16 (home, dflt_passwd.pw_dir);
+ filename_from_utf16 (shell, dflt_passwd.pw_shell);
+ }
+ else
+ {
+ char *home = getenv ("HOME");
+ char *shell = getenv ("SHELL");
+
+ if (home == NULL)
+ emacs_abort ();
+ if (shell == NULL)
+ emacs_abort ();
+ filename_from_ansi (home, dflt_passwd.pw_dir);
+ filename_from_ansi (shell, dflt_passwd.pw_shell);
+ }
xfree (buf);
if (token)
@@ -2442,8 +2460,22 @@ init_environment (char ** argv)
/* Remember the initial working directory for getcwd. */
/* FIXME: Do we need to resolve possible symlinks in startup_dir?
Does it matter anywhere in Emacs? */
- if (!GetCurrentDirectory (MAXPATHLEN, startup_dir))
- emacs_abort ();
+ if (w32_unicode_filenames)
+ {
+ wchar_t wstartup_dir[MAX_PATH];
+
+ if (!GetCurrentDirectoryW (MAX_PATH, wstartup_dir))
+ emacs_abort ();
+ filename_from_utf16 (wstartup_dir, startup_dir);
+ }
+ else
+ {
+ char astartup_dir[MAX_PATH];
+
+ if (!GetCurrentDirectoryA (MAX_PATH, astartup_dir))
+ emacs_abort ();
+ filename_from_ansi (astartup_dir, startup_dir);
+ }
{
static char modname[MAX_PATH];