🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1544

Patches for emacs18.58 under NeXT OS3.0

#1544
From: Thomas Funke
Date: Thu, 15 Oct 1992 15:36
929 lines
26311 bytes
Get the original emacs18.58 sources and run

     patch -p < patchfile

After that, become root and do a

	make install

in the emacs dir. 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Beware: The installation is done under /usr/lib/emacs
and will destroy the stuff NeXT has provided !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Have fun !

Here they are:

----------- cut here and save into 'patchfile' --------------------------
diff -rc2Na emacs-18.58/Makefile emacs-18.58-NeXT3.0/Makefile
*** emacs-18.58/Makefile	Thu Oct 15 15:20:37 1992
--- emacs-18.58-NeXT3.0/Makefile	Thu Oct 15 15:44:36 1992
***************
*** 17,23 ****
  # This got changed in late 1991 to say /usr/local/lib/emacs,
  # but there was no explanation of why, so it seems better to keep this stable.
! LIBDIR= /usr/local/emacs
! BINDIR= /usr/local/bin
! MANDIR= /usr/local/man/man1
  
  # Flags passed down to subdirectory makefiles.
--- 17,23 ----
  # This got changed in late 1991 to say /usr/local/lib/emacs,
  # but there was no explanation of why, so it seems better to keep this stable.
! LIBDIR= /usr/lib/emacs
! BINDIR= /usr/bin
! MANDIR= /usr/man/man1
  
  # Flags passed down to subdirectory makefiles.
diff -rc2Na emacs-18.58/lisp/version.el emacs-18.58-NeXT3.0/lisp/version.el
*** emacs-18.58/lisp/version.el	Thu Oct 15 15:21:33 1992
--- emacs-18.58-NeXT3.0/lisp/version.el	Thu Oct 15 15:55:22 1992
***************
*** 21,25 ****
  ;; The following line is modified automatically
  ;; by loading inc-version.el, each time a new Emacs is dumped.
! (defconst emacs-version "18.58.0" "\
  Version numbers of this version of Emacs.")
  
--- 21,25 ----
  ;; The following line is modified automatically
  ;; by loading inc-version.el, each time a new Emacs is dumped.
! (defconst emacs-version "18.58.2" "\
  Version numbers of this version of Emacs.")
  
