]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libndb/ndblookval.c
fix special case for null pointer constants in cond expressions
[plan9front.git] / sys / src / libndb / ndblookval.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include <ip.h>
5 #include <ndb.h>
6
7 /*
8  *  Look for a pair with the given attribute.  look first on the same line,
9  *  then in the whole entry.
10  */
11 Ndbtuple*
12 ndbfindattr(Ndbtuple *entry, Ndbtuple *line, char *attr)
13 {
14         Ndbtuple *nt;
15
16         /* first look on same line (closer binding) */
17         for(nt = line; nt;){
18                 if(strcmp(attr, nt->attr) == 0)
19                         return nt;
20                 nt = nt->line;
21                 if(nt == line)
22                         break;
23         }
24
25         /* search whole tuple */
26         for(nt = entry; nt; nt = nt->entry)
27                 if(strcmp(attr, nt->attr) == 0)
28                         return nt;
29
30         return nil;
31 }