Mercurial > emacs
comparison src/dosfns.c @ 19294:1f8ca0c4836f
(init_dosfns): Avoid calling DOS memory-allocation
service, NT DPMI server will crash Emacs in DOS box, if we do.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 11 Aug 1997 21:42:39 +0000 |
parents | bdc4b7818976 |
children | 674d7beabce0 |
comparison
equal
deleted
inserted
replaced
19293:af78882332ed | 19294:1f8ca0c4836f |
---|---|
1 /* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991. | 1 /* MS-DOS specific Lisp utilities. Coded by Manabu Higashida, 1991. |
2 Major changes May-July 1993 Morten Welinder (only 10% original code left) | 2 Major changes May-July 1993 Morten Welinder (only 10% original code left) |
3 Copyright (C) 1991, 1993 Free Software Foundation, Inc. | 3 Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GNU Emacs. | 5 This file is part of GNU Emacs. |
6 | 6 |
7 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
236 int dos_codepage; | 236 int dos_codepage; |
237 int dos_timezone_offset; | 237 int dos_timezone_offset; |
238 int dos_decimal_point; | 238 int dos_decimal_point; |
239 int dos_keyboard_layout; | 239 int dos_keyboard_layout; |
240 unsigned char dos_country_info[DOS_COUNTRY_INFO]; | 240 unsigned char dos_country_info[DOS_COUNTRY_INFO]; |
241 static unsigned char usa_country_info[DOS_COUNTRY_INFO] = { | |
242 0, 0, /* date format */ | |
243 '$', 0, 0, 0, 0, /* currency string */ | |
244 ',', 0, /* thousands separator */ | |
245 '.', 0, /* decimal separator */ | |
246 '/', 0, /* date separator */ | |
247 ':', 0, /* time separator */ | |
248 0, /* currency format */ | |
249 2, /* digits after decimal in currency */ | |
250 0, /* time format */ | |
251 0, 0, 0, 0, /* address of case map routine, GPF if used */ | |
252 ' ', 0, /* data-list separator (?) */ | |
253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* reserved */ | |
254 }; | |
241 | 255 |
242 int dos_hyper_key; | 256 int dos_hyper_key; |
243 int dos_super_key; | 257 int dos_super_key; |
244 int dos_keypad_mode; | 258 int dos_keypad_mode; |
245 | 259 |
248 | 262 |
249 void | 263 void |
250 init_dosfns () | 264 init_dosfns () |
251 { | 265 { |
252 union REGS regs; | 266 union REGS regs; |
253 _go32_dpmi_seginfo info; | |
254 _go32_dpmi_registers dpmiregs; | 267 _go32_dpmi_registers dpmiregs; |
268 unsigned long xbuf = _go32_info_block.linear_address_of_transfer_buffer; | |
255 | 269 |
256 #ifndef SYSTEM_MALLOC | 270 #ifndef SYSTEM_MALLOC |
257 get_lim_data (); /* why the hell isn't this called elsewhere? */ | 271 get_lim_data (); /* why the hell isn't this called elsewhere? */ |
258 #endif | 272 #endif |
259 | 273 |
260 regs.x.ax = 0x3000; | 274 regs.x.ax = 0x3000; |
261 intdos (®s, ®s); | 275 intdos (®s, ®s); |
262 Vdos_version = Fcons (make_number (regs.h.al), make_number (regs.h.ah)); | 276 Vdos_version = Fcons (make_number (regs.h.al), make_number (regs.h.ah)); |
263 | 277 |
264 /* Obtain the country code by calling Dos via Dpmi. Don't rely on GO32. */ | 278 /* Obtain the country code via DPMI, use DJGPP transfer buffer. */ |
265 info.size = (sizeof(dos_country_info) + 15) / 16; | 279 dpmiregs.x.ax = 0x3800; |
266 if (_go32_dpmi_allocate_dos_memory (&info)) | 280 dpmiregs.x.ds = xbuf; |
267 dos_country_code = 1; | 281 dpmiregs.x.dx = 0; |
282 dpmiregs.x.ss = dpmiregs.x.sp = dpmiregs.x.flags = 0; | |
283 _go32_dpmi_simulate_int (0x21, &dpmiregs); | |
284 if (dpmiregs.x.flags & 1) | |
285 { | |
286 dos_country_code = 1; /* assume USA if 213800 failed */ | |
287 memcpy (dos_country_info, usa_country_info, DOS_COUNTRY_INFO); | |
288 } | |
268 else | 289 else |
269 { | 290 { |
270 dpmiregs.x.ax = 0x3800; | |
271 dpmiregs.x.ds = info.rm_segment; | |
272 dpmiregs.x.dx = 0; | |
273 dpmiregs.x.ss = dpmiregs.x.sp = 0; | |
274 _go32_dpmi_simulate_int (0x21, &dpmiregs); | |
275 dos_country_code = dpmiregs.x.bx; | 291 dos_country_code = dpmiregs.x.bx; |
276 dosmemget (info.rm_segment * 16, DOS_COUNTRY_INFO, dos_country_info); | 292 dosmemget (xbuf, DOS_COUNTRY_INFO, dos_country_info); |
277 _go32_dpmi_free_dos_memory (&info); | 293 } |
278 } | 294 |
279 dos_set_keyboard (dos_country_code, 0); | 295 dos_set_keyboard (dos_country_code, 0); |
280 | 296 |
281 regs.x.ax = 0x6601; | 297 regs.x.ax = 0x6601; |
282 intdos (®s, ®s); | 298 intdos (®s, ®s); |
283 if (regs.x.cflag) | 299 if (regs.x.cflag) |