}
int
-type(char *buf, char *tag)
+type(char *buf, int nbuf, char *tag)
{
Rune r;
- char *p;
+ char *p, *e;
esetcursor(&busy);
p = buf;
+ e = buf + nbuf-UTFmax-1;
for(;;){
*p = 0;
mesg("%s: %s", tag, buf);
--p;
break;
default:
- p += runetochar(p, &r);
+ if(p < e)
+ p += runetochar(p, &r);
}
}
}
Thing *nt;
buttons(Up);
- if(type(buf, tag) == 0)
+ if(type(buf, sizeof(buf), tag) == 0)
return;
if(strcmp(tag, "file") == 0){
for(s=buf; *s; s++)
long l;
buttons(Up);
- if(type(buf, tag) == 0)
+ if(type(buf, sizeof(buf), tag) == 0)
return;
if(strcmp(tag, "mag") == 0){
if(buf[0]<'0' || '9'<buf[0] || (l=atoi(buf))<=0 || l>Maxmag){
return;
}
}
- if(type(buf, "char (hex or character or hex-hex)") == 0)
+ if(type(buf, sizeof(buf), "char (hex or character or hex-hex)") == 0)
return;
if(utflen(buf) == 1){
chartorune(&r, buf);
sel = emenuhit(3, &mouse, &menu3);
switch(sel){
case Mopen:
- if(type(buf, "file")){
+ if(type(buf, sizeof(buf), "file")){
t = tget(buf);
if(t)
drawthing(t, 1);