This commit is contained in:
rsc 2004-03-26 01:47:43 +00:00
parent d6f81d852d
commit 65d5010eda
2 changed files with 64 additions and 44 deletions

View file

@ -36,33 +36,37 @@ enum {
/* Assoc tables must be sorted on first field */ /* Assoc tables must be sorted on first field */
static char *tagtab[] = { static char *tagtab[NTAG];
[BEG] "$$",
[AB] "AB", static void
[AN] "AN", inittagtab(void)
[AS] "AS", {
[AU] "AU", tagtab[BEG]= "$$";
[AW] "AW", tagtab[AB]= "AB";
[BW] "BW", tagtab[AN]= "AN";
[CA] "CA", tagtab[AS]= "AS";
[CN] "CN", tagtab[AU]= "AU";
[CO] "CO", tagtab[AW]= "AW";
[CR] "CR", tagtab[BW]= "BW";
[DE] "DE", tagtab[CA]= "CA";
[DR] "DR", tagtab[CN]= "CN";
[ED] "ED", tagtab[CO]= "CO";
[MP] "MP", tagtab[CR]= "CR";
[NT] "NT", tagtab[DE]= "DE";
[PR] "PR", tagtab[DR]= "DR";
[PS] "PS", tagtab[ED]= "ED";
[RA] "RA", tagtab[MP]= "MP";
[RD] "RD", tagtab[NT]= "NT";
[RT] "RT", tagtab[PR]= "PR";
[RV] "RV", tagtab[PS]= "PS";
[ST] "ST", tagtab[RA]= "RA";
[TI] "TI", tagtab[RD]= "RD";
[TX] "TX", tagtab[RT]= "RT";
[VD] "VD", tagtab[RV]= "RV";
tagtab[ST]= "ST";
tagtab[TI]= "TI";
tagtab[TX]= "TX";
tagtab[VD]= "VD";
}; };
static char *mget(int, char *, char *, char **); static char *mget(int, char *, char *, char **);
@ -305,6 +309,8 @@ mget(int tag, char *b, char *e, char **eptr)
if(tag < 0 || tag >= NTAG) if(tag < 0 || tag >= NTAG)
return 0; return 0;
if(tagtab[BEG] == 0)
inittagtab();
t = tagtab[tag]; t = tagtab[tag];
ans = 0; ans = 0;
for(p = b;;) { for(p = b;;) {

View file

@ -58,28 +58,36 @@ static Rune intab[256] = {
0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x220e, 0xa0, 0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x220e, 0xa0,
}; };
static Rune suptab[] = { static Rune suptab[256];
['0'] 0x2070, ['1'] 0x2071, ['2'] 0x2072, ['3'] 0x2073,
['4'] 0x2074, ['5'] 0x2075, ['6'] 0x2076, ['7'] 0x2077,
['8'] 0x2078, ['9'] 0x2079, ['+'] 0x207a, ['-'] 0x207b,
['='] 0x207c, ['('] 0x207d, [')'] 0x207e, ['a'] 0xaa,
['n'] 0x207f, ['o'] 0xba
};
static Rune subtab[] = { static void
['0'] 0x2080, ['1'] 0x2081, ['2'] 0x2082, ['3'] 0x2083, initsuptab(void)
['4'] 0x2084, ['5'] 0x2085, ['6'] 0x2086, ['7'] 0x2087, {
['8'] 0x2088, ['9'] 0x2089, ['+'] 0x208a, ['-'] 0x208b, suptab['0']= 0x2070; suptab['1']= 0x2071; suptab['2']= 0x2072; suptab['3']= 0x2073;
['='] 0x208c, ['('] 0x208d, [')'] 0x208e suptab['4']= 0x2074; suptab['5']= 0x2075; suptab['6']= 0x2076; suptab['7']= 0x2077;
}; suptab['8']= 0x2078; suptab['9']= 0x2079; suptab['+']= 0x207a; suptab['-']= 0x207b;
suptab['=']= 0x207c; suptab['(']= 0x207d; suptab[')']= 0x207e; suptab['a']= 0xaa;
suptab['n']= 0x207f; suptab['o']= 0xba;
}
static Rune subtab[256];
static void
initsubtab(void)
{
subtab['0']= 0x2080; subtab['1']= 0x2081; subtab['2']= 0x2082; subtab['3']= 0x2083;
subtab['4']= 0x2084; subtab['5']= 0x2085; subtab['6']= 0x2086; subtab['7']= 0x2087;
subtab['8']= 0x2088; subtab['9']= 0x2089; subtab['+']= 0x208a; subtab['-']= 0x208b;
subtab['=']= 0x208c; subtab['(']= 0x208d; subtab[')']= 0x208e;
}
#define GSHORT(p) (((p)[0]<<8) | (p)[1]) #define GSHORT(p) (((p)[0]<<8) | (p)[1])
#define GLONG(p) (((p)[0]<<24) | ((p)[1]<<16) | ((p)[2]<<8) | (p)[3]) #define GLONG(p) (((p)[0]<<24) | ((p)[1]<<16) | ((p)[2]<<8) | (p)[3])
static char cfile[] = "/lib/dict/robert/cits.rob"; static char cfile[] = "#9/dict/robert/cits.rob";
static char dfile[] = "/lib/dict/robert/defs.rob"; static char dfile[] = "#9/dict/robert/defs.rob";
static char efile[] = "/lib/dict/robert/etym.rob"; static char efile[] = "#9/dict/robert/etym.rob";
static char kfile[] = "/lib/dict/robert/_phon"; static char kfile[] = "#9/dict/robert/_phon";
static Biobuf * cb; static Biobuf * cb;
static Biobuf * db; static Biobuf * db;
@ -137,6 +145,11 @@ robertprintentry(Entry *def, Entry *etym, int cmd)
int lineno = 0; int lineno = 0;
int cit = 0; int cit = 0;
if(suptab['0'] == 0)
initsuptab();
if(subtab['0'] == 0)
initsubtab();
p = (uchar *)def->start; p = (uchar *)def->start;
pe = (uchar *)def->end; pe = (uchar *)def->end;
while(p < pe){ while(p < pe){
@ -303,6 +316,7 @@ Bouvrir(char *fichier)
{ {
Biobuf *db; Biobuf *db;
fichier = unsharp(fichier);
db = Bopen(fichier, OREAD); db = Bopen(fichier, OREAD);
if(db == 0){ if(db == 0){
fprint(2, "%s: impossible d'ouvrir %s: %r\n", argv0, fichier); fprint(2, "%s: impossible d'ouvrir %s: %r\n", argv0, fichier);