2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
24 int keepold
= 1; /* keep old things for fgrep search */
28 char **fgnamp
= fgnames
;
30 extern char *mindex();
33 findline(char *in
, char **out
, int outlen
, long indexdate
)
35 static char name
[100] = "";
38 static FILE *fa
= NULL
;
43 fprintf(stderr
, "findline: %s\n", in
);
49 for (p
= in
; *p
&& *p
!= ':' && *p
!= ';'; p
++)
53 k
= sscanf(p
, "%ld,%ld", &lp
, &llen
);
55 fprintf(stderr
, "p %s k %d lp %ld llen %ld\n", p
, k
, lp
, llen
);
62 fprintf(stderr
, "lp %ld llen %ld\n", lp
, llen
);
65 fprintf(stderr
, "fa now %o, p %o in %o %s\n", fa
, p
, in
, in
);
69 fprintf(stderr
, "set fa to stdin\n");
73 if (strcmp(name
, in
) != 0 || 1) {
75 fprintf(stderr
, "old: %s new %s not equal\n", name
, in
);
78 fa
= freopen(in
, "r", fa
);
83 fprintf(stderr
, "failed to (re)open *%s*\n",
88 /* err("Can't open %s", in); */
90 if (gdate(fa
) > indexdate
&& indexdate
!= 0) {
92 for (ftp
= fgnames
; ftp
< fgnamp
; ftp
++)
93 if (strcmp(*ftp
, name
) == SAME
)
95 strcpy(*fgnamp
++ = fgp
, name
);
96 assert(fgnamp
< fgnames
+FGCT
);
97 while (*fgp
&& *fgp
!= ':')
100 assert(fgp
< fgspace
+FGSIZE
);
103 fprintf(stderr
, gettext(
104 "Warning: index predates file '%s'\n"),
110 fprintf(stderr
, "old %s new %s same fa %o\n",
115 *out
= (char *)malloc(llen
+ 1);
119 len
= fread(*out
, 1, llen
, fa
);
122 fprintf(stderr
, "length as read is %d\n", len
);