[gnu.ghostscript.bug] Patches for ghostscript-1.3 for BSD.

lmjm%doc.imperial.ac.uk@NSFNET-RELAY.AC.UK (Lee McLoughlin) (07/04/89)

Here are some patches I needed to get gs working on a 4.2 BSD system.

It still doesn't work fully.  On doing
	./gs leta.ps
It creates an inital window.  When I hit return it then creates
another window.  On hitting return again it then draws in the second window!

I've not yet looked into this problem.

	Lee

Ps:  Where did all the example postscript files go?  I had them around
but without them how are you supposed to test gs?


RCS file: RCS/ansi2knr.c,v
retrieving revision 1.1
diff -cbr -r1.1 ansi2knr.c
*** /tmp/,RCSt1008696	Mon Jul  3 23:33:39 1989
--- ansi2knr.c	Mon Jul  3 23:15:45 1989
***************
*** 21,27
  /* Convert ANSI function declarations to K&R syntax */
  #include <stdio.h>
  #include <ctype.h>
! #include <string.h>
  char *malloc();				/* avoid non-core .h files */
  
  /* Usage:

--- 21,27 -----
  /* Convert ANSI function declarations to K&R syntax */
  #include <stdio.h>
  #include <ctype.h>
! #include "string_.h"
  char *malloc();				/* avoid non-core .h files */
  
  #ifdef BSD4_2
***************
*** 23,28
  #include <ctype.h>
  #include <string.h>
  char *malloc();				/* avoid non-core .h files */
  
  /* Usage:
  	ansi2knr input_file output_file

--- 23,33 -----
  #include <ctype.h>
  #include "string_.h"
  char *malloc();				/* avoid non-core .h files */
+ 
+ #ifdef BSD4_2
+ #define strchr index
+ #endif
+ 
  
  /* Usage:
  	ansi2knr input_file output_file
===================================================================
RCS file: RCS/gsmisc.c,v
retrieving revision 1.1
diff -cbr -r1.1 gsmisc.c
*** /tmp/,RCSt1008696	Mon Jul  3 23:33:41 1989
--- gsmisc.c	Mon Jul  3 23:26:25 1989
***************
*** 27,32
  char gs_debug[128];
  #endif
  
  /* Versions of malloc and free compatible with GhostScript's */
  /* model of memory management. */
  char *

--- 27,50 -----
  char gs_debug[128];
  #endif
  
+ 
+ #ifndef SYS5
+ long clock()
+ {
+ 	return 0;
+ }
+ 
+ char *
+ memset( register char *b1, register int c, register int n )
+ {
+ 	char *start = b1;
+ 
+ 	while( n-- > 0 )
+ 		*b1++ = c;
+ 
+ 	return start;
+ }
+ #endif
  /* Versions of malloc and free compatible with GhostScript's */
  /* model of memory management. */
  char *
===================================================================
RCS file: RCS/makefile,v
retrieving revision 1.1
diff -cbr -r1.1 makefile
*** /tmp/,RCSt1008696	Mon Jul  3 23:33:43 1989
--- makefile	Mon Jul  3 23:29:04 1989
***************
*** 33,39
  # Add -DBSD4_2 for 4.2bsd systems.
  # Add -DSYSV for System V.
  
! CFLAGS=-O
  
  # Define platform flags for ld.
  # The following are appropriate for Sun OS4.0.

--- 33,39 -----
  # Add -DBSD4_2 for 4.2bsd systems.
  # Add -DSYSV for System V.
  
! CFLAGS=-DBSD4_2
  
  # Define platform flags for ld.
  # The following are appropriate for Sun OS4.0.
***************
*** 38,44
  # Define platform flags for ld.
  # The following are appropriate for Sun OS4.0.
  
! LDPLAT=-Bstatic
  
  # ---------------------------- End of options --------------------------- #
  

--- 38,44 -----
  # Define platform flags for ld.
  # The following are appropriate for Sun OS4.0.
  
! LDPLAT=
  
  # ---------------------------- End of options --------------------------- #
  
===================================================================
RCS file: RCS/std.h,v
retrieving revision 1.1
diff -cbr -r1.1 std.h
*** /tmp/,RCSt1008696	Mon Jul  3 23:33:45 1989
--- std.h	Mon Jul  3 22:35:19 1989
***************
*** 115,117
  # define P11(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11)
  # define P12(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12)
  #endif

--- 115,128 -----
  # define P11(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11)
  # define P12(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12)
  #endif
