Mercurial > emacs
comparison src/msdos.c @ 15125:4dc406e38d68
(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'.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 01 May 1996 23:25:33 +0000 |
parents | c62cd2650ced |
children | 08937f70419e |
comparison
equal
deleted
inserted
replaced
15124:b2c682fcd3ef | 15125:4dc406e38d68 |
---|---|
30 #include <stdio.h> | 30 #include <stdio.h> |
31 #include <stdlib.h> | 31 #include <stdlib.h> |
32 #include <sys/param.h> | 32 #include <sys/param.h> |
33 #include <sys/time.h> | 33 #include <sys/time.h> |
34 #include <dos.h> | 34 #include <dos.h> |
35 #include <errno.h> | |
36 #include <sys/stat.h> /* for _fixpath */ | |
35 #if __DJGPP__ >= 2 | 37 #if __DJGPP__ >= 2 |
36 #include <fcntl.h> | 38 #include <fcntl.h> |
39 #include <libc/dosio.h> /* for _USE_LFN */ | |
37 #endif | 40 #endif |
38 | 41 |
39 #include "dosfns.h" | 42 #include "dosfns.h" |
40 #include "msdos.h" | 43 #include "msdos.h" |
41 #include "systime.h" | 44 #include "systime.h" |
48 #include <pc.h> | 51 #include <pc.h> |
49 #include <ctype.h> | 52 #include <ctype.h> |
50 /* #include <process.h> */ | 53 /* #include <process.h> */ |
51 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ | 54 /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ |
52 #define P_WAIT 1 | 55 #define P_WAIT 1 |
56 | |
57 #ifndef _USE_LFN | |
58 #define _USE_LFN 0 | |
59 #endif | |
53 | 60 |
54 #if __DJGPP__ > 1 | 61 #if __DJGPP__ > 1 |
55 | 62 |
56 #include <signal.h> | 63 #include <signal.h> |
57 | 64 |
1314 mask |= SUPER_P; | 1321 mask |= SUPER_P; |
1315 modifiers |= super_modifier; | 1322 modifiers |= super_modifier; |
1316 } | 1323 } |
1317 } | 1324 } |
1318 | 1325 |
1319 if (regs.h.ah & 1) /* Left CTRL pressed | 1326 if (regs.h.ah & 1) /* Left CTRL pressed ? */ |
1320 mask |= CTRL_P; | 1327 mask |= CTRL_P; |
1321 | 1328 |
1322 if (regs.h.ah & 4) /* Right CTRL pressed ? */ | 1329 if (regs.h.ah & 4) /* Right CTRL pressed ? */ |
1323 { | 1330 { |
1324 if (dos_hyper_key == 2) | 1331 if (dos_hyper_key == 2) |
2087 int | 2094 int |
2088 getdefdir (drive, dst) | 2095 getdefdir (drive, dst) |
2089 int drive; | 2096 int drive; |
2090 char *dst; | 2097 char *dst; |
2091 { | 2098 { |
2092 union REGS regs; | 2099 char in_path[4], *p = in_path; |
2093 | 2100 int e = errno; |
2094 *dst++ = (drive) ? drive + 'A' - 1 : getdisk () + 'A'; | 2101 |
2095 *dst++ = ':' | 2102 /* Generate "X:." (when drive is X) or "." (when drive is 0). */ |
2096 *dst++ = '/'; | 2103 if (drive != 0) |
2097 regs.h.dl = drive; | 2104 { |
2098 #if __DJGPP__ > 1 | 2105 *p++ = drive + 'A' - 1; |
2099 /* regs.x.si can be 16 or 32 bits, depending on whether _NAIVE_DOS_REGS | 2106 *p++ = ':'; |
2100 or _BORLAND_DOS_REGS have or haven't been defined. We should work | 2107 } |
2101 with either, so use regs.d.esi which is always 32 bit-wide. */ | 2108 |
2102 regs.d.esi = (int) dst; | 2109 *p++ = '.'; |
2103 #else | 2110 *p = '\0'; |
2104 regs.x.si = (int) dst; | 2111 errno = 0; |
2105 #endif | 2112 _fixpath (in_path, dst); |
2106 regs.h.ah = 0x47; | 2113 if (errno) |
2107 intdos (®s, ®s); | 2114 return 0; |
2108 return !regs.x.cflag; | 2115 |
2116 /* Under LFN we expect to get pathnames in their true case. */ | |
2117 if (! (_USE_LFN)) | |
2118 for (p = dst; *p; p++) | |
2119 if (*p >= 'A' && *p <= 'Z') | |
2120 *p += 'a' - 'A'; | |
2121 | |
2122 errno = e; | |
2123 return 1; | |
2109 } | 2124 } |
2110 | 2125 |
2111 /* Remove all CR's that are followed by a LF. */ | 2126 /* Remove all CR's that are followed by a LF. */ |
2112 | 2127 |
2113 int | 2128 int |
2584 | 2599 |
2585 dup2 (tempin, 0); | 2600 dup2 (tempin, 0); |
2586 dup2 (tempout, 1); | 2601 dup2 (tempout, 1); |
2587 dup2 (temperr, 2); | 2602 dup2 (temperr, 2); |
2588 | 2603 |
2604 #if __DJGPP__ > 1 | |
2605 | |
2606 if (msshell && !argv[3]) | |
2607 { | |
2608 /* MS-DOS native shells are too restrictive. For starters, they | |
2609 cannot grok commands longer than 126 characters. In DJGPP v2 | |
2610 and later, `system' is much smarter, so we'll call it instead. */ | |
2611 | |
2612 extern char **environ; | |
2613 environ = envv; | |
2614 | |
2615 /* A shell gets a single argument--its full command | |
2616 line--whose original was saved in `saveargv2'. */ | |
2617 result = system (saveargv2); | |
2618 } | |
2619 else | |
2620 | |
2621 #endif /* __DJGPP__ > 1 */ | |
2622 | |
2589 result = spawnve (P_WAIT, argv[0], argv, envv); | 2623 result = spawnve (P_WAIT, argv[0], argv, envv); |
2590 | 2624 |
2591 dup2 (inbak, 0); | 2625 dup2 (inbak, 0); |
2592 dup2 (outbak, 1); | 2626 dup2 (outbak, 1); |
2593 dup2 (errbak, 2); | 2627 dup2 (errbak, 2); |