🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Phil Dykstra Wed, 28 Sep 1988 21:39
gcc 1.28 bug?
#1699
Author: Phil Dykstra
Date: Wed, 28 Sep 1988 21:39
870 lines
15403 bytes
System:	Sun 3/50 w/68881
OS:	SunOS 3.5
gcc:	1.28 compiled with 1.28

The output of the cpp follows.
gcc-cc1 -O causes an IOT trap on my system, without -O works.

- Phil
===============================
# 1 "device.c"
 










# 1 "main.h"
 



# 1 "/usr/include/stdio.h"
 




extern	struct	_iobuf {
	int	_cnt;
	unsigned char *_ptr;
	unsigned char *_base;
	int	_bufsiz;
	short	_flag;
	char	_file;		 
} _iob[];




























extern struct _iobuf 	*fopen();
extern struct _iobuf 	*fdopen();
extern struct _iobuf 	*freopen();
extern struct _iobuf 	*popen();
extern struct _iobuf 	*tmpfile();
extern long	ftell();
extern char	*fgets();
extern char	*gets();



extern char	*ctermid();
extern char	*cuserid();
extern char	*tempnam();
extern char	*tmpnam();






# 5 "main.h"

# 1 "/usr/include/math.h"
 


extern int errno, signgam;

 

extern double fmod(), gamma();
extern int matherr();

 

extern double asinh(), acosh(), atanh();
extern double erf(), erfc();
extern double exp(), expm1(), log(), log10(), log1p(), pow();
extern double fabs(), floor(), ceil(), rint();
extern double lgamma();
extern double hypot(), cabs();
extern double copysign(), drem(), logb(), scalb();
extern int finite();
extern double j0(), j1(), jn(), y0(), y1(), yn();
extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
extern double sinh(), cosh(), tanh();
extern double cbrt(), sqrt();
extern double modf(), ldexp(), frexp(), atof();

 
















# 55 "/usr/include/math.h"
















struct exception {
	int type;
	char *name;
	double arg1;
	double arg2;
	double retval;
};








# 6 "main.h"

# 1 "/usr/local/lib/gcc-include/assert.h"














void _eprintf ();		 


# 7 "main.h"

# 1 "/usr/include/setjmp.h"
 






typedef int jmp_buf[15];	 

# 8 "main.h"

# 1 "/usr/include/strings.h"
 

 



char	*strcat();
char	*strncat();
int	strcmp();
int	strncmp();
char	*strcpy();
char	*strncpy();
int	strlen();
char	*index();
char	*rindex();
# 9 "main.h"

















typedef struct dict_struct *Type;

typedef struct object
 {
 	int flags;
	Type type;
	int Length;
	union
	 {
		int Integer, Boolean, Font;
	 	float Real;
	 	Type Dictionary;
	 	unsigned char *String;
	 	struct name_struct *Name;
	 	struct op_struct *Operator;
	 	struct file_struct *File;
	 	struct object *Array;
	 } u;
	
 } Object;
 
enum file_type { StringFile, StreamFile };

struct file_struct
 {
 	enum file_type file_type;
 	int available;
 	union
 	 {
 	 	unsigned char	*c_ptr;
 	 	struct _iobuf 	*f_ptr;
 	 } f;
 };

struct dict_entry
 {
 	Object entry_key, entry_value;
 };

struct dict_struct
 {
 	int dict_flags, dict_size, dict_fill;
 	struct dict_entry *dict_body;
 };

typedef struct stack
 {
 	int stack_fill, stack_size;
 	Object overflow, underflow, *stack_body;
 } *Stack, StackOb;
 
Object SameFlags (), MakeObject (), Cvx (), Cvlit (), ReadOnly (), WriteOnly (), ExecOnly ();
int OpCheck (), min (), rCheck (), wCheck (), xCheck ();
Object MakeArray (), ParseArray (), getArray (), getIArray (), *BodyArray ();
Object MakeBoolean ();


Object MakeDict (), DictLoad (), Lookup (), DictFrom (), Load ();
Type MakeType (), TypeOf (), BodyDict ();

extern int EqTrue (), Equal ();

Object FileFrom (), FileString ();

int Getch ();
struct file_struct *BodyFile ();
Object MakeInteger (), IntReal ();

Object ParseNumber ();
float Deg (), Rad ();
Object ParseId (), NameFrom (), MakeName (), Cvn (), StringName ();
unsigned char *BodyName ();
Object MakeOp (), NameOperator ();
Object Parse ();


int PolyFirst (), PolySecond (), PolyThird (), PolyPair ();