+ 
+ #ifndef SYS5
+ #define memcpy(dst,src,n) bcopy((src),(dst),(n))
+ #define memcmp(b1,b2,n) bcmp((b1),(b2),(n))
+ #define strchr index
+ #define strrchr rindex
+ #endif
+ 
+ #ifdef BSD4_2
+ extern char *malloc();
+ #endif

--
Lee McLoughlin			01 589 5111 X 5028
Department of Computing,Imperial College,180 Queens Gate,London SW7 2BZ, UK
Janet: lmjm@uk.ac.ic.doc	Uucp:  lmjm@icdoc.UUCP (or ..!ukc!icdoc!lmjm)
DARPA: lmjm@doc.ic.ac.uk (or lmjm%uk.ac.ic.doc@nsfnet-relay.ac.uk)

snoopy@sopwith.UUCP (Snoopy) (07/04/89)

In article <8728.8907032240@oriona.doc.ic.ac.uk> lmjm%doc.imperial.ac.uk@NSFNET-RELAY.AC.UK (Lee McLoughlin) writes:
|Here are some patches I needed to get gs working on a 4.2 BSD system.
|
|It still doesn't work fully.  On doing
|	./gs leta.ps
|It creates an inital window.  When I hit return it then creates
|another window.  On hitting return again it then draws in the second window!
|
|I've not yet looked into this problem.

I suspect it is calling x_open(), x_close() and then x_open() again during
startup, and that the x driver isn't keeping track of what window it is
supposed to be using and thus starts a new one.  Look in gs.c, gsmain.c,
and gdevx.c for starters.  To add multi-device support, I have it starting
with the null device.

|Ps:  Where did all the example postscript files go?  I had them around
|but without them how are you supposed to test gs?

I suspect what happened is that Peter used a script to automatically add
the GNU copyright to all the files in release 1.0, and the script merrily
added it to the example files, many of which were copyrighted by others
(e.g. Adobe) who justifiably got upset.  The Adobe Cookbook suggests both
trying the programs and modifying them, so presumably they would not be
upset about people having copies on their machines.  The Adobe fileserver
provides the code from the green book, I don't know if it provides the
code from the cookbook (blue book).

|+ 
|+ #ifndef SYS5
|+ long clock()
|+ {
|+ 	return 0;
|+ }

If you want the time functions to work, here is code for systems which
provide gettimeofday(2).  Put it in whatever gp-<system>.c file (e.g.
gp-bsd.c) you are using.


/* Read the current date (in days since Jan. 1, 1980) */
/* and time (in milliseconds since midnight). */
void
gs_get_clock(long *pdt)
{
 	long secs_since_1980;
 	struct timeval tp;
 	struct timezone tzp;
	struct tm *tm, *localtime();
 	if(gettimeofday(&tp, &tzp) == -1)
		{
 		perror("Ghostscript: gettimeofday failed:");
		gs_exit(1);
		}
 	/* tp.tv_sec is #secs since Jan 1, 1970 */

 	/* subtract off number of seconds in 10 years */
 	/* leap seconds are not accounted for */
 	secs_since_1980 = tp.tv_sec - 60 * 60 * 24 * 365.25 * 10;

	/* adjust for timezone */
	secs_since_1980 -= (tzp.tz_minuteswest * 60);

	/* adjust for daylight savings time - assume dst offset is 1 hour */
	tm = localtime(&(tp.tv_sec));
	if (tm->tm_isdst)
		secs_since_1980 += (60 * 60);

 	/* divide secs by #secs/day to get #days (integer division truncates) */
 	pdt[0] = secs_since_1980 / (60 * 60 * 24);
 	/* modulo + microsecs/1000 gives number of millisecs since midnight */
 	pdt[1] = (secs_since_1980 % (60 * 60 * 24)) * 1000 + tp.tv_usec / 1000;
#ifdef DEBUG_CLOCK
	printf("tp.tv_sec = %d  tp.tv_usec = %d  pdt[0] = %d   pdt[1] = %d\n",
		tp.tv_sec, tp.tv_usec, pdt[0], pdt[1]);
#endif DEBUG_CLOCK
}


    _____     						  .-----.
   /_____\    Snoopy					./  RIP	 \.
  /_______\   qiclab!sopwith!snoopy			|  	  |
    |___|     parsely!sopwith!snoopy			| tekecs  |
    |___|     sun!nosun!illian!sopwith!snoopy		|_________|

		"I *was* the next man!"  -Indy