URI:
       tthesaurus.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tthesaurus.c (1273B)
       ---
            1 #include <u.h>
            2 #include <libc.h>
            3 #include <bio.h>
            4 #include "dict.h"
            5 
            6 void
            7 thesprintentry(Entry e, int cmd)
            8 {
            9         char *p, *pe;
           10         int c, i;
           11 
           12         p = e.start;
           13         pe = e.end;
           14         while(p < pe) {
           15                 c = *p++;
           16                 if(cmd == 'r') {
           17                         outchar(c);
           18                         continue;
           19                 }
           20                 switch(c) {
           21                 case '*':
           22                         c = *p++;
           23                         if(cmd == 'h' && c != 'L') {
           24                                 outnl(0);
           25                                 return;
           26                         }
           27                         if(c == 'L' && cmd != 'h')
           28                                 outnl(0);
           29                         if(c == 'S') {
           30                                 outchar('(');
           31                                 outchar(*p++);
           32                                 outchar(')');
           33                         }
           34                         break;
           35                 case '#':
           36                         c = *p++;
           37                         i = *p++ - '0' - 1;
           38                         if(i < 0 || i > 4)
           39                                 break;
           40                         switch(c) {
           41                         case 'a': outrune(L"áàâäa"[i]); break;
           42                         case 'e': outrune(L"éèêëe"[i]); break;
           43                         case 'o': outrune(L"óòôöo"[i]); break;
           44                         case 'c': outrune(L"ccccç"[i]); break;
           45                         default: outchar(c); break;
           46                         }
           47                         break;
           48                 case '+':
           49                 case '<':
           50                         break;
           51                 case ' ':
           52                         if(cmd == 'h' && *p == '*') {
           53                                 outnl(0);
           54                                 return;
           55                         }
           56                 default:
           57                         outchar(c);
           58                 }
           59         }
           60         outnl(0);
           61 }
           62 
           63 long
           64 thesnextoff(long fromoff)
           65 {
           66         long a;
           67         char *p;
           68 
           69         a = Bseek(bdict, fromoff, 0);
           70         if(a < 0)
           71                 return -1;
           72         for(;;) {
           73                 p = Brdline(bdict, '\n');
           74                 if(!p)
           75                         break;
           76                 if(p[0] == '*' && p[1] == 'L')
           77                         return (Boffset(bdict)-Blinelen(bdict));
           78         }
           79         return -1;
           80 }
           81 
           82 void
           83 thesprintkey(void)
           84 {
           85         Bprint(bout, "No key\n");
           86 }