Object MakeReal (), RealInteger ();

float BodyReal (), BodyFloat ();

char *Malloc ();
Object Pop (), Top (), Where (), DictLookup ();
int Push ();

extern Object MakeString (), StringFrom (), getIString (), ParseString (), ParseHexString ();
unsigned char *BodyString ();
int lengthString ();

extern Object PDictFull;
extern Object PDictOverflow,		PInvFont,		PSyntaxError;
extern Object PDictUnderflow,		PInvRestore,		PTypeCheck;
extern Object PExecOverflow,		PIOError,		PUndefined;
extern Object PExecUnderflow,		PLimitCheck,		PUnFilename;
extern Object PInterrupt,		PNoCurrentPoint,	PUnResult;
extern Object PInvAccess,		PRangeCheck,		PUnMatched;
extern Object PInvExit,			POpOverflow,		PUnregistered;
extern Object PInvFileAccess,		POpUnderflow,		PVMError;

extern Type Boolean, Mark, String, Real, Poly, Operator;
extern Type Name, File, Dictionary, Condition, Null, Integer;
extern Type Array, Mark, Condition, Null, Float, FontID;

extern Object SysDict, Absent, Nil;
extern Object True, False, Marker, Self;
extern Object OpInterp, Lbracket, Rbracket;
extern Object StatementEdit, Fstdin, Fstdout, Fstderr;

extern Stack OpStack, ExecStack, DictStack;
extern jmp_buf env;
extern int interactive, verbose;
extern char default_library[], *library;
extern unsigned char *Bcopy ();
extern struct _iobuf  *vfp, *Fopen ();
extern void Fclose ();















extern int getchbuf;










 


Object DictFind();



# 12 "device.c"

# 1 "graphics.h"
 



# 1 "device.h"
 



# 1 "hard.h"
 



# 1 "mat.h"
 



typedef struct matrix { float A, B, C, D, tx, ty; } Matrix;

typedef struct vector { float vx, vy, vt; } Vector;

extern Matrix NewMatrix (), MatMult (), MatInvert (), Translate (), Rotate (), Scale ();
extern Vector NewVector (), DiffVector ();
extern Vector Transform (), ITransform (), DTransform (), IDTransform ();
# 5 "hard.h"

# 1 "rop.h"
 



















# 6 "hard.h"

# 1 "colour.h"
 



typedef struct { float hue, saturation, brightness; } Colour;

extern Colour Black, White;

extern Colour NewColour (), NewHSBColour (), NewRGBColour (), NewGray ();
extern void ColourHSB (), ColourRGB ();
extern float Gray (), Brightness ();
# 7 "hard.h"

# 1 "path.h"
 



















typedef struct hard_point { float hx, hy; } HardPoint;

enum pelem_type { EHeader, EMove, ELine, EArc, ECurve, EClose };

struct path_element
 {
 	enum pelem_type ptype;
 	union {
  		HardPoint point;
		struct arc { int dir; HardPoint centre; float radius, from, to; } arc;
 		struct bezier { HardPoint x0, x1, x2; } curve;
 	} pe;
 	struct path_element *next, *last;
 };

typedef struct path_element *Path;

extern HardPoint NewHardPoint (), ExtToInt (), MoveHardPoint ();
extern Path NewPath (), PathCopy (), NewMove ();
extern int PNewPath (), PInitMatrix ();
extern Path NewClipPath (), PathRemove (), ReversePath (), FlattenPath ();
extern float Normalise (), PointX (), PointY ();
# 8 "hard.h"


typedef struct device_point { int dx, dy; } DevicePoint;

extern struct hardware *HardwareFromString (), *NewBitmapHardware (), *NewWindowHardware (), *InitHardware ();
extern DevicePoint HardwareExtent ();
extern char *StringFromHardware ();

extern void BitBlt (), BitBltBlob (), BitBltLine (), DestroyHardware ();
extern void HardUpdate (), UpdateControl ();
extern Matrix DeviceMatrix ();

extern void RasterTile (), BitBltTrapezoid ();

extern int IsWindowHardware (), TransferSize ();
extern void SetTransfer ();
extern void Paint (), PaintLine (), PaintTrapezoid ();
extern int ScreenSize ();
extern void BuildScreen (), SetScreen ();
extern DevicePoint NewDevicePoint ();
# 5 "device.h"


struct device
 {
 	Matrix default_matrix;
 	Path default_clip;
 	int link_count;
 	struct hardware *dev;
 };

extern struct device *NewDevice (), *NewCacheDevice (), *LinkDevice (), *DeviceFrom (), *UniqueDevice ();
extern struct device *NewBitmapDevice ();
# 5 "graphics.h"

