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 -#if D1
43 - fprintf(stderr, "findline: %s\n", in);
44 -#endif
45 41 if (mindex(in, '!'))
46 42 return (0);
47 43
48 44 nofil = in[0] == 0;
49 45 for (p = in; *p && *p != ':' && *p != ';'; p++)
50 46 ;
51 47 if (*p) *p++ = 0;
52 48 else p = in;
53 49 k = sscanf(p, "%ld,%ld", &lp, &llen);
54 -#ifdef D1
55 - fprintf(stderr, "p %s k %d lp %ld llen %ld\n", p, k, lp, llen);
56 -#endif
57 50 if (k < 2) {
58 51 lp = 0;
59 52 llen = outlen;
60 53 }
61 -#ifdef D1
62 - fprintf(stderr, "lp %ld llen %ld\n", lp, llen);
63 -#endif
64 -#ifdef D1
65 - fprintf(stderr, "fa now %o, p %o in %o %s\n", fa, p, in, in);
66 -#endif
67 54 if (nofil) {
68 -#if D1
69 - fprintf(stderr, "set fa to stdin\n");
70 -#endif
71 55 fa = stdin;
72 56 } else
73 57 if (strcmp(name, in) != 0 || 1) {
74 -#if D1
75 - fprintf(stderr, "old: %s new %s not equal\n", name, in);
76 -#endif
77 58 if (fa != NULL)
78 59 fa = freopen(in, "r", fa);
79 60 else
80 61 fa = fopen(in, "r");
81 -#if D1
82 62 if (fa == NULL)
83 - fprintf(stderr, "failed to (re)open *%s*\n",
84 - in);
85 -#endif
86 - if (fa == NULL)
87 63 return (0);
88 64 /* err("Can't open %s", in); */
89 65 strcpy(name, in);
90 66 if (gdate(fa) > indexdate && indexdate != 0) {
91 67 if (keepold) {
92 68 for (ftp = fgnames; ftp < fgnamp; ftp++)
93 69 if (strcmp(*ftp, name) == SAME)
94 70 return (0);
95 71 strcpy(*fgnamp++ = fgp, name);
96 72 assert(fgnamp < fgnames+FGCT);
97 73 while (*fgp && *fgp != ':')
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
98 74 fgp++;
99 75 *fgp++ = 0;
100 76 assert(fgp < fgspace+FGSIZE);
101 77 return (0);
102 78 }
103 79 fprintf(stderr, gettext(
104 80 "Warning: index predates file '%s'\n"),
105 81 name);
106 82 }
107 83 }
108 -#if D1
109 - else
110 - fprintf(stderr, "old %s new %s same fa %o\n",
111 - name, in, fa);
112 -#endif
113 84 if (fa != NULL) {
114 85 fseek(fa, lp, 0);
115 86 *out = (char *)malloc(llen + 1);
116 87 if (*out == NULL) {
117 88 return (0);
118 89 }
119 - len = fread(*out, 1, llen, fa);
90 + (void) fread(*out, 1, llen, fa);
120 91 *(*out + llen) = 0;
121 -#ifdef D1
122 - fprintf(stderr, "length as read is %d\n", len);
123 -#endif
124 92 }
125 93 return (llen);
126 94 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX