Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 README

CC=cc -ggdb -Wall
CC=cc -ggdb -Wall -Werror
#CC=cc -pg -Wall

BINDIR = /usr/local/bin
Expand Down
38 changes: 22 additions & 16 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <getopt.h>

#include "points.h"
#include "xwin.h"
#include "readfont.h"
#include <unistd.h>
#include "symbol.h"
#include "postscript.h"

Expand All @@ -27,29 +33,26 @@ 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];
char scratch[BUF_SIZE];
char scratch2[BUF_SIZE*2];
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) {
Expand All @@ -61,7 +64,7 @@ char **argv;
// com_ci(optarg); // open rawfile
// break;
default: /* '?' */
fprintf(stderr, "usage: %s [-p <psfile>] [-g <pngfile>] [-r <rawfile>] <script>\n", argv[0]);
fprintf(stderr, "usage: %s [-D display] <script>\n", argv[0]);
exit(1);
}
}
Expand All @@ -79,22 +82,25 @@ 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);
} else {
fprintf(stderr,"can't find NOTEDATA.F font file\n");
exit(0);
exit(2);
}

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");
exit(0);
exit(3);
}

while (1) {
Expand Down Expand Up @@ -325,7 +331,7 @@ char **argv;
xwin_dump_postscript("cat > pddump.dxf");
}
} else if (strncmp(sp,"exit",4)==0) {
exit(2);
exit(0);
} else {
savecmd(sp);
}
Expand All @@ -345,5 +351,5 @@ char **argv;
usleep(500); // don't hog CPU
clearerr(stdin); // recover from EOF on input pipe file
}
exit(1);
exit(0);
}
4 changes: 4 additions & 0 deletions points.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef __PDP_POINTS_H
#define __PDP_POINTS_H

typedef struct datum {
char *cmd; // either NULL or cmd string. If str, then x,y unused.
double x;
Expand Down Expand Up @@ -105,3 +108,4 @@ extern double xmin, xmax, ymin, ymax;
#define MIRROR_Y 2
#define MIRROR_XY 3

#endif
7 changes: 3 additions & 4 deletions stipple.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
// #include "db.h"

#include "points.h"
#include "xwin.h"
#include <stdlib.h>

#define STIPW 8
#define STIPH 8
Expand Down Expand Up @@ -128,11 +128,10 @@ int get_stipple_index(int fill, int pen) {
}

char *get_stipple_bits(int i) {

if (i >= MAXSTIP-1) {
return NULL;
} else {
return(&stip_src[i][0]);
return (&stip_src[i][0]);
}
}

Expand Down
10 changes: 7 additions & 3 deletions xwin.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 2
#endif

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
Expand Down Expand Up @@ -42,7 +46,7 @@ Display *dpy;
int screen_num;

int need_redraw=0;
char *progname;
extern char *progname;

#define BUF_SIZE 2000

Expand Down Expand Up @@ -511,9 +515,9 @@ double x1,y1,x2,y2;

void xwin_set_pen_line(int pen, int line)
{
int dash_n;
int dash_n = 2;
int dash_offset;
int line_style;
int line_style = LineSolid;
int line_width;
char dash_list[5];

Expand Down
1 change: 1 addition & 0 deletions xwin.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "points.h"

void initX(void);
int procXevent(char *s, int n);
Expand Down