diff -rc2Na emacs-18.58/src/config.h emacs-18.58-NeXT3.0/src/config.h
*** emacs-18.58/src/config.h
--- emacs-18.58-NeXT3.0/src/config.h	Thu Oct 15 15:37:38 1992
***************
*** 0 ****
--- 1,110 ----
+ /* GNU Emacs site configuration template file.
+    Copyright (C) 1988 Free Software Foundation, Inc.
+ 
+ This file is part of GNU Emacs.
+ 
+ GNU Emacs is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ 
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU Emacs; see the file COPYING.  If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+ 
+ 
+ 
+ /* Include here a s- file that describes the system type you are using.
+    See the file ../etc/MACHINES for a list of systems and
+    the names of the s- files to use for them.
+    See s-template.h for documentation on writing s- files.  */
+ #include "s-mach.h"
+ 
+ /* Include here a m- file that describes the machine and system you use.
+    See the file ../etc/MACHINES for a list of machines and
+    the names of the m- files to use for them.
+    See m-template.h for info on what m- files should define.
+    */
+ #include "m-NeXT.h"
+ 
+ /* Load in the conversion definitions if this system
+    needs them and the source file being compiled has not
+    said to inhibit this.  There should be no need for you
+    to alter these lines.  */
+ 
+ #ifdef SHORTNAMES
+ #ifndef NO_SHORTNAMES
+ #include "../shortnames/remap.h"
+ #endif /* not NO_SHORTNAMES */
+ #endif /* SHORTNAMES */
+ 
+ /* Define HAVE_X_WINDOWS if you want to use the X window system.  */
+ 
+ /* #define HAVE_X_WINDOWS */
+ 
+ /* Define X11 if you want to use version 11 of X windows.
+    Otherwise, Emacs expects to use version 10.  */
+ 
+ #ifdef HAVE_X_WINDOWS
+ #define X11
+ #endif
+ 
+ /* Define HAVE_X_MENU if you want to use the X window menu system.
+    This appears to work on some machines that support X
+    and not on others.  */
+ 
+ /* #define HAVE_X_MENU */
+ 
+ /* Define `subprocesses' should be defined if you want to
+    have code for asynchronous subprocesses
+    (as used in M-x compile and M-x shell).
+    These do not work for some USG systems yet;
+    for the ones where they work, the s-*.h file defines this flag.  */
+ 
+ #ifndef VMS
+ #ifndef USG
+ #define subprocesses
+ #endif
+ #endif
+ 
+ /* Define USER_FULL_NAME to return a string
+    that is the user's full name.
+    It can assume that the variable `pw'
+    points to the password file entry for this user.
+ 
+    At some sites, the pw_gecos field contains
+    the user's full name.  If neither this nor any other
+    field contains the right thing, use pw_name,
+    giving the user's login name, since that is better than nothing.  */
+ 
+ #define USER_FULL_NAME pw->pw_gecos
+ 
+ /* Define AMPERSAND_FULL_NAME if you use the convention
+    that & in the full name stands for the login id.  */
+ 
+ /* #define AMPERSAND_FULL_NAME */
+ 
+ /* # bytes of pure Lisp code to leave space for.
+    Note that s-vms.h and m-sun2.h may override this default.  */
+ 
+ #ifndef PURESIZE
+ #ifdef HAVE_X_WINDOWS
+ #define PURESIZE 122000
+ #else
+ #define PURESIZE 120000
+ #endif
+ #endif
+ 
+ /* Define HIGHPRI as a negative number
+    if you want Emacs to run at a higher than normal priority.
+    For this to take effect, you must install Emacs with setuid root.
+    Emacs will change back to the users's own uid after setting
+    its priority.  */
+ 
+ /* #define HIGHPRI */
+ 
diff -rc2Na emacs-18.58/src/emacs.c emacs-18.58-NeXT3.0/src/emacs.c
*** emacs-18.58/src/emacs.c	Thu Oct 15 15:22:19 1992
--- emacs-18.58-NeXT3.0/src/emacs.c	Thu Oct 15 15:37:31 1992
***************
*** 211,214 ****
--- 211,218 ----
  #endif /* VMS */
  
+ #ifdef NeXT
+ int malloc_cookie;
+ #endif /* NeXT */
+ 
  /* ARGSUSED */
  main (argc, argv, envp)
***************
*** 220,223 ****
--- 224,234 ----
    extern int errno;
    extern void malloc_warning ();
+ 
+ #ifdef NeXT
+    /* this helps out unexNeXT.c */
+    if (initialized)
+      if (malloc_jumpstart(malloc_cookie) != 0)
+        printf("malloc jumpstart failed!\n");
+ #endif /* NeXT */
  
  /* Map in shared memory, if we are using that.  */
diff -rc2Na emacs-18.58/src/fns.c emacs-18.58-NeXT3.0/src/fns.c
*** emacs-18.58/src/fns.c	Thu Oct 15 15:22:25 1992
--- emacs-18.58-NeXT3.0/src/fns.c	Thu Oct 15 15:37:32 1992
***************
*** 1228,1233 ****
--- 1228,1238 ----
        nl[1].n_un.n_name = 0;
  #else /* not convex */
+ #ifdef NEXT_KERNEL_FILE
+       nl[0].n_un.n_name = LDAV_SYMBOL;
+       nl[1].n_un.n_name = 0;
+ #else
        nl[0].n_name = LDAV_SYMBOL;
        nl[1].n_name = 0;
+ #endif /* not NEXT_KERNEL_FILE */
  #endif /* not convex */
  #endif /* NLIST_STRUCT */
***************
*** 1241,1245 ****
--- 1246,1254 ----
  	}
  #else
