aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/grap
diff options
context:
space:
mode:
authorwkj <devnull@localhost>2004-05-16 07:57:50 +0000
committerwkj <devnull@localhost>2004-05-16 07:57:50 +0000
commitb237df90f9390dac1ff1fdcb6813ca1f2a7bef4f (patch)
treee1ca0f939b9a7b9a3c817c7a77a4df9ddf610418 /src/cmd/grap
parent5f1cf8e6fb130fd48d6f016d13baf5408b3181f8 (diff)
downloadplan9port-b237df90f9390dac1ff1fdcb6813ca1f2a7bef4f.tar.gz
plan9port-b237df90f9390dac1ff1fdcb6813ca1f2a7bef4f.tar.bz2
plan9port-b237df90f9390dac1ff1fdcb6813ca1f2a7bef4f.zip
Checkpoint.
Diffstat (limited to 'src/cmd/grap')
-rw-r--r--src/cmd/grap/find2
-rw-r--r--src/cmd/grap/frame.c2
-rw-r--r--src/cmd/grap/grap.h2
-rw-r--r--src/cmd/grap/input.c9
-rw-r--r--src/cmd/grap/main.c31
-rw-r--r--src/cmd/grap/print.c6
-rw-r--r--src/cmd/grap/ticks.c1
7 files changed, 34 insertions, 19 deletions
diff --git a/src/cmd/grap/find b/src/cmd/grap/find
index 1c2e905b..eccbfbdb 100644
--- a/src/cmd/grap/find
+++ b/src/cmd/grap/find
@@ -1 +1 @@
-exec /usr/bin/egrep -n "$1" *.[chyl]
+grep $1 *.[ch]
diff --git a/src/cmd/grap/frame.c b/src/cmd/grap/frame.c
index a00a9d8d..61260871 100644
--- a/src/cmd/grap/frame.c
+++ b/src/cmd/grap/frame.c
@@ -53,6 +53,8 @@ void frameside(int type, Attr *desc) /* create and remember sides */
int n;
char buf[100];
+ n = 0; /* gcc */
+
nsides++;
switch (type) {
case 0: /* no side specified; kludge up all */
diff --git a/src/cmd/grap/grap.h b/src/cmd/grap/grap.h
index 65c7f83f..da761081 100644
--- a/src/cmd/grap/grap.h
+++ b/src/cmd/grap/grap.h
@@ -110,7 +110,7 @@ extern char *grow(char *, char *, int, int);
extern int lineno;
extern int synerr;
extern int codegen;
-extern char tempfile[];
+extern char *tempfile;
extern FILE *tfd;
extern Point ptmin, ptmax;
diff --git a/src/cmd/grap/input.c b/src/cmd/grap/input.c
index f558145e..0c25bba1 100644
--- a/src/cmd/grap/input.c
+++ b/src/cmd/grap/input.c
@@ -135,6 +135,7 @@ char *delimstr(char *s) /* get body of X ... X */
return tostring(buf);
}
+int
baldelim(int c, char *s) /* replace c by balancing entry in s */
{
for ( ; *s; s += 2)
@@ -175,6 +176,7 @@ void dodef(Obj *stp) /* collect args and switch input to defn */
pushsrc(Macro, stp->val);
}
+int
getarg(char *p) /* pick up single argument, store in p, return length */
{
int n, c, npar;
@@ -215,6 +217,7 @@ extern int thru;
extern Obj *thrudef;
extern char *untilstr;
+int
input(void)
{
register int c;
@@ -230,10 +233,13 @@ input(void)
return *ep++ = c;
}
+int
nextchar(void)
{
register int c;
+ c = 0; /* gcc */
+
loop:
switch (srcp->type) {
case Free: /* free string */
@@ -384,6 +390,7 @@ void do_thru(void) /* read one line, make into a macro expansion */
pushsrc(Macro, thrudef->val);
}
+int
unput(int c)
{
if (++pb >= pbuf + sizeof pbuf)
@@ -533,7 +540,7 @@ void copy(void) /* begin input from file, etc. */
FILE *fin;
if (newfile) {
- if ((fin = fopen(unsharp(newfile), "r")) == NULL)
+ if ((fin = fopen(newfile, "r")) == NULL)
ERROR "can't open file %s", newfile FATAL;
curfile++;
curfile->fin = fin;
diff --git a/src/cmd/grap/main.c b/src/cmd/grap/main.c
index 0aa67417..41797562 100644
--- a/src/cmd/grap/main.c
+++ b/src/cmd/grap/main.c
@@ -2,20 +2,20 @@
#include <signal.h>
#include <math.h>
#include <stdlib.h>
+#include <unistd.h>
#include <string.h>
#include "grap.h"
#include "y.tab.h"
+extern char *unsharp(char*);
+
int dbg = 0;
-#ifndef GRAPDEFINES
-#define GRAPDEFINES "#9/sys/lib/grap.defines"
-#endif
-char *lib_defines = GRAPDEFINES;
+char *lib_defines;
int lib = 1; /* 1 to include lib_defines */
FILE *tfd = NULL;
-char tempfile[L_tmpnam];
+char *tempfile;
int synerr = 0;
int codegen = 0; /* 1=>output for this picture; 0=>no output */
@@ -32,17 +32,22 @@ char *version = "version Dec 30, 1995";
extern int yyparse(void);
extern void setdefaults(void);
extern void getdata(void);
-extern int unlink(char *);
+/* extern int unlink(char *); */ /* in unistd.h */
+
+int
main(int argc, char *argv[])
{
extern void onintr(int), fpecatch(int);
+ lib_defines = unsharp("#9/lib/grap.defines");
+
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, onintr);
signal(SIGFPE, fpecatch);
cmdname = argv[0];
- tmpnam(tempfile);
+ tempfile = strdup("grap.XXXXXX");
+ mkstemp(tempfile);
while (argc > 1 && *argv[1] == '-') {
switch (argv[1][1]) {
case 'd':
@@ -85,7 +90,7 @@ main(int argc, char *argv[])
void onintr(int n)
{
- n;
+ //n;
if (!dbg)
unlink(tempfile);
exit(1);
@@ -114,11 +119,11 @@ static struct {
char *name;
double val;
} defaults[] ={
- "frameht", FRAMEHT,
- "framewid", FRAMEWID,
- "ticklen", TICKLEN,
- "slop", SLOP,
- NULL, 0
+ { "frameht", FRAMEHT },
+ { "framewid", FRAMEWID },
+ { "ticklen", TICKLEN },
+ { "slop", SLOP },
+ { NULL, 0 }
};
void setdefaults(void) /* set default sizes for variables */
diff --git a/src/cmd/grap/print.c b/src/cmd/grap/print.c
index 8f553c8f..9364d110 100644
--- a/src/cmd/grap/print.c
+++ b/src/cmd/grap/print.c
@@ -184,7 +184,7 @@ void do_first(void) /* done at first .G1: definitions, etc. */
sprintf(buf, "define pid /%d/\n", getpid());
pbstr(buf);
if (lib != 0) {
- if ((fp = fopen(unsharp(lib_defines), "r")) != NULL) {
+ if ((fp = fopen(lib_defines, "r")) != NULL) {
sprintf(buf1, "copy \"%s\"\n", lib_defines);
pbstr(buf1);
fclose(fp);
@@ -226,8 +226,8 @@ void opentemp(void)
if (tfd != NULL)
fclose(tfd);
if (tfd != stdout) {
-// if (tfd != NULL)
-// fclose(tfd);
+ if (tfd != NULL)
+ fclose(tfd);
if ((tfd = fopen(tempfile, "w")) == NULL) {
fprintf(stderr, "grap: can't open %s\n", tempfile);
exit(1);
diff --git a/src/cmd/grap/ticks.c b/src/cmd/grap/ticks.c
index 72fc06f5..72c81b21 100644
--- a/src/cmd/grap/ticks.c
+++ b/src/cmd/grap/ticks.c
@@ -481,6 +481,7 @@ char *desc_str(Attr *a) /* convert DOT to "dotted", etc. */
return p;
}
+int
sidelog(int logflag, int side) /* figure out whether to scale a side */
{
if ((logflag & XFLAG) && ((side & (BOT|TOP)) || side == 0))