mothra: fix bogus strtolength

This commit is contained in:
cinap_lenrek 2012-04-17 00:06:25 +02:00
parent 95d7fa1c0e
commit 1f0ea6cd96

View file

@ -72,19 +72,17 @@ enum{
HORIZ, HORIZ,
VERT, VERT,
}; };
int strtolength(Hglob *g, int dir, char *str)
{ int strtolength(Hglob *g, int dir, char *str){
double f; double f;
Point p;
f = atof(str); f = atof(str);
if(cistrstr(str, "px"))
return floor(f);
if(cistrstr(str, "%")) if(cistrstr(str, "%"))
return floor(f*((dir==HORIZ) ? Dx(g->dst->text->r) : Dy(g->dst->text->r))/100); return 0;
if(cistrstr(str, "em")){ if(cistrstr(str, "em")){
Point z; p=stringsize(pl_whichfont(g->state->font, g->state->size)->font, "M");
z = stringsize(g->dst->text->font, "M"); return floor(f*((dir==HORIZ) ? p.x : p.y));
return floor(f*((dir==HORIZ) ? z.x : z.y));
} }
return floor(f); return floor(f);
} }
@ -692,9 +690,9 @@ void plrdhtml(char *name, int fd, Www *dst){
nstrcpy(g.state->image, str, sizeof(g.state->image)); nstrcpy(g.state->image, str, sizeof(g.state->image));
g.state->ismap=pl_hasattr(g.attr, "ismap"); g.state->ismap=pl_hasattr(g.attr, "ismap");
if(str=pl_getattr(g.attr, "width")) if(str=pl_getattr(g.attr, "width"))
g.state->width = strtolength(&g, HORIZ, str); g.state->width=strtolength(&g, HORIZ, str);
if(str=pl_getattr(g.attr, "height")) if(str=pl_getattr(g.attr, "height"))
g.state->height = strtolength(&g, VERT, str); g.state->height=strtolength(&g, VERT, str);
str=pl_getattr(g.attr, "alt"); str=pl_getattr(g.attr, "alt");
if(str==0){ if(str==0){
if(g.state->image[0]) if(g.state->image[0])