+ #ifdef NEXT_KERNEL_FILE
+       nlist (NEXT_KERNEL_FILE, nl);
+ #else
        nlist (KERNEL_FILE, nl);
+ #endif /* not NEXT_KERNEL_FILE */
  #endif /* IRIS */
  
diff -rc2Na emacs-18.58/src/m-NeXT.h emacs-18.58-NeXT3.0/src/m-NeXT.h
*** emacs-18.58/src/m-NeXT.h
--- emacs-18.58-NeXT3.0/src/m-NeXT.h	Thu Oct 15 15:37:36 1992
***************
*** 0 ****
--- 1,99 ----
+ /* Configuration file for the NeXT machine. */
+ /*    Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+ 
+ This file is part of GNU Emacs.
+ 
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY.  No author or distributor
+ accepts responsibility to anyone for the consequences of using it
+ or for whether it serves any particular purpose or works at all,
+ unless he says so in writing.  Refer to the GNU Emacs General Public
+ License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ GNU Emacs, but only under the conditions described in the
+ GNU Emacs General Public License.   A copy of this license is
+ supposed to have been given to you along with GNU Emacs so you
+ can know your rights and responsibilities.  It should be in a
+ file named COPYING.  Among other things, the copyright notice
+ and this notice must be preserved on all copies.  */
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ /* The following three symbols give information on
+  the size of various data types.  */
+ 
+ #define SHORTBITS 16		/* Number of bits in a short */
+ 
+ #define INTBITS 32		/* Number of bits in an int */
+ 
+ #define LONGBITS 32		/* Number of bits in a long */
+ 
+ /* 68000 has lowest-numbered byte as most significant */
+ 
+ #define BIG_ENDIAN
+ 
+ /* Define how to take a char and sign-extend into an int.
+    On machines where char is signed, this is a no-op.  */
+ 
+ #define SIGN_EXTEND_CHAR(c) (c)
+ 
+ /* Say this machine is a 68000 */
+ 
+ #ifndef m68000
+ #define m68000
+ #endif
+ 
+ /* Use type int rather than a union, to represent Lisp_Object */
+ 
+ #define NO_UNION_TYPE
+ 
+ /* XINT must explicitly sign-extend */
+ 
+ #define EXPLICIT_SIGN_EXTEND
+ 
+ #define LIB_STANDARD -lsys_s
+ 
+ /* Data type of load average, as read out of kmem.  */
+ 
+ #define LOAD_AVE_TYPE long
+ 
+ /* Convert that into an integer that is 100 for a load average of 1.0  */
+ 
+ #define environ _environ
+ 
+ #define NO_REMAP
+ #define UNEXEC unexNeXT.o
+ 
+ #ifndef FSCALE
+ #define FSCALE 256
+ #endif
+ #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
+ 
+ /* Say that the text segment of a.out includes the header;
+    the header actually occupies the first few bytes of the text segment
+    and is counted in hdr.a_text.  */
+ 
+ #define A_TEXT_OFFSET(HDR) sizeof (HDR)
+ 
+ /* #define _setjmp setjmp */
+ /* #define _longjmp longjmp */
+ 
+ /* Use dk.h, not dkstat.h, in loadst.c.  */
+ 
+ #define DK_HEADER_FILE
+ /* Mask for address bits within a memory segment */
+ 
+ #define SEGSIZ 0x20000
+ #define SEGMENT_MASK (SEGSIZ - 1)
+ 
+ #define HAVE_ALLOCA
+ 
+ #define SYSTEM_MALLOC
+ 
+ #define HAVE_UNIX_DOMAIN
+ 
diff -rc2Na emacs-18.58/src/paths.h emacs-18.58-NeXT3.0/src/paths.h
*** emacs-18.58/src/paths.h
--- emacs-18.58-NeXT3.0/src/paths.h	Thu Oct 15 15:54:33 1992
***************
*** 0 ****
--- 1,19 ----
+ /* The default search path for Lisp function "load".
+    This sets load-path.  */
+ #define PATH_LOADSEARCH "/usr/lib/emacs/lisp"
+ 
+ /* the extra search path for programs to invoke.
+  This is appended to whatever the PATH environment variable says
+  to set the Lisp variable exec-path and the first file namein it
+   sets the Lisp variable exec-directory.  */
+ #define PATH_EXEC "/usr/lib/emacs/etc"
+ 
+ /* the name of the directory that contains lock files
+  with which we record what files are being modified in Emacs.
+  This directory should be writable by everyone.
+  THE STRING MUST END WITH A SLASH!!!  */
+ #define PATH_LOCK "/usr/lib/emacs/lock/"
+ 
+ /* the name of the file !!!SuperLock!!! in the directory
+  specified by PATH_LOCK.  Yes, this is redundant.  */
+ #define PATH_SUPERLOCK "/usr/lib/emacs/lock/!!!SuperLock!!!"
diff -rc2Na emacs-18.58/src/s-mach.h emacs-18.58-NeXT3.0/src/s-mach.h
*** emacs-18.58/src/s-mach.h
--- emacs-18.58-NeXT3.0/src/s-mach.h	Thu Oct 15 15:37:37 1992
***************
*** 0 ****
--- 1,28 ----
+ /* Definitions file for GNU Emacs running on bsd 4.3
+    Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+ 
+ This file is part of GNU Emacs.
+ 
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY.  No author or distributor
+ accepts responsibility to anyone for the consequences of using it
+ or for whether it serves any particular purpose or works at all,
+ unless he says so in writing.  Refer to the GNU Emacs General Public
+ License for full details.
+ 
+ Everyone is granted permission to copy, modify and redistribute
+ GNU Emacs, but only under the conditions described in the
+ GNU Emacs General Public License.   A copy of this license is
+ supposed to have been given to you along with GNU Emacs so you
+ can know your rights and responsibilities.  It should be in a
+ file named COPYING.  Among other things, the copyright notice
+ and this notice must be preserved on all copies.  */
+ 
+ 
+ #include "s-bsd4-3.h"
+ #define NEXT_KERNEL_FILE "/mach"
+ /* #define NEXT_KERNEL_FILE "/vmunix" */
+ #undef KERNEL_FILE
+ 
+ #define LD_SWITCH_SYSTEM -X -noseglinkedit
+ 
diff -rc2Na emacs-18.58/src/sysdep.c emacs-18.58-NeXT3.0/src/sysdep.c
*** emacs-18.58/src/sysdep.c	Thu Oct 15 15:23:18 1992
--- emacs-18.58-NeXT3.0/src/sysdep.c	Thu Oct 15 15:37:33 1992
***************
*** 1573,1578 ****
--- 1573,1582 ----
    return ((char *) csrt);
  #else /* not GOULD */
