-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.c
More file actions
58 lines (50 loc) · 969 Bytes
/
search.c
File metadata and controls
58 lines (50 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* cdoc
* Copyright (c) 2019 Matthew Veety.
* See LICENSE for details
*/
#include "impl.h"
Searchres*
findindocfile(Docfile *df, char *terms)
{
Searchres *sr = nil, *cursr;
Function *curfn;
char *tmp = nil;
if(df->funs == nil)
return nil;
for(curfn = df->funs; curfn != nil; curfn = curfn->next){
tmp = strcasestr(curfn->name, terms);
if(tmp != nil){
if(sr == nil){
sr = emallocz(sizeof(Searchres));
sr->fn = curfn;
cursr = sr;
} else {
cursr->next = emallocz(sizeof(Searchres));
cursr = cursr->next;
cursr->fn = curfn;
}
tmp = nil;
}
}
return sr;
}
void
searchresprinter(int ofd, Searchres *sr, int tab)
{
int lastfn;
if(sr->next == nil)
lastfn = 1;
else
lastfn = 0;
functionprinter(ofd, sr->fn, tab, lastfn);
}
void
allsearchresprinter(int ofd, Searchres *sr, int tab)
{
Searchres *cur;
if(sr == nil)
return;
for(cur = sr; cur != nil; cur = cur->next)
searchresprinter(ofd, cur, tab);
}