simple.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include "dict.h"
  13. /*
  14. * Routines for handling dictionaries in UTF, headword
  15. * separated from entry by tab, entries separated by newline.
  16. */
  17. void
  18. simpleprintentry(Entry e, int cmd)
  19. {
  20. uint8_t *p, *pe;
  21. p = (uint8_t *)e.start;
  22. pe = (uint8_t *)e.end;
  23. while(p < pe){
  24. if(*p == '\t'){
  25. if(cmd == 'h')
  26. break;
  27. else
  28. outchar(' '), ++p;
  29. }else if(*p == '\n')
  30. break;
  31. else
  32. outchar(*p++);
  33. }
  34. outnl(0);
  35. }
  36. int32_t
  37. simplenextoff(int32_t fromoff)
  38. {
  39. if(Bseek(bdict, fromoff, 0) < 0)
  40. return -1;
  41. if(Brdline(bdict, '\n') == 0)
  42. return -1;
  43. return Boffset(bdict);
  44. }
  45. void
  46. simpleprintkey(void)
  47. {
  48. Bprint(bout, "No pronunciation key.\n");
  49. }