william@oahu.cs.ucla.edu (William Cheng) (06/06/90)
I've just put tgif-1.6 in the `contrib' directory of `expo.lcs.ucla.edu' and the `pub' directory of `rye.cs.ucla.edu'. Here's a short list of added features/bug fixes. 1) Fix bugs reported by Sebastian Rahtz regarding the position of the PostScript bounding box and %!. 2) Add XDefault "Tgif*PrintCommand" to override lpr. 3) Add -DPSFILE_MOD in Imakefile to chmod the .ps file. 4) Update prtgif to use pipes instead of files. Following is a patch file to bring tgif from release 1.5 to 1.6. -------------------------------> cut here <----------------------------------- *** file.c.orig Tue Jun 5 12:00:47 1990 --- file.c Tue Jun 5 12:01:04 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/file.c,v 1.12 90/05/28 07:48:15 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/file.c,v 1.13 90/06/05 10:30:42 william Exp $"; #endif *************** *** 68,72 **** char * FileName; { ! char s[256]; FILE * fp; --- 68,72 ---- char * FileName; { ! char s[MAXSTRING]; FILE * fp; *************** *** 384,389 **** struct ObjRec * * ObjPtr; { ! char inbuf[256], obj_name[10], tmp_str[256], * s, * s1; ! char * line = NULL, * c_ptr; int len, id, old_len, cur_size, done = FALSE; int allocated = FALSE; --- 384,389 ---- struct ObjRec * * ObjPtr; { ! char inbuf[MAXSTRING+1], obj_name[10], tmp_str[MAXSTRING+1]; ! char * line = NULL, * c_ptr, * s, * s1; int len, id, old_len, cur_size, done = FALSE; int allocated = FALSE; *************** *** 392,396 **** struct AttrRec * top_attr = NULL, * bot_attr = NULL, * attr_ptr; ! while (fgets (inbuf, 256, FP) != NULL) { if (inbuf[0] == ']') return (FALSE); --- 392,396 ---- struct AttrRec * top_attr = NULL, * bot_attr = NULL, * attr_ptr; ! while (fgets (inbuf, MAXSTRING, FP) != NULL) { if (inbuf[0] == ']') return (FALSE); *************** *** 398,409 **** len = strlen(inbuf); if (inbuf[len-1] != '\r' && inbuf[len-1] != '\n') ! { /* line longer than 256 characters */ ! /* inbuf[255] == '\0' and len == 255 now */ ! cur_size = 510; allocated = TRUE; line = (char *) calloc (cur_size, sizeof(char)); strcpy (line, inbuf); ! c_ptr = &(line[255]); ! while (fgets (inbuf, 256, FP) != NULL && !done) { len = strlen(inbuf); --- 398,409 ---- len = strlen(inbuf); if (inbuf[len-1] != '\r' && inbuf[len-1] != '\n') ! { /* line longer than MAXSTRING characters */ ! /* inbuf[MAXSTRING-1] == '\0' and len == MAXSTRING-1 now */ ! cur_size = 2*(MAXSTRING-1); allocated = TRUE; line = (char *) calloc (cur_size, sizeof(char)); strcpy (line, inbuf); ! c_ptr = &(line[MAXSTRING-1]); ! while (fgets (inbuf, MAXSTRING, FP) != NULL && !done) { len = strlen(inbuf); *************** *** 416,423 **** else { ! cur_size += 255; line = (char *) realloc (line, cur_size); strcpy (c_ptr, inbuf); ! c_ptr += 255; } } --- 416,423 ---- else { ! cur_size += MAXSTRING-1; line = (char *) realloc (line, cur_size); strcpy (c_ptr, inbuf); ! c_ptr += MAXSTRING-1; } } *************** *** 530,534 **** ReadGroupObj (FP, ObjPtr); (*ObjPtr)->type = OBJ_ICON; ! if (fgets (line, 256, FP) == NULL) { if (allocated) cfree (line); --- 530,534 ---- ReadGroupObj (FP, ObjPtr); (*ObjPtr)->type = OBJ_ICON; ! if (fgets (line, MAXSTRING, FP) == NULL) { if (allocated) cfree (line); *************** *** 833,837 **** ury1 = -1.0*lty*real_ps_dots_per_inch/(PIX_PER_INCH); ! fprintf (fp,"%%%%BoundingBox: %.3f %.3f %.3f %.3f\n\n",llx1,lly1,urx1,ury1); } --- 833,837 ---- ury1 = -1.0*lty*real_ps_dots_per_inch/(PIX_PER_INCH); ! fprintf (fp,"%%%%BoundingBox: %.3f %.3f %.3f %.3f\n",llx1,lly1,urx1,ury1); } *************** *** 839,845 **** { register struct ObjRec * obj_ptr; ! char cmd[BUFSIZ], tmp_str[BUFSIZ]; ! char tmp_file[BUFSIZ], ps_file[BUFSIZ]; ! char message[BUFSIZ]; int i, len; FILE * fp, * fps; --- 839,845 ---- { register struct ObjRec * obj_ptr; ! char * c_ptr, cmd[MAXSTRING+1], tmp_str[MAXSTRING+1]; ! char tmp_file[MAXSTRING+1], ps_file[MAXSTRING+1]; ! char message[MAXSTRING+1]; int i, len; FILE * fp, * fps; *************** *** 859,862 **** --- 859,864 ---- } + fprintf (fp, "%%!\n"); + DumpBBox (fp); sprintf(ps_file, "%s/.psmac", drawPath); if ((fps = fopen (ps_file, "r")) == NULL) *************** *** 864,877 **** sprintf (message, "Can not find %s, print aborted.", ps_file); Msg (message); ! unlink(tmp_file); return; } ! /* ! * Copy the header file. ! */ ! while (fgets(tmp_str, 256, fps) != NULL) ! fputs(tmp_str, fp); - DumpBBox (fp); fprintf (fp, "gsave\n\n"); switch (pageStyle) --- 866,876 ---- sprintf (message, "Can not find %s, print aborted.", ps_file); Msg (message); ! fclose (fp); ! unlink (tmp_file); return; } ! while (fgets (tmp_str, MAXSTRING, fps) != NULL) /* copy the header file */ ! fputs (tmp_str, fp); fprintf (fp, "gsave\n\n"); switch (pageStyle) *************** *** 896,900 **** { case PRINTER: ! sprintf (cmd, "lpr %s 2>&1", tmp_file); if ((fp = popen (cmd, "r")) == NULL) { --- 895,903 ---- { case PRINTER: ! if ((c_ptr = XGetDefault (mainDisplay,"Tgif","PrintCommand")) != NULL) ! sprintf (cmd, "%s %s 2>&1", c_ptr, tmp_file); ! else ! sprintf (cmd, "lpr %s 2>&1", tmp_file); ! if ((fp = popen (cmd, "r")) == NULL) { *************** *** 904,908 **** return; } ! while (fgets (tmp_str, 256, fp) != NULL) { Msg (tmp_str); --- 907,911 ---- return; } ! while (fgets (tmp_str, MAXSTRING, fp) != NULL) { Msg (tmp_str); *************** *** 927,931 **** sprintf (cmd, "Printing into '%s'.", ps_file); Msg (cmd); ! sprintf (cmd, "tgif2ps < %s 1> %s 2>&1", tmp_file, ps_file); if ((fp = popen (cmd, "r")) == NULL) { --- 930,935 ---- sprintf (cmd, "Printing into '%s'.", ps_file); Msg (cmd); ! sprintf (cmd, "tgif2ps < %s 1> %s 2>&1; chmod %s %s", tmp_file, ! ps_file, PSFILE_MOD, ps_file); if ((fp = popen (cmd, "r")) == NULL) { *************** *** 935,939 **** return; } ! while (fgets(tmp_str, 256, fp) != NULL) { Msg (tmp_str); --- 939,943 ---- return; } ! while (fgets(tmp_str, MAXSTRING, fp) != NULL) { Msg (tmp_str); *** mainloop.c.orig Tue Jun 5 12:02:05 1990 --- mainloop.c Tue Jun 5 12:02:19 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/mainloop.c,v 1.2 90/05/07 15:15:33 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/mainloop.c,v 1.3 90/05/30 16:59:58 william Exp $"; #endif *** prtgif.c.orig Tue Jun 5 12:03:10 1990 --- prtgif.c Tue Jun 5 12:03:21 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/prtgif.c,v 1.7 90/05/25 20:33:59 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/prtgif.c,v 1.9 90/06/05 10:09:52 william Exp $"; #endif *************** *** 646,671 **** { register struct ObjRec * obj_ptr; ! char cmd[MAXSTRING+1]; ! char tmp_file1[30], tmp_file2[30]; ! FILE * fp; if (botObj == NULL) { printf ("No object to print."); return; } ! sprintf (tmp_file1, "/tmp/Tgif1XXXXXX"); ! sprintf (tmp_file2, "/tmp/Tgif2XXXXXX"); ! mktemp (tmp_file1); ! mktemp (tmp_file2); ! sprintf (cmd, "rm -f %s %s", tmp_file1, tmp_file2); ! system (cmd); ! if ((fp = fopen (tmp_file1, "w")) == NULL) { ! printf ("Can not create $s, print aborted.", tmp_file1); return; } ! printf ("Writing to %s ...\n", tmp_file2); DumpBBox (fp); fprintf (fp, "gsave\n\n"); switch (pageStyle) --- 646,680 ---- { register struct ObjRec * obj_ptr; ! char cmd[MAXSTRING+1], tmp_str[MAXSTRING+1]; ! char tmp_file[MAXSTRING+1], ps_file[MAXSTRING+1]; ! FILE * fp, * fps; if (botObj == NULL) { printf ("No object to print."); return; } ! strcpy (tmp_file, "/tmp/TgifXXXXXX"); ! mktemp (tmp_file); ! unlink (tmp_file); ! if ((fp = fopen (tmp_file, "w")) == NULL) { ! printf ("Can not create $s, print aborted.", tmp_file); return; } ! printf ("Writing to %s ...\n", tmp_file); + fprintf (fp, "%%!\n"); DumpBBox (fp); + sprintf(ps_file, "%s/.psmac", drawPath); + if ((fps = fopen (ps_file, "r")) == NULL) + { + printf ("Can not find %s, print aborted.\n", ps_file); + fclose (fp); + unlink (tmp_file); + return; + } + while (fgets (tmp_str, 256, fps) != NULL) /* copy the header file */ + fputs (tmp_str, fp); + fprintf (fp, "gsave\n\n"); switch (pageStyle) *************** *** 687,701 **** fclose (fp); ! sprintf (cmd, "cat %s/.psmac %s > %s", drawPath, tmp_file1, tmp_file2); ! system (cmd); ! chmod (tmp_file1, 0777); ! chmod (tmp_file2, 0777); ! sprintf (cmd, "lpr %s", tmp_file2); ! system (cmd); ! printf ("%s printed.\n\n", tmp_file2); ! sprintf (cmd, "rm -f %s %s", tmp_file1, tmp_file2); ! system (cmd); } --- 696,712 ---- fclose (fp); ! sprintf (cmd, "lpr %s 2>&1", tmp_file); ! if ((fp = popen (cmd, "r")) == NULL) ! { ! printf ("Can not execute '%s', print aborted.\n", cmd); ! unlink (tmp_file); ! return; ! } ! while (fgets (tmp_str, 256, fp) != NULL) sleep (5); ! pclose (fp); ! unlink (tmp_file); ! printf ("%s printed.\n\n", tmp_file); } *** setup.c.orig Tue Jun 5 12:03:44 1990 --- setup.c Tue Jun 5 12:03:54 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/setup.c,v 1.6 90/05/22 16:58:19 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/setup.c,v 1.7 90/05/30 16:41:07 william Exp $"; #endif *** tgif2ps.c.orig Tue Jun 5 12:04:24 1990 --- tgif2ps.c Tue Jun 5 12:04:35 1990 *************** *** 6,10 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/tgif2ps.c,v 1.2 90/05/23 13:17:34 william Exp $"; #endif --- 6,10 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/tgif2ps.c,v 1.4 90/06/05 09:31:14 william Exp $"; #endif *************** *** 25,28 **** --- 25,29 ---- exit (-1); } + printf ("%%!\n"); } *** version.c.orig Tue Jun 5 12:05:20 1990 --- version.c Tue Jun 5 12:05:29 1990 *************** *** 6,11 **** #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/version.c,v 1.8 90/05/29 09:46:20 william Exp $"; #endif ! char * version_string = "1.5"; --- 6,11 ---- #ifndef lint static char RCSid[] = ! "@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/version.c,v 1.9 90/06/05 10:32:28 william Exp $"; #endif ! char * version_string = "1.6"; *** Imakefile.orig Tue Jun 5 12:05:44 1990 --- Imakefile Tue Jun 5 12:05:57 1990 *************** *** 4,15 **** /**/# Copyright (C) 1990, William Cheng. /**/# ! /**/# @(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/Imakefile,v 1.12 90/05/29 09:45:48 william Exp $ /**/# ! TGIFVERSION = 1.5 PROGRAMS = tgif prtgif tgif2ps frontend11.o CDEBUGFLAGS = -g BINDIR = /u/tangram/bin ! DEFINES = -DTGIF_PATH=\"/u/tangram/u/william/X11/TGIF\" LOCAL_LIBRARIES = $(XLIB) SYS_LIBRARIES = -lm --- 4,16 ---- /**/# Copyright (C) 1990, William Cheng. /**/# ! /**/# @(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/Imakefile,v 1.13 90/06/05 10:32:37 william Exp $ /**/# ! TGIFVERSION = 1.6 PROGRAMS = tgif prtgif tgif2ps frontend11.o CDEBUGFLAGS = -g BINDIR = /u/tangram/bin ! DEFINES = -DTGIF_PATH=\"/u/tangram/u/william/X11/TGIF\" \ ! -DPSFILE_MOD=\"664\" LOCAL_LIBRARIES = $(XLIB) SYS_LIBRARIES = -lm *** .psmac.orig Tue Jun 5 12:07:04 1990 --- .psmac Tue Jun 5 12:07:15 1990 *************** *** 1,3 **** - %! /ellipsedict 6 dict def --- 1,2 ---- *** tgif.man.orig Tue Jun 5 12:20:48 1990 --- tgif.man Tue Jun 5 12:20:57 1990 *************** *** 1,4 **** ! .\"@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/tgif.man,v 1.5 90/05/25 14:29:20 william Exp $ ! .TH TGIF 1 "Version 1.3" "Tgif" .SH NAME \fItgif\fR \- Xlib based 2-D drawing facility under X11. Also supports --- 1,4 ---- ! .\"@(#)$Header: /n/kona/u/tangram/u/william/X11/TGIF/RCS/tgif.man,v 1.6 90/06/05 12:19:24 william Exp $ ! .TH TGIF 1 "Version 1.6" "Tgif" .SH NAME \fItgif\fR \- Xlib based 2-D drawing facility under X11. Also supports *************** *** 366,369 **** --- 366,373 ---- This specified the default color index if certain color can not be found. Default is 0. + .TP + .I Tgif*PrintCommand: COMMAND + This specified the print command used for printing the PostScript file. + Default is lpr (without any quotes). .SH ENVIRONMENT .TP -------------------------------> cut here <----------------------------------- -- -- Bill Cheng // UCLA Computer Science Department // (213) 206-7135 3277 Boelter Hall // Los Angeles, California 90024 // USA william@CS.UCLA.EDU ...!{uunet|ucbvax}!cs.ucla.edu!william