From fd8ad78605ffd04f856df5716d6a34cf135312cf Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 26 Jul 2021 13:48:26 -0300 Subject: get rat2float building against lrslib-072 Many things could be improved, particularly error processing, but at least it builds and seems to run. --- Makefile | 5 +++-- process_args.c | 2 ++ process_args.h | 4 ++++ rat2float.c | 15 +++++++++++++-- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 process_args.h diff --git a/Makefile b/Makefile index db57b12..ed6eb4a 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,10 @@ docstrings: ${DOCHEADERS} rat2float.h: rat2float.doc -rat2float: rat2float.c rat2float.h $(MPOBJ) process_args.o - $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $(MPOBJ) process_args.o $(LDFLAGS) $< +rat2float: rat2float.o $(MPOBJ) process_args.o + $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) +rat2float.o: rat2float.c rat2float.h rat2canon.h: rat2canon.doc diff --git a/process_args.c b/process_args.c index 6e6827d..3b82500 100644 --- a/process_args.c +++ b/process_args.c @@ -1,5 +1,7 @@ +#include "process_args.h" #include #include + void process_args(int argc, char **argv,char *docstring){ if (argc > 1 && argv[1][0]=='-' && argv[1][1]=='h') { fprintf(stderr,docstring); diff --git a/process_args.h b/process_args.h new file mode 100644 index 0000000..dacadd3 --- /dev/null +++ b/process_args.h @@ -0,0 +1,4 @@ +#ifndef PROCESS_ARGS_H +#define PROCESS_ARGS_H +void process_args(int argc, char **argv,char *docstring); +#endif diff --git a/rat2float.c b/rat2float.c index a23df4f..cfb3a0a 100644 --- a/rat2float.c +++ b/rat2float.c @@ -6,13 +6,12 @@ * */ -static char rcsid[]="$Id$"; - #include #include #include #include +#include "process_args.h" #ifdef LRSMP #include "lrsmp.h" #endif @@ -44,9 +43,18 @@ void my_readrat(long *num_p, long * denom_p) { void rattodouble(integer_t num, integer_t denom, double *out_p){ *out_p=(double)num/(double)denom; } + #else typedef lrs_mp integer_t; #define MP_DIGITS 1000L +FILE *lrs_ifp; +FILE *lrs_ofp; + +void +lrs_overflow (int ignored) { + fprintf (stderr, "lrs_overflow called. exiting\n"); + exit(1); +} #endif #include "rat2float.h" @@ -62,6 +70,9 @@ int main(argc,argv) char format[BUFSIZ]; char buf[BUFSIZ]; + + lrs_ifp = stdin; + lrs_ofp = stdout; process_args(argc,argv,DOCSTRING); -- cgit v1.2.3