# 1 "point.h"
 



typedef struct point { float x, y; } Point;

extern Matrix PointTranslate ();
extern Point NewPoint (), IntToExt (), MovePoint ();
extern int MoveTo (), LineTo ();
extern Object AssignMatrix ();
# 6 "graphics.h"

# 1 "font.h"
 




extern Object Fid, FD, FontMatrix, FontType, Encoding, FontBBox, FontName;
extern Object UserShow, CharStrings, Metrics;
# 7 "graphics.h"













struct show_context
 {
 	char InShow;
 	char space;
	Point Width;
	HardPoint shim, space_shim;
 	Object CharName;
 	struct cache *ccache;
 	Matrix mat;
 };

struct state
 {
 	Matrix CTM;
 	Colour colour;
 	HardPoint cp; int cp_defined;
 	Path path;
 	Path clip;
 	Object font;
 	float line_width;
 	int line_cap;
 	int line_join;
 	struct
 	 {
 	 	float frequency, rotation, *thresh;
 	 	int count;
 	 	Object spot_function;
 	  } screen;
 	struct {
 		Object transfn;
 		float *tran;
 		int tcount;
 	} transfer;
 	int flatness;
 	float miter_limit;
 	float dash_offset, dash_array [11 ];
 	int dash_length;
	struct device *device;
	struct show_context *show;
	struct device *clipdevice;
 };

extern struct state *gstate;

extern int stroke_method, fill_method;
# 13 "device.c"


static int NullDevice ();
static int FrameDevice ();
static int GrabBits ();

Colour Black = { 0.0, 0.0, 0.0 }, White = { 0.0, 0.0, 1.0 };

struct device *NewWindowDevice (), *NewBitmapDevice (), *NewCacheDevice ();

InitDevices ()
 {
 	struct hardware *h;
 	DevicePoint extent;
 	
	InstallOp ("framedevice",	FrameDevice, 		4, 0, 0, 0, Array, Integer, Integer, Array);
	InstallOp ("nulldevice",	NullDevice,		0, 0, 0, 0);
	InstallOp ("grabbits",		GrabBits,		4, 0, 0, 0, Float, Float, Float, Float);
	
	extent = HardwareExtent (h = InitHardware ());
 	gstate->device = 0 ; gstate->clipdevice = 0 ;
	SetDevice (LinkDevice (DeviceFrom (h, DeviceMatrix (extent.dx, extent.dy))));
 }

static int GrabBits (x, y, w, h) Object x, y, w, h;
 {
 	HardPoint origin, corner, extent;
 	int width, height, size;
 	char *s;
 	struct hardware *dev;
 	
 	origin = ExtToInt (NewPoint (BodyReal (x), BodyReal (y)));
 	corner = ExtToInt (NewPoint (BodyReal (x) + BodyReal (w), BodyReal (y) + BodyReal (h)));
 	width = corner.hx - origin.hx;
 	height = corner.hy - origin.hy;
 	
 	fprintf ((&_iob[2]) , "width = %d, height = %d\n", width, height);
 	
 	extent = NewHardPoint ((float) width, (float) height);
 	
 	dev = NewBitmapHardware (width, height);
 	
 	BitBlt (gstate->device->dev, dev,
 		NewDevicePoint ((int) origin.hx, (int) origin.hy),
 		NewDevicePoint (0, 0),
 		NewDevicePoint ((int) extent.hx, (int) extent.hy),
 		3	);
 	s = StringFromHardware (dev);
 	DestroyHardware (dev);
 	size = (width + 7) / 8 * height;
 	
 	(((OpStack)->stack_fill != (OpStack)->stack_size) ?	((OpStack)->stack_body[(OpStack)->stack_fill] = ( MakeString (s, size)), (OpStack)->stack_fill++, 	1 ) : 	0 ) ;
 	Free (s);
 	(((OpStack)->stack_fill != (OpStack)->stack_size) ?	((OpStack)->stack_body[(OpStack)->stack_fill] = ( MakeInteger (width)), (OpStack)->stack_fill++, 	1 ) : 	0 ) ;
 	(((OpStack)->stack_fill != (OpStack)->stack_size) ?	((OpStack)->stack_body[(OpStack)->stack_fill] = ( MakeInteger (height)), (OpStack)->stack_fill++, 	1 ) : 	0 ) ;
 	
 	return 	1 ;
 }

