[gnu.ghostscript.bug] Sun gcc support for 1.3

tli@sargas.usc.edu (Tony Li) (07/03/89)

Attached is a patch which at least lets 1.3 compile correctly with
gcc.  Note that you'll have to configure ux-gcc-x.mak for your site.

Tony

-----------------------------------cut here-----------------------------------
*** /tmp/,RCSt1a16670	Mon Jul  3 02:59:29 1989
--- gs.c	Mon Jul  3 00:12:57 1989
***************
*** 165,171
  {	stream st;
  	stream *s = &st;
  	int code;
! 	sread_string(s, str, strlen(str));
  	code = scan_token(s, 0, pr);
  	if ( code < 0 )
  		printf("scan_token returns %d\n", code);

--- 165,171 -----
  {	stream st;
  	stream *s = &st;
  	int code;
! 	sread_string(s, (byte *) str, strlen(str));
  	code = scan_token(s, 0, pr);
  	if ( code < 0 )
  		printf("scan_token returns %d\n", code);
*** /tmp/,RCSt1a16676	Mon Jul  3 02:59:32 1989
--- gschar.c	Mon Jul  3 02:33:25 1989
***************
*** 27,33
  #include "gzstate.h"			/* must precede gzdevice */
  #include "gzdevice.h"			/* must precede gxchar */
  #include "gxdevmem.h"
- #include "gxfont.h"
  #include "gxchar.h"
  #include "gxpath.h"
  #include "gzcolor.h"

--- 27,32 -----
  #include "gzstate.h"			/* must precede gzdevice */
  #include "gzdevice.h"			/* must precede gxchar */
  #include "gxdevmem.h"
  #include "gxchar.h"
  #include "gxfont.h"
  #include "gxpath.h"
***************
*** 29,34
  #include "gxdevmem.h"
  #include "gxfont.h"
  #include "gxchar.h"
  #include "gxpath.h"
  #include "gzcolor.h"
  

--- 28,34 -----
  #include "gzdevice.h"			/* must precede gxchar */
  #include "gxdevmem.h"
  #include "gxchar.h"
+ #include "gxfont.h"
  #include "gxpath.h"
  #include "gzcolor.h"
  
***************
*** 367,375
  /* Continuation procedures for show (all varieties) */
  #define show_fast_move(wxy, pgs)\
    gx_path_add_relative_point(pgs->path, wxy.x, wxy.y)
! int show_update(P1(register gs_show_enum *penum));
! int show_move(P1(register gs_show_enum *penum));
! int show_proceed(P1(register gs_show_enum *penum));
  private int
  continue_show_update(register gs_show_enum *penum)
  {	int code = show_update(penum);

--- 367,375 -----
  /* Continuation procedures for show (all varieties) */
  #define show_fast_move(wxy, pgs)\
    gx_path_add_relative_point(pgs->path, wxy.x, wxy.y)
! private int show_update(P1(register gs_show_enum *penum));
! private int show_move(P1(register gs_show_enum *penum));
! private int show_proceed(P1(register gs_show_enum *penum));
  private int
  continue_show_update(register gs_show_enum *penum)
  {	int code = show_update(penum);
***************
*** 494,502
  }
  
  /* Continuation procedures for stringwidth */
! int stringwidth_update(P1(register gs_show_enum *penum));
! int stringwidth_move(P1(register gs_show_enum *penum));
! int stringwidth_proceed(P1(register gs_show_enum *penum));
  private int
  continue_stringwidth_update(register gs_show_enum *penum)
  {	int code = stringwidth_update(penum);

--- 494,502 -----
  }
  
  /* Continuation procedures for stringwidth */
! private int stringwidth_update(P1(register gs_show_enum *penum));
! private int stringwidth_move(P1(register gs_show_enum *penum));
! private int stringwidth_proceed(P1(register gs_show_enum *penum));
  private int
  continue_stringwidth_update(register gs_show_enum *penum)
  {	int code = stringwidth_update(penum);
*** /tmp/,RCSt1a16684	Mon Jul  3 02:59:36 1989
--- gscoord.c	Mon Jul  3 01:51:09 1989
***************
*** 38,44
  #endif
  #define ensure_inverse_valid(pgs)\
  	if ( !pgs->inverse_valid )\
! 	   {	int code = gs_matrix_invert(&pgs->ctm, &pgs->ctm_inverse);\
  		print_inverse(pgs);\
  		if ( code < 0 ) return code;\
  		pgs->inverse_valid = 1;\

--- 38,44 -----
  #endif
  #define ensure_inverse_valid(pgs)\
  	if ( !pgs->inverse_valid )\
! 	   {	int code = gs_matrix_invert((gs_matrix *)&pgs->ctm, &pgs->ctm_inverse);\
  		print_inverse(pgs);\
  		if ( code < 0 ) return code;\
  		pgs->inverse_valid = 1;\
***************
*** 90,96
  gs_translate(gs_state *pgs, floatp dx, floatp dy)
  {	gs_point pt;
  	int code;
! 	if ( (code = gs_distance_transform((float)dx, (float)dy, &pgs->ctm, &pt)) < 0 )
  		return code;
  	pgs->ctm.tx += pt.x;
  	pgs->ctm.ty += pt.y;

--- 90,96 -----
  gs_translate(gs_state *pgs, floatp dx, floatp dy)
  {	gs_point pt;
  	int code;
! 	if ( (code = gs_distance_transform(dx, dy, (gs_matrix *)&pgs->ctm, &pt)) < 0 )
  		return code;
  	pgs->ctm.tx += pt.x;
  	pgs->ctm.ty += pt.y;
***************
*** 120,126
  
  int
  gs_rotate(gs_state *pgs, floatp ang)
! {	int code = gs_matrix_rotate(&pgs->ctm, (float)ang, &pgs->ctm);
  	pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
  #ifdef DEBUG
  if ( gs_debug['x'] )

--- 120,127 -----
  
  int
  gs_rotate(gs_state *pgs, floatp ang)
! {	int code = gs_matrix_rotate((gs_matrix *)&pgs->ctm,
! 				    (float)ang, (gs_matrix *)&pgs->ctm);
  	pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
  #ifdef DEBUG
  if ( gs_debug['x'] )
***************
*** 131,137
  
  int
  gs_concat(gs_state *pgs, gs_matrix *pmat)
! {	int code = gs_matrix_multiply(pmat, &pgs->ctm, &pgs->ctm);
  	update_ctm(pgs);
  #ifdef DEBUG
  if ( gs_debug['x'] )

--- 132,139 -----
  
  int
  gs_concat(gs_state *pgs, gs_matrix *pmat)
! {	int code = gs_matrix_multiply(pmat, (gs_matrix *)&pgs->ctm,
! 				      (gs_matrix *)&pgs->ctm);
  	update_ctm(pgs);
  #ifdef DEBUG
  if ( gs_debug['x'] )
***************
*** 144,150
  
  int
  gs_transform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
! {	return gs_point_transform((float)x, (float)y, &pgs->ctm, pt);
  }
  
  int

--- 146,153 -----
  
  int
  gs_transform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
! {	return gs_point_transform((float)x, (float)y,
! 				  (gs_matrix *)&pgs->ctm, pt);
  }
  
  int
***************
*** 149,155
  
  int
  gs_dtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
! {	return gs_distance_transform((float)dx, (float)dy, &pgs->ctm, pt);
  }
  
  int

--- 152,159 -----
  
  int
  gs_dtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
! {	return gs_distance_transform((float)dx, (float)dy,
! 				     (gs_matrix *)&pgs->ctm, pt);
  }
  
  int
*** /tmp/,RCSt1a16690	Mon Jul  3 02:59:39 1989
--- gsfont.c	Mon Jul  3 01:55:19 1989
***************
*** 26,31
  #include "gxmatrix.h"
  #include "gzstate.h"			/* must precede gxdevice */
  #include "gxdevice.h"			/* must precede gxfont */
  #include "gxfont.h"
  
  /* Size of cache structures */

--- 26,32 -----
  #include "gxmatrix.h"
  #include "gzstate.h"			/* must precede gxdevice */
  #include "gxdevice.h"			/* must precede gxfont */
+ #include "gschar.h"
  #include "gxfont.h"
  
  /* Size of cache structures */
*** /tmp/,RCSt1a16695	Mon Jul  3 02:59:41 1989
--- gsimage.c	Mon Jul  3 01:56:32 1989
***************
*** 116,122
  		return_error(gs_error_undefinedresult);
  	if ( height == 0 ) return 0;	/* empty image */
  	if (	(code = gs_matrix_invert(pmat, &mat)) < 0 ||
! 		(code = gs_matrix_multiply(&mat, &pgs->ctm, &mat)) < 0
  	   )	return code;
  	buffer = (byte *)malloc(bsize);
  	if ( buffer == 0 ) return_error(gs_error_VMerror);

--- 116,123 -----
  		return_error(gs_error_undefinedresult);
  	if ( height == 0 ) return 0;	/* empty image */
  	if (	(code = gs_matrix_invert(pmat, &mat)) < 0 ||
! 		(code = gs_matrix_multiply(&mat,
! 					   (gs_matrix *)&pgs->ctm, &mat)) < 0
  	   )	return code;
  	buffer = (byte *)malloc(bsize);
  	if ( buffer == 0 ) return_error(gs_error_VMerror);
*** /tmp/,RCSt1a16703	Mon Jul  3 02:59:45 1989
--- gsmain.c	Mon Jul  3 00:22:21 1989
***************
*** 152,158
  /* Close the device and exit */
  void
  gs_exit(int code)
! {	(*gx_device_default_p->procs->close_device)(gx_device_default_p);
  	exit(code);
  }
  

--- 152,159 -----
  /* Close the device and exit */
  void
  gs_exit(int code)
! {	extern gx_device *gx_device_default_p;
! 	(*gx_device_default_p->procs->close_device)(gx_device_default_p);
  	exit(code);
  }
  
*** /tmp/,RCSt1a16708	Mon Jul  3 02:59:47 1989
--- gspath2.c	Mon Jul  3 02:07:16 1989
***************
*** 73,79
  	dbox[1] = fixed2float(fbox.ymin);
  	dbox[2] = fixed2float(fbox.xmax);
  	dbox[3] = fixed2float(fbox.ymax);
! 	return gs_bbox_transform_inverse(dbox, &pgs->ctm, box);
  }
  
  /* ------ Enumerators ------ */

--- 73,79 -----
  	dbox[1] = fixed2float(fbox.ymin);
  	dbox[2] = fixed2float(fbox.xmax);
  	dbox[3] = fixed2float(fbox.ymax);
! 	return gs_bbox_transform_inverse(dbox, (gs_matrix *)&pgs->ctm, box);
  }
  
  /* ------ Enumerators ------ */
*** /tmp/,RCSt1a16713	Mon Jul  3 02:59:48 1989
--- gxcache.c	Mon Jul  3 02:44:51 1989
***************
*** 28,34
  #include "gzdevice.h"			/* requires gsstate.h */
  #include "gzcolor.h"
  #include "gxdevmem.h"
- #include "gxfont.h"
  #include "gxchar.h"
  
  /* Define the size of the cache structures */

--- 28,33 -----
  #include "gzdevice.h"			/* requires gsstate.h */
  #include "gzcolor.h"
  #include "gxdevmem.h"
  #include "gxchar.h"
  #include "gxfont.h"
  
***************
*** 30,35
  #include "gxdevmem.h"
  #include "gxfont.h"
  #include "gxchar.h"
  
  /* Define the size of the cache structures */
  int cached_char_sizeof = sizeof(cached_char);

--- 29,35 -----
  #include "gzcolor.h"
  #include "gxdevmem.h"
  #include "gxchar.h"
+ #include "gxfont.h"
  
  /* Define the size of the cache structures */
  int cached_char_sizeof = sizeof(cached_char);
***************
*** 36,42
  int cached_fm_pair_sizeof = sizeof(cached_fm_pair);
  
  /* Forward references */
! void zap_cache(P1(gs_font_dir *));
  
  /* Allocate storage for caching a rendered character, */
  /* and set up the memory device. */

--- 36,42 -----
  int cached_fm_pair_sizeof = sizeof(cached_fm_pair);
  
  /* Forward references */
! private void zap_cache(P1(gs_font_dir *));
  
  /* Allocate storage for caching a rendered character, */
  /* and set up the memory device. */
*** /tmp/,RCSt1a16718	Mon Jul  3 02:59:50 1989
--- gxchar.h	Mon Jul  3 02:31:01 1989
***************
*** 83,88
  	show_width_status width_set;
  	int (*continue_proc)(P1(struct gs_show_enum_s *));	/* continuation procedure */
  };
  
  /* Cached character procedures (in gxfont.c) */
  cached_char *	gx_alloc_char_bits(P4(struct gs_font_dir_s *,

--- 83,89 -----
  	show_width_status width_set;
  	int (*continue_proc)(P1(struct gs_show_enum_s *));	/* continuation procedure */
  };
+ struct gs_font_dir_s;
  
  /* Cached character procedures (in gxfont.c) */
  cached_char *	gx_alloc_char_bits(P4(struct gs_font_dir_s *,
*** /tmp/,RCSt1a16723	Mon Jul  3 02:59:51 1989
--- gxdevice.h	Mon Jul  3 00:20:05 1989
***************
*** 32,37
  
  /* Structure for device procedures */
  typedef struct gx_device_procs_s gx_device_procs;
  struct gx_device_procs_s {
  
  	int (*open_device)(P1(struct gx_device_s *));

--- 32,56 -----
  
  /* Structure for device procedures */
  typedef struct gx_device_procs_s gx_device_procs;
+ 
+ /* Structure for generic device description */
+ #define gx_device_common\
+ 	int params_size;		/* size of this structure */\
+ 	gx_device_procs *procs;\
+ 	gs_matrix initial_matrix;	/* initial transformation */\
+ 	int width;			/* width in pixels */\
+ 	int height;			/* height in pixels */\
+ 	int has_color;			/* true if device supports color */\
+ 	unsigned short max_rgb_value;	/* max r, g, b value */\
+ 	int bits_per_color_pixel;	/* for copy_color */\
+ 	int bits_from_MSB;		/* true if bit-big-endian */\
+ 	int is_open			/* true if device has been opened */
+ 
+ /* A generic device */
+ struct gx_device_s {
+ 	gx_device_common;
+ };
+ 
  struct gx_device_procs_s {
  
  	int (*open_device)(P1(struct gx_device_s *));
***************
*** 101,119
      (P10(struct gx_device_s *, gx_bitmap *, int, int, int, int, int, int,
        gx_color_index, gx_color_index));
  
- /* Structure for generic device description */
- #define gx_device_common\
- 	int params_size;		/* size of this structure */\
- 	gx_device_procs *procs;\
- 	gs_matrix initial_matrix;	/* initial transformation */\
- 	int width;			/* width in pixels */\
- 	int height;			/* height in pixels */\
- 	int has_color;			/* true if device supports color */\
- 	unsigned short max_rgb_value;	/* max r, g, b value */\
- 	int bits_per_color_pixel;	/* for copy_color */\
- 	int bits_from_MSB;		/* true if bit-big-endian */\
- 	int is_open			/* true if device has been opened */
- /* A generic device */
- struct gx_device_s {
- 	gx_device_common;
- };

--- 120,122 -----
      (P10(struct gx_device_s *, gx_bitmap *, int, int, int, int, int, int,
        gx_color_index, gx_color_index));
  
*** /tmp/,RCSt1a16728	Mon Jul  3 02:59:53 1989
--- interp.c	Mon Jul  3 00:27:37 1989
***************
*** 31,36
  
  /* Forward references */
  private int interp(P1(ref *pref));
  
  /* Configuration parameters */
  #define max_ostack 500

--- 31,37 -----
  
  /* Forward references */
  private int interp(P1(ref *pref));
+ private	op_proc interp_exit;
  
  /* Configuration parameters */
  #define max_ostack 500
*** /tmp/,RCSt1a16734	Mon Jul  3 02:59:57 1989
--- ux-gcc-x.mak	Mon Jul  3 02:56:29 1989
***************
*** 33,39
  # Add -DBSD4_2 for 4.2bsd systems.
  # Add -DSYSV for System V.
  
! CFLAGS=-O -ansi
  
  # 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=-O -I/usr/usc/include
  
  # 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=-Bstatic -L/usr/usc/X11/lib
  
  # ---------------------------- End of options --------------------------- #
  
***************
*** 49,54
  
  # Define the compilation rules.
  
  .c.o:
  	$(GCC) $(CFLAGS) $(CCDEBUG) -c $*.c
  

--- 49,55 -----
  
  # Define the compilation rules.
  
+ GCC=gcc
  .c.o:
  	$(GCC) $(CFLAGS) $(CCDEBUG) -c $*.c
  
***************
*** 108,110
   $(PLATBSD) $(DEVFORUNIX)
  gs: $(GSUNIX)
  	cc $(CFLAGS) $(LDPLAT) -X -o gs $(GSUNIX) -lX11 -lm

--- 109,114 -----
   $(PLATBSD) $(DEVFORUNIX)
  gs: $(GSUNIX)
  	cc $(CFLAGS) $(LDPLAT) -X -o gs $(GSUNIX) -lX11 -lm
+ 
+ clean:
+ 	rm -rf gs *.o
*** /tmp/,RCSt1a16746	Mon Jul  3 03:00:02 1989
--- zchar.c	Mon Jul  3 01:10:52 1989
***************
*** 58,64
  zshow(register ref *op)
  {	int code = setup_show(op, finish_show);
  	if ( code < 0 ) return code;
! 	if ( (code = gs_show_n_init(senum, igs, op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 58,64 -----
  zshow(register ref *op)
  {	int code = setup_show(op, finish_show);
  	if ( code < 0 ) return code;
! 	if ( (code = gs_show_n_init(senum, igs, (char *)op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }
***************
*** 75,81
  		(code = setup_show(op, finish_show)) < 0
  	   )
  		return code;
! 	if ( (code = gs_ashow_n_init(senum, igs, axy[0], axy[1], op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 75,81 -----
  		(code = setup_show(op, finish_show)) < 0
  	   )
  		return code;
! 	if ( (code = gs_ashow_n_init(senum, igs, axy[0], axy[1], (char *)op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }
***************
*** 94,100
  		(code = setup_show(op, finish_show)) < 0
  	   )
  		return code;
! 	if ( (code = gs_widthshow_n_init(senum, igs, cxy[0], cxy[1], (char)op[-1].value.intval, op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 94,103 -----
  		(code = setup_show(op, finish_show)) < 0
  	   )
  		return code;
! 	if ( (code = gs_widthshow_n_init(senum, igs, cxy[0], cxy[1],
! 					 (char)op[-1].value.intval,
! 					 (char *)op->value.bytes,
! 					 op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }
***************
*** 114,120
  		(code = setup_show(op, finish_show)) < 0
  	   )
  		return code;
! 	if ( (code = gs_awidthshow_n_init(senum, igs, cxy[0], cxy[1], (char)op[-3].value.intval, axy[0], axy[1], op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 117,127 -----
  		(code = setup_show(op, finish_show)) < 0
  	   )
  		return code;
! 	if ( (code = gs_awidthshow_n_init(senum, igs, cxy[0], cxy[1],
! 					  (char)op[-3].value.intval,
! 					  axy[0], axy[1],
! 					  (char *)op->value.bytes,
! 					  op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }
***************
*** 128,134
  {	int code;
  	check_proc(op[-1]);
  	if ( (code = setup_show(op, finish_show)) < 0 ) return code;
! 	if ( (code = gs_kshow_n_init(senum, igs, op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 135,141 -----
  {	int code;
  	check_proc(op[-1]);
  	if ( (code = setup_show(op, finish_show)) < 0 ) return code;
! 	if ( (code = gs_kshow_n_init(senum, igs, (char *)op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }
***************
*** 149,155
  zstringwidth(register ref *op)
  {	int code = setup_show(op, finish_stringwidth);
  	if ( code < 0 ) return code;
! 	if ( (code = gs_stringwidth_n_init(senum, igs, op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 156,162 -----
  zstringwidth(register ref *op)
  {	int code = setup_show(op, finish_stringwidth);
  	if ( code < 0 ) return code;
! 	if ( (code = gs_stringwidth_n_init(senum, igs, (char *)op->value.bytes, op->size)) < 0 )
  	   {	free_show();
  		return code;
  	   }
***************
*** 175,181
  	check_type(*op, t_boolean);
  	code = setup_show(op - 1, finish_show);
  	if ( code < 0 ) return code;
! 	if ( (code = gs_charpath_n_init(senum, igs, op[-1].value.bytes, op[-1].size, op->value.index)) < 0 )
  	   {	free_show();
  		return code;
  	   }

--- 182,188 -----
  	check_type(*op, t_boolean);
  	code = setup_show(op - 1, finish_show);
  	if ( code < 0 ) return code;
! 	if ( (code = gs_charpath_n_init(senum, igs, (char *)op[-1].value.bytes, op[-1].size, op->value.index)) < 0 )
  	   {	free_show();
  		return code;
  	   }
*** /tmp/,RCSt1a16756	Mon Jul  3 03:00:08 1989
--- zfont.c	Mon Jul  3 01:39:17 1989
***************
*** 22,29
  #include "ghost.h"
  #include "errors.h"
  #include "oper.h"
! #include "gsmatrix.h"
! #include "gxdevice.h"		/* for gxfont.h */
  #include "gxfont.h"
  #include "alloc.h"
  #include "font.h"

--- 22,33 -----
  #include "ghost.h"
  #include "errors.h"
  #include "oper.h"
! #include "gserrors.h"
! #include "gxfixed.h"
! #include "gxmatrix.h"
! #include "gzstate.h"			/* must precede gxdevice */
! #include "gxdevice.h"			/* must precede gxfont */
! #include "gschar.h"
  #include "gxfont.h"
  #include "alloc.h"
  #include "font.h"
Tony Li - USC University Computing Services
Internet: tli@usc.edu	Uucp: usc!tli	Bitnet: tli@gamera, tli@ramoth
This is a test.  This is a only a test.  In the event of a real life
you would have been given instructions.