simple.c 692 B

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