summaryrefslogtreecommitdiff
path: root/src/msdos.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-05-01 23:25:33 +0000
committerRichard M. Stallman <rms@gnu.org>1996-05-01 23:25:33 +0000
commit101e2bf30a750b793f76f26cdac8c00314089e31 (patch)
treed14d00ba38cfc1fb978a272a69a30dccb574cbc9 /src/msdos.c
parent8b551ca220803912c94544dbc08873b6dcb8da91 (diff)
downloademacs-101e2bf30a750b793f76f26cdac8c00314089e31.tar.gz
(dos_get_modifiers): Restore missing comment terminator.
(getdefdir): Rewrite to call `_fixpath' instead of `intdos'. (run_msdos_command) [DJGPP > 1]: Work around some MSDOS command-line restrictions by running shell commands via `system' instead of `spawnve'.
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c68
1 files changed, 51 insertions, 17 deletions
diff --git a/src/msdos.c b/src/msdos.c
index e7df9b13f1f..60cd73ae0ca 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -32,8 +32,11 @@ Boston, MA 02111-1307, USA. */
#include <sys/param.h>
#include <sys/time.h>
#include <dos.h>
+#include <errno.h>
+#include <sys/stat.h> /* for _fixpath */
#if __DJGPP__ >= 2
#include <fcntl.h>
+#include <libc/dosio.h> /* for _USE_LFN */
#endif
#include "dosfns.h"
@@ -51,6 +54,10 @@ Boston, MA 02111-1307, USA. */
/* Damn that local process.h! Instead we can define P_WAIT ourselves. */
#define P_WAIT 1
+#ifndef _USE_LFN
+#define _USE_LFN 0
+#endif
+
#if __DJGPP__ > 1
#include <signal.h>
@@ -1316,7 +1323,7 @@ dos_get_modifiers (keymask)
}
}
- if (regs.h.ah & 1) /* Left CTRL pressed
+ if (regs.h.ah & 1) /* Left CTRL pressed ? */
mask |= CTRL_P;
if (regs.h.ah & 4) /* Right CTRL pressed ? */
@@ -2089,23 +2096,31 @@ getdefdir (drive, dst)
int drive;
char *dst;
{
- union REGS regs;
+ char in_path[4], *p = in_path;
+ int e = errno;
- *dst++ = (drive) ? drive + 'A' - 1 : getdisk () + 'A';
- *dst++ = ':'
- *dst++ = '/';
- regs.h.dl = drive;
-#if __DJGPP__ > 1
- /* regs.x.si can be 16 or 32 bits, depending on whether _NAIVE_DOS_REGS
- or _BORLAND_DOS_REGS have or haven't been defined. We should work
- with either, so use regs.d.esi which is always 32 bit-wide. */
- regs.d.esi = (int) dst;
-#else
- regs.x.si = (int) dst;
-#endif
- regs.h.ah = 0x47;
- intdos (&regs, &regs);
- return !regs.x.cflag;
+ /* Generate "X:." (when drive is X) or "." (when drive is 0). */
+ if (drive != 0)
+ {
+ *p++ = drive + 'A' - 1;
+ *p++ = ':';
+ }
+
+ *p++ = '.';
+ *p = '\0';
+ errno = 0;
+ _fixpath (in_path, dst);
+ if (errno)
+ return 0;
+
+ /* Under LFN we expect to get pathnames in their true case. */
+ if (! (_USE_LFN))
+ for (p = dst; *p; p++)
+ if (*p >= 'A' && *p <= 'Z')
+ *p += 'a' - 'A';
+
+ errno = e;
+ return 1;
}
/* Remove all CR's that are followed by a LF. */
@@ -2586,6 +2601,25 @@ run_msdos_command (argv, dir, tempin, tempout, temperr)
dup2 (tempout, 1);
dup2 (temperr, 2);
+#if __DJGPP__ > 1
+
+ if (msshell && !argv[3])
+ {
+ /* MS-DOS native shells are too restrictive. For starters, they
+ cannot grok commands longer than 126 characters. In DJGPP v2
+ and later, `system' is much smarter, so we'll call it instead. */
+
+ extern char **environ;
+ environ = envv;
+
+ /* A shell gets a single argument--its full command
+ line--whose original was saved in `saveargv2'. */
+ result = system (saveargv2);
+ }
+ else
+
+#endif /* __DJGPP__ > 1 */
+
result = spawnve (P_WAIT, argv[0], argv, envv);
dup2 (inbak, 0);