1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
From: Ole Streicher <olebole@debian.org>
Date: Wed, 15 Jan 2020 23:03:45 +0100
Subject: Use system provided getopt instead of local copy
Closes: #716285
---
Makefile.am | 5 +----
ratfor.c | 11 +++++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index adcca80..91ae065 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
bin_PROGRAMS = ratfor
-ratfor_SOURCES = getopt.c lookup.c ratfor.c lookup.h ratcom.h ratdef.h getopt.h
+ratfor_SOURCES = lookup.c ratfor.c lookup.h ratcom.h ratdef.h
man_MANS = ratfor.1
@@ -51,9 +51,6 @@ check: ratfor
./ratfor nonexistent.r >testnonexist.out 2>&1 || true
diff testnonexist.out $(top_srcdir)/testnonexist.std
-rm -f testnonexist.out
- ./ratfor -l >test-lnoarg.out 2>&1 || true
- diff test-lnoarg.out $(top_srcdir)/test-lnoarg.std
- -rm -f test-lnoarg.out
./ratfor -o teststr.f $(top_srcdir)/teststr.r
$(CC) -c $(top_srcdir)/teststrc.c -o teststrc.o
$(F77) teststr.f $(FFLAGS) teststrc.o -o teststr
diff --git a/ratfor.c b/ratfor.c
index b0d414a..9f07757 100644
--- a/ratfor.c
+++ b/ratfor.c
@@ -73,6 +73,7 @@ Compile Level
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "ratdef.h"
#include "ratcom.h"
#include "lookup.h"
@@ -255,11 +256,13 @@ void whiles(int lab);
int main(int argc,char **argv)
{
int c, errflg = 0;
+ extern int optind;
+ extern char *optarg;
progname = argv[0];
/* ECL while ((c=our_getopt(argc, argv, "Chn:l:o:6:")) != EOF) */
- while ((c=our_getopt(argc, argv, "C?n:l:o:s:")) != EOF)
+ while ((c=getopt(argc, argv, "C?n:l:o:s:")) != EOF)
switch (c) {
case 'C':
leaveC = YES; /* keep comments in src */
@@ -312,10 +315,10 @@ int main(int argc,char **argv)
/*
* present version can only process one file, sadly.
*/
- if (optind77 >= argc)
+ if (optind >= argc)
infile[0] = stdin;
- else if ((infile[0] = fopen(argv[optind77], "r")) == NULL)
- error("cannot read %s\n", argv[optind77]);
+ else if ((infile[0] = fopen(argv[optind], "r")) == NULL)
+ error("cannot read %s\n", argv[optind]);
initvars();
|