Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!tut.cis.ohio-state.edu!CSL.SRI.COM!aida From: aida@CSL.SRI.COM (Hitoshi Aida) Newsgroups: gnu.ghostscript.bug Subject: (none) Message-ID: <8904211848.AA01055@porthos.csl.sri.com> Date: 21 Apr 89 18:48:44 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 649 Dear the author of GhostScript, I got a copy of the source of GhostScript from the archive, and ported to the SunView(monochrome) environment. I found some bugs during transportation. Here are the diffs of the bug-fixes and modifications to run on SunView. I hope these will be eventually incorporated into the release. Hitoshi AIDA (aida@csl.sri.com) Computer Science Laboratory, SRI International ############################## begin bug-fixes ############################## *** gxdraw.c Fri Mar 3 13:09:08 1989 --- gxdraw.c.org Fri Feb 24 01:13:25 1989 *************** *** 68,75 **** gs_color *pcolor, gs_state *pgs) { gx_device *dev = pgs->device->info; if ( wt == 0 && wb == 0 || h <= 0 ) return 0; ! if ( color_is_pure(pcolor) && /* 3/3/89 H.AIDA (line below) */ ! (*dev->procs->fill_trapezoid)(dev, xt, yt, wt, xb, yt + h - 1, wb, pcolor->dev_color.color1) >= 0 ) return 0; { int x, fx; --- 68,75 ---- gs_color *pcolor, gs_state *pgs) { gx_device *dev = pgs->device->info; if ( wt == 0 && wb == 0 || h <= 0 ) return 0; ! if ( color_is_pure(pcolor) && ! (*dev->procs->fill_trapezoid)(dev, xt, yt, wt, xb, yt + h, wb, pcolor->dev_color.color1) >= 0 ) return 0; { int x, fx; *************** *** 105,113 **** /* be drawn. Correct for this now. */ abs_dx = abs(dx); if ( abs_dx > 1 ) ! { /* Adjust xt if dx < 0 3/3/89 H.AIDA */ ! if ( wt < - dx ) xt -= abs_dx - wt; ! /* Increase the width */ if ( wt < abs_dx ) wt = abs_dx; if ( wb < abs_dx ) wb = abs_dx; dwf = wb - wt; --- 105,111 ---- /* be drawn. Correct for this now. */ abs_dx = abs(dx); if ( abs_dx > 1 ) ! { /* Increase the width */ if ( wt < abs_dx ) wt = abs_dx; if ( wb < abs_dx ) wb = abs_dx; dwf = wb - wt; *************** *** 214,233 **** gz_fill_rectangle(ix, iy, w, 1, pcolor, pgs); } else ! { int h = itoy - iy; /* 3/3/89 H.AIDA */ gx_device *dev = pgs->device->info; ! if ( h < 0 ) /* 3/3/89 H.AIDA */ { /* Fill primitive requires h > 0 */ int tix = ix; ix = itox, iy = itoy; itox = tix; ! h = - h; /* 3/3/89 H.AIDA */ } if ( color_is_pure(pcolor) && (*dev->procs->draw_line)(dev, ix, iy, itox, iy + h, pcolor->dev_color.color1) >= 0 ) ! return 0; /* 3/3/89 H.AIDA (line below) */ ! gz_fill_trapezoid(ix, 1, iy, itox, 1, h + 1, pcolor, pgs); } return 0; } --- 212,231 ---- gz_fill_rectangle(ix, iy, w, 1, pcolor, pgs); } else ! { int h = itoy - iy + 1; gx_device *dev = pgs->device->info; ! if ( h <= 0 ) { /* Fill primitive requires h > 0 */ int tix = ix; ix = itox, iy = itoy; itox = tix; ! h = 2 - h; } if ( color_is_pure(pcolor) && (*dev->procs->draw_line)(dev, ix, iy, itox, iy + h, pcolor->dev_color.color1) >= 0 ) ! return 0; ! gz_fill_trapezoid(ix, 1, iy, itox, 1, h, pcolor, pgs); } return 0; } *** gxstroke.c Thu Mar 16 15:24:10 1989 --- gxstroke.c.org Fri Feb 24 01:37:39 1989 *************** *** 56,62 **** /* Procedures that stroke a partial_line (the first argument). */ /* If both partial_lines are non-null, the procedure creates */ /* an appropriate join; otherwise, the procedure creates an */ ! /* end cap. If the first int is 0, the procedure also starts with */ /* an appropriate cap. */ int stroke_add(P4(int, partial_line *, partial_line *, gs_state *)); int stroke_fill(P4(int, partial_line *, partial_line *, gs_state *)); --- 56,62 ---- /* Procedures that stroke a partial_line (the first argument). */ /* If both partial_lines are non-null, the procedure creates */ /* an appropriate join; otherwise, the procedure creates an */ ! /* end cap. If the first int is true, the procedure also starts with */ /* an appropriate cap. */ int stroke_add(P4(int, partial_line *, partial_line *, gs_state *)); int stroke_fill(P4(int, partial_line *, partial_line *, gs_state *)); *************** *** 115,121 **** (pl.o.p.x = x, pl.o.p.y = y, pl.e.p.x = (ex), pl.e.p.y = (ey),\ compute_caps(&pl, pgs, 0),\ (first++ == 0 ? (pl_first = pl, 0) : 0),\ ! (index++ ? (*line_proc)(index - 2, &pl_prev, &pl, pgs) : 0),\ pl_prev = pl, 0) char ink_on = dash->init_ink_on; int dash_index = dash->init_index; --- 115,121 ---- (pl.o.p.x = x, pl.o.p.y = y, pl.e.p.x = (ex), pl.e.p.y = (ey),\ compute_caps(&pl, pgs, 0),\ (first++ == 0 ? (pl_first = pl, 0) : 0),\ ! (index++ ? (*line_proc)(index - 1, &pl_prev, &pl, pgs) : 0),\ pl_prev = pl, 0) char ink_on = dash->init_ink_on; int dash_index = dash->init_index; *************** *** 301,307 **** { gx_path *ppath = stroke_path; int code; if ( ppath == 0 ) return 0; /****** strokepath is NYI ******/ ! if ( (code = add_capped(ppath, (first == 0 ? pgs->line_params->cap : gs_cap_butt), gx_path_add_point, &plp->o)) < 0 ) return code; if ( nplp == 0 ) { code = add_capped(ppath, pgs->line_params->cap, gx_path_add_line, &plp->e); --- 301,307 ---- { gx_path *ppath = stroke_path; int code; if ( ppath == 0 ) return 0; /****** strokepath is NYI ******/ ! if ( (code = add_capped(ppath, (first ? pgs->line_params->cap : gs_cap_butt), gx_path_add_point, &plp->o)) < 0 ) return code; if ( nplp == 0 ) { code = add_capped(ppath, pgs->line_params->cap, gx_path_add_line, &plp->e); ################################ end bug-fixes ################################ ############################# begin modifications ############################# *** Makefile Thu Mar 2 10:14:49 1989 --- ux-cc-x.mak Thu Feb 23 22:46:57 1989 *************** *** 32,43 **** # Define the other compilation flags. ! CFLAGS=-O -DSUNWINDOW # Define platform flags for ld. # The following are appropriate for Sun OS4.0. ! LDPLAT= # ---------------------------- End of options --------------------------- # --- 32,43 ---- # Define the other compilation flags. ! CFLAGS=-O # Define platform flags for ld. # The following are appropriate for Sun OS4.0. ! LDPLAT=-Bstatic # ---------------------------- End of options --------------------------- # *************** *** 60,76 **** # ---------------------------- Device drivers ---------------------------- # ! ## The Sunview device ! DEVSUN=gdevsun.$(OBJ) ! gdevsun.$(OBJ): gdevsun.c gx.h gxdevice.h # -------------------------------- Library -------------------------------- # # Choose the output device ! DEVFORUNIX=$(DEVSUN) LIBUNIX=$(LIB) $(DEVFORUNIX) gs_lib.o: $(LIBUNIX) --- 60,76 ---- # ---------------------------- Device drivers ---------------------------- # ! ## The X.11 device ! DEVX=gdevx.$(OBJ) ! gdevx.$(OBJ): gdevx.c gx.h gxdevice.h # -------------------------------- Library -------------------------------- # # Choose the output device ! DEVFORUNIX=$(DEVX) LIBUNIX=$(LIB) $(DEVFORUNIX) gs_lib.o: $(LIBUNIX) *************** *** 87,101 **** # Library test programs ! x: x.$(OBJ) gdevsun.$(OBJ) ! cc $(LDPLAT) -X -o x x.$(OBJ) gdevsun.$(OBJ) -lsuntool -lsunwindow -lpixrect -lm GTUNIX=gt.$(OBJ) gsmain.$(OBJ) utrace.$(OBJ) gs_lib0.$(OBJ) $(DEVFORUNIX) gt: $(GTUNIX) ! cc $(CFLAGS) $(LDPLAT) -X -o gt $(GTUNIX) -lsuntool -lsunwindow -lpixrect -lm # Interpreter main program ! GSUNIX=gs.$(OBJ) gsmain.$(OBJ) utrace.$(OBJ) $(INT) gs_lib0.$(OBJ) gdevsun.$(OBJ) gs: $(GSUNIX) ! cc $(CFLAGS) $(LDPLAT) -X -o gs $(GSUNIX) -lsuntool -lsunwindow -lpixrect -lm --- 87,101 ---- # Library test programs ! x: x.$(OBJ) gdevx.$(OBJ) ! cc $(LDPLAT) -X -o x x.$(OBJ) gdevx.$(OBJ) -lX11 -lm GTUNIX=gt.$(OBJ) gsmain.$(OBJ) utrace.$(OBJ) gs_lib0.$(OBJ) $(DEVFORUNIX) gt: $(GTUNIX) ! cc $(CFLAGS) $(LDPLAT) -X -o gt $(GTUNIX) -lX11 -lm # Interpreter main program ! GSUNIX=gs.$(OBJ) gsmain.$(OBJ) utrace.$(OBJ) $(INT) gs_lib0.$(OBJ) gdevx.$(OBJ) gs: $(GSUNIX) ! cc $(CFLAGS) $(LDPLAT) -X -o gs $(GSUNIX) -lX11 -lm *** gs.c Thu Mar 2 10:15:15 1989 --- gs.c.org Thu Feb 23 23:53:16 1989 *************** *** 41,47 **** extern ref estack[]; /* Forward references */ ! void init1(), init2(), main1(); /* Parameters set by swproc */ static int user_errors; --- 41,47 ---- extern ref estack[]; /* Forward references */ ! void init1(), init2(); /* Parameters set by swproc */ static int user_errors; *************** *** 53,62 **** int code; int swproc(P2(char, char *)); void argproc(P2(char *, int)); - #ifdef SUNWINDOW - void sun_window_create(P2(int *, char **)); - sun_window_create(&argc, argv); - #endif /* Execute files named in the command line, */ /* processing options along the way. */ /* Wait until the first file name (or the end */ --- 53,58 ---- *************** *** 71,108 **** init2(); } strcpy(line, "{start prompt}"); - #ifndef SUNWINDOW while ( 1 ) ! { main1(line); strcpy(line, "{{"); if ( gets(line + 2) == NULL ) break; /* end of input */ strcat(line, "} execute prompt}"); } - #else SUNWINDOW - main1(line); - sun_main_loop(); - #endif SUNWINDOW } - - void - main1(char *line) - { - ref r; - int code; - code = tscan(line, &r); - if ( !code ) { - code = interpret(&r, user_errors); - zcopypage(0); /* force display update */ - #ifdef DEBUG - if ( code < 0 || osp >= osbot || esp >= estack ) - #else - if ( code < 0 ) - #endif - stack_dump(code); - interp_init(2); - } - } - /* Process switches */ int swproc(char sw, char *arg) --- 67,90 ---- init2(); } strcpy(line, "{start prompt}"); while ( 1 ) ! { code = tscan(line, &r); ! if ( !code ) ! { code = interpret(&r, user_errors); ! zcopypage(0); /* force display update */ ! #ifdef DEBUG ! if ( code < 0 || osp >= osbot || esp >= estack ) ! #else ! if ( code < 0 ) ! #endif ! stack_dump(code); ! interp_init(2); ! } strcpy(line, "{{"); if ( gets(line + 2) == NULL ) break; /* end of input */ strcat(line, "} execute prompt}"); } } /* Process switches */ int swproc(char sw, char *arg) *************** *** 109,119 **** { switch ( sw ) { default: - #ifdef SUNWINDOW - return sun_swproc(sw, arg); - #else return -1; - #endif case 'D': /* define names */ { char *eqp = strchr(arg, '='); ref value; --- 91,97 ---- *** gt.c Thu Mar 2 10:15:22 1989 --- gt.c.org Fri Feb 24 00:49:32 1989 *************** *** 99,112 **** else printf("%ld / %d = %ld\n", ttime, repeat, ttime / repeat); } - #ifndef SUNWINDOW getchar(); /* wait for confirmation */ - #else - sun_main_loop(); - } - main1() - { - #endif } float htproc(floatp x, floatp y) --- 99,105 ---- ############################## end modifications ############################## ########################## begin new file "gdevsun.c" ######################### /* Copyright (C) 1989 Aladdin Enterprises. All rights reserved. Distributed by Free Software Foundation, Inc. This file is part of Ghostscript. Ghostscript 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 Ghostscript General Public License for full details. Everyone is granted permission to copy, modify and redistribute Ghostscript, but only under the conditions described in the Ghostscript General Public License. A copy of this license is supposed to have been given to you along with Ghostscript 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. */ /* gdevsun.c */ /* SunView driver for GhostScript library */ #include #include #include /* Hack to get around the fact that something in the X library */ /* defines uint and ushort.... */ # define uint _uint # define ushort _ushort #include "gx.h" /* for gx_bitmap; includes std.h */ # undef _uint # undef _ushort #include "gxdevice.h" /* Procedures */ int sun_open(P1(gx_device *)); int sun_close(P1(gx_device *)); int sun_fill_rectangle(P6(gx_device *, int, int, int, int, int)); int sun_copy_mono(P10(gx_device *, byte *, int, int, int, int, int, int, int, int)); int sun_copy_color(P9(gx_device *, byte *, int, int, int, int, int, int, int)); int sun_draw_line(P6(gx_device *, int, int, int, int, int)); /* The device descriptor */ static gx_device_procs sun_procs = { sun_open, sun_close, gx_default_map_rgb_color, gx_default_map_color_rgb, gx_default_sync_output, sun_fill_rectangle, gx_default_tile_rectangle, sun_copy_mono, sun_copy_color, sun_draw_line, gx_default_fill_trapezoid, gx_default_tile_trapezoid }; /* Define the X Windows device */ typedef struct gx_device_sun { gx_device_common; Frame frame; Canvas canvas; Pixwin *pw; struct mpr_data mpr; Pixrect pr; } gx_device_sun; /* The instance is public. */ gx_device_sun x_device = { sizeof(gx_device_sun), &sun_procs, (int)(8.5*80), 11*80, /* x and y extent */ /* Following parameters are initialized for monochrome */ 0, /* has color */ 1, /* max r-g-b value */ 1, /* bits per color pixel */ /* End of monochrome/color parameters */ }; /* Macro for casting gx_device argument */ #define xdev ((gx_device_sun *)dev) /* Macro to validate arguments */ #define check_rect()\ if ( w <= 0 || h <= 0 ) return 0;\ if ( x < 0 || x > xdev->width - w || y < 0 || y > xdev->height - h )\ return -1 /* Process switches */ int sun_swproc(char sw, char *arg) { switch (sw) { default: return -1; case 'w': if ((x_device.width = atoi(arg)) <= 0) return -1; break; case 'h': if ((x_device.height = atoi(arg)) <= 0) return -1; break; } return 0; } Notify_value sun_input_func() { static char line[200] = "{{"; static char *ptr = line + 2; int c; do { switch (c = getchar()) { case EOF: if (ptr == line + 2) { strcpy(ptr, "} execute}"); main1(line); } exit(0); case '\n': strcpy(ptr, "} execute prompt}"); main1(line); strcpy(line, "{{"); ptr = line + 2; break; default: *ptr++ = c; } } while (stdin->_cnt > 0); return NOTIFY_DONE; } void sun_main_loop() { notify_set_input_func(x_device.frame, sun_input_func, 0); window_main_loop(x_device.frame); exit(0); } void sun_window_create(int *argc_ptr, char **argv) { x_device.frame = window_create(NULL, FRAME, FRAME_LABEL, "ghostscript", FRAME_ARGC_PTR_ARGV, argc_ptr, argv, 0); } int sun_open(register gx_device *dev) { #ifdef gs_DEBUG if ( gs_debug['X'] ) { extern int _Xdebug; _Xdebug = 1; } #endif if (xdev->frame == (Frame)0) xdev->frame = window_create(NULL, FRAME, FRAME_LABEL, "ghostscript", 0); xdev->canvas = window_create(xdev->frame, CANVAS, CANVAS_AUTO_EXPAND, FALSE, CANVAS_AUTO_SHRINK, FALSE, CANVAS_WIDTH, xdev->width, CANVAS_HEIGHT, xdev->height, WIN_VERTICAL_SCROLLBAR, scrollbar_create(0), WIN_HORIZONTAL_SCROLLBAR, scrollbar_create(0), 0); xdev->pw = canvas_pixwin(xdev->canvas); return 0; } /* Close the device. NOT SURE WHAT TO DO HERE YET. */ int sun_close(gx_device *dev) { window_destroy(xdev->frame); xdev->frame = (Frame)0; xdev->canvas = (Canvas)0; xdev->pw = (Pixwin *)0; return 0; } /* Fill a rectangle with a color. */ int sun_fill_rectangle(register gx_device *dev, int x, int y, int w, int h, int color) { #ifdef gs_DEBUG if ( gs_debug['F'] ) printf("[F] fill (%d,%d):(%d,%d) %d\n", x, y, w, h, color); #endif check_rect(); if (color != -1) pw_write(xdev->pw, x, y, w, h, color ? PIX_CLR : PIX_SET, (Pixrect *)0, 0, 0); return 0; } /* Copy a monochrome bitmap. */ int sun_copy_mono(register gx_device *dev, byte *base, int sourcex, int raster, int x, int y, int w, int h, int zero, int one) { static int optab[3][3] = { PIX_DST, PIX_SRC|PIX_DST, PIX_NOT(PIX_SRC)&PIX_DST, PIX_NOT(PIX_SRC)|PIX_DST, PIX_SET, PIX_NOT(PIX_SRC), PIX_SRC&PIX_DST, PIX_SRC, PIX_CLR, }; int op; register i; extern struct pixrectops mem_ops; check_rect(); if ((op = optab[zero+1][one+1]) == PIX_DST) return 0; xdev->pr.pr_ops = &mem_ops; xdev->pr.pr_width = w + sourcex + 8; xdev->pr.pr_height = h; xdev->pr.pr_depth = 1; xdev->pr.pr_data = (caddr_t)&(xdev->mpr); if ((raster & 1) == 0) { xdev->mpr.md_linebytes = raster; xdev->mpr.md_image = (short *)((int)base & ~1); pw_write(xdev->pw, x, y, w, h, op, &(xdev->pr), ((int)base & 1) ? sourcex + 8 : sourcex, 0); return 0; } xdev->pr.pr_height = 1; for (i = 0; i < h; i++) { xdev->mpr.md_linebytes = raster; xdev->mpr.md_image = (short *)((int)base & ~1); pw_write(xdev->pw, x, y, w, 1, op, &(xdev->pr), ((int)base & 1) ? sourcex + 8 : sourcex, 0); base += raster; y++; } } /* Copy a "color" bitmap. Since "color" is the same as monochrome, */ /* this just reduces to copying a monochrome bitmap. */ int sun_copy_color(register gx_device *dev, byte *base, int sourcex, int raster, int x, int y, int w, int h, int color_transparent) { int zero = 0, one = 1; switch ( color_transparent ) { case 0: zero = -1; break; case 1: one = -1; break; } return sun_copy_mono(dev, base, sourcex, raster, x, y, w, h, zero, one); } /* Draw a line */ int sun_draw_line(register gx_device *dev, int x0, int y0, int x1, int y1, int color) { if (color != -1) pw_vector(xdev->pw, x0, y0, x1, y1, color?PIX_CLR:PIX_SET, 0); return 0; } ########################## end new file "gdevsun.c" ##########################