Print this page
8485 Remove set but unused variables in usr/src/cmd
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/refer/hunt7.c
+++ new/usr/src/cmd/refer/hunt7.c
1 1 /*
2 + * Copyright 2017 Gary Mills
2 3 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 4 * Use is subject to license terms.
4 5 */
5 6
6 7 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 8 /* All Rights Reserved */
8 9
9 10 /*
10 11 * Copyright (c) 1980 Regents of the University of California.
11 12 * All rights reserved. The Berkeley software License Agreement
12 13 * specifies the terms and conditions for redistribution.
13 14 */
14 15
15 -#pragma ident "%Z%%M% %I% %E% SMI"
16 -
17 16 #include <stdio.h>
18 17 #include <locale.h>
19 18 #include <assert.h>
20 19 #define SAME 0
21 20 #define FGCT 10
22 21 #define FGSIZE 150
23 22
24 23 int keepold = 1; /* keep old things for fgrep search */
25 24 char fgspace[FGSIZE];
26 25 char *fgp = fgspace;
27 26 char *fgnames[FGCT];
28 27 char **fgnamp = fgnames;
29 28
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
30 29 extern char *mindex();
31 30
32 31 long
33 32 findline(char *in, char **out, int outlen, long indexdate)
34 33 {
35 34 static char name[100] = "";
36 35 char *p, **ftp;
37 36 extern long gdate();
38 37 static FILE *fa = NULL;
39 38 long lp, llen;
40 - int len, k, nofil;
39 + int k, nofil;
41 40
42 41 #if D1
43 42 fprintf(stderr, "findline: %s\n", in);
44 43 #endif
45 44 if (mindex(in, '!'))
46 45 return (0);
47 46
48 47 nofil = in[0] == 0;
49 48 for (p = in; *p && *p != ':' && *p != ';'; p++)
50 49 ;
51 50 if (*p) *p++ = 0;
52 51 else p = in;
53 52 k = sscanf(p, "%ld,%ld", &lp, &llen);
54 53 #ifdef D1
55 54 fprintf(stderr, "p %s k %d lp %ld llen %ld\n", p, k, lp, llen);
56 55 #endif
57 56 if (k < 2) {
58 57 lp = 0;
59 58 llen = outlen;
60 59 }
61 60 #ifdef D1
62 61 fprintf(stderr, "lp %ld llen %ld\n", lp, llen);
63 62 #endif
64 63 #ifdef D1
65 64 fprintf(stderr, "fa now %o, p %o in %o %s\n", fa, p, in, in);
66 65 #endif
67 66 if (nofil) {
68 67 #if D1
69 68 fprintf(stderr, "set fa to stdin\n");
70 69 #endif
71 70 fa = stdin;
72 71 } else
73 72 if (strcmp(name, in) != 0 || 1) {
74 73 #if D1
75 74 fprintf(stderr, "old: %s new %s not equal\n", name, in);
76 75 #endif
77 76 if (fa != NULL)
78 77 fa = freopen(in, "r", fa);
79 78 else
80 79 fa = fopen(in, "r");
81 80 #if D1
82 81 if (fa == NULL)
83 82 fprintf(stderr, "failed to (re)open *%s*\n",
84 83 in);
85 84 #endif
86 85 if (fa == NULL)
87 86 return (0);
88 87 /* err("Can't open %s", in); */
89 88 strcpy(name, in);
90 89 if (gdate(fa) > indexdate && indexdate != 0) {
91 90 if (keepold) {
92 91 for (ftp = fgnames; ftp < fgnamp; ftp++)
93 92 if (strcmp(*ftp, name) == SAME)
94 93 return (0);
95 94 strcpy(*fgnamp++ = fgp, name);
96 95 assert(fgnamp < fgnames+FGCT);
97 96 while (*fgp && *fgp != ':')
98 97 fgp++;
99 98 *fgp++ = 0;
100 99 assert(fgp < fgspace+FGSIZE);
101 100 return (0);
102 101 }
103 102 fprintf(stderr, gettext(
104 103 "Warning: index predates file '%s'\n"),
105 104 name);
106 105 }
107 106 }
108 107 #if D1
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
109 108 else
110 109 fprintf(stderr, "old %s new %s same fa %o\n",
111 110 name, in, fa);
112 111 #endif
113 112 if (fa != NULL) {
114 113 fseek(fa, lp, 0);
115 114 *out = (char *)malloc(llen + 1);
116 115 if (*out == NULL) {
117 116 return (0);
118 117 }
119 - len = fread(*out, 1, llen, fa);
118 + (void) fread(*out, 1, llen, fa);
120 119 *(*out + llen) = 0;
121 120 #ifdef D1
122 121 fprintf(stderr, "length as read is %d\n", len);
123 122 #endif
124 123 }
125 124 return (llen);
126 125 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX