dict: similar fixes, different files. also remove runescpy
This commit is contained in:
parent
2a5b2f4c76
commit
c6aa11d04e
4 changed files with 17 additions and 34 deletions
|
@ -74,22 +74,18 @@ main(int argc, char **argv)
|
|||
}
|
||||
ARGBEGIN {
|
||||
case 'd':
|
||||
p = ARGF();
|
||||
p = EARGF(usage());
|
||||
dict = 0;
|
||||
if(p) {
|
||||
for(i=0; dicts[i].name; i++)
|
||||
if(strcmp(p, dicts[i].name)==0) {
|
||||
dict = &dicts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(i=0; dicts[i].name; i++)
|
||||
if(strcmp(p, dicts[i].name)==0) {
|
||||
dict = &dicts[i];
|
||||
break;
|
||||
}
|
||||
if(!dict)
|
||||
usage();
|
||||
break;
|
||||
case 'c':
|
||||
line = ARGF();
|
||||
if(!line)
|
||||
usage();
|
||||
line = EARGF(usage());
|
||||
break;
|
||||
case 'k':
|
||||
kflag++;
|
||||
|
@ -99,7 +95,7 @@ main(int argc, char **argv)
|
|||
break;
|
||||
default:
|
||||
usage();
|
||||
ARGEND }
|
||||
}ARGEND
|
||||
if(dict == 0){
|
||||
err("no dictionaries present on this system");
|
||||
exits("nodict");
|
||||
|
@ -354,7 +350,7 @@ search(char *pat, int dofold)
|
|||
|
||||
prelen = getpref(pat+1, pre);
|
||||
if(pat[prelen+1] == 0 || pat[prelen+1] == '$') {
|
||||
runescpy(lit, pre);
|
||||
runestrcpy(lit, pre);
|
||||
if(dofold)
|
||||
fold(lit);
|
||||
needre = 0;
|
||||
|
@ -390,10 +386,8 @@ search(char *pat, int dofold)
|
|||
n = 2*dot->maxn;
|
||||
dot = realloc(dot,
|
||||
sizeof(Addr)+(n-1)*sizeof(long));
|
||||
if(!dot) {
|
||||
err("out of memory");
|
||||
exits("nomem");
|
||||
}
|
||||
if(dot == nil)
|
||||
sysfatal("realloc: %r");
|
||||
dot->maxn = n;
|
||||
}
|
||||
dot->doff[dot->n++] = v;
|
||||
|
@ -609,10 +603,8 @@ getentry(int i)
|
|||
n = e-b;
|
||||
if(n+1 > anslen) {
|
||||
ans.start = realloc(ans.start, n+1);
|
||||
if(!ans.start) {
|
||||
err("out of memory");
|
||||
exits("nomem");
|
||||
}
|
||||
if(ans.start == nil)
|
||||
sysfatal("realloc: %r");
|
||||
anslen = n+1;
|
||||
}
|
||||
Bseek(bdict, b, 0);
|
||||
|
|
|
@ -109,7 +109,6 @@ void outchar(int);
|
|||
void outchars(char *);
|
||||
void outnl(int);
|
||||
void outpiece(char *, char *);
|
||||
void runescpy(Rune*, Rune*);
|
||||
long runetol(Rune*);
|
||||
|
||||
long oednextoff(long);
|
||||
|
|
|
@ -105,7 +105,8 @@ robertindexentry(Entry e, int cmd)
|
|||
|
||||
if(db == 0)
|
||||
db = Bouvrir(dfile);
|
||||
def.start = malloc(dl+1);
|
||||
if((def.start = malloc(dl+1)) == nil)
|
||||
sysfatal("malloc: %r");
|
||||
def.end = def.start + dl;
|
||||
def.doff = da;
|
||||
Bseek(db, da, 0);
|
||||
|
@ -116,7 +117,8 @@ robertindexentry(Entry e, int cmd)
|
|||
}else{
|
||||
if(eb == 0)
|
||||
eb = Bouvrir(efile);
|
||||
etym.start = malloc(el+1);
|
||||
if((etym.start = malloc(el+1)) == nil)
|
||||
sysfatal("malloc: %r");
|
||||
etym.end = etym.start + el;
|
||||
etym.doff = ea;
|
||||
Bseek(eb, ea, 0);
|
||||
|
|
|
@ -497,16 +497,6 @@ acomp(Rune *s, Rune *t)
|
|||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy null terminated Runes from 'from' to 'to'.
|
||||
*/
|
||||
void
|
||||
runescpy(Rune *to, Rune *from)
|
||||
{
|
||||
while((*to++ = *from++) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion of unsigned number to long, no overflow detection
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue