aboutsummaryrefslogtreecommitdiffstats
path: root/src/msdos.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/msdos.c')
-rw-r--r--src/msdos.c458
1 files changed, 4 insertions, 454 deletions
diff --git a/src/msdos.c b/src/msdos.c
index a413184f966..6cde7cd6ebc 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -39,7 +39,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include <sys/stat.h> /* for _fixpath */ 39#include <sys/stat.h> /* for _fixpath */
40#include <unistd.h> /* for chdir, dup, dup2, etc. */ 40#include <unistd.h> /* for chdir, dup, dup2, etc. */
41#include <dir.h> /* for getdisk */ 41#include <dir.h> /* for getdisk */
42#if __DJGPP__ >= 2
43#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */ 42#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */
44#include <fcntl.h> 43#include <fcntl.h>
45#include <io.h> /* for setmode */ 44#include <io.h> /* for setmode */
@@ -47,7 +46,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47#include <sys/farptr.h> /* for _farsetsel, _farnspokeb */ 46#include <sys/farptr.h> /* for _farsetsel, _farnspokeb */
48#include <libc/dosio.h> /* for _USE_LFN */ 47#include <libc/dosio.h> /* for _USE_LFN */
49#include <conio.h> /* for cputs */ 48#include <conio.h> /* for cputs */
50#endif
51 49
52#include "msdos.h" 50#include "msdos.h"
53#include "systime.h" 51#include "systime.h"
@@ -81,8 +79,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
81#define _dos_ds _go32_info_block.selector_for_linear_memory 79#define _dos_ds _go32_info_block.selector_for_linear_memory
82#endif 80#endif
83 81
84#if __DJGPP__ > 1
85
86#include <signal.h> 82#include <signal.h>
87#include "syssignal.h" 83#include "syssignal.h"
88 84
@@ -104,7 +100,6 @@ int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY);
104#endif /* GNU_MALLOC */ 100#endif /* GNU_MALLOC */
105 101
106#endif /* not SYSTEM_MALLOC */ 102#endif /* not SYSTEM_MALLOC */
107#endif /* __DJGPP__ > 1 */
108 103
109static unsigned long 104static unsigned long
110event_timestamp () 105event_timestamp ()
@@ -427,7 +422,6 @@ extern Lisp_Object Qbar, Qhbar;
427 colors for newly-created frames. */ 422 colors for newly-created frames. */
428static int initial_screen_colors[2]; 423static int initial_screen_colors[2];
429 424
430#if __DJGPP__ > 1
431/* Update the screen from a part of relocated DOS/V screen buffer which 425/* Update the screen from a part of relocated DOS/V screen buffer which
432 begins at OFFSET and includes COUNT characters. */ 426 begins at OFFSET and includes COUNT characters. */
433static void 427static void
@@ -444,7 +438,6 @@ dosv_refresh_virtual_screen (int offset, int count)
444 regs.x.cx = count; 438 regs.x.cx = count;
445 __dpmi_int (0x10, &regs); 439 __dpmi_int (0x10, &regs);
446} 440}
447#endif
448 441
449static void 442static void
450dos_direct_output (y, x, buf, len) 443dos_direct_output (y, x, buf, len)
@@ -456,67 +449,12 @@ dos_direct_output (y, x, buf, len)
456 int t = t0 + (int) ScreenPrimary; 449 int t = t0 + (int) ScreenPrimary;
457 int l0 = len; 450 int l0 = len;
458 451
459#if (__DJGPP__ < 2)
460 while (--len >= 0) {
461 dosmemput (buf++, 1, t);
462 t += 2;
463 }
464#else
465 /* This is faster. */ 452 /* This is faster. */
466 for (_farsetsel (_dos_ds); --len >= 0; t += 2, buf++) 453 for (_farsetsel (_dos_ds); --len >= 0; t += 2, buf++)
467 _farnspokeb (t, *buf); 454 _farnspokeb (t, *buf);
468 455
469 if (screen_virtual_segment) 456 if (screen_virtual_segment)
470 dosv_refresh_virtual_screen (t0, l0); 457 dosv_refresh_virtual_screen (t0, l0);
471#endif
472}
473#endif
474
475/* Flash the screen as a substitute for BEEPs. */
476
477#if (__DJGPP__ < 2)
478static void
479do_visible_bell (xorattr)
480 unsigned char xorattr;
481{
482 asm volatile
483 (" movb $1,%%dl \n\
484visible_bell_0: \n\
485 movl _ScreenPrimary,%%eax \n\
486 call dosmemsetup \n\
487 movl %%eax,%%ebx \n\
488 movl %1,%%ecx \n\
489 movb %0,%%al \n\
490 incl %%ebx \n\
491visible_bell_1: \n\
492 xorb %%al,%%gs:(%%ebx) \n\
493 addl $2,%%ebx \n\
494 decl %%ecx \n\
495 jne visible_bell_1 \n\
496 decb %%dl \n\
497 jne visible_bell_3 \n\
498visible_bell_2: \n\
499 movzwl %%ax,%%eax \n\
500 movzwl %%ax,%%eax \n\
501 movzwl %%ax,%%eax \n\
502 movzwl %%ax,%%eax \n\
503 decw %%cx \n\
504 jne visible_bell_2 \n\
505 jmp visible_bell_0 \n\
506visible_bell_3:"
507 : /* no output */
508 : "m" (xorattr), "g" (screen_size)
509 : "%eax", "%ebx", /* "%gs",*/ "%ecx", "%edx");
510}
511
512static void
513ScreenVisualBell (void)
514{
515 /* This creates an xor-mask that will swap the default fore- and
516 background colors. */
517 do_visible_bell (((FRAME_FOREGROUND_PIXEL (SELECTED_FRAME ())
518 ^ FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()))
519 * 0x11) & 0x7f);
520} 458}
521#endif 459#endif
522 460
@@ -611,9 +549,6 @@ dos_set_window_size (rows, cols)
611 549
612 /* Find one of the dimensions supported by standard EGA/VGA 550 /* Find one of the dimensions supported by standard EGA/VGA
613 which gives us at least the required dimensions. */ 551 which gives us at least the required dimensions. */
614
615#if __DJGPP__ > 1
616
617 else 552 else
618 { 553 {
619 static struct { 554 static struct {
@@ -642,41 +577,6 @@ dos_set_window_size (rows, cols)
642 } 577 }
643 } 578 }
644 579
645#else /* not __DJGPP__ > 1 */
646
647 else if (*rows <= 25)
648 {
649 if (current_rows != 25 || current_cols != 80)
650 {
651 regs.x.ax = 3;
652 int86 (0x10, &regs, &regs);
653 regs.x.ax = 0x1101;
654 regs.h.bl = 0;
655 int86 (0x10, &regs, &regs);
656 regs.x.ax = 0x1200;
657 regs.h.bl = 32;
658 int86 (0x10, &regs, &regs);
659 regs.x.ax = 3;
660 int86 (0x10, &regs, &regs);
661 }
662 }
663 else if (*rows <= 50)
664 if (have_vga && (current_rows != 50 || current_cols != 80)
665 || *rows <= 43 && (current_rows != 43 || current_cols != 80))
666 {
667 regs.x.ax = 3;
668 int86 (0x10, &regs, &regs);
669 regs.x.ax = 0x1112;
670 regs.h.bl = 0;
671 int86 (0x10, &regs, &regs);
672 regs.x.ax = 0x1200;
673 regs.h.bl = 32;
674 int86 (0x10, &regs, &regs);
675 regs.x.ax = 0x0100;
676 regs.x.cx = 7;
677 int86 (0x10, &regs, &regs);
678 }
679#endif /* not __DJGPP__ > 1 */
680 580
681 if (have_mouse) 581 if (have_mouse)
682 { 582 {
@@ -693,7 +593,6 @@ dos_set_window_size (rows, cols)
693 screen_size_Y = *rows; 593 screen_size_Y = *rows;
694 screen_size = *cols * *rows; 594 screen_size = *cols * *rows;
695 595
696#if __DJGPP__ > 1
697 /* If the dimensions changed, the mouse highlight info is invalid. */ 596 /* If the dimensions changed, the mouse highlight info is invalid. */
698 if (current_rows != *rows || current_cols != *cols) 597 if (current_rows != *rows || current_cols != *cols)
699 { 598 {
@@ -708,7 +607,6 @@ dos_set_window_size (rows, cols)
708 dpyinfo->mouse_face_window = Qnil; 607 dpyinfo->mouse_face_window = Qnil;
709 } 608 }
710 } 609 }
711#endif
712 610
713 /* Enable bright background colors. */ 611 /* Enable bright background colors. */
714 bright_bg (); 612 bright_bg ();
@@ -747,7 +645,6 @@ mouse_off_maybe ()
747static void 645static void
748msdos_set_cursor_shape (struct frame *f, int start_line, int width) 646msdos_set_cursor_shape (struct frame *f, int start_line, int width)
749{ 647{
750#if __DJGPP__ > 1
751 unsigned desired_cursor; 648 unsigned desired_cursor;
752 __dpmi_regs regs; 649 __dpmi_regs regs;
753 int max_line, top_line, bot_line; 650 int max_line, top_line, bot_line;
@@ -824,7 +721,6 @@ msdos_set_cursor_shape (struct frame *f, int start_line, int width)
824 regs.h.ah = 1; 721 regs.h.ah = 1;
825 regs.x.cx = desired_cursor; 722 regs.x.cx = desired_cursor;
826 __dpmi_int (0x10, &regs); 723 __dpmi_int (0x10, &regs);
827#endif /* __DJGPP__ > 1 */
828} 724}
829 725
830static void 726static void
@@ -2041,7 +1937,6 @@ IT_set_terminal_modes (struct terminal *term)
2041 startup_screen_size_Y = screen_size_Y; 1937 startup_screen_size_Y = screen_size_Y;
2042 startup_screen_attrib = ScreenAttrib; 1938 startup_screen_attrib = ScreenAttrib;
2043 1939
2044#if __DJGPP__ > 1
2045 /* Is DOS/V (or any other RSIS software which relocates 1940 /* Is DOS/V (or any other RSIS software which relocates
2046 the screen) installed? */ 1941 the screen) installed? */
2047 { 1942 {
@@ -2072,7 +1967,6 @@ IT_set_terminal_modes (struct terminal *term)
2072 ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset; 1967 ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset;
2073 } 1968 }
2074 } 1969 }
2075#endif /* __DJGPP__ > 1 */
2076 1970
2077 ScreenGetCursor (&startup_pos_Y, &startup_pos_X); 1971 ScreenGetCursor (&startup_pos_Y, &startup_pos_X);
2078 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2)); 1972 ScreenRetrieve (startup_screen_buffer = xmalloc (screen_size * 2));
@@ -4068,195 +3962,6 @@ crlf_to_lf (n, buf)
4068 return np - startp; 3962 return np - startp;
4069} 3963}
4070 3964
4071#if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 0
4072
4073/* In DJGPP v2.0, library `write' can call `malloc', which might
4074 cause relocation of the buffer whose address we get in ADDR.
4075 Here is a version of `write' that avoids calling `malloc',
4076 to serve us until such time as the library is fixed.
4077 Actually, what we define here is called `__write', because
4078 `write' is a stub that just jmp's to `__write' (to be
4079 POSIXLY-correct with respect to the global name-space). */
4080
4081#include <io.h> /* for _write */
4082#include <libc/dosio.h> /* for __file_handle_modes[] */
4083
4084static char xbuf[64 * 1024]; /* DOS cannot write more in one chunk */
4085
4086#define XBUF_END (xbuf + sizeof (xbuf) - 1)
4087
4088int
4089__write (int handle, const void *buffer, size_t count)
4090{
4091 if (count == 0)
4092 return 0;
4093
4094 if(__file_handle_modes[handle] & O_BINARY)
4095 return _write (handle, buffer, count);
4096 else
4097 {
4098 char *xbp = xbuf;
4099 const char *bp = buffer;
4100 int total_written = 0;
4101 int nmoved = 0, ncr = 0;
4102
4103 while (count)
4104 {
4105 /* The next test makes sure there's space for at least 2 more
4106 characters in xbuf[], so both CR and LF can be put there. */
4107 if (xbp < XBUF_END)
4108 {
4109 if (*bp == '\n')
4110 {
4111 ncr++;
4112 *xbp++ = '\r';
4113 }
4114 *xbp++ = *bp++;
4115 nmoved++;
4116 count--;
4117 }
4118 if (xbp >= XBUF_END || !count)
4119 {
4120 size_t to_write = nmoved + ncr;
4121 int written = _write (handle, xbuf, to_write);
4122
4123 if (written == -1)
4124 return -1;
4125 else
4126 total_written += nmoved; /* CRs aren't counted in ret value */
4127
4128 /* If some, but not all were written (disk full?), return
4129 an estimate of the total written bytes not counting CRs. */
4130 if (written < to_write)
4131 return total_written - (to_write - written) * nmoved/to_write;
4132
4133 nmoved = 0;
4134 ncr = 0;
4135 xbp = xbuf;
4136 }
4137 }
4138 return total_written;
4139 }
4140}
4141
4142/* A low-level file-renaming function which works around Windows 95 bug.
4143 This is pulled directly out of DJGPP v2.01 library sources, and only
4144 used when you compile with DJGPP v2.0. */
4145
4146#include <io.h>
4147
4148int _rename(const char *old, const char *new)
4149{
4150 __dpmi_regs r;
4151 int olen = strlen(old) + 1;
4152 int i;
4153 int use_lfn = _USE_LFN;
4154 char tempfile[FILENAME_MAX];
4155 const char *orig = old;
4156 int lfn_fd = -1;
4157
4158 r.x.dx = __tb_offset;
4159 r.x.di = __tb_offset + olen;
4160 r.x.ds = r.x.es = __tb_segment;
4161
4162 if (use_lfn)
4163 {
4164 /* Windows 95 bug: for some filenames, when you rename
4165 file -> file~ (as in Emacs, to leave a backup), the
4166 short 8+3 alias doesn't change, which effectively
4167 makes OLD and NEW the same file. We must rename
4168 through a temporary file to work around this. */
4169
4170 char *pbase = 0, *p;
4171 static char try_char[] = "abcdefghijklmnopqrstuvwxyz012345789";
4172 int idx = sizeof(try_char) - 1;
4173
4174 /* Generate a temporary name. Can't use `tmpnam', since $TMPDIR
4175 might point to another drive, which will fail the DOS call. */
4176 strcpy(tempfile, old);
4177 for (p = tempfile; *p; p++) /* ensure temporary is on the same drive */
4178 if (*p == '/' || *p == '\\' || *p == ':')
4179 pbase = p;
4180 if (pbase)
4181 pbase++;
4182 else
4183 pbase = tempfile;
4184 strcpy(pbase, "X$$djren$$.$$temp$$");
4185
4186 do
4187 {
4188 if (idx <= 0)
4189 return -1;
4190 *pbase = try_char[--idx];
4191 } while (_chmod(tempfile, 0) != -1);
4192
4193 r.x.ax = 0x7156;
4194 _put_path2(tempfile, olen);
4195 _put_path(old);
4196 __dpmi_int(0x21, &r);
4197 if (r.x.flags & 1)
4198 {
4199 errno = __doserr_to_errno(r.x.ax);
4200 return -1;
4201 }
4202
4203 /* Now create a file with the original name. This will
4204 ensure that NEW will always have a 8+3 alias
4205 different from that of OLD. (Seems to be required
4206 when NameNumericTail in the Registry is set to 0.) */
4207 lfn_fd = _creat(old, 0);
4208
4209 olen = strlen(tempfile) + 1;
4210 old = tempfile;
4211 r.x.di = __tb_offset + olen;
4212 }
4213
4214 for (i=0; i<2; i++)
4215 {
4216 if(use_lfn)
4217 r.x.ax = 0x7156;
4218 else
4219 r.h.ah = 0x56;
4220 _put_path2(new, olen);
4221 _put_path(old);
4222 __dpmi_int(0x21, &r);
4223 if(r.x.flags & 1)
4224 {
4225 if (r.x.ax == 5 && i == 0) /* access denied */
4226 remove(new); /* and try again */
4227 else
4228 {
4229 errno = __doserr_to_errno(r.x.ax);
4230
4231 /* Restore to original name if we renamed it to temporary. */
4232 if (use_lfn)
4233 {
4234 if (lfn_fd != -1)
4235 {
4236 _close (lfn_fd);
4237 remove (orig);
4238 }
4239 _put_path2(orig, olen);
4240 _put_path(tempfile);
4241 r.x.ax = 0x7156;
4242 __dpmi_int(0x21, &r);
4243 }
4244 return -1;
4245 }
4246 }
4247 else
4248 break;
4249 }
4250
4251 /* Success. Delete the file possibly created to work
4252 around the Windows 95 bug. */
4253 if (lfn_fd != -1)
4254 return (_close (lfn_fd) == 0) ? remove (orig) : -1;
4255 return 0;
4256}
4257
4258#endif /* __DJGPP__ == 2 && __DJGPP_MINOR__ == 0 */
4259
4260DEFUN ("msdos-long-file-names", Fmsdos_long_file_names, Smsdos_long_file_names, 3965DEFUN ("msdos-long-file-names", Fmsdos_long_file_names, Smsdos_long_file_names,
4261 0, 0, 0, 3966 0, 0, 0,
4262 doc: /* Return non-nil if long file names are supported on MS-DOS. */) 3967 doc: /* Return non-nil if long file names are supported on MS-DOS. */)
@@ -4502,39 +4207,6 @@ init_environment (argc, argv, skip_args)
4502static int break_stat; /* BREAK check mode status. */ 4207static int break_stat; /* BREAK check mode status. */
4503static int stdin_stat; /* stdin IOCTL status. */ 4208static int stdin_stat; /* stdin IOCTL status. */
4504 4209
4505#if __DJGPP__ < 2
4506
4507/* These must be global. */
4508static _go32_dpmi_seginfo ctrl_break_vector;
4509static _go32_dpmi_registers ctrl_break_regs;
4510static int ctrlbreakinstalled = 0;
4511
4512/* Interrupt level detection of Ctrl-Break. Don't do anything fancy here! */
4513
4514void
4515ctrl_break_func (regs)
4516 _go32_dpmi_registers *regs;
4517{
4518 Vquit_flag = Qt;
4519}
4520
4521void
4522install_ctrl_break_check ()
4523{
4524 if (!ctrlbreakinstalled)
4525 {
4526 /* Don't press Ctrl-Break if you don't have either DPMI or Emacs
4527 was compiler with Djgpp 1.11 maintenance level 5 or later! */
4528 ctrlbreakinstalled = 1;
4529 ctrl_break_vector.pm_offset = (int) ctrl_break_func;
4530 _go32_dpmi_allocate_real_mode_callback_iret (&ctrl_break_vector,
4531 &ctrl_break_regs);
4532 _go32_dpmi_set_real_mode_interrupt_vector (0x1b, &ctrl_break_vector);
4533 }
4534}
4535
4536#endif /* __DJGPP__ < 2 */
4537
4538/* Turn off Dos' Ctrl-C checking and inhibit interpretation of 4210/* Turn off Dos' Ctrl-C checking and inhibit interpretation of
4539 control chars by DOS. Determine the keyboard type. */ 4211 control chars by DOS. Determine the keyboard type. */
4540 4212
@@ -4551,9 +4223,6 @@ dos_ttraw (struct tty_display_info *tty)
4551 4223
4552 break_stat = getcbrk (); 4224 break_stat = getcbrk ();
4553 setcbrk (0); 4225 setcbrk (0);
4554#if __DJGPP__ < 2
4555 install_ctrl_break_check ();
4556#endif
4557 4226
4558 if (first_time) 4227 if (first_time)
4559 { 4228 {
@@ -4585,42 +4254,18 @@ dos_ttraw (struct tty_display_info *tty)
4585 mouse_button_count = outregs.x.bx; 4254 mouse_button_count = outregs.x.bx;
4586 4255
4587#ifndef HAVE_X_WINDOWS 4256#ifndef HAVE_X_WINDOWS
4588#if __DJGPP__ >= 2
4589 /* Save the cursor shape used outside Emacs. */ 4257 /* Save the cursor shape used outside Emacs. */
4590 outside_cursor = _farpeekw (_dos_ds, 0x460); 4258 outside_cursor = _farpeekw (_dos_ds, 0x460);
4591#endif 4259#endif
4592#endif
4593 } 4260 }
4594 4261
4595 first_time = 0; 4262 first_time = 0;
4596 4263
4597#if __DJGPP__ >= 2
4598
4599 stdin_stat = setmode (fileno (stdin), O_BINARY); 4264 stdin_stat = setmode (fileno (stdin), O_BINARY);
4600 return (stdin_stat != -1); 4265 return (stdin_stat != -1);
4601 } 4266 }
4602 else 4267 else
4603 return (setmode (fileno (stdin), O_BINARY) != -1); 4268 return (setmode (fileno (stdin), O_BINARY) != -1);
4604
4605#else /* __DJGPP__ < 2 */
4606
4607 }
4608
4609 /* I think it is wrong to overwrite `stdin_stat' every time
4610 but the first one this function is called, but I don't
4611 want to change the way it used to work in v1.x.--EZ */
4612
4613 inregs.x.ax = 0x4400; /* Get IOCTL status. */
4614 inregs.x.bx = 0x00; /* 0 = stdin. */
4615 intdos (&inregs, &outregs);
4616 stdin_stat = outregs.h.dl;
4617
4618 inregs.x.dx = stdin_stat | 0x0020; /* raw mode */
4619 inregs.x.ax = 0x4401; /* Set IOCTL status */
4620 intdos (&inregs, &outregs);
4621 return !outregs.x.cflag;
4622
4623#endif /* __DJGPP__ < 2 */
4624} 4269}
4625 4270
4626/* Restore status of standard input and Ctrl-C checking. */ 4271/* Restore status of standard input and Ctrl-C checking. */
@@ -4633,8 +4278,6 @@ dos_ttcooked ()
4633 setcbrk (break_stat); 4278 setcbrk (break_stat);
4634 mouse_off (); 4279 mouse_off ();
4635 4280
4636#if __DJGPP__ >= 2
4637
4638#ifndef HAVE_X_WINDOWS 4281#ifndef HAVE_X_WINDOWS
4639 /* Restore the cursor shape we found on startup. */ 4282 /* Restore the cursor shape we found on startup. */
4640 if (outside_cursor) 4283 if (outside_cursor)
@@ -4646,16 +4289,6 @@ dos_ttcooked ()
4646#endif 4289#endif
4647 4290
4648 return (setmode (fileno (stdin), stdin_stat) != -1); 4291 return (setmode (fileno (stdin), stdin_stat) != -1);
4649
4650#else /* not __DJGPP__ >= 2 */
4651
4652 inregs.x.ax = 0x4401; /* Set IOCTL status. */
4653 inregs.x.bx = 0x00; /* 0 = stdin. */
4654 inregs.x.dx = stdin_stat;
4655 intdos (&inregs, &outregs);
4656 return !outregs.x.cflag;
4657
4658#endif /* not __DJGPP__ >= 2 */
4659} 4292}
4660 4293
4661 4294
@@ -4735,8 +4368,6 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv)
4735 dup2 (tempout, 1); 4368 dup2 (tempout, 1);
4736 dup2 (temperr, 2); 4369 dup2 (temperr, 2);
4737 4370
4738#if __DJGPP__ > 1
4739
4740 if (msshell && !argv[3]) 4371 if (msshell && !argv[3])
4741 { 4372 {
4742 /* MS-DOS native shells are too restrictive. For starters, they 4373 /* MS-DOS native shells are too restrictive. For starters, they
@@ -4777,10 +4408,7 @@ run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv)
4777 result = 0; /* emulate Unixy shell behavior with empty cmd line */ 4408 result = 0; /* emulate Unixy shell behavior with empty cmd line */
4778 } 4409 }
4779 else 4410 else
4780 4411 result = spawnve (P_WAIT, argv[0], argv, envv);
4781#endif /* __DJGPP__ > 1 */
4782
4783 result = spawnve (P_WAIT, argv[0], argv, envv);
4784 4412
4785 dup2 (inbak, 0); 4413 dup2 (inbak, 0);
4786 dup2 (outbak, 1); 4414 dup2 (outbak, 1);
@@ -4822,88 +4450,13 @@ croak (badfunc)
4822 exit (1); 4450 exit (1);
4823} 4451}
4824 4452
4825#if __DJGPP__ < 2
4826
4827/* ------------------------- Compatibility functions -------------------
4828 * gethostname
4829 * gettimeofday
4830 */
4831
4832/* Hostnames for a pc are not really funny,
4833 but they are used in change log so we emulate the best we can. */
4834
4835gethostname (p, size)
4836 char *p;
4837 int size;
4838{
4839 char *q = egetenv ("HOSTNAME");
4840
4841 if (!q) q = "pc";
4842 strcpy (p, q);
4843 return 0;
4844}
4845
4846/* When time zones are set from Ms-Dos too many C-libraries are playing
4847 tricks with time values. We solve this by defining our own version
4848 of `gettimeofday' bypassing GO32. Our version needs to be initialized
4849 once and after each call to `tzset' with TZ changed. That is
4850 accomplished by aliasing tzset to init_gettimeofday. */
4851
4852static struct tm time_rec;
4853
4854int
4855gettimeofday (struct timeval *tp, struct timezone *tzp)
4856{
4857 if (tp)
4858 {
4859 struct time t;
4860 struct tm tm;
4861
4862 gettime (&t);
4863 if (t.ti_hour < time_rec.tm_hour) /* midnight wrap */
4864 {
4865 struct date d;
4866 getdate (&d);
4867 time_rec.tm_year = d.da_year - 1900;
4868 time_rec.tm_mon = d.da_mon - 1;
4869 time_rec.tm_mday = d.da_day;
4870 }
4871
4872 time_rec.tm_hour = t.ti_hour;
4873 time_rec.tm_min = t.ti_min;
4874 time_rec.tm_sec = t.ti_sec;
4875
4876 tm = time_rec;
4877 tm.tm_gmtoff = dos_timezone_offset;
4878
4879 tp->tv_sec = mktime (&tm); /* may modify tm */
4880 tp->tv_usec = t.ti_hund * (1000000 / 100);
4881 }
4882 /* Ignore tzp; it's obsolescent. */
4883 return 0;
4884}
4885
4886#endif /* __DJGPP__ < 2 */
4887
4888/* 4453/*
4889 * A list of unimplemented functions that we silently ignore. 4454 * A few unimplemented functions that we silently ignore.
4890 */ 4455 */
4891
4892#if __DJGPP__ < 2
4893unsigned alarm (s) unsigned s; {}
4894fork () { return 0; }
4895int kill (x, y) int x, y; { return -1; }
4896nice (p) int p; {}
4897void volatile pause () {}
4898sigsetmask (x) int x; { return 0; }
4899sigblock (mask) int mask; { return 0; }
4900#endif
4901
4902setpgrp () {return 0; } 4456setpgrp () {return 0; }
4903setpriority (x,y,z) int x,y,z; { return 0; } 4457setpriority (x,y,z) int x,y,z; { return 0; }
4904 4458
4905#if __DJGPP__ > 1 4459#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
4906#if __DJGPP_MINOR__ < 2
4907 4460
4908#ifdef POSIX_SIGNALS 4461#ifdef POSIX_SIGNALS
4909 4462
@@ -5011,7 +4564,6 @@ sigblock (mask) int mask; { return 0; }
5011 4564
5012#endif /* not POSIX_SIGNALS */ 4565#endif /* not POSIX_SIGNALS */
5013#endif /* not __DJGPP_MINOR__ < 2 */ 4566#endif /* not __DJGPP_MINOR__ < 2 */
5014#endif /* __DJGPP__ > 1 */
5015 4567
5016#ifndef HAVE_SELECT 4568#ifndef HAVE_SELECT
5017#include "sysselect.h" 4569#include "sysselect.h"
@@ -5194,7 +4746,6 @@ abort ()
5194 dos_ttcooked (); 4746 dos_ttcooked ();
5195 ScreenSetCursor (10, 0); 4747 ScreenSetCursor (10, 0);
5196 cputs ("\r\n\nEmacs aborted!\r\n"); 4748 cputs ("\r\n\nEmacs aborted!\r\n");
5197#if __DJGPP__ > 1
5198#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 4749#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
5199 if (screen_virtual_segment) 4750 if (screen_virtual_segment)
5200 dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X); 4751 dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X);
@@ -5204,7 +4755,6 @@ abort ()
5204#else /* __DJGPP_MINOR__ >= 2 */ 4755#else /* __DJGPP_MINOR__ >= 2 */
5205 raise (SIGABRT); 4756 raise (SIGABRT);
5206#endif /* __DJGPP_MINOR__ >= 2 */ 4757#endif /* __DJGPP_MINOR__ >= 2 */
5207#endif
5208 exit (2); 4758 exit (2);
5209} 4759}
5210#endif 4760#endif