]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/dict/simple.c
fix strncmp/memcmp used with a wrong number
[plan9front.git] / sys / src / cmd / dict / simple.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include "dict.h"
5
6 /*
7  * Routines for handling dictionaries in UTF, headword
8  * separated from entry by tab, entries separated by newline.
9  */
10
11 void
12 simpleprintentry(Entry e, int cmd)
13 {
14         uchar *p, *pe;
15
16         p = (uchar *)e.start;
17         pe = (uchar *)e.end;
18         while(p < pe){
19                 if(*p == '\t'){
20                         if(cmd == 'h')
21                                 break;
22                         else
23                                 outchar(' '), ++p;
24                 }else if(*p == '\n')
25                         break;
26                 else
27                         outchar(*p++);
28         }
29         outnl(0);
30 }
31
32 long
33 simplenextoff(long fromoff)
34 {
35         if(Bseek(bdict, fromoff, 0) < 0)
36                 return -1;
37         if(Brdline(bdict, '\n') == 0)
38                 return -1;
39         return Boffset(bdict);
40 }
41
42 void
43 simpleprintkey(void)
44 {
45         Bprint(bout, "No pronunciation key.\n");
46 }