+ #ifdef NeXT
+   return ((char *)0); /* wrong: but nobody uses it anyway */
+ #else
    extern int _start ();
    return ((char *) _start);
+ #endif /* NeXT */
  #endif /* GOULD */
  #endif /* TEXT_START */
***************
*** 1632,1636 ****
--- 1636,1646 ----
    return ((char *) TEXT_END);
  #else
+ #ifdef __NeXT__
+   static int etext;
+ 
+   etext = get_etext();
+ #else
    extern int etext;
+ #endif
    return ((char *) &etext);
  #endif
***************
*** 1648,1652 ****
--- 1658,1668 ----
    return ((char *) DATA_END);
  #else
+ #ifdef __NeXT__
+   static int edata;
+ 
+   edata = get_edata();
+ #else
    extern int edata;
+ #endif
    return ((char *) &edata);
  #endif
diff -rc2Na emacs-18.58/src/unexNeXT.c emacs-18.58-NeXT3.0/src/unexNeXT.c
*** emacs-18.58/src/unexNeXT.c
--- emacs-18.58-NeXT3.0/src/unexNeXT.c	Thu Oct 15 15:51:22 1992
***************
*** 0 ****
--- 1,426 ----
+ /*
+  * unexec for the NeXT Mach environment.
+  *
+  * Bradley Taylor (btaylor@NeXT.COM) 
+  * February 28, 1990
+  *
+  * Updated for 3.0 by Thomas Funke (thf@zelator.in-berlin.de)
+  *
+  */
+ #ifdef NeXT
+ 
+ #undef __STRICT_BSD__
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <mach/mach.h>
+ #include <mach-o/loader.h>
+ #include <sys/file.h>
+ #include <sys/stat.h>
+ #include <libc.h>
+ 
+ /* only for 2.1 (thf)
+ extern struct section *getsectbyname(char *, char *);
+ */
+ 
+ /*
+  * Kludge: we don't expect any program data beyond VM_HIGHDATA
+  * What is really needed is a way to find out from malloc() which
+  * pages it vm_allocated and write only those out into the data segment.
+  *
+  * This kludge may break when we stop using fixed virtual address
+  * shared libraries. Actually, emacs will probably continue working, but be 
+  * much larger on disk than it needs to be (because non-malloced data will
+  * be in the file).
+  */
+ static const unsigned VM_HIGHDATA = 0x2000000;
+ 
+ typedef struct region_t {
+ 	vm_address_t address;
+ 	vm_size_t size;
+ 	vm_prot_t protection;
+ 	vm_prot_t max_protection;
+ 	vm_inherit_t inheritance;
+ 	boolean_t shared;
+ 	port_t object_name;
+ 	vm_offset_t offset;
+ } region_t;
+ 
+ 
+ static void
+ grow(
+      struct load_command ***the_commands,
+      unsigned *the_commands_len
+      )
+ {
+ 	if (*the_commands == NULL) {
+ 		*the_commands_len = 1;
+ 		*the_commands = malloc(sizeof(*the_commands));
+ 	} else {
+ 		(*the_commands_len)++;
+ 		*the_commands = realloc(*the_commands, 
+ 					(*the_commands_len *
+ 					 sizeof(**the_commands)));
+ 	}
+ }
+ 
+ 
+ static void
+ save_command(
+ 	     struct load_command *command,
+ 	     struct load_command ***the_commands,
+ 	     unsigned *the_commands_len
+ 	     )
+ {
+ 	struct load_command **tmp;
+ 
+ 	grow(the_commands, the_commands_len);
+ 	tmp = &(*the_commands)[*the_commands_len - 1];
+ 	*tmp = malloc(command->cmdsize);
+ 	bcopy(command, *tmp, command->cmdsize);
+ }
+ 
+ static void
+ fatal_unexec(char *format, ...)
+ {
+ 	va_list ap;
+ 
+ 	va_start(ap, format);
+ 	fprintf(stderr, "unexec: ");
+ 	vfprintf(stderr, format, ap);
+ 	fprintf(stderr, "\n");
+ 	va_end(ap);
+ }
+ 
+ static int
+ read_macho(
+ 	   int fd,
+ 	   struct mach_header *the_header,
+ 	   struct load_command ***the_commands,
+ 	   unsigned *the_commands_len
+ 	   )
+ {
+ 	struct load_command command;
+ 	struct load_command *buf;
+ 	int i;
+ 	int size;
+ 
+ 	if (read(fd, the_header, sizeof(*the_header)) != sizeof(*the_header)) {
+ 		fatal_unexec("cannot read macho header");
+ 		return (0);
+ 	}
+ 	for (i = 0; i < the_header->ncmds; i++) {
+ 		if (read(fd, &command, sizeof(struct load_command)) != 
+ 		    sizeof(struct load_command)) {
+ 		  	fatal_unexec("cannot read macho load command header");
+ 			return (0);
+ 		}
+ 		size = command.cmdsize - sizeof(struct load_command);
+ 		if (size < 0) {
+ 		  	fatal_unexec("bogus load command size");
+ 			return (0);
+ 		}
+ 		buf = malloc(command.cmdsize);
+ 		buf->cmd = command.cmd;
+ 		buf->cmdsize = command.cmdsize;
+ 		if (read(fd, ((char *)buf + 
+ 			      sizeof(struct load_command)), 
+ 			 size) != size) {
+ 		  	fatal_unexec("cannot read load command data");
+ 			return (0);
+ 		}
+ 		save_command(buf, the_commands, the_commands_len);
+ 	}
+ 	return (1);
+ }
+ 
+ static int
+ filldatagap(
+ 	    vm_address_t start_address,
+ 	    vm_size_t *size,
+ 	    vm_address_t end_address
+ 	    )
+ {
+ 	vm_address_t address;
+ 	vm_size_t gapsize;
+ 
+ 	address = (start_address + *size);
+ 	gapsize = end_address - address;
+ 	*size += gapsize;
+ 	if (vm_allocate(task_self(), &address, gapsize,
+ 			FALSE) != KERN_SUCCESS) {
+ 		fatal_unexec("cannot vm_allocate");
+ 	        return (0);
+ 	}
+ 	return (1);
+ }
+ 
+ static int
+ get_data_region(
+ 		vm_address_t *address,
+ 		vm_size_t *size
+ 		)
+ {
+ 	region_t region;
+ 	kern_return_t ret;
+ 	struct section *sect;
+ 
+ 	sect = getsectbyname(SEG_DATA, SECT_DATA);
+ 	region.address = 0;
+ 	*address = 0;
+ 	for (;;) {
+ 		ret = vm_region(task_self(), 
+ 				&region.address, 
+ 				&region.size, 
+ 				&region.protection, 
+ 				&region.max_protection, 
+ 				&region.inheritance,
+ 				&region.shared, 
+ 				&region.object_name, 
+ 				&region.offset);
+ 		if (ret != KERN_SUCCESS || region.address >= VM_HIGHDATA) {
+ 			break;
+ 		}
+ 		if (*address != 0) {
+ 			if (region.address > *address + *size) {
+ 				if (!filldatagap(*address, size, 
+ 						 region.address)) {
+ 					return (0);
+ 				}
+ 			} 
+ 			*size += region.size;
+ 		} else {
+ 			if (region.address == sect->addr) {
+ 				*address = region.address;
+ 				*size = region.size;
+ 			} 
+ 		}
+ 		region.address += region.size;
+ 	}
+ 	return (1);
+ }
+ 
+ static char *
+ my_malloc(
+ 	  vm_size_t size
+ 	  )
+ {
+ 	vm_address_t address;
+ 
+ 	if (vm_allocate(task_self(), &address, size, TRUE) != KERN_SUCCESS) {
+ 		return (NULL);
+ 	}
+ 	return ((char *)address);
+ }
+ 
+ static void
+ my_free(
+ 	char *buf,
+ 	vm_size_t size
+ 	)
+ {
+ 	vm_deallocate(task_self(), (vm_address_t)buf, size);
+ }
+ 
+ static int
+ unexec_doit(
+ 	    int infd,
+ 	    int outfd
+ 	    )
+ {
+ 	int i;
+ 	struct load_command **the_commands = NULL;
+ 	unsigned the_commands_len;
+ 	struct mach_header the_header;
+ 	int fgrowth;
+ 	int fdatastart;
+ 	int fdatasize;
+ 	int size;
+ 	struct stat st;
+ 	char *buf;
+ 	vm_address_t data_address;
+ 	vm_size_t data_size;
+ 
+ 	struct segment_command *segment;
+ 
+ 	if (!read_macho(infd, &the_header, &the_commands, &the_commands_len)) {
+ 		return (0);
+ 	}
+ 
+ 
+ 	{
+ 	  extern int malloc_cookie;
+ 	  malloc_cookie = malloc_freezedry();
+ 	}
+ 	if (!get_data_region(&data_address, &data_size)) {
+ 		return (0);
+ 	}
+ 
+ 
+ 	/*
+ 	 * DO NOT USE MALLOC IN THIS SECTION
+ 	 */
+ 	{
+ 		/*
+ 		 * Fix offsets
+ 		 */
+ 		for (i = 0; i < the_commands_len; i++) {
+ 			switch (the_commands[i]->cmd) {
+ 			case LC_SEGMENT:
+ 				segment = ((struct segment_command *)
+ 					   the_commands[i]);
+ 				if (strcmp(segment->segname, SEG_DATA) == 0) {
+ 					fdatastart = segment->fileoff;
+ 					fdatasize = segment->filesize;
+ 					fgrowth = (data_size - 
+ 						   segment->filesize);
+ 					segment->vmsize = data_size;
+ 					segment->filesize = data_size;
+ 				}
+ 				break;
+ 			case LC_SYMTAB:
+ 				((struct symtab_command *)
+ 				 the_commands[i])->symoff += fgrowth;
+ 				((struct symtab_command *)
+ 				 the_commands[i])->stroff += fgrowth;
+ 				break;
+ 			case LC_SYMSEG:
+ 				((struct symseg_command *)
+ 				 the_commands[i])->offset += fgrowth;
+ 				break;
+ 			default:
+ 				break;
+ 			}
+ 		}
+ 		
+ 		/*
+ 		 * Write header
+ 		 */
+ 		if (write(outfd, &the_header, 
+ 			  sizeof(the_header)) != sizeof(the_header)) {
+ 			fatal_unexec("cannot write output file");
+ 			return (0);
+ 		}
+ 		
+ 		/*
+ 		 * Write commands
+ 		 */
+ 		for (i = 0; i < the_commands_len; i++) {
+ 			if (write(outfd, the_commands[i], 
+ 				  the_commands[i]->cmdsize) != 
+ 			    the_commands[i]->cmdsize) {
+ 			  	fatal_unexec("cannot write output file");
+ 				return (0);
+ 			}
+ 		}
+ 		
+ 		/*
+ 		 * Write original text
+ 		 */
+ 		if (lseek(infd, the_header.sizeofcmds + sizeof(the_header), 
+ 			  L_SET) < 0) {
+ 		  	fatal_unexec("cannot seek input file");
+ 			return (0);
+ 		}
+ 		size = fdatastart - (sizeof(the_header) + 
+ 				     the_header.sizeofcmds);
+ 		buf = my_malloc(size);
+ 		if (read(infd, buf, size) != size) {
+ 			my_free(buf, size);
+ 		  	fatal_unexec("cannot read input file");
+ 		}
+ 		if (write(outfd, buf, size) != size) {
+ 			my_free(buf, size);
+ 			fatal_unexec("cannot write output file");
+ 			return (0);
+ 		}
+ 		my_free(buf, size);
+ 		
+ 		
+ 		/*
+ 		 * Write new data
+ 		 */
+ 		if (write(outfd, (char *)data_address, 
+ 			  data_size) != data_size) {
+ 			fatal_unexec("cannot write output file");
+ 			return (0);
+ 		}
+ 		
+ 	}
+ 
+ 	/*
+ 	 * OKAY TO USE MALLOC NOW
+ 	 */
+ 
+ 	/*
+ 	 * Write rest of file
+ 	 */
+ 	fstat(infd, &st);
+ 	if (lseek(infd, fdatasize, L_INCR) < 0) {
+ 		fatal_unexec("cannot seek input file");
+ 		return (0);
+ 	}
+ 	size = st.st_size - lseek(infd, 0, L_INCR);
+ 
+ 	buf = malloc(size);
+ 	if (read(infd, buf, size) != size) {
+ 		free(buf);
+ 		fatal_unexec("cannot read input file");
+ 		return (0);
+ 	}
+ 	if (write(outfd, buf, size) != size) {
+ 		free(buf);
+ 		fatal_unexec("cannot write output file");
+ 		return (0);
+ 	}
+ 	free(buf);
+ 	return (1);
+ }
+ 
+ void
+ unexec(
+        char *outfile,
+        char *infile
+        )
+ {
+ 	int infd;
+ 	int outfd;
+ 	char tmpbuf[L_tmpnam];
+ 	char *tmpfile;
+ 
+ 	infd = open(infile, O_RDONLY, 0);
+ 	if (infd < 0) {
+ 	  	fatal_unexec("cannot open input file `%s'", infile);
+ 		exit(1);
+ 	}
+ 	
+ 	tmpnam(tmpbuf);
+ 	tmpfile = rindex(tmpbuf, '/');
+ 	if (tmpfile == NULL) {
+ 		tmpfile = tmpbuf;
+ 	} else {
+ 		tmpfile++;
+ 	}
+ 	outfd = open(tmpfile, O_WRONLY|O_TRUNC|O_CREAT, 0755);
+ 	if (outfd < 0) {
+ 		close(infd);
+ 		fatal_unexec("cannot open tmp file `%s'", tmpfile);
+ 		exit(1);
+ 	}
+ 	if (!unexec_doit(infd, outfd)) {
+ 		close(infd);
+ 		close(outfd);
+ 		unlink(tmpfile);
+ 		exit(1);
+ 	}
+ 	close(infd);
+ 	close(outfd);
+ 	if (rename(tmpfile, outfile) < 0) {
+ 		unlink(tmpfile);
+ 		fatal_unexec("cannot rename `%s' to `%s'", tmpfile, outfile);
+ 		exit(1);
+ 	}
+ }
+ #endif
+ 
diff -rc2Na emacs-18.58/src/ymakefile emacs-18.58-NeXT3.0/src/ymakefile
*** emacs-18.58/src/ymakefile	Thu Oct 15 15:23:36 1992
--- emacs-18.58-NeXT3.0/src/ymakefile	Thu Oct 15 15:42:16 1992
***************
*** 64,68 ****
  /* Unless inhibited or changed, use -lg to link for debugging.  */
  #ifndef LIBS_DEBUG
