From 6e0782e69c7cf8b44df724a7e2d8432bbbd27fd5 Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 20:33:18 -0400 Subject: [PATCH 01/10] Add missing stipple file from upstream "piglet" --- stipple.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 stipple.c diff --git a/stipple.c b/stipple.c new file mode 100644 index 0000000..df6e999 --- /dev/null +++ b/stipple.c @@ -0,0 +1,166 @@ +#include +#include +#include +#include +#include +#include "db.h" +#include "xwin.h" + +#define STIPW 8 +#define STIPH 8 +#define MAXSTIP 100 + +extern Display *dpy; +extern int scr; +extern Window win; + +Pixmap stipple[MAXSTIP]; + +char stip_src[MAXSTIP][STIPW] = { + + /* EQU :F1 solid fill */ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, /* solid fill */ + + /* (EQU :F2) family of ten 45 degree stipples, each offset */ + /* by one pixel. last two are doubled */ + {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, /* 8x+0 45d */ + {0x01, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02}, /* 8x+1 45d */ + {0x02, 0x01, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04}, /* 8x+2 45d */ + {0x04, 0x02, 0x01, 0x80, 0x40, 0x20, 0x10, 0x08}, /* 8x+3 45d */ + {0x08, 0x04, 0x02, 0x01, 0x80, 0x40, 0x20, 0x10}, /* 8x+4 45d */ + {0x10, 0x08, 0x04, 0x02, 0x01, 0x80, 0x40, 0x20}, /* 8x+5 45d */ + {0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x80, 0x40}, /* 8x+6 45d */ + {0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x80}, /* 8x+7 45d */ + {0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x80, 0x40}, /* 8x+6 45d */ + {0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x80}, /* 8x+7 45d */ + + /* (EQU :F3) family of ten 135 degree stipples, each offset */ + /* by one pixel. last two are doubled */ + + {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, /* 8x+0 135d */ + {0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40}, /* 8x+1 135d */ + {0x40, 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20}, /* 8x+2 135d */ + {0x20, 0x40, 0x80, 0x01, 0x02, 0x04, 0x08, 0x10}, /* 8x+3 135d */ + {0x10, 0x20, 0x40, 0x80, 0x01, 0x02, 0x04, 0x08}, /* 8x+4 135d */ + {0x08, 0x10, 0x20, 0x40, 0x80, 0x01, 0x02, 0x04}, /* 8x+5 135d */ + {0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x01, 0x02}, /* 8x+6 135d */ + {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x01}, /* 8x+7 135d */ + {0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x01, 0x02}, /* 8x+6 135d */ + {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x01}, /* 8x+7 135d */ + + /* (EQU :F4) family of ten 4x4 single point stipples */ + + {0x11, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00}, /* 4x4,1 */ + {0x44, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00}, /* 4x4,2 */ + {0x88, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00}, /* 4x4,3 */ + {0x00, 0x11, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00}, /* 4x4,4 */ + {0x00, 0x22, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00}, /* 4x4,5 */ + {0x00, 0x44, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00}, /* 4x4,6 */ + {0x00, 0x88, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00}, /* 4x4,7 */ + {0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x44, 0x00}, /* 4x4,8 */ + {0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x88, 0x00}, /* 4x4,9 */ + {0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x11, 0x00}, /* 4x4,10 */ + + /* (EQU :F5) family of ten horizontal period 8 stipples */ + + {0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00}, /* 4x4,1 */ + {0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00}, /* 4x4,2 */ + {0x88, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00}, /* 4x4,3 */ + {0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00}, /* 4x4,4 */ + {0x00, 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00}, /* 4x4,5 */ + {0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00}, /* 4x4,6 */ + {0x00, 0x88, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00}, /* 4x4,7 */ + {0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00}, /* 4x4,8 */ + {0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x22, 0x00}, /* 4x4,9 */ + {0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00}, /* 4x4,10 */ + + + /* (EQU :F6) family of ten horizontal period 8 stipples */ + {0xf0, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00}, + {0x00, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00}, + {0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0x00}, + {0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x0f}, + {0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00}, + {0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00}, + {0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00}, + {0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0}, + {0xf0, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00}, + {0x00, 0xf0, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00} +}; + +void init_stipples() { + int i,j; + unsigned char a; + for (i=0; i<50; i++) { /* deterministic stipples */ + stipple[i] = XCreateBitmapFromData(dpy, win, (const char *)stip_src[i], + (unsigned int) STIPW, (unsigned int) STIPH); + } + for (; i= MAXSTIP-1) { + return NULL; + } else { + return (&stip_src[i][0]); + } +} + +const char * get_hpgl_fill(int fill) +{ + switch (fill % 8) { + case 0: + return ("FT10,0;"); + break; + case 1: + return ("FT10,50;"); + break; + case 2: + return ("FT3,3,45;"); + break; + case 3: + return ("FT3,4,135;"); + break; + case 4: + return ("FT3,5,0;"); + break; + case 5: + return ("FT3,4,90;"); + break; + case 6: + return ("FT4,3,0;"); + break; + case 7: + return ("FT4,4,45;"); + break; + } + return NULL; +} From 0f74517378f9a3150339d70ace16ea17c3d4128a Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 21:52:13 -0400 Subject: [PATCH 02/10] fix build --- main.c | 16 +++++++++++++--- xwin.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 86acba4..af4f552 100644 --- a/main.c +++ b/main.c @@ -1,8 +1,15 @@ +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif + #include #include #include #include #include +#include +#include + #include "points.h" #include "xwin.h" #include "readfont.h" @@ -79,7 +86,7 @@ char **argv; initsym(); initplot(); - if (0 && access("./NOTEDATA.F", R_OK) == 0) { + if (access("./NOTEDATA.F", R_OK) == 0) { loadfont("./NOTEDATA.F", 0); } else if (access("/usr/local/lib/pdplot/NOTEDATA.F", R_OK) == 0) { loadfont("/usr/local/lib/pdplot/NOTEDATA.F", 0); @@ -88,9 +95,12 @@ char **argv; exit(0); } - if (0 && access("./SYMBOL.F", R_OK) == 0) { +#ifdef DEBUG + if (access("./SYMBOL.F", R_OK) == 0) { loadfont("./SYMBOL.F", 1); - } else if (access("/usr/local/lib/pdplot/SYMBOL.F", R_OK) == 0) { + } else +#endif + if (access("/usr/local/lib/pdplot/SYMBOL.F", R_OK) == 0) { loadfont("/usr/local/lib/pdplot/SYMBOL.F", 1); } else { fprintf(stderr,"can't find SYMBOL.F font file\n"); diff --git a/xwin.h b/xwin.h index d16deb9..4451606 100644 --- a/xwin.h +++ b/xwin.h @@ -1,3 +1,4 @@ +#include "points.h" void initX(void); int procXevent(char *s, int n); From 396e3026d92f1cbe5a430a01f9f474fc6ea78d78 Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 21:53:09 -0400 Subject: [PATCH 03/10] Improve build. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2862133..8a707bc 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ TARS=Makefile main.c points.c readfont.c xwin.c label.c clip.c points.h \ symbol.c symbol.h xwin.h readfont.h eventnames.h postscript.c stipple.c \ postscript.h ${FONTS} pd pd.1 -CC=cc -ggdb -Wall +CC=cc -ggdb -Wall -Werror #CC=cc -pg -Wall BINDIR = /usr/local/bin From 4a604db3fddba1d75c4c0cd7c670716fb58e2962 Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 21:53:22 -0400 Subject: [PATCH 04/10] Prevent multiple inclusion --- points.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/points.h b/points.h index eaa20ee..48c4f80 100644 --- a/points.h +++ b/points.h @@ -1,3 +1,6 @@ +#ifndef __PDP_POINTS_H +#define __PGP_POINTS_H + typedef struct datum { char *cmd; // either NULL or cmd string. If str, then x,y unused. double x; @@ -105,3 +108,4 @@ extern double xmin, xmax, ymin, ymax; #define MIRROR_Y 2 #define MIRROR_XY 3 +#endif From 997f6956814a330a751e1b86fc24a0d1f4f28623 Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 22:04:54 -0400 Subject: [PATCH 05/10] fix typo --- points.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/points.h b/points.h index 48c4f80..a8584ca 100644 --- a/points.h +++ b/points.h @@ -1,5 +1,5 @@ #ifndef __PDP_POINTS_H -#define __PGP_POINTS_H +#define __PDP_POINTS_H typedef struct datum { char *cmd; // either NULL or cmd string. If str, then x,y unused. From d95bfa2b2ecd6d16923f10361a5063e74e940797 Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 22:14:29 -0400 Subject: [PATCH 06/10] fix duplicate include --- main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/main.c b/main.c index af4f552..1e4d4ad 100644 --- a/main.c +++ b/main.c @@ -13,7 +13,6 @@ #include "points.h" #include "xwin.h" #include "readfont.h" -#include #include "symbol.h" #include "postscript.h" From 0488d8e8c6f93029a20f646a4a6d1ba1cb3b62c1 Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 22:19:27 -0400 Subject: [PATCH 07/10] fix runtime bug --- main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 1e4d4ad..af400af 100644 --- a/main.c +++ b/main.c @@ -33,16 +33,13 @@ int getz(char *s, int n) { // return a pointer to the first // non-blank character in s char *skipblanks(char *s) { - while (isblank(*s) && s!='\0') { + while (isblank(*s) && (*s != '\0')) { s++; } - return(s); + return s; } -int main(argc,argv) -int argc; -char **argv; -{ +int main(int argc, char *argv[]) { int n; double x,y; char s[BUF_SIZE]; @@ -50,12 +47,12 @@ char **argv; char scratch2[BUF_SIZE]; char *sp; int line=0; - progname = argv[0]; double xmin,xmax,ymin,ymax; double tmp; int itmp; int opt; + progname = argv[0]; setvbuf(stdin, NULL, _IONBF, 0); // make stdin unbuffered while ((opt=getopt(argc, argv, "D:")) != -1) { From 3029030194746565e0f760b658d41e673a81802b Mon Sep 17 00:00:00 2001 From: Ben Stern Date: Thu, 25 Apr 2019 22:41:48 -0400 Subject: [PATCH 08/10] remove outdated args --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index af400af..1af0fbe 100644 --- a/main.c +++ b/main.c @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) { // com_ci(optarg); // open rawfile // break; default: /* '?' */ - fprintf(stderr, "usage: %s [-p ] [-g ] [-r ]