summaryrefslogtreecommitdiff
path: root/textproc/heirloom-doctools/files/patch-refer_refer7.c
blob: 4e770e14c9ee0a59f5123c729505ff3e39a258c8 (plain) (blame)
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
--- refer/refer7.c.orig	2016-03-09 21:27:38 UTC
+++ refer/refer7.c
@@ -56,16 +56,21 @@ dumpold(void)
 
 	if (!endpush)
 		return;
-	fclose(fo);
-	fo = NULL;
+	if (fo != NULL) {
+		fclose(fo);
+		fo = NULL;
+	}
+	fi = fopen(tfile, "r");
+	if (fi == NULL)
+		return;
 	if (sort) {
 		char comm[100];
+
+		fclose(fi);
 		snprintf(comm, sizeof(comm), "sort -f %s -o %s", tfile, tfile);
 		system(comm);
+		fi = fopen(tfile, "r");
 	}
-	fi = fopen(tfile, "r");
-	if (fi == NULL)
-		return;
 	flout();
 	fprintf(ftemp, ".]<\n");
 	while ((c = getc(fi)) > 0) {