comparison src/emacs.c @ 2367:ecf1ebac70d8

[xemacs-hg @ 2004-11-04 23:05:23 by ben] commit mega-patch configure.in: Turn off -Winline and -Wchar-subscripts. Use the right set of cflags when compiling modules. Rewrite ldap configuration to separate the inclusion of lber (needed in recent Cygwin) from the basic checks for the needed libraries. add a function for MAKE_JUNK_C; initially code was added to generate xemacs.def using this, but it will need to be rewritten. add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto an existing file. Sort list of auto-detected functions and eliminate unused checks for stpcpy, setlocale and getwd. Add autodetection of Cygwin scanf problems BETA: Rewrite section on configure to indicate what flags are important and what not. digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main(). make-msgfile.c: Document that this is old junk. Move proposal to text.c. make-msgfile.lex: Move proposal to text.c. make-mswin-unicode.pl: Convert error-generating code so that the entire message will be seen as a single unrecognized token. mule/mule-ccl.el: Update docs. lispref/mule.texi: Update CCL docs. ldap/eldap.c: Mule-ize. Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP. * XEmacs 21.5.18 "chestnut" is released. --------------------------------------------------------------- MULE-RELATED WORK: --------------------------------------------------------------- --------------------------- byte-char conversion --------------------------- buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken previous version. Track the char position of the gap. Add functions to do char-byte conversion downwards as well as upwards. Move comments about algorithm workings to internals manual. --------------------------- work on types --------------------------- alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all the basic semantics of `char' that I have so far identified, so that its semantics can always be identified for the purposes of proper Mule-safe code, and the raw use of `char' always avoided. (1) More type renaming, for consistency of naming. Char_ASCII -> Ascbyte UChar_ASCII -> UAscbyte Char_Binary -> CBinbyte UChar_Binary -> Binbyte SChar_Binary -> SBinbyte (2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and Bitbyte and use them. (3) New types Itext, Wexttext and Textcount for separating out the concepts of bytes and textual units (different under UTF-16 and UTF-32, which are potential internal encodings). (4) qxestr*_c -> qxestr*_ascii. lisp.h: New; goes with other qxe() functions. #### Maybe goes in a different section. lisp.h: Group generic int-type defs together with EMACS_INT defs. lisp.h: * lisp.h (WEXTTEXT_IS_WIDE) New defns. lisp.h: New type to replace places where int occurs as a boolean. It's signed because occasionally people may want to use -1 as an error value, and because unsigned ints are viral -- see comments in the internals manual against using them. dynarr.c: int -> Bytecount. --------------------------- Mule-izing --------------------------- device-x.c: Partially Mule-ize. dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*(). sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be Unicode (e.g. startup code under Windows). emacs.c: Mule-ize. Properly deal with argv in external encoding. Use wext_*() and Wexttext. Use Rawbyte. #if 0 some old junk on SCO that is unlikely to be correct. Rewrite allocation code in run-temacs. emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to initialize mswindows_9x_p even earlier, for use in startup code (XEUNICODE_P). process.c: Use _wenviron not environ under Windows, to get Unicode environment variables. event-Xt.c: Mule-ize drag-n-drop related stuff. dragdrop.c, dragdrop.h, frame-x.c: Mule-ize. text.h: Add some more stand-in defines for particular kinds of conversion; use in Mule-ization work in frame-x.c etc. --------------------------- Freshening --------------------------- intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate. --------------------------- Unicode-work --------------------------- intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc() and convert_unicode_to_multibyte_dynarr() and use. Add stuff for alloca() conversion of multibyte/unicode. alloc.c: Use dfc_external_data_len() in case of unicode coding system. alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up dump-time loading. Anyway, either we load them at dump time or run time, never both. unicode.c: Dump the blank tables as well. --------------------------------------------------------------- DOCUMENTATION, MOSTLY MULE-RELATED: --------------------------------------------------------------- EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed. text.h: Add more documentation describing why DFC routines were not written to return their value. Add some other DFC documentation. console-msw.c, console-msw.h: Add pointer to docs in win32.c. emacs.c: Add comments on sources of doc info. text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and internationalization, and proposals for work to be done, in text.c or Internals manual, stuff related to specific textual API's in text.h, and stuff related to internal implementation of Unicode conversion in unicode.c. Put lots of pointers to the comments to make them easier to find. s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of builds and environments under Windows and how they work. Collect this info in win32.c. Add pointers to these docs in the relevant s/* files. emacs.c: Document places with long comments. Remove comment about exiting, move to internals manual, put in pointer. event-stream.c: Move docs about event queues and focus to internals manual, put in pointer. events.h: Move docs about event stream callbacks to internals manual, put in pointer. profile.c, redisplay.c, signal.c: Move documentation to the Internals manual. process-nt.c: Add pointer to comment in win32-native.el. lisp.h: Add comments about some comment conventions. lisp.h: Add comment about the second argument. device-msw.c, redisplay-msw.c: @@#### comments are out-of-date. --------------------------------------------------------------- PDUMP WORK (MOTIVATED BY UNICODE CHANGES) --------------------------------------------------------------- alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP: Properly implement dump_add_root_block(), which never worked before, and is necessary for dumping Unicode tables. Pdump name changes for accuracy: XD_STRUCT_PTR -> XD_BLOCK_PTR. XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY. XD_C_STRING -> XD_ASCII_STRING. *_structure_* -> *_block_*. lrecord.h: some comments added about dump_add_root_block() vs dump_add_root_block_ptr(). extents.c: remove incorrect comment about pdump problems with gap array. --------------------------------------------------------------- ALLOCATION --------------------------------------------------------------- abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for more convenient allocation of these commonly requested items. Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes, xnew_ibytes, etc. also XREALLOC_ARRAY, xnew. alloc.c: Rewrite the allocation functions to factor out repeated code. Add assertions for freeing dumped data. lisp.h: Moved down and consolidated with other allocation stuff. lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in LIFO order. lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs. text.h, lisp.h: Fill out convenience routines for allocating various kinds of bytes and put them in lisp.h. Use them in place of xmalloc(), ALLOCA(). text.h: Fill out the convenience functions so the _MALLOC() kinds match the alloca() kinds. --------------------------------------------------------------- ERROR-CHECKING --------------------------------------------------------------- text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN() from similar Eistring checkers and change the Eistring checkers to use them instead. --------------------------------------------------------------- MACROS IN LISP.H --------------------------------------------------------------- lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can be used to generate any kind of gcpro sets -- regular, ngcpro, nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2. buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities. Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3 or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2 (new macro). Removed/redid comments on EXTERNAL_LIST_LOOP. --------------------------------------------------------------- SPACING FIXES --------------------------------------------------------------- callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes. --------------------------------------------------------------- FIX FOR GEOMETRY PROBLEM IN FIRST FRAME --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows. will be overridden by my other ws. --------------------------------------------------------------- FIX FOR LEAKING PROCESS HANDLES: --------------------------------------------------------------- process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner <adrian@xemacs.org>. --------------------------------------------------------------- FIX FOR CYGWIN BUG (Unicode-related): --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. --------------------------------------------------------------- WARNING FIXES: --------------------------------------------------------------- console-stream.c: `reinit' is unused. compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got. regex.c: Gather includes together to avoid warning. --------------------------------------------------------------- CHANGES TO INITIALIZATION ROUTINES: --------------------------------------------------------------- buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity. Factor out some redundant init code. Move disallowed stuff that had crept into vars_of_glyphs() into complex_vars_of_glyphs(). Call init_eval_semi_early() from eval.c not in the middle of vars_of_() in emacs.c since there should be no order dependency in the latter calls. --------------------------------------------------------------- ARMAGEDDON: --------------------------------------------------------------- alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to inhibit_non_essential_conversion_operations. text.c: Assert on !inhibit_non_essential_conversion_operations. console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT in places where problems would arise. --------------------------------------------------------------- CHANGES TO THE BUILD PROCEDURE: --------------------------------------------------------------- config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file. Rearrange everything to follow this -- put all #undefs together and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA, BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE. m/gec63.h: Deleted; totally broken, not used at all, not in FSF. m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION, BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected. When in doubt, I followed recent FSF sources, which also have these things deleted.
author ben
date Thu, 04 Nov 2004 23:08:28 +0000
parents 04bc9d2f42c7
children 3d8143fc88e1
comparison
equal deleted inserted replaced
2366:2a392e0c390a 2367:ecf1ebac70d8
1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms. 1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms.
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994 2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 2000, 2001, 2002, 2003 Ben Wing. 5 Copyright (C) 2000, 2001, 2002, 2003, 2004 Ben Wing.
6 6
7 This file is part of XEmacs. 7 This file is part of XEmacs.
8 8
9 XEmacs is free software; you can redistribute it and/or modify it 9 XEmacs is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
20 along with XEmacs; see the file COPYING. If not, write to 20 along with XEmacs; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */ 22 Boston, MA 02111-1307, USA. */
23 23
24 /* Synched up with: Mule 2.0, FSF 19.28. */ 24 /* Synched up with: Mule 2.0, FSF 19.28. */
25
26 /* This file has been Mule-ized, Ben Wing, 10-7-04. */
25 27
26 /* Capsule summary of the various releases of Lucid Emacs/XEmacs and 28 /* Capsule summary of the various releases of Lucid Emacs/XEmacs and
27 FSF/GNU Emacs. (Copied from the Internals Manual, where the 29 FSF/GNU Emacs. (Copied from the Internals Manual, where the
28 canonical version lives.) Provided here for use in cross-referencing 30 canonical version lives.) Provided here for use in cross-referencing
29 version releases and dates in comments, esp. in the authorship 31 version releases and dates in comments, esp. in the authorship
232 version 18.58 released ?????. 234 version 18.58 released ?????.
233 version 18.59 released October 31, 1992. 235 version 18.59 released October 31, 1992.
234 236
235 */ 237 */
236 238
239 /* Sources for further information:
240
241 -----------------------------------
242 1. Using XEmacs, Programming Elisp:
243 -----------------------------------
244
245 ;;; -- the XEmacs User's Manual (Access using the online Info browser:
246 ;;; Use `Help->Info (Online Docs)->XEmacs User's Manual' (if
247 ;;; there is such an entry); or get to the Info contents page
248 ;;; using `Help->Info Contents' or `C-h i', and then
249 ;;; *middle-click* the XEmacs link or move the cursor into the
250 ;;; link and hit ENTER. This manual contains a great deal of
251 ;;; documentation on customization: Scroll down to the
252 ;;; Customization link and select it in the same fashion as for
253 ;;; the XEmacs link just mentioned.)
254
255 ;;; -- the XEmacs FAQ (`C-h F' for the local version; get either the
256 ;;; local version or the very latest version off the net using
257 ;;; the Help menu)
258
259 ;;; -- the XEmacs Lisp Reference Manual, containing detailed
260 ;;; documentation on Elisp. (Access using Info, just like for the
261 ;;; XEmacs User's Manual.)
262
263 ;;; -- the documentation strings for specific commands, functions,
264 ;;; key sequences, and variables. NOTE: This is *not* the same
265 ;;; information as in the XEmacs User's Manual or XEmacs Lisp
266 ;;; Reference Manual! In general, the doc strings are more
267 ;;; terse and more up-to-date than what is found in the manuals.
268 ;;; Once you understand the general concepts, these doc strings
269 ;;; should be your first point of reference for further
270 ;;; info. (Access using menu entries under `Help->Commands,
271 ;;; Variables, Keys' or using the keyboard: `C-h k' for a key
272 ;;; sequence, `C-h f' for a named command or Elisp function,
273 ;;; `C-h v' for a variable. There is various other useful
274 ;;; information accessible similarly, such as `C-h a'
275 ;;; ["Apropos", i.e. search for a command, function, or variable
276 ;;; by name]; `C-h C-a' ["Apropos Docs", i.e. search through the
277 ;;; text of the doc strings]; `C-h b' to list all key bindings;
278 ;;; `C-h m' to describe the current major and minor modes; etc.
279 ;;; Type `C-h ? ?' for a complete list.)
280
281 ;;; -- Getting Started with XEmacs [aka the "New User's Guide"], a
282 ;;; more introductory manual than the XEmacs User's Manual.
283 ;;; (Access using Info, just like for the XEmacs User's Manual.
284 ;;; There are some sections on customization here.)
285
286 ;;; -- the XEmacs tutorial, a very simple introduction to XEmacs for
287 ;;; total beginners. (`C-h t' for English; get the version in
288 ;;; various languages from the Help menu)
289
290 ;;; -- the XEmacs web site, www.xemacs.org.
291
292 ;;; -- the XEmacs mailing lists (xemacs-FOO@xemacs.org;
293 ;;; see http://www.xemacs.org/Lists/ for more info. Before
294 ;;; posting, consider looking through the archives -- they go back
295 ;;; years and there is a powerful searching interface. Currently
296 ;;; the archives are at http://list-archive.xemacs.org/, but if
297 ;;; this doesn't work, you can always access them through
298 ;;; www.xemacs.org.)
299
300 ;;; -- the XEmacs newsgroup, comp.emacs.xemacs. This is
301 ;;; bi-directionally gatewayed with xemacs@xemacs.org. WARNING:
302 ;;; The developers do not normally hang out on this newsgroup. If
303 ;;; you need to contact them, use xemacs-beta@xemacs.org.
304
305 ;;; -- the XEmacs internals manual, for those interested in working on
306 ;;; the XEmacs C code. (Available through Info.)
307
308 ;;; -- `Help->About XEmacs' to find out who the maintainers are.
309
310 ---------------------
311 2. Developing XEmacs:
312 ---------------------
313
314 -- the internals manual, man/internals/internals.texi
315
316 -- long comments at the head of certain files:
317
318 emacs.c
319 extents.c
320 text.c
321 text.h
322 lisp.h
323 redisplay.h
324 dynarr.c
325 blocktype.c
326 eval.c
327 event-Xt.c (sort of)
328 event-stream.c (command event queue)
329 frame.c
330 intl-encap-win32.c
331 keymap.c
332 line-number.c (a little bit)
333 menubar-msw.c (sort of)
334 menubar-x.c (sort of)
335 mule-canna.c (sort of)
336 mule-ccl.c
337 mule-coding.c (scattered in the file)
338 mule-wnn.c (in japanese)
339 ntheap.c (near the top)
340 redisplay.c (various scattered)
341 regex.c (various scattered)
342 sysdep.c (maybe; wait_for_termination)
343 unexec.c
344 unicode.c
345 xgccache.c (a bit)
346
347 #### review .h files; write a perl program to look for long comments
348 throughout the files, ignoring stuff inside of DEFUN's.
349
350 #### elsewhere?
351
352 -- comments scattered throughout the sources (#### should be grouped
353 together if feasible). For example, lrecord.h (pdump and object-
354 creation), alloc.c (fixed-type allocation), etc. #### fill in.
355
356 -- Ben's Architecting XEmacs web site.
357 (http://www.xemacs.org/Architecting-XEmacs/index.html; #### should be
358 integrated into the sources)
359
360 -- Back discussions on xemacs-beta (#### The juiciest tidbits, esp.
361 those with specific proposals, should be extracted and stuck in
362 the source)
363
364 -- README.* in the src/ directory (and maybe other directories)
365
366 -- The ChangeLog files, sometimes.
367
368 */
369
370
371
237 /* Note: It is necessary to specify <config.h> and not "config.h" in 372 /* Note: It is necessary to specify <config.h> and not "config.h" in
238 order for the --srcdir type of compilation to work properly. 373 order for the --srcdir type of compilation to work properly.
239 Otherwise the config.h from the srcdir, rather than the one from 374 Otherwise the config.h from the srcdir, rather than the one from
240 the build dir, will be used. */ 375 the build dir, will be used. */
241 376
381 int display_arg; 516 int display_arg;
382 517
383 /* Type of display specified. We cannot use a Lisp symbol here because 518 /* Type of display specified. We cannot use a Lisp symbol here because
384 Lisp symbols may not initialized at the time that we set this 519 Lisp symbols may not initialized at the time that we set this
385 variable. */ 520 variable. */
386 const Char_ASCII *display_use; 521 const Ascbyte *display_use;
387 522
388 /* If non-zero, then the early error handler will only print the error 523 /* If non-zero, then the early error handler will only print the error
389 message and exit. */ 524 message and exit. */
390 int suppress_early_error_handler_backtrace; 525 int suppress_early_error_handler_backtrace;
391 526
392 /* An address near the bottom of the stack. 527 /* An address near the bottom of the stack.
393 Tells GC how to save a copy of the stack. */ 528 Tells GC how to save a copy of the stack. */
394 char *stack_bottom; 529 Rawbyte *stack_bottom;
395 530
396 #ifdef USG_SHARED_LIBRARIES 531 #ifdef USG_SHARED_LIBRARIES
397 /* If nonzero, this is the place to put the end of the writable segment 532 /* If nonzero, this is the place to put the end of the writable segment
398 at startup. */ 533 at startup. */
399 534
460 595
461 /* Nonzero means print debug information about path searching */ 596 /* Nonzero means print debug information about path searching */
462 int debug_paths; 597 int debug_paths;
463 598
464 /* Save argv and argc. */ 599 /* Save argv and argc. */
465 static Extbyte **initial_argv; /* #### currently unused */ 600 static Wexttext **initial_argv; /* #### currently unused */
466 static int initial_argc; /* #### currently unused */ 601 static int initial_argc; /* #### currently unused */
467 602
468 static void sort_args (int argc, char **argv); 603 static void sort_args (int argc, Wexttext **argv);
469 604
470 Lisp_Object Qkill_emacs_hook; 605 Lisp_Object Qkill_emacs_hook;
471 Lisp_Object Qsave_buffers_kill_emacs; 606 Lisp_Object Qsave_buffers_kill_emacs;
472 607
473 Lisp_Object Qtemacs, Qdumping, Qrestarted, Qpdump, Qbatch; 608 Lisp_Object Qtemacs, Qdumping, Qrestarted, Qpdump, Qbatch;
478 /* Nonzero means we're going down, so we better not run any hooks 613 /* Nonzero means we're going down, so we better not run any hooks
479 or do other non-essential stuff. */ 614 or do other non-essential stuff. */
480 int preparing_for_armageddon; 615 int preparing_for_armageddon;
481 616
482 /* Nonzero means we're in an unstable situation and need to skip 617 /* Nonzero means we're in an unstable situation and need to skip
483 i18n conversions and such during printing. */ 618 i18n conversions and such. During printing we check for this,
484 int inhibit_non_essential_printing_operations; 619 and during conversion we abort if we see this. */
620 int inhibit_non_essential_conversion_operations;
485 621
486 static JMP_BUF run_temacs_catch; 622 static JMP_BUF run_temacs_catch;
487 623
488 static int run_temacs_argc; 624 static int run_temacs_argc;
489 static Extbyte **run_temacs_argv; 625 static Wexttext **run_temacs_argv;
490 static Extbyte *run_temacs_args;
491 static int run_temacs_argv_size;
492 static int run_temacs_args_size;
493 626
494 #ifdef _MSC_VER 627 #ifdef _MSC_VER
495 static DWORD mswindows_handle_hardware_exceptions (DWORD code); 628 static DWORD mswindows_handle_hardware_exceptions (DWORD code);
496 #endif 629 #endif
497 630
505 /************************************************************************/ 638 /************************************************************************/
506 639
507 /* Code for dealing with Lisp access to the Unix command line */ 640 /* Code for dealing with Lisp access to the Unix command line */
508 641
509 static Lisp_Object 642 static Lisp_Object
510 make_arg_list_1 (int argc, Extbyte **argv, int skip_args) 643 make_arg_list_1 (int argc, Wexttext **argv, int skip_args)
511 { 644 {
512 Lisp_Object result = Qnil; 645 Lisp_Object result = Qnil;
513 REGISTER int i; 646 REGISTER int i;
514 647
515 for (i = argc - 1; i >= 0; i--) 648 for (i = argc - 1; i >= 0; i--)
529 xfree (full_exe_path, Extbyte *); 662 xfree (full_exe_path, Extbyte *);
530 result = Fcons (fullpath, result); 663 result = Fcons (fullpath, result);
531 } 664 }
532 else 665 else
533 #endif 666 #endif
534 result = Fcons (build_ext_string (argv[i], 667 result = Fcons (build_wext_string (argv[i],
535 Qcommand_argument_encoding), 668 Qcommand_argument_encoding),
536 result); 669 result);
537 } 670 }
538 } 671 }
539 return result; 672 return result;
540 } 673 }
541 674
542 Lisp_Object 675 Lisp_Object
543 make_arg_list (int argc, Extbyte **argv) 676 make_arg_list (int argc, Wexttext **argv)
544 { 677 {
545 return make_arg_list_1 (argc, argv, 0); 678 return make_arg_list_1 (argc, argv, 0);
546 } 679 }
547 680
548 /* Calling functions are also responsible for calling free_argc_argv 681 /* Calling functions are also responsible for calling free_argc_argv
549 when they are done with the generated list. */ 682 when they are done with the generated list. */
550 void 683 void
551 make_argc_argv (Lisp_Object argv_list, int *argc, Extbyte ***argv) 684 make_argc_argv (Lisp_Object argv_list, int *argc, Wexttext ***argv)
552 { 685 {
553 Lisp_Object next; 686 Lisp_Object next;
554 int n = XINT (Flength (argv_list)); 687 int n = XINT (Flength (argv_list));
555 REGISTER int i; 688 REGISTER int i;
556 *argv = (Extbyte**) xmalloc ((n+1) * sizeof (Extbyte*)); 689 *argv = xnew_array (Wexttext *, n + 1);
557 690
558 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next)) 691 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
559 { 692 {
560 const Extbyte *temp;
561 CHECK_STRING (XCAR (next)); 693 CHECK_STRING (XCAR (next));
562 694
563 LISP_STRING_TO_EXTERNAL (XCAR (next), temp, Qcommand_argument_encoding); 695 LISP_STRING_TO_EXTERNAL_MALLOC (XCAR (next), (*argv) [i],
564 (*argv) [i] = xstrdup (temp); 696 Qcommand_argument_encoding);
565 } 697 }
566 (*argv) [n] = 0; 698 (*argv) [n] = 0;
567 *argc = i; 699 *argc = i;
568 } 700 }
569 701
570 void 702 void
571 free_argc_argv (Extbyte **argv) 703 free_argc_argv (Wexttext **argv)
572 { 704 {
573 int elt = 0; 705 int elt = 0;
574 706
575 while (argv[elt]) 707 while (argv[elt])
576 { 708 {
577 xfree (argv[elt], Extbyte *); 709 xfree (argv[elt], Wexttext *);
578 elt++; 710 elt++;
579 } 711 }
580 xfree (argv, Extbyte **); 712 xfree (argv, Wexttext **);
581 } 713 }
582 714
583 static void 715 static void
584 init_cmdargs (int argc, Extbyte **argv, int skip_args) 716 init_cmdargs (int argc, Wexttext **argv, int skip_args)
585 { 717 {
586 initial_argv = argv; 718 initial_argv = argv;
587 initial_argc = argc; 719 initial_argc = argc;
588 720
589 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args); 721 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args);
617 749
618 Too bad we can't just use getopt for all of this, but we don't have 750 Too bad we can't just use getopt for all of this, but we don't have
619 enough information to do it right. */ 751 enough information to do it right. */
620 752
621 static int 753 static int
622 argmatch (char **argv, int argc, char *sstr, char *lstr, 754 argmatch (Wexttext **argv, int argc, Ascbyte *sstr, Ascbyte *lstr,
623 int minlen, char **valptr, int *skipptr) 755 int minlen, Wexttext **valptr, int *skipptr)
624 { 756 {
625 char *p = NULL; 757 Wexttext *p = NULL;
626 int arglen; 758 Charcount arglen;
627 char *arg; 759 Wexttext *arg;
628 760
629 /* Don't access argv[argc]; give up in advance. */ 761 /* Don't access argv[argc]; give up in advance. */
630 if (argc <= *skipptr + 1) 762 if (argc <= *skipptr + 1)
631 return 0; 763 return 0;
632 764
633 arg = argv[*skipptr+1]; 765 arg = argv[*skipptr+1];
634 if (arg == NULL) 766 if (arg == NULL)
635 return 0; 767 return 0;
636 if (strcmp (arg, sstr) == 0) 768 if (wext_strcmp_ascii (arg, sstr) == 0)
637 { 769 {
638 if (valptr != NULL) 770 if (valptr != NULL)
639 { 771 {
640 *valptr = argv[*skipptr+2]; 772 *valptr = argv[*skipptr+2];
641 *skipptr += 2; 773 *skipptr += 2;
642 } 774 }
643 else 775 else
644 *skipptr += 1; 776 *skipptr += 1;
645 return 1; 777 return 1;
646 } 778 }
647 arglen = (valptr != NULL && (p = strchr (arg, '=')) != NULL 779 arglen = (valptr != NULL && (p = wext_strchr (arg, '=')) != NULL
648 ? p - arg : (int) strlen (arg)); 780 ? p - arg : (Charcount) wext_strlen (arg));
649 if (lstr && !minlen) 781 if (lstr && !minlen)
650 minlen = strlen (lstr); 782 minlen = strlen (lstr);
651 if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0) 783 if (lstr == 0 || arglen < minlen ||
784 wext_strncmp_ascii (arg, lstr, arglen) != 0)
652 return 0; 785 return 0;
653 else if (valptr == NULL) 786 else if (valptr == NULL)
654 { 787 {
655 *skipptr += 1; 788 *skipptr += 1;
656 return 1; 789 return 1;
657 } 790 }
658 else if (p != NULL) 791 else if (p != NULL)
659 { 792 {
660 *valptr = p+1; 793 *valptr = p + 1;
661 *skipptr += 1; 794 *skipptr += 1;
662 return 1; 795 return 1;
663 } 796 }
664 else if (argv[*skipptr+2] != NULL) 797 else if (argv[*skipptr + 2] != NULL)
665 { 798 {
666 *valptr = argv[*skipptr+2]; 799 *valptr = argv[*skipptr + 2];
667 *skipptr += 2; 800 *skipptr += 2;
668 return 1; 801 return 1;
669 } 802 }
670 else 803 else
671 { 804 {
672 return 0; 805 return 0;
673 } 806 }
674 } 807 }
675 808
676 static void 809 static void
677 check_compatible_window_system (char *must) 810 check_compatible_window_system (Ascbyte *must)
678 { 811 {
679 if (display_use && strcmp (display_use, must)) 812 if (display_use && strcmp (display_use, must))
680 fatal ("Incompatible window system type `%s': `%s' already specified", 813 fatal ("Incompatible window system type `%s': `%s' already specified",
681 must, display_use); 814 must, display_use);
682 display_use = must; 815 display_use = must;
698 happens as a result of using `run-temacs' in the command line, when 831 happens as a result of using `run-temacs' in the command line, when
699 invoking a bare (without dumped data) XEmacs (i.e. `temacs' with 832 invoking a bare (without dumped data) XEmacs (i.e. `temacs' with
700 the conventional dumper or `xemacs -nd' with the pdumper). See 833 the conventional dumper or `xemacs -nd' with the pdumper). See
701 Frun_emacs_from_temacs(). 834 Frun_emacs_from_temacs().
702 */ 835 */
703 DECLARE_DOESNT_RETURN (main_1 (int, Extbyte **, Extbyte **, int)); 836 DECLARE_DOESNT_RETURN (main_1 (int, Wexttext **, Wexttext **, int));
704 DOESNT_RETURN 837 DOESNT_RETURN
705 main_1 (int argc, Extbyte **argv, 838 main_1 (int argc, Wexttext **argv, Wexttext **UNUSED (envp), int restart)
706 #if defined (WIN32_NATIVE) || defined (_SCO_DS)
707 Extbyte **envp,
708 #else
709 Extbyte **UNUSED (envp),
710 #endif
711 int restart)
712 { 839 {
713 char stack_bottom_variable; 840 Rawbyte stack_bottom_variable;
714 int skip_args = 0; 841 int skip_args = 0;
715 Lisp_Object load_me; 842 Lisp_Object load_me;
716 #ifdef NeXT 843 #ifdef NeXT
717 extern int malloc_cookie; 844 extern int malloc_cookie;
718 #endif 845 #endif
719
720 /* !!#### Under MS Windows, this should all be rewritten to deal with
721 Unicode arguments and environment. We need to retrieve the command
722 line with GetCommandLine and convert to argv format with
723 CommandLineToArgvW. Unfortunately we have a bootstrapping problem
724 currently because we can't initialize the Unicode tables until we've
725 computed the location of data-directory, which doesn't happen till
726 startup.el, which is way late. We need to be dumping the Unicode
727 data, which means we need to fix pdump to correctly dump the "union"
728 format used by the tables. */
729 846
730 #if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \ 847 #if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \
731 && !defined (DOUG_LEA_MALLOC)) 848 && !defined (DOUG_LEA_MALLOC))
732 /* Make sure that any libraries we link against haven't installed a 849 /* Make sure that any libraries we link against haven't installed a
733 hook for a gmalloc of a potentially incompatible version. */ 850 hook for a gmalloc of a potentially incompatible version. */
738 __free_hook = NULL; 855 __free_hook = NULL;
739 #endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */ 856 #endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */
740 857
741 noninteractive = 0; 858 noninteractive = 0;
742 display_use = 0; 859 display_use = 0;
743 inhibit_non_essential_printing_operations = 1; 860 inhibit_non_essential_conversion_operations = 1;
744 861
745 #ifdef NeXT 862 #ifdef NeXT
746 /* 19-Jun-1995 -baw 863 /* 19-Jun-1995 -baw
747 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman 864 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman
748 * <cedman@princeton.edu>. Note that even Carl doesn't know what this 865 * <cedman@princeton.edu>. Note that even Carl doesn't know what this
768 init_free_hook (); 885 init_free_hook ();
769 #endif 886 #endif
770 887
771 sort_args (argc, argv); 888 sort_args (argc, argv);
772 889
773 #if defined (WIN32_NATIVE) || defined (_SCO_DS) 890 #if 0 /* defined (_SCO_DS)
891 #### Turn this off, we already have another SCO_DS hack in main().
892 */
774 environ = envp; 893 environ = envp;
775 #endif 894 #endif
776 895
777 /* Record (approximately) where the stack begins. */ 896 /* Record (approximately) where the stack begins. */
778 stack_bottom = &stack_bottom_variable; 897 stack_bottom = &stack_bottom_variable;
832 951
833 /* Handle the -si/--show-inline-info switch, which means show the 952 /* Handle the -si/--show-inline-info switch, which means show the
834 alignment and max size of the inline data and quit */ 953 alignment and max size of the inline data and quit */
835 if (argmatch (argv, argc, "-si", "--show-inline-info", 0, NULL, &skip_args)) 954 if (argmatch (argv, argc, "-si", "--show-inline-info", 0, NULL, &skip_args))
836 { 955 {
837 #if defined(PDUMP) && !defined(WIN32_NATIVE) 956 #if defined (PDUMP) && !defined (WIN32_NATIVE)
838 printf ("%u %u\n", dumped_data_max_size(), dumped_data_align_offset()); 957 printf ("%u %u\n", dumped_data_max_size (), dumped_data_align_offset ());
839 #else 958 #else
840 printf ("Portable dumper not configured or windows native; -si just forces exit.\n"); 959 printf ("Portable dumper not configured or windows native; -si just forces exit.\n");
841 #endif 960 #endif
842 exit (0); 961 exit (0);
843 } 962 }
867 (using GenerateConsoleCtrlEvent), it in turn signals us to commit 986 (using GenerateConsoleCtrlEvent), it in turn signals us to commit
868 suicide. (This is cleaner than using TerminateProcess()). This 987 suicide. (This is cleaner than using TerminateProcess()). This
869 makes (e.g.) the "Stop Build" command from VC++ correctly terminate 988 makes (e.g.) the "Stop Build" command from VC++ correctly terminate
870 XEmacs. */ 989 XEmacs. */
871 990
872 char *heventstr; 991 Wexttext *heventstr;
873 if (argmatch (argv, argc, "-mswindows-termination-handle", 0, 0, 992 if (argmatch (argv, argc, "-mswindows-termination-handle", 0, 0,
874 &heventstr, &skip_args)) 993 &heventstr, &skip_args))
875 { 994 {
876 HANDLE hevent = (HANDLE) atol (heventstr); 995 HANDLE hevent = (HANDLE) wext_atol (heventstr);
877 DWORD unused; 996 DWORD unused;
878 HANDLE h_thread = CreateThread (NULL, 0, wait_for_termination_signal, 997 HANDLE h_thread = CreateThread (NULL, 0, wait_for_termination_signal,
879 (void *) hevent, 0, &unused); 998 (void *) hevent, 0, &unused);
880 CloseHandle (h_thread); 999 CloseHandle (h_thread);
881 } 1000 }
980 1099
981 /* Handle other switches implying particular window systems: */ 1100 /* Handle other switches implying particular window systems: */
982 1101
983 /* Handle the -t switch, which specifies filename to use as terminal */ 1102 /* Handle the -t switch, which specifies filename to use as terminal */
984 { 1103 {
985 Extbyte *term; 1104 Wexttext *term;
986 if (argmatch (argv, argc, "-t", "--terminal", 0, &term, &skip_args)) 1105 if (argmatch (argv, argc, "-t", "--terminal", 0, &term, &skip_args))
987 { 1106 {
1107 int fd;
1108
988 check_compatible_window_system ("tty"); 1109 check_compatible_window_system ("tty");
989 #ifndef HAVE_TTY 1110 #ifndef HAVE_TTY
990 fatal ("Sorry, this XEmacs was not compiled with TTY support"); 1111 fatal ("Sorry, this XEmacs was not compiled with TTY support");
991 #endif 1112 #endif
992 1113
993 retry_close (0); 1114 retry_close (0);
994 retry_close (1); 1115 retry_close (1);
995 if (open (term, O_RDWR | OPEN_BINARY, 2) < 0) 1116
996 fatal ("%s: %s", term, strerror (errno)); 1117 fd = wext_retry_open (term, O_RDWR | OPEN_BINARY, 2);
1118 /* Conversions are not possible yet, and printing will be in
1119 external format, so strerror() and ttyname() are OK. */
1120 if (fd < 0)
1121 fatal ("%s: %s", WEXTTEXT_TO_8_BIT (term), strerror (errno));
997 dup (0); 1122 dup (0);
998 if (! isatty (0)) 1123 if (! isatty (0))
999 fatal ("%s: not a tty", term); 1124 fatal ("%s: not a tty", WEXTTEXT_TO_8_BIT (term));
1000 1125
1001 #if 0 1126 #if 0
1002 stderr_out ("Using %s", ttyname (0)); 1127 stderr_out ("Using %s", ttyname (0));
1003 #endif 1128 #endif
1004 stderr_out ("Using %s", term); 1129 stderr_out ("Using %s", WEXTTEXT_TO_8_BIT (term));
1005 } 1130 }
1006 } 1131 }
1007 1132
1008 /* Stupid kludge to catch command-line display spec. We can't 1133 /* Stupid kludge to catch command-line display spec. We can't
1009 handle this argument entirely in window-system-dependent code 1134 handle this argument entirely in window-system-dependent code
1010 because we don't even know which window-system-dependent code 1135 because we don't even know which window-system-dependent code
1011 to run until we've recognized this argument. */ 1136 to run until we've recognized this argument. */
1012 { 1137 {
1013 #ifdef HAVE_X_WINDOWS 1138 #ifdef HAVE_X_WINDOWS
1014 char *dpy = 0; 1139 Wexttext *dpy = 0;
1015 int count_before = skip_args; 1140 int count_before = skip_args;
1016 1141
1017 if (argmatch (argv, argc, "-d", "--display", 3, &dpy, &skip_args) || 1142 if (argmatch (argv, argc, "-d", "--display", 3, &dpy, &skip_args) ||
1018 argmatch (argv, argc, "-display", 0, 3, &dpy, &skip_args)) 1143 argmatch (argv, argc, "-display", 0, 3, &dpy, &skip_args))
1019 { 1144 {
1023 /* If we have the form --display=NAME, 1148 /* If we have the form --display=NAME,
1024 convert it into -d name. 1149 convert it into -d name.
1025 This requires inserting a new element into argv. */ 1150 This requires inserting a new element into argv. */
1026 if (dpy != 0 && skip_args - count_before == 1) 1151 if (dpy != 0 && skip_args - count_before == 1)
1027 { 1152 {
1028 char **new = (char **) xmalloc (sizeof (char *) * (argc + 2)); 1153 Wexttext **new = xnew_array (Wexttext *, argc + 2);
1029 int j; 1154 int j;
1030 1155
1031 for (j = 0; j < count_before + 1; j++) 1156 for (j = 0; j < count_before + 1; j++)
1032 new[j] = argv[j]; 1157 new[j] = argv[j];
1033 new[count_before + 1] = "-d"; 1158 new[count_before + 1] = WEXTSTRING ("-d");
1034 new[count_before + 2] = dpy; 1159 new[count_before + 2] = dpy;
1035 for (j = count_before + 2; j <argc; j++) 1160 for (j = count_before + 2; j <argc; j++)
1036 new[j + 1] = argv[j]; 1161 new[j + 1] = argv[j];
1037 argv = new; 1162 argv = new;
1038 argc++; 1163 argc++;
1039 } 1164 }
1040 /* Change --display to -d, when its arg is separate. */ 1165 /* Change --display to -d, when its arg is separate. */
1041 else if (dpy != 0 && skip_args > count_before 1166 else if (dpy != 0 && skip_args > count_before
1042 && argv[count_before + 1][1] == '-') 1167 && argv[count_before + 1][1] == '-')
1043 argv[count_before + 1] = "-d"; 1168 argv[count_before + 1] = WEXTSTRING ("-d");
1044 1169
1045 /* Don't actually discard this arg. */ 1170 /* Don't actually discard this arg. */
1046 skip_args = count_before; 1171 skip_args = count_before;
1047 #endif /* HAVE_X_WINDOWS */ 1172 #endif /* HAVE_X_WINDOWS */
1048 } 1173 }
1051 possibilities: */ 1176 possibilities: */
1052 1177
1053 #if defined (HAVE_X_WINDOWS) || defined (HAVE_GTK) 1178 #if defined (HAVE_X_WINDOWS) || defined (HAVE_GTK)
1054 if (!display_use) 1179 if (!display_use)
1055 { 1180 {
1056 char *dpy; 1181 Wexttext *dpy;
1057 /* If there is a non-empty environment var DISPLAY, assume X or GTK, 1182 /* If there is a non-empty environment var DISPLAY, assume X or GTK,
1058 but don't set `display_arg', which is only to be set if the 1183 but don't set `display_arg', which is only to be set if the
1059 display was specified on the command line. */ 1184 display was specified on the command line. */
1060 if ((dpy = getenv ("DISPLAY")) && dpy[0]) 1185 if ((dpy = wext_getenv (WEXTSTRING ("DISPLAY"))) && dpy[0])
1061 #ifdef HAVE_X_WINDOWS 1186 #ifdef HAVE_X_WINDOWS
1062 /* #### Who gets precedence? X or GTK? For the moment, GTK support is 1187 /* #### Who gets precedence? X or GTK? For the moment, GTK support is
1063 unstable so use X. Maybe eventually we will switch this. */ 1188 unstable so use X. Maybe eventually we will switch this. */
1064 display_use = "x"; 1189 display_use = "x";
1065 #else 1190 #else
1124 init_floatfns_very_early (); /* Catch floating-point math errors. */ 1249 init_floatfns_very_early (); /* Catch floating-point math errors. */
1125 init_process_times_very_early (); /* Initialize our process timers. 1250 init_process_times_very_early (); /* Initialize our process timers.
1126 As early as possible, of course, 1251 As early as possible, of course,
1127 so we can be fairly accurate. */ 1252 so we can be fairly accurate. */
1128 1253
1129 #ifdef WIN32_ANY
1130 init_win32_very_early ();
1131 #endif
1132 #ifdef HAVE_MS_WINDOWS 1254 #ifdef HAVE_MS_WINDOWS
1133 /* Depends on XEUNICODE_P, only accurate after the previous call */ 1255 /* Depends on XEUNICODE_P */
1134 init_mswindows_dde_very_early (); /* DDE needs to be initialized early so 1256 init_mswindows_dde_very_early (); /* DDE needs to be initialized early so
1135 that the client doesn't give up 1257 that the client doesn't give up
1136 waiting. */ 1258 waiting. */
1137 #endif 1259 #endif
1138 1260
1199 if (initialized) 1321 if (initialized)
1200 run_temacs_argc = restart ? -2 : -1; 1322 run_temacs_argc = restart ? -2 : -1;
1201 else 1323 else
1202 purify_flag = 1; 1324 purify_flag = 1;
1203 } 1325 }
1204 #else 1326 #else /* not PDUMP */
1205 if (!initialized) 1327 if (!initialized)
1206 purify_flag = 1; 1328 purify_flag = 1;
1207 #endif 1329 #endif
1208 1330
1209 init_alloc_early (); 1331 init_alloc_early ();
1624 #endif 1746 #endif
1625 #ifdef MULE 1747 #ifdef MULE
1626 coding_system_type_create_mule_coding (); 1748 coding_system_type_create_mule_coding ();
1627 #endif 1749 #endif
1628 1750
1629 /* Now initialize the structure types and associated symbols.
1630 Other than the first function below, the functions may
1631 make exactly the following function/macro calls:
1632
1633 define_structure_type()
1634 define_structure_type_keyword()
1635
1636 */
1637
1638 structure_type_create ();
1639
1640 structure_type_create_chartab ();
1641 structure_type_create_faces ();
1642 structure_type_create_rangetab ();
1643 structure_type_create_hash_table ();
1644
1645 /* Now initialize the image instantiator formats and associated symbols. 1751 /* Now initialize the image instantiator formats and associated symbols.
1646 Other than the first function below, the functions may 1752 Other than the first function below, the functions may
1647 make exactly the following function/macro calls: 1753 make exactly the following function/macro calls:
1648 1754
1649 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT() 1755 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT()
1666 image_instantiator_format_create_glyphs_mswindows (); 1772 image_instantiator_format_create_glyphs_mswindows ();
1667 #endif /* HAVE_MS_WINDOWS */ 1773 #endif /* HAVE_MS_WINDOWS */
1668 #ifdef HAVE_GTK 1774 #ifdef HAVE_GTK
1669 image_instantiator_format_create_glyphs_gtk (); 1775 image_instantiator_format_create_glyphs_gtk ();
1670 #endif 1776 #endif
1777 }
1778 #ifdef PDUMP
1779 else if (!restart) /* after successful pdump_load()
1780 (note, we are inside ifdef PDUMP) */
1781 {
1782 reinit_alloc_early ();
1783 reinit_symbols_early ();
1784 reinit_opaque_early ();
1785 reinit_eistring_early ();
1786
1787 reinit_console_type_create_stream ();
1788 #ifdef HAVE_TTY
1789 reinit_console_type_create_tty ();
1790 #endif
1791 #ifdef HAVE_X_WINDOWS
1792 reinit_console_type_create_x ();
1793 reinit_console_type_create_device_x ();
1794 #endif
1795 #ifdef HAVE_MS_WINDOWS
1796 reinit_console_type_create_mswindows ();
1797 #endif
1798 #ifdef HAVE_GTK
1799 reinit_console_type_create_gtk ();
1800 #endif
1801
1802 reinit_specifier_type_create ();
1803 reinit_specifier_type_create_image ();
1804 reinit_specifier_type_create_gutter ();
1805 reinit_specifier_type_create_objects ();
1806 #ifdef HAVE_TOOLBARS
1807 reinit_specifier_type_create_toolbar ();
1808 #endif
1809
1810 reinit_coding_system_type_create ();
1811 reinit_coding_system_type_create_unicode ();
1812 #ifdef WIN32_ANY
1813 reinit_coding_system_type_create_intl_win32 ();
1814 #endif
1815 #ifdef MULE
1816 reinit_coding_system_type_create_mule_coding ();
1817 #endif
1818 }
1819 #endif /* PDUMP */
1820
1821 if (!initialized
1822 #ifdef PDUMP
1823 || !restart
1824 #endif
1825 )
1826 {
1827 /* Now initialize the structure types and associated symbols.
1828 Other than the first function below, the functions may
1829 make exactly the following function/macro calls:
1830
1831 define_structure_type()
1832 define_structure_type_keyword()
1833
1834 */
1835
1836 structure_type_create ();
1837
1838 structure_type_create_chartab ();
1839 structure_type_create_faces ();
1840 structure_type_create_rangetab ();
1841 structure_type_create_hash_table ();
1671 1842
1672 /* Now initialize the lstream types and associated symbols. 1843 /* Now initialize the lstream types and associated symbols.
1673 Other than the first function below, the functions may 1844 Other than the first function below, the functions may
1674 make exactly the following function/macro calls: 1845 make exactly the following function/macro calls:
1675 1846
1692 process_type_create_unix (); 1863 process_type_create_unix ();
1693 #endif 1864 #endif
1694 #ifdef HAVE_WIN32_PROCESSES 1865 #ifdef HAVE_WIN32_PROCESSES
1695 process_type_create_nt (); 1866 process_type_create_nt ();
1696 #endif 1867 #endif
1697 1868 }
1869
1870 if (!initialized)
1871 {
1698 /* Now initialize most variables. 1872 /* Now initialize most variables.
1699 1873
1700 These functions may do exactly the following: 1874 These functions may do exactly the following:
1701 1875
1702 -- assigning a symbol or constant value to a variable 1876 -- assigning a symbol or constant value to a variable
1742 1916
1743 NB: Initialization or assignment should not be done here to certain 1917 NB: Initialization or assignment should not be done here to certain
1744 variables settable from the command line. See the comment above 1918 variables settable from the command line. See the comment above
1745 the call to pdump_load() in main_1(). This caveat should only 1919 the call to pdump_load() in main_1(). This caveat should only
1746 apply to vars_of_emacs(). 1920 apply to vars_of_emacs().
1921
1922 Order should not matter in these functions.
1747 */ 1923 */
1748 1924
1749 /* Now allow Fprovide() statements to be made. */ 1925 /* Now allow Fprovide() statements to be made. */
1750 init_provide_once (); 1926 init_provide_once ();
1751 1927
1777 vars_of_dragdrop (); 1953 vars_of_dragdrop ();
1778 #endif 1954 #endif
1779 vars_of_editfns (); 1955 vars_of_editfns ();
1780 vars_of_emacs (); 1956 vars_of_emacs ();
1781 vars_of_eval (); 1957 vars_of_eval ();
1782 init_eval_semi_early ();
1783 1958
1784 #ifdef HAVE_X_WINDOWS 1959 #ifdef HAVE_X_WINDOWS
1785 vars_of_event_Xt (); 1960 vars_of_event_Xt ();
1786 #endif 1961 #endif
1787 #if defined (HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS)) 1962 #if defined (HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
1984 #endif 2159 #endif
1985 2160
1986 #ifdef HAVE_GPM 2161 #ifdef HAVE_GPM
1987 vars_of_gpmevent (); 2162 vars_of_gpmevent ();
1988 #endif 2163 #endif
1989
1990 /* Now initialize any specifier variables. We do this later
1991 because it has some dependence on the vars initialized
1992 above.
1993
1994 These functions should *only* initialize specifier variables,
1995 and may make use of the following functions/macros in addition
1996 to the ones listed above:
1997
1998 DEFVAR_SPECIFIER()
1999 Fmake_specifier()
2000 set_specifier_fallback()
2001 set_specifier_caching()
2002 */
2003
2004 specifier_vars_of_glyphs ();
2005 specifier_vars_of_glyphs_widget ();
2006 specifier_vars_of_gutter ();
2007 #ifdef HAVE_MENUBARS
2008 specifier_vars_of_menubar ();
2009 #endif
2010 specifier_vars_of_redisplay ();
2011 #ifdef HAVE_SCROLLBARS
2012 specifier_vars_of_scrollbar ();
2013 #endif
2014 #ifdef HAVE_TOOLBARS
2015 specifier_vars_of_toolbar ();
2016 #endif
2017 specifier_vars_of_window ();
2018
2019 /* Now comes all the rest of the variables that couldn't
2020 be handled above. There may be dependencies on variables
2021 initialized above, and dependencies between one complex_vars_()
2022 function and another. */
2023
2024 #ifdef MULE
2025 /* This depends on vars initialized in vars_of_unicode(). */
2026 complex_vars_of_mule_charset ();
2027 #endif
2028 /* This one doesn't depend on anything really, and could go into
2029 vars_of_(), but lots of lots of code gets called and it's easily
2030 possible that it could get changed to require being a
2031 complex_vars_of_(), for example if a charset appears anywhere,
2032 then we suddenly have dependence on the previous call. */
2033 complex_vars_of_file_coding ();
2034 #ifdef WIN32_ANY
2035 complex_vars_of_intl_win32 ();
2036 #endif
2037
2038 /* Depends on specifiers. */
2039 complex_vars_of_faces ();
2040
2041 /* This calls allocate_glyph(), which creates specifiers
2042 and also relies on a variable (Vthe_nothing_vector) initialized
2043 above. */
2044 complex_vars_of_glyphs ();
2045
2046 /* These rely on the glyphs just created in the previous function,
2047 and call Fadd_spec_to_specifier(), which relies on various
2048 variables initialized above. */
2049 #ifdef HAVE_GTK
2050 complex_vars_of_glyphs_gtk ();
2051 #endif
2052 #ifdef HAVE_X_WINDOWS
2053 complex_vars_of_glyphs_x ();
2054 #endif
2055 #ifdef HAVE_MS_WINDOWS
2056 complex_vars_of_glyphs_mswindows ();
2057 #endif
2058
2059 /* This calls Fmake_glyph_internal(). */
2060 complex_vars_of_alloc ();
2061
2062 /* This calls Fmake_glyph_internal(). */
2063 #ifdef HAVE_MENUBARS
2064 complex_vars_of_menubar ();
2065 #endif
2066
2067 #ifdef HAVE_SCROLLBARS
2068 /* This calls Fmake_glyph_internal(). */
2069 complex_vars_of_scrollbar ();
2070 #endif
2071
2072 /* This calls allocate_glyph(). */
2073 complex_vars_of_frame ();
2074
2075 /* This calls Fcopy_category_table() under Mule, which calls who
2076 knows what. */
2077 complex_vars_of_chartab ();
2078
2079 /* This calls Fput_char_table(), which (under Mule) depends on the
2080 charsets being initialized. */
2081 complex_vars_of_casetab ();
2082
2083 /* This calls Fcopy_syntax_table(), which relies on char tables. */
2084 complex_vars_of_syntax ();
2085
2086 /* This initializes buffer-local variables, sets things up so
2087 that buffers can be created, and creates a couple of basic
2088 buffers. This depends on Vstandard_syntax_table and
2089 Vstandard_category_table (initialized in the previous
2090 functions), as well as a whole horde of variables that may
2091 have been initialized above. */
2092 complex_vars_of_buffer ();
2093
2094 /* This initializes console-local variables. */
2095 complex_vars_of_console ();
2096
2097 /* This creates a couple more buffers, and depends on the
2098 previous function. */
2099 complex_vars_of_minibuf ();
2100
2101 /* These two might call Ffile_name_as_directory(), which
2102 might depend on all sorts of things; I'm not sure. */
2103 complex_vars_of_emacs ();
2104
2105 /* This creates a couple of basic keymaps and depends on Lisp
2106 hash tables and Ffset() (both of which depend on some variables
2107 initialized in the vars_of_*() section) and possibly other
2108 stuff. */
2109 complex_vars_of_keymap ();
2110
2111 #ifdef ERROR_CHECK_GC
2112 {
2113 extern int always_gc;
2114 if (always_gc) /* purification debugging hack */
2115 garbage_collect_1 ();
2116 }
2117 #endif
2118 } 2164 }
2119 2165
2166 if (!initialized
2120 #ifdef PDUMP 2167 #ifdef PDUMP
2121 if (initialized && !restart) /* after successful pdump_load() 2168 || !restart
2122 (note, we are inside ifdef PDUMP) */ 2169 #endif
2170 )
2123 { 2171 {
2124 reinit_alloc_early (); 2172 /* Now do additional vars_of_*() initialization that happens both
2125 reinit_symbols_early (); 2173 at dump time and after pdump load. */
2126 reinit_opaque_early ();
2127 reinit_eistring_early ();
2128
2129 reinit_console_type_create_stream ();
2130 #ifdef HAVE_TTY
2131 reinit_console_type_create_tty ();
2132 #endif
2133 #ifdef HAVE_X_WINDOWS
2134 reinit_console_type_create_x ();
2135 reinit_console_type_create_device_x ();
2136 #endif
2137 #ifdef HAVE_MS_WINDOWS
2138 reinit_console_type_create_mswindows ();
2139 #endif
2140 #ifdef HAVE_GTK
2141 reinit_console_type_create_gtk ();
2142 #endif
2143
2144 reinit_specifier_type_create ();
2145 reinit_specifier_type_create_image ();
2146 reinit_specifier_type_create_gutter ();
2147 reinit_specifier_type_create_objects ();
2148 #ifdef HAVE_TOOLBARS
2149 reinit_specifier_type_create_toolbar ();
2150 #endif
2151
2152 structure_type_create ();
2153
2154 reinit_coding_system_type_create ();
2155 reinit_coding_system_type_create_unicode ();
2156 #ifdef WIN32_ANY
2157 reinit_coding_system_type_create_intl_win32 ();
2158 #endif
2159 #ifdef MULE
2160 reinit_coding_system_type_create_mule_coding ();
2161 #endif
2162
2163 structure_type_create_chartab ();
2164 structure_type_create_faces ();
2165 structure_type_create_rangetab ();
2166 structure_type_create_hash_table ();
2167
2168 lstream_type_create ();
2169 lstream_type_create_file_coding ();
2170 #if defined (HAVE_MS_WINDOWS) && !defined (HAVE_MSG_SELECT)
2171 lstream_type_create_mswindows_selectable ();
2172 #endif
2173 #ifdef HAVE_UNIX_PROCESSES
2174 process_type_create_unix ();
2175 #endif
2176 #ifdef HAVE_WIN32_PROCESSES
2177 process_type_create_nt ();
2178 #endif
2179
2180 reinit_vars_of_buffer (); 2174 reinit_vars_of_buffer ();
2181 reinit_vars_of_console (); 2175 reinit_vars_of_console ();
2182 #ifdef DEBUG_XEMACS 2176 #ifdef DEBUG_XEMACS
2183 reinit_vars_of_debug (); 2177 reinit_vars_of_debug ();
2184 #endif 2178 #endif
2207 reinit_vars_of_objects (); 2201 reinit_vars_of_objects ();
2208 reinit_vars_of_print (); 2202 reinit_vars_of_print ();
2209 reinit_vars_of_search (); 2203 reinit_vars_of_search ();
2210 reinit_vars_of_text (); 2204 reinit_vars_of_text ();
2211 reinit_vars_of_undo (); 2205 reinit_vars_of_undo ();
2212 reinit_vars_of_unicode ();
2213 reinit_vars_of_window (); 2206 reinit_vars_of_window ();
2214 2207
2215 #ifdef HAVE_MS_WINDOWS 2208 #ifdef HAVE_MS_WINDOWS
2216 reinit_vars_of_event_mswindows (); 2209 reinit_vars_of_event_mswindows ();
2217 reinit_vars_of_frame_mswindows (); 2210 reinit_vars_of_frame_mswindows ();
2242 reinit_vars_of_mule_coding (); 2235 reinit_vars_of_mule_coding ();
2243 #endif 2236 #endif
2244 #if defined (MULE) && defined (HAVE_WNN) 2237 #if defined (MULE) && defined (HAVE_WNN)
2245 reinit_vars_of_mule_wnn (); 2238 reinit_vars_of_mule_wnn ();
2246 #endif 2239 #endif
2247
2248 reinit_complex_vars_of_buffer_runtime_only ();
2249 reinit_complex_vars_of_console_runtime_only ();
2250 reinit_complex_vars_of_minibuf ();
2251 } 2240 }
2241
2242 if (!initialized)
2243 {
2244 /* Now initialize any specifier variables. We do this later
2245 because it has some dependence on the vars initialized
2246 above.
2247
2248 These functions should *only* initialize specifier variables,
2249 and may make use of the following functions/macros in addition
2250 to the ones listed above:
2251
2252 DEFVAR_SPECIFIER()
2253 Fmake_specifier()
2254 set_specifier_fallback()
2255 set_specifier_caching()
2256 */
2257
2258 specifier_vars_of_glyphs ();
2259 specifier_vars_of_glyphs_widget ();
2260 specifier_vars_of_gutter ();
2261 #ifdef HAVE_MENUBARS
2262 specifier_vars_of_menubar ();
2263 #endif
2264 specifier_vars_of_redisplay ();
2265 #ifdef HAVE_SCROLLBARS
2266 specifier_vars_of_scrollbar ();
2267 #endif
2268 #ifdef HAVE_TOOLBARS
2269 specifier_vars_of_toolbar ();
2270 #endif
2271 specifier_vars_of_window ();
2272
2273 /* Now comes all the rest of the variables that couldn't
2274 be handled above. There may be dependencies on variables
2275 initialized above, and dependencies between one complex_vars_()
2276 function and another. */
2277
2278 #ifdef MULE
2279 /* This depends on vars initialized in vars_of_unicode(). */
2280 complex_vars_of_mule_charset ();
2281 #endif
2282 /* This one doesn't depend on anything really, and could go into
2283 vars_of_(), but lots of lots of code gets called and it's easily
2284 possible that it could get changed to require being a
2285 complex_vars_of_(), for example if a charset appears anywhere,
2286 then we suddenly have dependence on the previous call. */
2287 complex_vars_of_file_coding ();
2288 #ifdef WIN32_ANY
2289 complex_vars_of_intl_win32 ();
2290 #endif
2291
2292 /* At this point we should be able to do conversion operations.
2293 We have initialized things to the point that we can create Lisp
2294 objects and we have defined the basic coding systems (in the
2295 just-previous complex-vars calls). We will in fact do conversion
2296 quite soon, e.g. in complex_vars_of_glyphs_x(). */
2297 inhibit_non_essential_conversion_operations = 0;
2298
2299 /* Depends on specifiers. */
2300 complex_vars_of_faces ();
2301
2302 /* This calls allocate_glyph(), which creates specifiers
2303 and also relies on a variable (Vthe_nothing_vector) initialized
2304 above. */
2305 complex_vars_of_glyphs ();
2306
2307 /* These rely on the glyphs just created in the previous function,
2308 and call Fadd_spec_to_specifier(), which relies on various
2309 variables initialized above. */
2310 #ifdef HAVE_GTK
2311 complex_vars_of_glyphs_gtk ();
2312 #endif
2313 #ifdef HAVE_X_WINDOWS
2314 complex_vars_of_glyphs_x ();
2315 #endif
2316 #ifdef HAVE_MS_WINDOWS
2317 complex_vars_of_glyphs_mswindows ();
2318 #endif
2319
2320 /* This calls Fmake_glyph_internal(). */
2321 complex_vars_of_alloc ();
2322
2323 /* This calls Fmake_glyph_internal(). */
2324 #ifdef HAVE_MENUBARS
2325 complex_vars_of_menubar ();
2326 #endif
2327
2328 #ifdef HAVE_SCROLLBARS
2329 /* This calls Fmake_glyph_internal(). */
2330 complex_vars_of_scrollbar ();
2331 #endif
2332
2333 /* This calls allocate_glyph(). */
2334 complex_vars_of_frame ();
2335
2336 /* This calls Fcopy_category_table() under Mule, which calls who
2337 knows what. */
2338 complex_vars_of_chartab ();
2339
2340 /* This calls Fput_char_table(), which (under Mule) depends on the
2341 charsets being initialized. */
2342 complex_vars_of_casetab ();
2343
2344 /* This calls Fcopy_syntax_table(), which relies on char tables. */
2345 complex_vars_of_syntax ();
2346
2347 /* This initializes buffer-local variables, sets things up so
2348 that buffers can be created, and creates a couple of basic
2349 buffers. This depends on Vstandard_syntax_table and
2350 Vstandard_category_table (initialized in the previous
2351 functions), as well as a whole horde of variables that may
2352 have been initialized above. */
2353 complex_vars_of_buffer ();
2354
2355 /* This initializes console-local variables. */
2356 complex_vars_of_console ();
2357
2358 /* This creates a couple more buffers, and depends on the
2359 previous function. */
2360 complex_vars_of_minibuf ();
2361
2362 /* These two might call Ffile_name_as_directory(), which
2363 might depend on all sorts of things; I'm not sure. */
2364 complex_vars_of_emacs ();
2365
2366 /* This creates a couple of basic keymaps and depends on Lisp
2367 hash tables and Ffset() (both of which depend on some variables
2368 initialized in the vars_of_*() section) and possibly other
2369 stuff. */
2370 complex_vars_of_keymap ();
2371
2372 #ifdef ERROR_CHECK_GC
2373 {
2374 extern int always_gc;
2375 if (always_gc) /* purification debugging hack */
2376 garbage_collect_1 ();
2377 }
2378 #endif
2379 }
2380 else
2381 {
2382 /* We are at the equivalent place where we reset this in the
2383 non-initialized case. */
2384 inhibit_non_essential_conversion_operations = 0;
2385
2386 #ifdef PDUMP
2387 if (!restart) /* after successful pdump_load()
2388 (note, we are inside ifdef PDUMP) */
2389 {
2390 reinit_complex_vars_of_buffer_runtime_only ();
2391 reinit_complex_vars_of_console_runtime_only ();
2392 reinit_complex_vars_of_minibuf ();
2393 }
2252 #endif /* PDUMP */ 2394 #endif /* PDUMP */
2395 }
2396
2397 if (initialized)
2398 init_eval_semi_early ();
2253 2399
2254 /* CONGRATULATIONS!!! We have successfully initialized the Lisp 2400 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
2255 engine. */ 2401 engine. */
2256
2257 if (initialized)
2258 init_eval_semi_early ();
2259
2260 #ifdef MULE
2261 init_mule_charset ();
2262 #endif
2263 2402
2264 /* Now do further initialization/setup of stuff that is not needed by the 2403 /* Now do further initialization/setup of stuff that is not needed by the
2265 syms_of_() routines. This involves stuff that only is enabled in 2404 syms_of_() routines. This involves stuff that only is enabled in
2266 an interactive run (redisplay, user input, etc.) and stuff that is 2405 an interactive run (redisplay, user input, etc.) and stuff that is
2267 not needed until we start loading Lisp code (the reader). A lot 2406 not needed until we start loading Lisp code (the reader). A lot
2268 of this stuff involves querying the current environment and needs 2407 of this stuff involves querying the current environment and needs
2269 to be done both at dump time and at run time. Some will be done 2408 to be done both at dump time and at run time. Some will be done
2270 only at run time, by querying the `initialized' variable. */ 2409 only at run time, by querying the `initialized' variable.
2410
2411 The ordering of these functions is critical, especially the early ones,
2412 where there is typically a dependency from each to the previous.
2413 */
2271 2414
2272 #ifdef WIN32_ANY 2415 #ifdef WIN32_ANY
2273 init_intl_win32 (); /* Under Windows, determine whether we use Unicode 2416 init_intl_win32 (); /* Under Windows, determine whether we use Unicode
2274 or ANSI to call the system routines -- i.e. 2417 or ANSI to call the system routines -- i.e.
2275 determine what the coding system `mswindows-tstr' 2418 determine what the coding system `mswindows-tstr'
2308 This must be done before the Lisp reader is set up. */ 2451 This must be done before the Lisp reader is set up. */
2309 init_number (); 2452 init_number ();
2310 #endif 2453 #endif
2311 2454
2312 init_lread (); /* Set up the Lisp reader. */ 2455 init_lread (); /* Set up the Lisp reader. */
2313 init_cmdargs (argc, (Extbyte **) argv, 2456 init_cmdargs (argc, argv, skip_args); /* Create list Vcommand_line_args */
2314 skip_args); /* Create list Vcommand_line_args */
2315 init_buffer_2 (); /* Set default directory of *scratch* buffer */ 2457 init_buffer_2 (); /* Set default directory of *scratch* buffer */
2316 2458
2317 #ifdef WIN32_NATIVE 2459 #ifdef WIN32_NATIVE
2318 init_nt (); 2460 init_nt ();
2319 init_select_mswindows (); 2461 init_select_mswindows ();
2388 2530
2389 load_me = Qnil; 2531 load_me = Qnil;
2390 if (!initialized) 2532 if (!initialized)
2391 { 2533 {
2392 /* Handle -l loadup-and-dump, args passed by Makefile. */ 2534 /* Handle -l loadup-and-dump, args passed by Makefile. */
2393 if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l")) 2535 if (argc > 2 + skip_args &&
2394 /* !!#### need to be Mule-translating this, but later */ 2536 !wext_strcmp_ascii (argv[1 + skip_args], "-l"))
2395 load_me = build_string (argv[2 + skip_args]); 2537 load_me = build_wext_string (argv[2 + skip_args],
2538 Qcommand_argument_encoding);
2396 } 2539 }
2397 2540
2398 #ifdef QUANTIFY 2541 #ifdef QUANTIFY
2399 if (initialized) 2542 if (initialized)
2400 quantify_start_recording_data (); 2543 quantify_start_recording_data ();
2401 #endif /* QUANTIFY */ 2544 #endif /* QUANTIFY */
2402 2545
2403 initialized = 1; 2546 initialized = 1;
2404 inhibit_non_essential_printing_operations = 0;
2405 2547
2406 /* This never returns. */ 2548 /* This never returns. */
2407 initial_command_loop (load_me); 2549 initial_command_loop (load_me);
2408 /* NOTREACHED */ 2550 /* NOTREACHED */
2409 } 2551 }
2414 2556
2415 /* First, here's a table of all the standard options. */ 2557 /* First, here's a table of all the standard options. */
2416 2558
2417 struct standard_args 2559 struct standard_args
2418 { 2560 {
2419 const char *name; 2561 const Ascbyte *name;
2420 const char *longname; 2562 const Ascbyte *longname;
2421 int priority; 2563 int priority;
2422 int nargs; 2564 int nargs;
2423 }; 2565 };
2424 2566
2425 static const struct standard_args standard_args[] = 2567 static const struct standard_args standard_args[] =
2510 so that the highest priority ones come first. 2652 so that the highest priority ones come first.
2511 Do not change the order of elements of equal priority. 2653 Do not change the order of elements of equal priority.
2512 If an option takes an argument, keep it and its argument together. */ 2654 If an option takes an argument, keep it and its argument together. */
2513 2655
2514 static void 2656 static void
2515 sort_args (int argc, char **argv) 2657 sort_args (int argc, Wexttext **argv)
2516 { 2658 {
2517 char **new_argv = xnew_array (char *, argc); 2659 Wexttext **new_argv = xnew_array (Wexttext *, argc);
2518 /* For each element of argv, 2660 /* For each element of argv,
2519 the corresponding element of options is: 2661 the corresponding element of options is:
2520 0 for an option that takes no arguments, 2662 0 for an option that takes no arguments,
2521 1 for an option that takes one argument, etc. 2663 1 for an option that takes one argument, etc.
2522 -1 for an ordinary non-option argument. */ 2664 -1 for an ordinary non-option argument. */
2532 for (from = 1; from < argc; from++) 2674 for (from = 1; from < argc; from++)
2533 { 2675 {
2534 options[from] = -1; 2676 options[from] = -1;
2535 priority[from] = 0; 2677 priority[from] = 0;
2536 /* Pseudo options "--" and "run-temacs" indicate end of options */ 2678 /* Pseudo options "--" and "run-temacs" indicate end of options */
2537 if (!strcmp (argv[from], "--") || 2679 if (!wext_strcmp_ascii (argv[from], "--") ||
2538 !strcmp (argv[from], "run-temacs")) 2680 !wext_strcmp_ascii (argv[from], "run-temacs"))
2539 end_of_options_p = 1; 2681 end_of_options_p = 1;
2540 if (!end_of_options_p && argv[from][0] == '-') 2682 if (!end_of_options_p && argv[from][0] == '-')
2541 { 2683 {
2542 int match, thislen; 2684 int match;
2543 char *equals; 2685 Charcount thislen;
2686 Wexttext *equals;
2544 2687
2545 /* Look for a match with a known old-fashioned option. */ 2688 /* Look for a match with a known old-fashioned option. */
2546 for (i = 0; i < countof (standard_args); i++) 2689 for (i = 0; i < countof (standard_args); i++)
2547 if (!strcmp (argv[from], standard_args[i].name)) 2690 if (!wext_strcmp_ascii (argv[from], standard_args[i].name))
2548 { 2691 {
2549 options[from] = standard_args[i].nargs; 2692 options[from] = standard_args[i].nargs;
2550 priority[from] = standard_args[i].priority; 2693 priority[from] = standard_args[i].priority;
2551 if (from + standard_args[i].nargs >= argc) 2694 if (from + standard_args[i].nargs >= argc)
2552 fatal ("Option `%s' requires an argument\n", argv[from]); 2695 fatal ("Option `%s' requires an argument\n",
2696 WEXTTEXT_TO_8_BIT (argv[from]));
2553 from += standard_args[i].nargs; 2697 from += standard_args[i].nargs;
2554 goto done; 2698 goto done;
2555 } 2699 }
2556 2700
2557 /* Look for a match with a known long option. 2701 /* Look for a match with a known long option.
2558 MATCH is -1 if no match so far, -2 if two or more matches so far, 2702 MATCH is -1 if no match so far, -2 if two or more matches so far,
2559 >= 0 (the table index of the match) if just one match so far. */ 2703 >= 0 (the table index of the match) if just one match so far. */
2560 if (argv[from][1] == '-') 2704 if (argv[from][1] == '-')
2561 { 2705 {
2562 match = -1; 2706 match = -1;
2563 thislen = strlen (argv[from]); 2707 thislen = wext_strlen (argv[from]);
2564 equals = strchr (argv[from], '='); 2708 equals = wext_strchr (argv[from], '=');
2565 if (equals != 0) 2709 if (equals != 0)
2566 thislen = equals - argv[from]; 2710 thislen = equals - argv[from];
2567 2711
2568 for (i = 0; i < countof (standard_args); i++) 2712 for (i = 0; i < countof (standard_args); i++)
2569 if (standard_args[i].longname 2713 if (standard_args[i].longname
2570 && !strncmp (argv[from], standard_args[i].longname, 2714 && !wext_strncmp_ascii (argv[from],
2571 thislen)) 2715 standard_args[i].longname,
2716 thislen))
2572 { 2717 {
2573 if (match == -1) 2718 if (match == -1)
2574 match = i; 2719 match = i;
2575 else 2720 else
2576 match = -2; 2721 match = -2;
2584 /* If --OPTION=VALUE syntax is used, 2729 /* If --OPTION=VALUE syntax is used,
2585 this option uses just one argv element. */ 2730 this option uses just one argv element. */
2586 if (equals != 0) 2731 if (equals != 0)
2587 options[from] = 0; 2732 options[from] = 0;
2588 if (from + options[from] >= argc) 2733 if (from + options[from] >= argc)
2589 fatal ("Option `%s' requires an argument\n", argv[from]); 2734 fatal ("Option `%s' requires an argument\n",
2735 WEXTTEXT_TO_8_BIT (argv[from]));
2590 from += options[from]; 2736 from += options[from];
2591 } 2737 }
2592 } 2738 }
2593 done: ; 2739 done: ;
2594 } 2740 }
2628 argv[best] = 0; 2774 argv[best] = 0;
2629 for (i = 0; i < options[best]; i++) 2775 for (i = 0; i < options[best]; i++)
2630 argv[best + i + 1] = 0; 2776 argv[best + i + 1] = 0;
2631 } 2777 }
2632 2778
2633 memcpy (argv, new_argv, sizeof (char *) * argc); 2779 memcpy (argv, new_argv, sizeof (Wexttext *) * argc);
2634 xfree (new_argv, char **); 2780 xfree (new_argv, Wexttext **);
2635 xfree (options, int *); 2781 xfree (options, int *);
2636 xfree (priority, int *); 2782 xfree (priority, int *);
2637 } 2783 }
2638 2784
2639 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /* 2785 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
2702 2848
2703 Martin thinks this function is most useful when using debugging 2849 Martin thinks this function is most useful when using debugging
2704 tools like Purify or tcov that get confused by XEmacs' dumping. */ 2850 tools like Purify or tcov that get confused by XEmacs' dumping. */
2705 (int nargs, Lisp_Object *args)) 2851 (int nargs, Lisp_Object *args))
2706 { 2852 {
2707 int ac; 2853 int i;
2708 const Extbyte *wampum;
2709 int namesize;
2710 int total_len;
2711 Lisp_Object orig_invoc_name = Fcar (Vcommand_line_args);
2712 const Extbyte **wampum_all = alloca_array (const Extbyte *, nargs);
2713 int *wampum_all_len = alloca_array (int, nargs);
2714 2854
2715 assert (!gc_in_progress); 2855 assert (!gc_in_progress);
2716 2856
2717 if (run_temacs_argc < 0) 2857 if (run_temacs_argc < 0)
2718 invalid_operation ("I've lost my temacs-hood.", Qunbound); 2858 invalid_operation ("I've lost my temacs-hood", Qunbound);
2719 2859
2720 /* Need to convert the orig_invoc_name and all of the arguments 2860 run_temacs_argc = nargs + 1;
2721 to external format. */ 2861 run_temacs_argv = xnew_array (Wexttext *, nargs + 2);
2722 2862
2723 TO_EXTERNAL_FORMAT (LISP_STRING, orig_invoc_name, 2863 LISP_STRING_TO_EXTERNAL_MALLOC (Fcar (Vcommand_line_args),
2724 ALLOCA, (wampum, namesize), 2864 run_temacs_argv[0],
2725 Qnative); 2865 Qcommand_argument_encoding);
2726 namesize++; 2866 for (i = 0; i < nargs; i++)
2727
2728 for (ac = 0, total_len = namesize; ac < nargs; ac++)
2729 { 2867 {
2730 CHECK_STRING (args[ac]); 2868 CHECK_STRING (args[i]);
2731 TO_EXTERNAL_FORMAT (LISP_STRING, args[ac], 2869
2732 ALLOCA, (wampum_all[ac], wampum_all_len[ac]), 2870 LISP_STRING_TO_EXTERNAL_MALLOC (args[i], run_temacs_argv[i + 1],
2733 Qnative); 2871 Qcommand_argument_encoding);
2734 wampum_all_len[ac]++;
2735 total_len += wampum_all_len[ac];
2736 } 2872 }
2737 DO_REALLOC (run_temacs_args, run_temacs_args_size, total_len, char); 2873 run_temacs_argv[nargs + 1] = 0;
2738 DO_REALLOC (run_temacs_argv, run_temacs_argv_size, nargs+2, char *); 2874
2739
2740 memcpy (run_temacs_args, wampum, namesize);
2741 run_temacs_argv [0] = run_temacs_args;
2742 for (ac = 0; ac < nargs; ac++)
2743 {
2744 memcpy (run_temacs_args + namesize,
2745 wampum_all[ac], wampum_all_len[ac]);
2746 run_temacs_argv [ac + 1] = run_temacs_args + namesize;
2747 namesize += wampum_all_len[ac];
2748 }
2749 run_temacs_argv [nargs + 1] = 0;
2750 catchlist = NULL; /* Important! Otherwise free_cons() calls in 2875 catchlist = NULL; /* Important! Otherwise free_cons() calls in
2751 condition_case_unwind() may lead to GC death. */ 2876 condition_case_unwind() may lead to GC death. */
2752 unbind_to (0); /* this closes loadup.el */ 2877 unbind_to (0); /* this closes loadup.el */
2753 purify_flag = 0; 2878 purify_flag = 0;
2754 run_temacs_argc = nargs + 1;
2755 #if defined (HEAP_IN_DATA) && !defined (PDUMP) 2879 #if defined (HEAP_IN_DATA) && !defined (PDUMP)
2756 report_sheap_usage (0); 2880 report_sheap_usage (0);
2757 #endif 2881 #endif
2758 2882
2759 /* run-temacs usually only occurs as a result of building, and in all such 2883 /* run-temacs usually only occurs as a result of building, and in all such
2765 RETURN_NOT_REACHED (Qnil); 2889 RETURN_NOT_REACHED (Qnil);
2766 } 2890 }
2767 2891
2768 /* ARGSUSED */ 2892 /* ARGSUSED */
2769 int 2893 int
2770 main (int argc, char **argv, char **envp) 2894 main (int argc, Extbyte **argv, Extbyte **UNUSED (envp))
2771 { 2895 {
2772 2896
2773 #ifdef _MSC_VER 2897 #ifdef _MSC_VER
2774 /* Under VC++, access violations and the like are not sent through 2898 /* Under VC++, access violations and the like are not sent through
2775 the standard signal() mechanism. Rather, they need to be handled 2899 the standard signal() mechanism. Rather, they need to be handled
2778 __try 2902 __try
2779 { 2903 {
2780 #endif 2904 #endif
2781 2905
2782 int volatile vol_argc = argc; 2906 int volatile vol_argc = argc;
2783 char ** volatile vol_argv = argv; 2907 Wexttext ** volatile vol_argv;
2784 char ** volatile vol_envp = envp;
2785 /* This is hairy. We need to compute where the XEmacs binary was invoked 2908 /* This is hairy. We need to compute where the XEmacs binary was invoked
2786 from because temacs initialization requires it to find the lisp 2909 from because temacs initialization requires it to find the lisp
2787 directories. The code that recomputes the path is guarded by the 2910 directories. The code that recomputes the path is guarded by the
2788 restarted flag. There are three possible paths I've found so far 2911 restarted flag. There are three possible paths I've found so far
2789 through this: 2912 through this:
2813 #ifdef QUANTIFY 2936 #ifdef QUANTIFY
2814 quantify_stop_recording_data (); 2937 quantify_stop_recording_data ();
2815 quantify_clear_data (); 2938 quantify_clear_data ();
2816 #endif /* QUANTIFY */ 2939 #endif /* QUANTIFY */
2817 2940
2818 inhibit_non_essential_printing_operations = 1; 2941 inhibit_non_essential_conversion_operations = 1;
2819 suppress_early_error_handler_backtrace = 0; 2942 suppress_early_error_handler_backtrace = 0;
2820 lim_data = 0; /* force reinitialization of this variable */ 2943 lim_data = 0; /* force reinitialization of this variable */
2821 2944
2822 /* Lisp_Object must fit in a word; check VALBITS and GCTYPEBITS */ 2945 /* Lisp_Object must fit in a word; check VALBITS and GCTYPEBITS */
2823 assert (sizeof (Lisp_Object) == sizeof (void *)); 2946 assert (sizeof (Lisp_Object) == sizeof (void *));
2824 2947
2825 #ifdef LINUX_SBRK_BUG 2948 #ifdef LINUX_SBRK_BUG
2826 sbrk (1); 2949 sbrk (1);
2827 #endif 2950 #endif
2951
2952 #ifdef WIN32_ANY
2953 /* Figure out which version we're running so XEUNICODE_P works */
2954 init_win32_very_very_early ();
2955 #endif
2956
2957 #ifdef WIN32_NATIVE
2958 #if 0
2959 /* !!#### We should be doing something like this, but this messes up
2960 globbing. I tried using wmain() and linking with WSETARGV, but the
2961 routines for WSETARGV are left out of MSVCRT.DLL!
2962
2963 To fix this we need to copy the argument-expanding and globbing code
2964 from Cygwin and Unicode-ize it. Yuck. */
2965 if (XEUNICODE_P)
2966 /* Set up Unicode versions of the arguments. */
2967 vol_argv = CommandLineToArgvW (GetCommandLineW (), &vol_argc);
2968 #else
2969 {
2970 int i;
2971
2972 vol_argv = alloca_array (Wexttext *, argc);
2973 for (i = 0; i < argc; i++)
2974 vol_argv[i] = MULTIBYTE_TO_WEXTTEXT (argv[i]);
2975 }
2976 #endif
2977 #else
2978 vol_argv = (Wexttext **) argv;
2979 #endif /* WIN32_NATIVE */
2828 2980
2829 if (!initialized) 2981 if (!initialized)
2830 { 2982 {
2831 #ifdef DOUG_LEA_MALLOC 2983 #ifdef DOUG_LEA_MALLOC
2832 mallopt (M_MMAP_MAX, 0); 2984 mallopt (M_MMAP_MAX, 0);
2833 #endif 2985 #endif
2834 run_temacs_argc = 0; 2986 run_temacs_argc = 0;
2835 if (! SETJMP (run_temacs_catch)) 2987 if (! SETJMP (run_temacs_catch))
2836 { 2988 {
2837 main_1 (vol_argc, vol_argv, vol_envp, 0); 2989 main_1 (vol_argc, vol_argv, NULL, 0);
2838 } 2990 }
2839 /* run-emacs-from-temacs called */ 2991 /* run-emacs-from-temacs called */
2840 restarted = 1; 2992 restarted = 1;
2841 vol_argc = run_temacs_argc; 2993 vol_argc = run_temacs_argc;
2842 vol_argv = run_temacs_argv; 2994 vol_argv = run_temacs_argv;
2853 is bracketed with both a system specific preprocessor test 3005 is bracketed with both a system specific preprocessor test
2854 and a runtime "do you have this problem" test 3006 and a runtime "do you have this problem" test
2855 3007
2856 06/20/96 robertl@dgii.com */ 3008 06/20/96 robertl@dgii.com */
2857 { 3009 {
2858 extern char **_environ; 3010 extern Extbyte *_environ;
2859 if ((unsigned) environ == 0) 3011 if (environ == NULL)
2860 environ = _environ; 3012 environ = _environ;
2861 } 3013 }
2862 #endif /* _SCO_DS */ 3014 #endif /* _SCO_DS */
2863 vol_envp = environ;
2864 } 3015 }
2865 #if defined (RUN_TIME_REMAP) && ! defined (PDUMP) 3016 #if defined (RUN_TIME_REMAP) && ! defined (PDUMP)
2866 else 3017 else
2867 /* obviously no-one uses this because where it was before initialized was 3018 /* obviously no-one uses this because where it was before initialized was
2868 *always* true */ 3019 *always* true */
2894 } 3045 }
2895 #endif /* DOUG_LEA_MALLOC */ 3046 #endif /* DOUG_LEA_MALLOC */
2896 3047
2897 run_temacs_argc = -2; 3048 run_temacs_argc = -2;
2898 3049
2899 main_1 (vol_argc, vol_argv, vol_envp, restarted); 3050 main_1 (vol_argc, vol_argv, NULL, restarted);
2900 3051
2901 #ifdef _MSC_VER 3052 #ifdef _MSC_VER
2902 } 3053 }
2903 /* VC++ documentation says that 3054 /* VC++ documentation says that
2904 GetExceptionCode() cannot be called inside the filter itself. */ 3055 GetExceptionCode() cannot be called inside the filter itself. */
2912 /************************************************************************/ 3063 /************************************************************************/
2913 /* dumping XEmacs (to a new EXE file) */ 3064 /* dumping XEmacs (to a new EXE file) */
2914 /************************************************************************/ 3065 /************************************************************************/
2915 3066
2916 #if !defined (PDUMP) || !defined (SYSTEM_MALLOC) 3067 #if !defined (PDUMP) || !defined (SYSTEM_MALLOC)
2917 extern Char_Binary my_edata[]; 3068 extern Rawbyte my_edata[];
2918 #endif 3069 #endif
2919 3070
2920 extern void disable_free_hook (void); 3071 extern void disable_free_hook (void);
2921 3072
2922 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /* 3073 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /*
3020 3171
3021 /************************************************************************/ 3172 /************************************************************************/
3022 /* exiting XEmacs (intended or not) */ 3173 /* exiting XEmacs (intended or not) */
3023 /************************************************************************/ 3174 /************************************************************************/
3024 3175
3025 /* Ben's capsule summary about expected and unexpected exits from XEmacs. 3176 /*
3026 3177
3027 Expected exits occur when the user directs XEmacs to exit, for example 3178 Info on intended/unintended exits:
3028 by pressing the close button on the only frame in XEmacs, or by typing 3179
3029 C-x C-c. This runs `save-buffers-kill-emacs', which saves any necessary 3180 (Info-goto-node "(internals)Exiting")
3030 buffers, and then exits using the primitive `kill-emacs'.
3031
3032 However, unexpected exits occur in a few different ways:
3033
3034 -- a memory access violation or other hardware-generated exception
3035 occurs. This is the worst possible problem to deal with, because
3036 the fault can occur while XEmacs is in any state whatsoever, even
3037 quite unstable ones. As a result, we need to be *extremely* careful
3038 what we do.
3039 -- we are using one X display (or if we've used more, we've closed the
3040 others already), and some hardware or other problem happens and
3041 suddenly we've lost our connection to the display. In this situation,
3042 things are not so dire as in the last one; our code itself isn't
3043 trashed, so we can continue execution as normal, after having set
3044 things up so that we can exit at the appropriate time. Our exit
3045 still needs to be of the emergency nature; we have no displays, so
3046 any attempts to use them will fail. We simply want to auto-save
3047 (the single most important thing to do during shut-down), do minimal
3048 cleanup of stuff that has an independent existence outside of XEmacs,
3049 and exit.
3050
3051 Currently, both unexpected exit scenarios described above set
3052 preparing_for_armageddon to indicate that nonessential and possibly
3053 dangerous things should not be done, specifically:
3054
3055 -- no garbage collection.
3056 -- no hooks are run.
3057 -- no messages of any sort from autosaving.
3058 -- autosaving tries harder, ignoring certain failures.
3059 -- existing frames are not deleted.
3060
3061 (Also, all places that set preparing_for_armageddon also
3062 set dont_check_for_quit. This happens separately because it's
3063 also necessary to set other variables to make absolutely sure
3064 no quitting happens.)
3065
3066 In the first scenario above (the access violation), we also set
3067 fatal_error_in_progress. This causes more things to not happen:
3068
3069 -- assertion failures do not abort.
3070 -- printing code does not do code conversion or gettext when
3071 printing to stdout/stderr.
3072 */ 3181 */
3073 3182
3074 /* ------------------------------- */ 3183 /* ------------------------------- */
3075 /* low-level debugging functions */ 3184 /* low-level debugging functions */
3076 /* ------------------------------- */ 3185 /* ------------------------------- */
3129 3238
3130 if (len > 1) 3239 if (len > 1)
3131 /* If we can, try to avoid problems with super-optimizing compilers 3240 /* If we can, try to avoid problems with super-optimizing compilers
3132 that might decide that memcmp (ptr, ptr, len) can be optimized 3241 that might decide that memcmp (ptr, ptr, len) can be optimized
3133 away since its result is always 1. */ 3242 away since its result is always 1. */
3134 memcmp (ptr, (char *) ptr + 1, len - 1); 3243 memcmp (ptr, (Rawbyte *) ptr + 1, len - 1);
3135 else 3244 else
3136 memcmp (ptr, ptr, len); 3245 memcmp (ptr, ptr, len);
3137 } 3246 }
3138 else 3247 else
3139 retval = 0; 3248 retval = 0;
3313 " gdb " 3422 " gdb "
3314 #endif 3423 #endif
3315 ); 3424 );
3316 #ifndef _MSC_VER 3425 #ifndef _MSC_VER
3317 { 3426 {
3318 const char *name; 3427 const Ibyte *name;
3319 char *dir = 0; 3428 Ibyte *dir = 0;
3320 3429
3321 /* Now try to determine the actual path to the executable, 3430 /* Now try to determine the actual path to the executable,
3322 to try to make the backtrace-determination process as foolproof 3431 to try to make the backtrace-determination process as foolproof
3323 as possible. */ 3432 as possible. */
3324 if (STRINGP (Vinvocation_name)) 3433 if (STRINGP (Vinvocation_name))
3325 name = (char *) XSTRING_DATA (Vinvocation_name); 3434 name = XSTRING_DATA (Vinvocation_name);
3326 else 3435 else
3327 name = "xemacs"; 3436 name = (const Ibyte *) "xemacs";
3328 if (STRINGP (Vinvocation_directory)) 3437 if (STRINGP (Vinvocation_directory))
3329 dir = (char *) XSTRING_DATA (Vinvocation_directory); 3438 dir = XSTRING_DATA (Vinvocation_directory);
3330 if (!dir || dir[0] != '/') 3439 if (!dir || dir[0] != '/')
3331 stderr_out ("`which %s`", name); 3440 stderr_out ("`which %s`", name);
3332 else if (dir[strlen (dir) - 1] != '/') 3441 else if (dir[qxestrlen (dir) - 1] != '/')
3333 stderr_out ("%s/%s", dir, name); 3442 stderr_out ("%s/%s", dir, name);
3334 else 3443 else
3335 stderr_out ("%s%s", dir, name); 3444 stderr_out ("%s%s", dir, name);
3336 } 3445 }
3337 stderr_out 3446 stderr_out
3474 /* Handle bus errors, illegal instruction, etc: actual implementation. */ 3583 /* Handle bus errors, illegal instruction, etc: actual implementation. */
3475 static void 3584 static void
3476 guts_of_fatal_error_signal (int sig) 3585 guts_of_fatal_error_signal (int sig)
3477 { 3586 {
3478 fatal_error_in_progress++; 3587 fatal_error_in_progress++;
3479 inhibit_non_essential_printing_operations = 1; 3588 inhibit_non_essential_conversion_operations = 1;
3480 preparing_for_armageddon = 1; 3589 preparing_for_armageddon = 1;
3481 3590
3482 ensure_no_quitting_from_now_on (); 3591 ensure_no_quitting_from_now_on ();
3483 3592
3484 /* Only try auto-saving first time through. If we crash in auto-saving, 3593 /* Only try auto-saving first time through. If we crash in auto-saving,
3509 stderr_out ("\nLisp backtrace follows:\n\n"); 3618 stderr_out ("\nLisp backtrace follows:\n\n");
3510 debug_backtrace (); 3619 debug_backtrace ();
3511 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */ 3620 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */
3512 /* Check for Sun-style stack printing via /proc */ 3621 /* Check for Sun-style stack printing via /proc */
3513 { 3622 {
3514 const Char_ASCII *pstack = "/usr/proc/bin/pstack"; 3623 const Ascbyte *pstack = "/usr/proc/bin/pstack";
3515 if (access (pstack, X_OK) == 0) 3624 if (access (pstack, X_OK) == 0)
3516 { 3625 {
3517 Char_ASCII buf[100]; 3626 Ascbyte buf[100];
3518 stderr_out ("\nC backtrace follows:\n" 3627 stderr_out ("\nC backtrace follows:\n"
3519 "(A real debugger may provide better information)\n\n"); 3628 "(A real debugger may provide better information)\n\n");
3520 sprintf (buf, "%s %d >&2", pstack, (int)getpid()); 3629 sprintf (buf, "%s %d >&2", pstack, (int) getpid());
3521 system (buf); 3630 system (buf);
3522 } 3631 }
3523 } 3632 }
3524 # endif 3633 # endif
3525 #if defined (HAVE_MS_WINDOWS) && !defined (USER_IS_DEVELOPING_XEMACS) 3634 #if defined (HAVE_MS_WINDOWS) && !defined (USER_IS_DEVELOPING_XEMACS)
3555 #define STATUS_ASSERTION_FAILURE 0xE0000001 3664 #define STATUS_ASSERTION_FAILURE 0xE0000001
3556 3665
3557 static DWORD 3666 static DWORD
3558 mswindows_handle_hardware_exceptions_1 (void) 3667 mswindows_handle_hardware_exceptions_1 (void)
3559 { 3668 {
3560 inhibit_non_essential_printing_operations = 1; 3669 inhibit_non_essential_conversion_operations = 1;
3561 preparing_for_armageddon = 1; 3670 preparing_for_armageddon = 1;
3562 #if !defined (USER_IS_DEVELOPING_XEMACS) 3671 #if !defined (USER_IS_DEVELOPING_XEMACS)
3563 pause_so_user_can_read_messages (0); 3672 pause_so_user_can_read_messages (0);
3564 #endif 3673 #endif
3565 return EXCEPTION_EXECUTE_HANDLER; 3674 return EXCEPTION_EXECUTE_HANDLER;
3642 3751
3643 /* Nonzero if handling an assertion failure. (Bumped by one each time 3752 /* Nonzero if handling an assertion failure. (Bumped by one each time
3644 we recursively hit such a failure.) */ 3753 we recursively hit such a failure.) */
3645 static int in_assert_failed; 3754 static int in_assert_failed;
3646 3755
3647 static const char *assert_failed_file; 3756 static const Ascbyte *assert_failed_file;
3648 static int assert_failed_line; 3757 static int assert_failed_line;
3649 static const char *assert_failed_expr; 3758 static const Ascbyte *assert_failed_expr;
3650 3759
3651 #ifdef fprintf 3760 #ifdef fprintf
3652 #undef fprintf 3761 #undef fprintf
3653 #endif 3762 #endif
3654 3763
3655 /* This is called when an assert() fails or when abort() is called -- both 3764 /* This is called when an assert() fails or when abort() is called -- both
3656 of those are defined in the preprocessor to an expansion involving 3765 of those are defined in the preprocessor to an expansion involving
3657 assert_failed(). */ 3766 assert_failed(). */
3658 void 3767 void
3659 assert_failed (const char *file, int line, const char *expr) 3768 assert_failed (const Ascbyte *file, int line, const Ascbyte *expr)
3660 { 3769 {
3661 /* If we're already crashing, let's not crash again. This might be 3770 /* If we're already crashing, let's not crash again. This might be
3662 critical to getting auto-saving working properly. */ 3771 critical to getting auto-saving working properly. */
3663 if (fatal_error_in_progress) 3772 if (fatal_error_in_progress)
3664 return; 3773 return;
3665 3774
3666 /* We are extremely paranoid so we sensibly deal with recursive 3775 /* We are extremely paranoid so we sensibly deal with recursive
3667 assertion failures. */ 3776 assertion failures. */
3668 in_assert_failed++; 3777 in_assert_failed++;
3669 inhibit_non_essential_printing_operations = 1; 3778 inhibit_non_essential_conversion_operations = 1;
3670 3779
3671 if (in_assert_failed >= 4) 3780 if (in_assert_failed >= 4)
3672 _exit (-1); 3781 _exit (-1);
3673 else if (in_assert_failed == 3) 3782 else if (in_assert_failed == 3)
3674 { 3783 {
3732 0); */ 3841 0); */
3733 #else 3842 #else
3734 really_abort (); 3843 really_abort ();
3735 #endif /* defined (_MSC_VER) || defined (CYGWIN) */ 3844 #endif /* defined (_MSC_VER) || defined (CYGWIN) */
3736 #endif /* !defined (ASSERTIONS_DONT_ABORT) */ 3845 #endif /* !defined (ASSERTIONS_DONT_ABORT) */
3737 inhibit_non_essential_printing_operations = 0; 3846 inhibit_non_essential_conversion_operations = 0;
3738 in_assert_failed = 0; 3847 in_assert_failed = 0;
3739 } 3848 }
3740 #endif /* USE_ASSERTIONS */ 3849 #endif /* USE_ASSERTIONS */
3741 3850
3742 /* -------------------------------------- */ 3851 /* -------------------------------------- */
4220 For internal use by the build procedure only. 4329 For internal use by the build procedure only.
4221 configure's idea of what `mule-lisp-directory' will be. 4330 configure's idea of what `mule-lisp-directory' will be.
4222 */ ); 4331 */ );
4223 #ifdef PATH_MULELOADSEARCH 4332 #ifdef PATH_MULELOADSEARCH
4224 Vconfigure_mule_lisp_directory = Ffile_name_as_directory 4333 Vconfigure_mule_lisp_directory = Ffile_name_as_directory
4225 (build_string ((char *) PATH_MULELOADSEARCH)); 4334 (build_ext_string (PATH_MULELOADSEARCH, Qfile_name);
4226 #else 4335 #else
4227 Vconfigure_mule_lisp_directory = Qnil; 4336 Vconfigure_mule_lisp_directory = Qnil;
4228 #endif 4337 #endif
4229 4338
4230 DEFVAR_LISP ("module-directory", &Vmodule_directory /* 4339 DEFVAR_LISP ("module-directory", &Vmodule_directory /*