diff options
Diffstat (limited to 'src/msdos.c')
| -rw-r--r-- | src/msdos.c | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/src/msdos.c b/src/msdos.c index 5507416210d..eefd48ee564 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -32,6 +32,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 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 | #if __DJGPP__ >= 2 | ||
| 36 | #include <fcntl.h> | ||
| 37 | #endif | ||
| 38 | |||
| 35 | #include "dosfns.h" | 39 | #include "dosfns.h" |
| 36 | #include "msdos.h" | 40 | #include "msdos.h" |
| 37 | #include "systime.h" | 41 | #include "systime.h" |
| @@ -47,6 +51,27 @@ Boston, MA 02111-1307, USA. */ | |||
| 47 | /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ | 51 | /* Damn that local process.h! Instead we can define P_WAIT ourselves. */ |
| 48 | #define P_WAIT 1 | 52 | #define P_WAIT 1 |
| 49 | 53 | ||
| 54 | #if __DJGPP__ > 1 | ||
| 55 | |||
| 56 | #ifndef SYSTEM_MALLOC | ||
| 57 | |||
| 58 | #ifdef GNU_MALLOC | ||
| 59 | |||
| 60 | /* If other `malloc' than ours is used, force our `sbrk' behave like | ||
| 61 | Unix programs expect (resize memory blocks to keep them contiguous). | ||
| 62 | If `sbrk' from `ralloc.c' is NOT used, also zero-out sbrk'ed memory, | ||
| 63 | because that's what `gmalloc' expects to get. */ | ||
| 64 | #include <crt0.h> | ||
| 65 | |||
| 66 | #ifdef REL_ALLOC | ||
| 67 | int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK; | ||
| 68 | #else /* not REL_ALLOC */ | ||
| 69 | int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY); | ||
| 70 | #endif /* not REL_ALLOC */ | ||
| 71 | #endif /* GNU_MALLOC */ | ||
| 72 | |||
| 73 | #endif /* not SYSTEM_MALLOC */ | ||
| 74 | #endif /* __DJGPP__ > 1 */ | ||
| 50 | 75 | ||
| 51 | static unsigned long | 76 | static unsigned long |
| 52 | event_timestamp () | 77 | event_timestamp () |
| @@ -862,8 +887,13 @@ internal_terminal_init () | |||
| 862 | colors = getenv ("EMACSCOLORS"); | 887 | colors = getenv ("EMACSCOLORS"); |
| 863 | if (colors && strlen (colors) >= 2) | 888 | if (colors && strlen (colors) >= 2) |
| 864 | { | 889 | { |
| 865 | the_only_x_display.foreground_pixel = colors[0] & 0x07; | 890 | /* Foreground colrs use 4 bits, background only 3. */ |
| 866 | the_only_x_display.background_pixel = colors[1] & 0x07; | 891 | if (isxdigit (colors[0]) && !isdigit (colors[0])) |
| 892 | colors[0] += 10 - (isupper (colors[0]) ? 'A' : 'a'); | ||
| 893 | if (colors[0] >= 0 && colors[0] < 16) | ||
| 894 | the_only_x_display.foreground_pixel = colors[0]; | ||
| 895 | if (colors[1] >= 0 && colors[1] < 8) | ||
| 896 | the_only_x_display.background_pixel = colors[1]; | ||
| 867 | } | 897 | } |
| 868 | the_only_x_display.line_height = 1; | 898 | the_only_x_display.line_height = 1; |
| 869 | the_only_frame.output_data.x = &the_only_x_display; | 899 | the_only_frame.output_data.x = &the_only_x_display; |
| @@ -2226,7 +2256,7 @@ init_environment (argc, argv, skip_args) | |||
| 2226 | setenv ("TZ", "IST-02IDT-03,M4.1.6/00:00,M9.5.6/01:00", 0); | 2256 | setenv ("TZ", "IST-02IDT-03,M4.1.6/00:00,M9.5.6/01:00", 0); |
| 2227 | break; | 2257 | break; |
| 2228 | } | 2258 | } |
| 2229 | init_gettimeofday (); | 2259 | tzset (); |
| 2230 | } | 2260 | } |
| 2231 | 2261 | ||
| 2232 | 2262 | ||
| @@ -2234,6 +2264,8 @@ init_environment (argc, argv, skip_args) | |||
| 2234 | static int break_stat; /* BREAK check mode status. */ | 2264 | static int break_stat; /* BREAK check mode status. */ |
| 2235 | static int stdin_stat; /* stdin IOCTL status. */ | 2265 | static int stdin_stat; /* stdin IOCTL status. */ |
| 2236 | 2266 | ||
| 2267 | #if __DJGPP__ < 2 | ||
| 2268 | |||
| 2237 | /* These must be global. */ | 2269 | /* These must be global. */ |
| 2238 | static _go32_dpmi_seginfo ctrl_break_vector; | 2270 | static _go32_dpmi_seginfo ctrl_break_vector; |
| 2239 | static _go32_dpmi_registers ctrl_break_regs; | 2271 | static _go32_dpmi_registers ctrl_break_regs; |
| @@ -2263,6 +2295,8 @@ install_ctrl_break_check () | |||
| 2263 | } | 2295 | } |
| 2264 | } | 2296 | } |
| 2265 | 2297 | ||
| 2298 | #endif /* __DJGPP__ < 2 */ | ||
| 2299 | |||
| 2266 | /* Turn off Dos' Ctrl-C checking and inhibit interpretation of | 2300 | /* Turn off Dos' Ctrl-C checking and inhibit interpretation of |
| 2267 | control chars by DOS. Determine the keyboard type. */ | 2301 | control chars by DOS. Determine the keyboard type. */ |
| 2268 | 2302 | ||
| @@ -2274,7 +2308,9 @@ dos_ttraw () | |||
| 2274 | 2308 | ||
| 2275 | break_stat = getcbrk (); | 2309 | break_stat = getcbrk (); |
| 2276 | setcbrk (0); | 2310 | setcbrk (0); |
| 2311 | #if __DJGPP__ < 2 | ||
| 2277 | install_ctrl_break_check (); | 2312 | install_ctrl_break_check (); |
| 2313 | #endif | ||
| 2278 | 2314 | ||
| 2279 | if (first_time) | 2315 | if (first_time) |
| 2280 | { | 2316 | { |
| @@ -2325,10 +2361,25 @@ dos_ttraw () | |||
| 2325 | mouse_init (); | 2361 | mouse_init (); |
| 2326 | } | 2362 | } |
| 2327 | } | 2363 | } |
| 2328 | 2364 | ||
| 2329 | first_time = 0; | 2365 | first_time = 0; |
| 2366 | |||
| 2367 | #if __DJGPP__ >= 2 | ||
| 2368 | |||
| 2369 | stdin_stat = setmode (fileno (stdin), O_BINARY); | ||
| 2370 | return (stdin_stat != -1); | ||
| 2371 | } | ||
| 2372 | else | ||
| 2373 | return (setmode (fileno (stdin), O_BINARY) != -1); | ||
| 2374 | |||
| 2375 | #else /* __DJGPP__ < 2 */ | ||
| 2376 | |||
| 2330 | } | 2377 | } |
| 2331 | 2378 | ||
| 2379 | /* I think it is wrong to overwrite `stdin_stat' every time | ||
| 2380 | but the first one this function is called, but I don't | ||
| 2381 | want to change the way it used to work in v1.x.--EZ */ | ||
| 2382 | |||
| 2332 | inregs.x.ax = 0x4400; /* Get IOCTL status. */ | 2383 | inregs.x.ax = 0x4400; /* Get IOCTL status. */ |
| 2333 | inregs.x.bx = 0x00; /* 0 = stdin. */ | 2384 | inregs.x.bx = 0x00; /* 0 = stdin. */ |
| 2334 | intdos (&inregs, &outregs); | 2385 | intdos (&inregs, &outregs); |
| @@ -2338,6 +2389,8 @@ dos_ttraw () | |||
| 2338 | inregs.x.ax = 0x4401; /* Set IOCTL status */ | 2389 | inregs.x.ax = 0x4401; /* Set IOCTL status */ |
| 2339 | intdos (&inregs, &outregs); | 2390 | intdos (&inregs, &outregs); |
| 2340 | return !outregs.x.cflag; | 2391 | return !outregs.x.cflag; |
| 2392 | |||
| 2393 | #endif /* __DJGPP__ < 2 */ | ||
| 2341 | } | 2394 | } |
| 2342 | 2395 | ||
| 2343 | /* Restore status of standard input and Ctrl-C checking. */ | 2396 | /* Restore status of standard input and Ctrl-C checking. */ |
| @@ -2350,11 +2403,19 @@ dos_ttcooked () | |||
| 2350 | setcbrk (break_stat); | 2403 | setcbrk (break_stat); |
| 2351 | mouse_off (); | 2404 | mouse_off (); |
| 2352 | 2405 | ||
| 2406 | #if __DJGPP__ >= 2 | ||
| 2407 | |||
| 2408 | return (setmode (fileno (stdin), stdin_stat) != -1); | ||
| 2409 | |||
| 2410 | #else /* not __DJGPP__ >= 2 */ | ||
| 2411 | |||
| 2353 | inregs.x.ax = 0x4401; /* Set IOCTL status. */ | 2412 | inregs.x.ax = 0x4401; /* Set IOCTL status. */ |
| 2354 | inregs.x.bx = 0x00; /* 0 = stdin. */ | 2413 | inregs.x.bx = 0x00; /* 0 = stdin. */ |
| 2355 | inregs.x.dx = stdin_stat; | 2414 | inregs.x.dx = stdin_stat; |
| 2356 | intdos (&inregs, &outregs); | 2415 | intdos (&inregs, &outregs); |
| 2357 | return !outregs.x.cflag; | 2416 | return !outregs.x.cflag; |
| 2417 | |||
| 2418 | #endif /* not __DJGPP__ >= 2 */ | ||
| 2358 | } | 2419 | } |
| 2359 | 2420 | ||
| 2360 | 2421 | ||
| @@ -2473,6 +2534,8 @@ croak (badfunc) | |||
| 2473 | exit (1); | 2534 | exit (1); |
| 2474 | } | 2535 | } |
| 2475 | 2536 | ||
| 2537 | #if __DJGPP__ < 2 | ||
| 2538 | |||
| 2476 | /* ------------------------- Compatibility functions ------------------- | 2539 | /* ------------------------- Compatibility functions ------------------- |
| 2477 | * gethostname | 2540 | * gethostname |
| 2478 | * gettimeofday | 2541 | * gettimeofday |
| @@ -2532,20 +2595,24 @@ gettimeofday (struct timeval *tp, struct timezone *tzp) | |||
| 2532 | return 0; | 2595 | return 0; |
| 2533 | } | 2596 | } |
| 2534 | 2597 | ||
| 2598 | #endif /* __DJGPP__ < 2 */ | ||
| 2535 | 2599 | ||
| 2536 | /* | 2600 | /* |
| 2537 | * A list of unimplemented functions that we silently ignore. | 2601 | * A list of unimplemented functions that we silently ignore. |
| 2538 | */ | 2602 | */ |
| 2539 | 2603 | ||
| 2604 | #if __DJGPP__ < 2 | ||
| 2540 | unsigned alarm (s) unsigned s; {} | 2605 | unsigned alarm (s) unsigned s; {} |
| 2541 | fork () { return 0; } | 2606 | fork () { return 0; } |
| 2542 | int kill (x, y) int x, y; { return -1; } | 2607 | int kill (x, y) int x, y; { return -1; } |
| 2543 | nice (p) int p; {} | 2608 | nice (p) int p; {} |
| 2544 | void volatile pause () {} | 2609 | void volatile pause () {} |
| 2610 | sigsetmask (x) int x; { return 0; } | ||
| 2611 | #endif | ||
| 2612 | |||
| 2545 | request_sigio () {} | 2613 | request_sigio () {} |
| 2546 | setpgrp () {return 0; } | 2614 | setpgrp () {return 0; } |
| 2547 | setpriority (x,y,z) int x,y,z; { return 0; } | 2615 | setpriority (x,y,z) int x,y,z; { return 0; } |
| 2548 | sigsetmask (x) int x; { return 0; } | ||
| 2549 | sigblock (mask) int mask; { return 0; } | 2616 | sigblock (mask) int mask; { return 0; } |
| 2550 | unrequest_sigio () {} | 2617 | unrequest_sigio () {} |
| 2551 | 2618 | ||