static int NullDevice ()
 {
 	SetDevice (
 		NewDevice (
 			NewClipPath (0.0, 0.0, 0.0, 0.0),
 			NewMatrix (1.0, 0.0, 0.0, 1.0, 0.0, 0.0),
 			(struct hardware *) 0 ));
 	return 	1 ;
 }

 
static int FrameDevice (mat, width, height, proc) Object mat, width, height, proc;
 {
 	Matrix m;
 	
 	if (lengthArray (mat) != 6 || !ExtractMatrix (&m, mat))
 		return Error (PTypeCheck);
 	if (BodyInteger (width) < 0 || BodyInteger (height) < 0)
 		return Error (PRangeCheck);
 	SetDevice (NewWindowDevice (BodyInteger (width) * 8, BodyInteger (height), m));
 	ErasePage ();
 	
	return 	1 ;
 }

struct device *DeviceFrom (h, m) struct hardware *h; Matrix m;
 {
 	DevicePoint extent;
 	
 	extent = HardwareExtent (h);
 	return NewDevice (
 			NewClipPath (0.0, (float) extent.dx, (float) extent.dy, 0.0),
 			m,
 			h);
 }

struct device *NewWindowDevice (width, height, m) int width, height; Matrix m;
 {
 	return DeviceFrom (NewWindowHardware (width, height), m);
 }

struct device *NewBitmapDevice (width, height, m) int width, height; Matrix m;
 {
 	return DeviceFrom (NewBitmapHardware (width, height), m);
 }

struct device *NewCacheDevice (m, width, height, swidth, sheight) Matrix m; int width, height, swidth, sheight;
 {
 	return NewDevice (
 			NewClipPath (0.0, (float) width, (float) height, 0.0),
 			NewMatrix (m.A, m.B, m.C, m.D, (float) swidth, (float) height - sheight),
 			NewBitmapHardware (width, height));
 }

Path NewClipPath (left, right, top, bottom) float left, right, top, bottom;
 {
 	Path p = NewPath ();
 	HardPoint cp;
 	int cp_def = gstate->cp_defined;
 	
 	cp = gstate->cp;
 	(void)  MoveTo (p, NewHardPoint (left, 	bottom));
 	(void)  LineTo (p, NewHardPoint (right, bottom));
 	(void)  LineTo (p, NewHardPoint (right, top));
 	(void)  LineTo (p, NewHardPoint (left,  top));
 	ClosePath (p);
 	
 	gstate->cp = cp; gstate->cp_defined = cp_def;
 	
 	return p;
 }

struct device *NewDevice (clip, m, dev) Path clip; Matrix m; struct hardware *dev;
 {
 	struct device *res = (struct device *) Malloc (sizeof (struct device));
 	
 	res->link_count = 0;
 	res->default_clip = clip;
 	res->default_matrix = m;
 	res->dev = dev;
 	
 	return res;
 }

SetDevice (d) struct device *d;
 {
 	UnlinkDevice (gstate->device);
 	gstate->device = LinkDevice (d);
 	gstate->CTM = d->default_matrix;
 	InitClip ();
 }

int IsCache (d) struct device *d;
 {
	return !IsWindowHardware (d->dev);
 }

struct device *LinkDevice (d) struct device *d;
 {
 	if (d)
 		++d->link_count;
 	
	return d;
 }

UnlinkDevice (d) struct device *d;
 {
 	if (d == 0 )
 		return;
 	if (--d->link_count != 0)
		return;
	if (d->dev != 0 )
 		DestroyHardware (d->dev);	
 	Free ((char *) d);
 }

struct device *UniqueDevice (d) struct device *d;
 {
 	struct device *res;
 	DevicePoint ex;
 	
 	if (d && d->link_count == 1)
 		return d;
 	ex = HardwareExtent (gstate->device->dev);
 	res = LinkDevice (NewBitmapDevice (ex.dx, ex.dy, gstate->CTM));
 	 





BitBlt (0 , res->dev, NewDevicePoint (0, 0), NewDevicePoint (0, 0), ex, 0	);
 	
 	return res;
 }

DevicePoint NewDevicePoint (x, y) int x, y;
 {
 	DevicePoint res;
 	
 	res.dx = x; res.dy = y;
 	
 	return res;
 }

DevicePoint HardToDevice (p) HardPoint p;
 {
 	return NewDevicePoint ((int) p.hx, (int) p.hy);
 }

DevicePaintLine (d, fromPoint, toPoint, colour)
	struct device *d;
	HardPoint fromPoint, toPoint;
	Colour colour;
 {
 	PaintLine (d->dev, HardToDevice (fromPoint), HardToDevice (toPoint), colour);
 }

 







































 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads