Print this page
8485 Remove set but unused variables in usr/src/cmd
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/refer/glue4.c
+++ new/usr/src/cmd/refer/glue4.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 16
17 -
18 17 #include <stdio.h>
19 18 #include <ctype.h>
20 19
21 20 extern char gfile[];
22 21
23 22 void
24 23 grepcall(char *in, char *out, char *arg)
25 24 {
26 25 char line[200], *s, argig[100], *cv[50];
27 26 char *inp, inb[500];
28 27 FILE *qf, *gf;
29 - int c, oldc = 0, alph = 0, nv = 0;
28 + int c, alph = 0, nv = 0;
30 29 int sv0, sv1;
31 30 strcpy(argig, arg);
32 31 strcat(argig, ".ig");
33 32 strcpy(inp = inb, in);
34 33 if (gfile[0] == 0)
35 34 sprintf(gfile, "/tmp/rj%dg", getpid());
36 35 #if D1
37 36 fprintf(stderr, "in grepcall, gfile %s in %o out %o\n",
38 37 gfile, in, out);
39 38 #endif
40 39 for (cv[nv++] = "fgrep"; c = *inp; inp++) {
41 40 if (c == ' ')
42 41 c = *inp = 0;
43 42 else if (isupper(c))
44 43 *inp = tolower(c);
45 44 alph = (c == 0) ? 0 : alph+1;
46 45 if (alph == 1)
47 46 cv[nv++] = inp;
48 47 if (alph > 6)
49 48 *inp = 0;
50 - oldc = c;
51 49 }
52 50 #if D1
53 51 fprintf(stderr, "%d args set up\n", nv);
54 52 #endif
55 53 {
56 54 sv0 = dup(0);
57 55 close(0);
58 56 if (open(argig, 0) != 0)
59 57 err("Can't read fgrep index %s", argig);
60 58 sv1 = dup(1);
61 59 close(1);
62 60 if (creat(gfile, 0666) != 1)
63 61 err("Can't write fgrep output %s", gfile);
64 62 fgrep(nv, cv);
65 63 #if D1
66 64 fprintf(stderr, "fgrep returned, output is..\n");
67 65 #endif
68 66 close(0);
69 67 dup(sv0);
70 68 close(sv0);
71 69 close(1);
72 70 dup(sv1);
73 71 close(sv1);
74 72 }
75 73
76 74 #if D1
77 75 fprintf(stderr, "back from fgrep\n");
78 76 #endif
79 77 gf = fopen(gfile, "r");
80 78 if (gf == NULL)
81 79 err("can't read fgrep output %s", gfile);
82 80 while (fgets(line, 100, gf) == line) {
83 81 line[100] = 0;
84 82 #if D1
85 83 fprintf(stderr, "read line as //%s//\n", line);
86 84 #endif
87 85 for (s = line; *s && (*s != '\t'); s++)
88 86 ;
89 87 if (*s == '\t') {
90 88 *s++ = '\n';
91 89 *s++ = 0;
92 90 }
93 91 if (line[0])
94 92 strcat(out, line);
95 93 #if D1
96 94 fprintf(stderr, "out now /%s/\n", out);
97 95 #endif
98 96 while (*s) s++;
99 97 #if D1
100 98 fprintf(stderr, "line %o s %o s-1 %o\n", line, s, s[-1]);
101 99 #endif
102 100 if (s[-1] != '\n')
103 101 while (!feof(gf) && getc(gf) != '\n')
104 102 ;
105 103 }
106 104 fclose(gf);
107 105 #if D1
108 106 fprintf(stderr, "back from reading %, out %s\n", out);
109 107 #else
110 108 unlink(gfile);
111 109 #endif
112 110 }
113 111
114 112 void
115 113 clfgrep(void)
116 114 {
117 115 if (gfile[0])
118 116 unlink(gfile);
119 117 }
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX