aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dict/simple.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-11-25 03:37:45 +0000
committerrsc <devnull@localhost>2003-11-25 03:37:45 +0000
commit08708877939323c1e1cb87210193ec25fc472ff7 (patch)
treebd34e2144a3e9532ab228619d7ae8d4a0078aeeb /src/cmd/dict/simple.c
parent091f74d0a0db5ba1e098a518922525cb032a97b4 (diff)
downloadplan9port-08708877939323c1e1cb87210193ec25fc472ff7.tar.gz
plan9port-08708877939323c1e1cb87210193ec25fc472ff7.tar.bz2
plan9port-08708877939323c1e1cb87210193ec25fc472ff7.zip
add dict
Diffstat (limited to 'src/cmd/dict/simple.c')
-rw-r--r--src/cmd/dict/simple.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/cmd/dict/simple.c b/src/cmd/dict/simple.c
new file mode 100644
index 00000000..ea0443ba
--- /dev/null
+++ b/src/cmd/dict/simple.c
@@ -0,0 +1,46 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include "dict.h"
+
+/*
+ * Routines for handling dictionaries in UTF, headword
+ * separated from entry by tab, entries separated by newline.
+ */
+
+void
+simpleprintentry(Entry e, int cmd)
+{
+ uchar *p, *pe;
+
+ p = (uchar *)e.start;
+ pe = (uchar *)e.end;
+ while(p < pe){
+ if(*p == '\t'){
+ if(cmd == 'h')
+ break;
+ else
+ outchar(' '), ++p;
+ }else if(*p == '\n')
+ break;
+ else
+ outchar(*p++);
+ }
+ outnl(0);
+}
+
+long
+simplenextoff(long fromoff)
+{
+ if(Bseek(bdict, fromoff, 0) < 0)
+ return -1;
+ if(Brdline(bdict, '\n') == 0)
+ return -1;
+ return Boffset(bdict);
+}
+
+void
+simpleprintkey(void)
+{
+ Bprint(bout, "No pronunciation key.\n");
+}