thesaurus.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. void
  14. thesprintentry(Entry e, int cmd)
  15. {
  16. char *p, *pe;
  17. int c, i;
  18. p = e.start;
  19. pe = e.end;
  20. while(p < pe) {
  21. c = *p++;
  22. if(cmd == 'r') {
  23. outchar(c);
  24. continue;
  25. }
  26. switch(c) {
  27. case '*':
  28. c = *p++;
  29. if(cmd == 'h' && c != 'L') {
  30. outnl(0);
  31. return;
  32. }
  33. if(c == 'L' && cmd != 'h')
  34. outnl(0);
  35. if(c == 'S') {
  36. outchar('(');
  37. outchar(*p++);
  38. outchar(')');
  39. }
  40. break;
  41. case '#':
  42. c = *p++;
  43. i = *p++ - '0' - 1;
  44. if(i < 0 || i > 4)
  45. break;
  46. switch(c) {
  47. case 'a': outrune(L"áàâäa"[i]); break;
  48. case 'e': outrune(L"éèêëe"[i]); break;
  49. case 'o': outrune(L"óòôöo"[i]); break;
  50. case 'c': outrune(L"ccccç"[i]); break;
  51. default: outchar(c); break;
  52. }
  53. break;
  54. case '+':
  55. case '<':
  56. break;
  57. case ' ':
  58. if(cmd == 'h' && *p == '*') {
  59. outnl(0);
  60. return;
  61. }
  62. default:
  63. outchar(c);
  64. }
  65. }
  66. outnl(0);
  67. }
  68. int32_t
  69. thesnextoff(int32_t fromoff)
  70. {
  71. int32_t a;
  72. char *p;
  73. a = Bseek(bdict, fromoff, 0);
  74. if(a < 0)
  75. return -1;
  76. for(;;) {
  77. p = Brdline(bdict, '\n');
  78. if(!p)
  79. break;
  80. if(p[0] == '*' && p[1] == 'L')
  81. return (Boffset(bdict)-Blinelen(bdict));
  82. }
  83. return -1;
  84. }
  85. void
  86. thesprintkey(void)
  87. {
  88. Bprint(bout, "No key\n");
  89. }