! #define LIBS_DEBUG -lg
  #endif
  
--- 64,68 ----
  /* Unless inhibited or changed, use -lg to link for debugging.  */
  #ifndef LIBS_DEBUG
! #define LIBS_DEBUG 
  #endif
  
***************
*** 119,123 ****
  /* If user wants to optimize, this is how.  */
  #ifndef C_OPTIMIZE_SWITCH
! #define C_OPTIMIZE_SWITCH -O
  #endif
  
--- 119,123 ----
  /* If user wants to optimize, this is how.  */
  #ifndef C_OPTIMIZE_SWITCH
! #define C_OPTIMIZE_SWITCH -O2 -w
  #endif
  
***************
*** 162,166 ****
  #endif /* SHORTNAMES */
  
! CFLAGS= C_DEBUG_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM
  /* DO NOT use -R.  There is a special hack described in lastfile.c
     which is used instead.  Some initialized data areas are modified
--- 162,166 ----
  #endif /* SHORTNAMES */
  
! CFLAGS= C_OPTIMIZE_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM
  /* DO NOT use -R.  There is a special hack described in lastfile.c
     which is used instead.  Some initialized data areas are modified
***************
*** 219,223 ****
  #if __GNUC__ > 1
  #ifndef LIB_GCC
! #define LIB_GCC -lgcc
  #endif
  GNULIB_VAR = LIB_GCC
--- 219,223 ----
  #if __GNUC__ > 1
  #ifndef LIB_GCC
! #define LIB_GCC 
  #endif
  GNULIB_VAR = LIB_GCC
-- 
------------------------------------------------------------------
Thomas Funke  ** E-mail: thf@zelator.in-berlin.de
NeXT-Developer * Unix-Consultant
------------------------------------------------------------------
Technical Details
Message-ID: <1992Oct15.153655.2920@gamelan>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zelator!gamelan!thomas

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zelator!gamelan!thomas
From: thf@zelator.in-berlin.de (Thomas Funke)
Subject: Patches for emacs18.58 under NeXT  OS3.0
Message-ID: <1992Oct15.153655.2920@gamelan>
Sender: thomas@gamelan (thomas)
Reply-To: thf@zelator.in-berlin.de (Thomas Funke)
Organization: NNU Corp. - NeXT is Not UN*X
Date: Thu, 15 Oct 1992 15:36:55 GMT
Lines: 929