Lines 78-83
Link Here
|
78 |
#include <stdio.h> |
78 |
#include <stdio.h> |
79 |
#include <stdlib.h> |
79 |
#include <stdlib.h> |
80 |
#include <string.h> |
80 |
#include <string.h> |
|
|
81 |
#include <unistd.h> |
82 |
#include <fcntl.h> |
81 |
|
83 |
|
82 |
#define LINESIZE 65536 // NeXT_MOD |
84 |
#define LINESIZE 65536 // NeXT_MOD |
83 |
|
85 |
|
Lines 100-105
Link Here
|
100 |
} dep_files[1000]; |
102 |
} dep_files[1000]; |
101 |
int dep_file_index; |
103 |
int dep_file_index; |
102 |
|
104 |
|
|
|
105 |
static int |
103 |
qsort_strcmp(a, b) |
106 |
qsort_strcmp(a, b) |
104 |
struct dep *a, *b; |
107 |
struct dep *a, *b; |
105 |
{ |
108 |
{ |
Lines 137-143
Link Here
|
137 |
|
140 |
|
138 |
static void scan_mak(FILE *, FILE *, char *); |
141 |
static void scan_mak(FILE *, FILE *, char *); |
139 |
static void finish_mak(FILE *, FILE *); |
142 |
static void finish_mak(FILE *, FILE *); |
|
|
143 |
static int read_dep(register char *); |
144 |
static void expunge_mak(register FILE *, register FILE *); |
145 |
static void skip_mak(register FILE *, register FILE *); |
146 |
static void output_dep(FILE *); |
147 |
static void parse_dep(); |
148 |
static void save_dot_o(); |
140 |
|
149 |
|
|
|
150 |
int |
141 |
main(argc,argv) |
151 |
main(argc,argv) |
142 |
register char **argv; |
152 |
register char **argv; |
143 |
{ |
153 |
{ |
Lines 152-158
Link Here
|
152 |
if (*token++ != '-' || !*token) |
162 |
if (*token++ != '-' || !*token) |
153 |
break; |
163 |
break; |
154 |
else { register int flag; |
164 |
else { register int flag; |
155 |
for ( ; flag = *token++ ; ) { |
165 |
for ( ; (flag = *token++) ; ) { |
156 |
switch (flag) { |
166 |
switch (flag) { |
157 |
case 'd': |
167 |
case 'd': |
158 |
delete++; |
168 |
delete++; |
Lines 177-183
Link Here
|
177 |
expunge++; |
187 |
expunge++; |
178 |
break; |
188 |
break; |
179 |
case 'D': |
189 |
case 'D': |
180 |
for ( ; flag = *token++ ; ) |
190 |
for ( ; (flag = *token++) ; ) |
181 |
switch (flag) { |
191 |
switch (flag) { |
182 |
case 'c': |
192 |
case 'c': |
183 |
D_contents++; |
193 |
D_contents++; |
Lines 227-233
Link Here
|
227 |
exit(1); |
237 |
exit(1); |
228 |
} else if (D_open) |
238 |
} else if (D_open) |
229 |
printf("%s: opened outfile \"%s\"\n", name, outfile); |
239 |
printf("%s: opened outfile \"%s\"\n", name, outfile); |
230 |
} else if (mak = find_mak(makefile)) { |
240 |
} else if ((mak = find_mak(makefile))) { |
231 |
makout = temp_mak(); |
241 |
makout = temp_mak(); |
232 |
out = makout; |
242 |
out = makout; |
233 |
if (expunge) |
243 |
if (expunge) |
Lines 246-252
Link Here
|
246 |
for (; argc--; argv++) { |
256 |
for (; argc--; argv++) { |
247 |
dep_file_index = 0; |
257 |
dep_file_index = 0; |
248 |
|
258 |
|
249 |
if (size = read_dep(*argv)) { |
259 |
if ((size = read_dep(*argv))) { |
250 |
|
260 |
|
251 |
save_dot_o(); |
261 |
save_dot_o(); |
252 |
if (D_depend) printf("%s: dot_o = \"%s\"\n", name, dot_o); |
262 |
if (D_depend) printf("%s: dot_o = \"%s\"\n", name, dot_o); |
Lines 269-274
Link Here
|
269 |
} |
279 |
} |
270 |
|
280 |
|
271 |
|
281 |
|
|
|
282 |
int |
272 |
read_dep(file) |
283 |
read_dep(file) |
273 |
register char *file; |
284 |
register char *file; |
274 |
{ |
285 |
{ |
Lines 294-300
Link Here
|
294 |
switch(statbuf.st_mode & S_IFMT) { |
305 |
switch(statbuf.st_mode & S_IFMT) { |
295 |
case S_IFREG: |
306 |
case S_IFREG: |
296 |
if (D_time) |
307 |
if (D_time) |
297 |
printf("%s: file time = %d\n", name, statbuf.st_mtime); |
308 |
printf("%s: file time = %ld\n", name, statbuf.st_mtime); |
298 |
|
309 |
|
299 |
if (statbuf.st_size > IObuffer) { |
310 |
if (statbuf.st_size > IObuffer) { |
300 |
fprintf(stderr, "%s: file \"%s\" tooo big for IObuffer\n", |
311 |
fprintf(stderr, "%s: file \"%s\" tooo big for IObuffer\n", |
Lines 304-310
Link Here
|
304 |
break; |
315 |
break; |
305 |
else if ((int) mak && statbuf.st_mtime < makstat.st_mtime) { |
316 |
else if ((int) mak && statbuf.st_mtime < makstat.st_mtime) { |
306 |
if (verbose || D_time) |
317 |
if (verbose || D_time) |
307 |
fprintf(stderr, "%s: skipping \"%s\" %d < %d \"%s\"\n", |
318 |
fprintf(stderr, "%s: skipping \"%s\" %ld < %ld \"%s\"\n", |
308 |
name, file, statbuf.st_mtime, makstat.st_mtime, |
319 |
name, file, statbuf.st_mtime, makstat.st_mtime, |
309 |
real_mak_name); |
320 |
real_mak_name); |
310 |
goto out; |
321 |
goto out; |
Lines 345-350
Link Here
|
345 |
return 0; |
356 |
return 0; |
346 |
} |
357 |
} |
347 |
|
358 |
|
|
|
359 |
static void |
348 |
save_dot_o() |
360 |
save_dot_o() |
349 |
{ |
361 |
{ |
350 |
register char *cp = file_array; |
362 |
register char *cp = file_array; |
Lines 355-360
Link Here
|
355 |
*svp = 0; |
367 |
*svp = 0; |
356 |
} |
368 |
} |
357 |
|
369 |
|
|
|
370 |
static void |
358 |
parse_dep() |
371 |
parse_dep() |
359 |
{ |
372 |
{ |
360 |
register char *lp = file_array; |
373 |
register char *lp = file_array; |
Lines 381-387
Link Here
|
381 |
cp = dep_line; |
394 |
cp = dep_line; |
382 |
lp[-1] = 0; |
395 |
lp[-1] = 0; |
383 |
/* skip .o file name */ |
396 |
/* skip .o file name */ |
384 |
while ((c = *cp++) && c != ':'); if (!c) continue; |
397 |
while ((c = *cp++) && c != ':'); |
|
|
398 |
if (!c) continue; |
385 |
next_filename: |
399 |
next_filename: |
386 |
i = 0; |
400 |
i = 0; |
387 |
abspath = 0; |
401 |
abspath = 0; |
Lines 415-421
Link Here
|
415 |
if (abspath) |
429 |
if (abspath) |
416 |
*cp++ = '/'; |
430 |
*cp++ = '/'; |
417 |
for (c=0; c<i; c++) {register char *ccp = path_component[c]; |
431 |
for (c=0; c<i; c++) {register char *ccp = path_component[c]; |
418 |
while (*cp++ = *ccp++); |
432 |
while ((*cp++ = *ccp++)); |
419 |
*--cp = '/'; |
433 |
*--cp = '/'; |
420 |
cp++; |
434 |
cp++; |
421 |
} |
435 |
} |
Lines 425-431
Link Here
|
425 |
dep_files[c].str = tlp; |
439 |
dep_files[c].str = tlp; |
426 |
dep_files[c].len = cp - tlp; |
440 |
dep_files[c].len = cp - tlp; |
427 |
if (D_depend) |
441 |
if (D_depend) |
428 |
printf("%s: dep_file[%d] = \"%s\" Len %d\n", |
442 |
printf("%s: dep_file[%d] = \"%s\" Len %ld\n", |
429 |
name, dep_file_index - 1, tlp, cp - tlp); |
443 |
name, dep_file_index - 1, tlp, cp - tlp); |
430 |
tlp = cp + 1; |
444 |
tlp = cp + 1; |
431 |
if (oldc) |
445 |
if (oldc) |
Lines 436-441
Link Here
|
436 |
} |
450 |
} |
437 |
} |
451 |
} |
438 |
|
452 |
|
|
|
453 |
static void |
439 |
output_dep(out) |
454 |
output_dep(out) |
440 |
FILE *out; |
455 |
FILE *out; |
441 |
{ |
456 |
{ |
Lines 514-520
Link Here
|
514 |
if (D_open) |
529 |
if (D_open) |
515 |
printf("%s: opened makefile \"%s\"\n", name, real_mak_name); |
530 |
printf("%s: opened makefile \"%s\"\n", name, real_mak_name); |
516 |
if (D_time) |
531 |
if (D_time) |
517 |
printf("%s: makefile time = %d\n", name, makstat.st_mtime); |
532 |
printf("%s: makefile time = %ld\n", name, makstat.st_mtime); |
518 |
|
533 |
|
519 |
return mak; |
534 |
return mak; |
520 |
} |
535 |
} |
Lines 543-548
Link Here
|
543 |
return mak; |
558 |
return mak; |
544 |
} |
559 |
} |
545 |
|
560 |
|
|
|
561 |
static void |
546 |
skip_mak(makin, makout) |
562 |
skip_mak(makin, makout) |
547 |
register FILE *makin, *makout; |
563 |
register FILE *makin, *makout; |
548 |
{ |
564 |
{ |
Lines 566-571
Link Here
|
566 |
printf("eof = %d str = \"%s\"", mak_eof, makbuf); |
582 |
printf("eof = %d str = \"%s\"", mak_eof, makbuf); |
567 |
} |
583 |
} |
568 |
|
584 |
|
|
|
585 |
static void |
569 |
expunge_mak(makin, makout) |
586 |
expunge_mak(makin, makout) |
570 |
register FILE *makin, *makout; |
587 |
register FILE *makin, *makout; |
571 |
{ |
588 |
{ |