aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-07-26 14:16:19 -0300
committerDavid Bremner <david@tethera.net>2021-07-26 14:16:19 -0300
commit488a4f1cee6bede9c2cfe138cd74bf4243df731c (patch)
tree71de456096db91654b841d83a8f9a2902aa89542
parentb1c178e0cc5834c180e2c883e42dca138819310b (diff)
move lrs file pointer boilerplate into process_args.
-rw-r--r--process_args.c7
-rw-r--r--rat2float.c5
2 files changed, 6 insertions, 6 deletions
diff --git a/process_args.c b/process_args.c
index 3b82500..d316a26 100644
--- a/process_args.c
+++ b/process_args.c
@@ -2,6 +2,9 @@
#include <stdio.h>
#include <stdlib.h>
+FILE *lrs_ifp;
+FILE *lrs_ofp;
+
void process_args(int argc, char **argv,char *docstring){
if (argc > 1 && argv[1][0]=='-' && argv[1][1]=='h') {
fprintf(stderr,docstring);
@@ -16,7 +19,9 @@ void process_args(int argc, char **argv,char *docstring){
if (argc > 2){
freopen(argv[2],"w",stdout);
}
-
+
+ lrs_ifp = stdin;
+ lrs_ofp = stdout;
}
diff --git a/rat2float.c b/rat2float.c
index cfb3a0a..2b23de8 100644
--- a/rat2float.c
+++ b/rat2float.c
@@ -47,8 +47,6 @@ void rattodouble(integer_t num, integer_t denom, double *out_p){
#else
typedef lrs_mp integer_t;
#define MP_DIGITS 1000L
-FILE *lrs_ifp;
-FILE *lrs_ofp;
void
lrs_overflow (int ignored) {
@@ -71,9 +69,6 @@ int main(argc,argv)
char format[BUFSIZ];
char buf[BUFSIZ];
- lrs_ifp = stdin;
- lrs_ofp = stdout;
-
process_args(argc,argv,DOCSTRING);
#ifdef LRSMP