diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/dict/thesaurus.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/dict/thesaurus.c')
-rwxr-xr-x | sys/src/cmd/dict/thesaurus.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/sys/src/cmd/dict/thesaurus.c b/sys/src/cmd/dict/thesaurus.c new file mode 100755 index 000000000..8ad3006bb --- /dev/null +++ b/sys/src/cmd/dict/thesaurus.c @@ -0,0 +1,86 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> +#include "dict.h" + +void +thesprintentry(Entry e, int cmd) +{ + char *p, *pe; + int c, i; + + p = e.start; + pe = e.end; + while(p < pe) { + c = *p++; + if(cmd == 'r') { + outchar(c); + continue; + } + switch(c) { + case '*': + c = *p++; + if(cmd == 'h' && c != 'L') { + outnl(0); + return; + } + if(c == 'L' && cmd != 'h') + outnl(0); + if(c == 'S') { + outchar('('); + outchar(*p++); + outchar(')'); + } + break; + case '#': + c = *p++; + i = *p++ - '0' - 1; + if(i < 0 || i > 4) + break; + switch(c) { + case 'a': outrune(L"áàâäa"[i]); break; + case 'e': outrune(L"éèêëe"[i]); break; + case 'o': outrune(L"óòôöo"[i]); break; + case 'c': outrune(L"ccccç"[i]); break; + default: outchar(c); break; + } + break; + case '+': + case '<': + break; + case ' ': + if(cmd == 'h' && *p == '*') { + outnl(0); + return; + } + default: + outchar(c); + } + } + outnl(0); +} + +long +thesnextoff(long fromoff) +{ + long a; + char *p; + + a = Bseek(bdict, fromoff, 0); + if(a < 0) + return -1; + for(;;) { + p = Brdline(bdict, '\n'); + if(!p) + break; + if(p[0] == '*' && p[1] == 'L') + return (Boffset(bdict)-Blinelen(bdict)); + } + return -1; +} + +void +thesprintkey(void) +{ + Bprint(bout, "No key\n"); +} |