aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-10-26 15:14:33 +0300
committerEli Zaretskii2013-10-26 15:14:33 +0300
commit5c4a19a90f803ed46629c2bdc1ac3d3563caa738 (patch)
treed9e33430f67ad451d7777a819273a615a0f662f7 /src
parentc3e9160b8c375760d6bc53602caeed211e91389d (diff)
downloademacs-5c4a19a90f803ed46629c2bdc1ac3d3563caa738.tar.gz
emacs-5c4a19a90f803ed46629c2bdc1ac3d3563caa738.zip
getcwd and dflt_passwd stuff is done.
Diffstat (limited to 'src')
-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). */)
1267 indirectly by prepending newdir to nm if necessary, and using 1267 indirectly by prepending newdir to nm if necessary, and using
1268 cwd (or the wd of newdir's drive) as the new newdir. */ 1268 cwd (or the wd of newdir's drive) as the new newdir. */
1269 char *adir; 1269 char *adir;
1270#ifdef WINDOWSNT
1271 const int adir_size = MAX_UTF8_PATH;
1272#else
1273 const int adir_size = MAXPATHLEN + 1;
1274#endif
1270 1275
1271 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) 1276 if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1]))
1272 { 1277 {
@@ -1282,14 +1287,14 @@ filesystem tree, not (expand-file-name ".." dirname). */)
1282 strcat (tmp, nm); 1287 strcat (tmp, nm);
1283 nm = tmp; 1288 nm = tmp;
1284 } 1289 }
1285 adir = alloca (MAXPATHLEN + 1); 1290 adir = alloca (adir_size);
1286 if (drive) 1291 if (drive)
1287 { 1292 {
1288 if (!getdefdir (c_toupper (drive) - 'A' + 1, adir)) 1293 if (!getdefdir (c_toupper (drive) - 'A' + 1, adir))
1289 strcpy (adir, "/"); 1294 strcpy (adir, "/");
1290 } 1295 }
1291 else 1296 else
1292 getcwd (adir, MAXPATHLEN + 1); 1297 getcwd (adir, adir_size);
1293 if (multibyte) 1298 if (multibyte)
1294 { 1299 {
1295 Lisp_Object tem = build_string (adir); 1300 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)
464{ 464{
465#ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ 465#ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */
466 int st; 466 int st;
467#ifdef MSDOS
467 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */ 468 char oldwd[MAXPATHLEN+1]; /* Fixed length is safe on MSDOS. */
469#else
470 char oldwd[MAX_UTF8_PATH];
471#endif
468#endif 472#endif
469 pid_t pid; 473 pid_t pid;
470 int status; 474 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)
1367 1367
1368 1368
1369 1369
1370/* The directory where we started, in UTF-8. */
1370static char startup_dir[MAX_UTF8_PATH]; 1371static char startup_dir[MAX_UTF8_PATH];
1371 1372
1372/* Get the current working directory. */ 1373/* Get the current working directory. */
@@ -1559,8 +1560,8 @@ getloadavg (double loadavg[], int nelem)
1559static char dflt_passwd_name[PASSWD_FIELD_SIZE]; 1560static char dflt_passwd_name[PASSWD_FIELD_SIZE];
1560static char dflt_passwd_passwd[PASSWD_FIELD_SIZE]; 1561static char dflt_passwd_passwd[PASSWD_FIELD_SIZE];
1561static char dflt_passwd_gecos[PASSWD_FIELD_SIZE]; 1562static char dflt_passwd_gecos[PASSWD_FIELD_SIZE];
1562static char dflt_passwd_dir[PASSWD_FIELD_SIZE]; 1563static char dflt_passwd_dir[MAX_UTF8_PATH];
1563static char dflt_passwd_shell[PASSWD_FIELD_SIZE]; 1564static char dflt_passwd_shell[MAX_UTF8_PATH];
1564 1565
1565static struct passwd dflt_passwd = 1566static struct passwd dflt_passwd =
1566{ 1567{
@@ -1741,15 +1742,32 @@ init_user_info (void)
1741 } 1742 }
1742 dflt_group.gr_gid = dflt_passwd.pw_gid; 1743 dflt_group.gr_gid = dflt_passwd.pw_gid;
1743 1744
1744 /* Ensure HOME and SHELL are defined. */
1745 if (getenv ("HOME") == NULL)
1746 emacs_abort ();
1747 if (getenv ("SHELL") == NULL)
1748 emacs_abort ();
1749
1750 /* Set dir and shell from environment variables. */ 1745 /* Set dir and shell from environment variables. */
1751 strcpy (dflt_passwd.pw_dir, getenv ("HOME")); 1746 if (w32_unicode_filenames)
1752 strcpy (dflt_passwd.pw_shell, getenv ("SHELL")); 1747 {
1748 wchar_t *home = _wgetenv (L"HOME");
1749 wchar_t *shell = _wgetenv (L"SHELL");
1750
1751 /* Ensure HOME and SHELL are defined. */
1752 if (home == NULL)
1753 emacs_abort ();
1754 if (shell == NULL)
1755 emacs_abort ();
1756 filename_from_utf16 (home, dflt_passwd.pw_dir);
1757 filename_from_utf16 (shell, dflt_passwd.pw_shell);
1758 }
1759 else
1760 {
1761 char *home = getenv ("HOME");
1762 char *shell = getenv ("SHELL");
1763
1764 if (home == NULL)
1765 emacs_abort ();
1766 if (shell == NULL)
1767 emacs_abort ();
1768 filename_from_ansi (home, dflt_passwd.pw_dir);
1769 filename_from_ansi (shell, dflt_passwd.pw_shell);
1770 }
1753 1771
1754 xfree (buf); 1772 xfree (buf);
1755 if (token) 1773 if (token)
@@ -2442,8 +2460,22 @@ init_environment (char ** argv)
2442 /* Remember the initial working directory for getcwd. */ 2460 /* Remember the initial working directory for getcwd. */
2443 /* FIXME: Do we need to resolve possible symlinks in startup_dir? 2461 /* FIXME: Do we need to resolve possible symlinks in startup_dir?
2444 Does it matter anywhere in Emacs? */ 2462 Does it matter anywhere in Emacs? */
2445 if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) 2463 if (w32_unicode_filenames)
2446 emacs_abort (); 2464 {
2465 wchar_t wstartup_dir[MAX_PATH];
2466
2467 if (!GetCurrentDirectoryW (MAX_PATH, wstartup_dir))
2468 emacs_abort ();
2469 filename_from_utf16 (wstartup_dir, startup_dir);
2470 }
2471 else
2472 {
2473 char astartup_dir[MAX_PATH];
2474
2475 if (!GetCurrentDirectoryA (MAX_PATH, astartup_dir))
2476 emacs_abort ();
2477 filename_from_ansi (astartup_dir, startup_dir);
2478 }
2447 2479
2448 { 2480 {
2449 static char modname[MAX_PATH]; 2481 static char modname[MAX_PATH];