aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-07-26 13:48:26 -0300
committerDavid Bremner <david@tethera.net>2021-07-26 14:07:29 -0300
commitfd8ad78605ffd04f856df5716d6a34cf135312cf (patch)
treee89baa1c2d3c53edc716f3857cacc3b90c77b2c5
parentd2b8abcab3ee2e9e224c0886dd278a4e66f7ad06 (diff)
get rat2float building against lrslib-072
Many things could be improved, particularly error processing, but at least it builds and seems to run.
-rw-r--r--Makefile5
-rw-r--r--process_args.c2
-rw-r--r--process_args.h4
-rw-r--r--rat2float.c15
4 files changed, 22 insertions, 4 deletions
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 <stdio.h>
#include <stdlib.h>
+
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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
+#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);