Browse Source

add `int' casts to some strlen() expressions, and center labels on a xlog scale

pre-master-46
rlar 16 years ago
parent
commit
75b6eeb94a
  1. 10
      ChangeLog
  2. 4
      src/frontend/plotting/agraf.c
  3. 2
      src/frontend/plotting/graf.c
  4. 24
      src/frontend/plotting/grid.c
  5. 6
      src/frontend/postcoms.c
  6. 7
      src/misc/dstring.c
  7. 2
      src/spicelib/parser/inp2r.c
  8. 2
      src/spicelib/parser/inpgmod.c

10
ChangeLog

@ -1,3 +1,13 @@
2010-11-06 Robert Larice
* src/frontend/postcoms.c ,
* src/frontend/plotting/agraf.c ,
* src/frontend/plotting/graf.c ,
* src/frontend/plotting/grid.c ,
* src/misc/dstring.c ,
* src/spicelib/parser/inp2r.c ,
* src/spicelib/parser/inpgmod.c :
add `int' casts to some strlen() expressions, and center labels on a xlog scale
2010-11-06 Robert Larice 2010-11-06 Robert Larice
* src/frontend/outitf.c , * src/frontend/outitf.c ,
* src/frontend/plotting/grid.c , * src/frontend/plotting/grid.c ,

4
src/frontend/plotting/agraf.c

@ -247,7 +247,7 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s
for (i = 0; i < omaxy + margin; i++) for (i = 0; i < omaxy + margin; i++)
out_send("-"); out_send("-");
out_send("\n"); out_send("\n");
i = (omaxy + margin - strlen(plot->pl_title)) / 2;
i = (omaxy + margin - (int) strlen(plot->pl_title)) / 2;
while (i-- > 0) while (i-- > 0)
out_send(" "); out_send(" ");
(void) strcpy(buf, plot->pl_title); (void) strcpy(buf, plot->pl_title);
@ -256,7 +256,7 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s
out_send("\n"); out_send("\n");
(void) sprintf(buf, "%s %s", plot->pl_name, plot->pl_date); (void) sprintf(buf, "%s %s", plot->pl_name, plot->pl_date);
buf[maxy + margin] = '\0'; buf[maxy + margin] = '\0';
i = (omaxy + margin - strlen(buf)) / 2;
i = (omaxy + margin - (int) strlen(buf)) / 2;
while (i-- > 0) while (i-- > 0)
out_send(" "); out_send(" ");
out_send(buf); out_send(buf);

2
src/frontend/plotting/graf.c

@ -463,7 +463,7 @@ gr_pmsg(char *text)
/* MW. grid.xlabel may be NULL */ /* MW. grid.xlabel may be NULL */
if (currentgraph->grid.xlabel) if (currentgraph->grid.xlabel)
DevDrawText(text, currentgraph->viewport.width DevDrawText(text, currentgraph->viewport.width
- (strlen(currentgraph->grid.xlabel) + 3)
- (int) (strlen(currentgraph->grid.xlabel) + 3)
* currentgraph->fontwidth, * currentgraph->fontwidth,
currentgraph->absolute.height - currentgraph->fontheight); currentgraph->absolute.height - currentgraph->fontheight);
else else

24
src/frontend/plotting/grid.c

@ -512,11 +512,11 @@ drawlingrid(GRAPH *graph, char *units, int spacing, int nsp, double dst, double
if (axis == x_axis) if (axis == x_axis)
DevDrawText(buf, graph->viewportxoff + i - DevDrawText(buf, graph->viewportxoff + i -
strlen(buf) / 2 * graph->fontwidth,
((int) strlen(buf) * graph->fontwidth) / 2 ,
(int) (graph->fontheight * 2.5)); (int) (graph->fontheight * 2.5));
else else
DevDrawText(buf, graph->viewportxoff - DevDrawText(buf, graph->viewportxoff -
graph->fontwidth * (strlen(buf)),
graph->fontwidth * (int) strlen(buf),
graph->viewportyoff + i - graph->viewportyoff + i -
graph->fontheight / 2); graph->fontheight / 2);
@ -679,11 +679,12 @@ drawloggrid(GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, in
else else
(void) sprintf(buf, "10^%d", j); (void) sprintf(buf, "10^%d", j);
if (axis == x_axis) if (axis == x_axis)
DevDrawText(buf, graph->viewportxoff + i - strlen(buf) / 2,
DevDrawText(buf, graph->viewportxoff + i -
((int) strlen(buf) * graph->fontwidth) / 2,
(int) (graph->fontheight * 2.5)); (int) (graph->fontheight * 2.5));
else else
DevDrawText(buf, graph->viewportxoff - graph->fontwidth * DevDrawText(buf, graph->viewportxoff - graph->fontwidth *
(strlen(buf) + 1),
(int) (strlen(buf) + 1),
graph->viewportyoff + i - graph->viewportyoff + i -
graph->fontheight / 2); graph->fontheight / 2);
@ -969,7 +970,7 @@ adddeglabel(GRAPH *graph, int deg, int x, int y, int cx, int cy, int lx, int ly)
if (sqrt((double) (x - cx) * (x - cx) + (y - cy) * (y - cy)) < MINDIST) if (sqrt((double) (x - cx) * (x - cx) + (y - cy) * (y - cy)) < MINDIST)
return; return;
(void) sprintf(buf, "%d", deg); (void) sprintf(buf, "%d", deg);
w = graph->fontwidth * (strlen(buf) + 1);
w = graph->fontwidth * (int) (strlen(buf) + 1);
h = graph->fontheight * 1.5; h = graph->fontheight * 1.5;
angle = atan2((double) (y - ly), (double) (x - lx)); angle = atan2((double) (y - ly), (double) (x - lx));
d = fabs(cos(angle)) * w / 2 + fabs(sin(angle)) * h / 2 + LOFF; d = fabs(cos(angle)) * w / 2 + fabs(sin(angle)) * h / 2 + LOFF;
@ -978,7 +979,7 @@ adddeglabel(GRAPH *graph, int deg, int x, int y, int cx, int cy, int lx, int ly)
y = y + d * sin(angle) - h / 2; y = y + d * sin(angle) - h / 2;
DevDrawText(buf, x, y); DevDrawText(buf, x, y);
DevDrawText("o", x + strlen(buf) * graph->fontwidth,
DevDrawText("o", x + (int) strlen(buf) * graph->fontwidth,
y + graph->fontheight / 2); y + graph->fontheight / 2);
return; return;
} }
@ -996,10 +997,11 @@ addradlabel(GRAPH *graph, int lab, double theta, int x, int y)
(void) sprintf(buf, "%d", lab); (void) sprintf(buf, "%d", lab);
if (theta == M_PI) { if (theta == M_PI) {
y = y - graph->fontheight - 2;
x = x - graph->fontwidth * strlen(buf) - 3;
} else
x = x - graph->fontwidth * strlen(buf) - 3;
y -= graph->fontheight + 2;
x -= graph->fontwidth * (int) strlen(buf) + 3;
} else {
x -= graph->fontwidth * (int) strlen(buf) + 3;
}
DevDrawText(buf, x, y); DevDrawText(buf, x, y);
return; return;
} }
@ -1369,7 +1371,7 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d
SetColor(1); SetColor(1);
x = centx + xoffset + (int)radoff - 2 * (int)rad - x = centx + xoffset + (int)radoff - 2 * (int)rad -
gi_fntwidth * strlen(plab) - 2;
gi_fntwidth * (int) strlen(plab) - 2;
if ((x > pxmin) && (x < pxmax)) { if ((x > pxmin) && (x < pxmax)) {
if ((yoffset > - gr_radius) && (yoffset < gr_radius)) if ((yoffset > - gr_radius) && (yoffset < gr_radius))
DevDrawText(plab, x, centy + yoffset - gi_fntheight - 1); DevDrawText(plab, x, centy + yoffset - gi_fntheight - 1);

6
src/frontend/postcoms.c

@ -190,7 +190,7 @@ com_print(wordlist *wl)
printnum(numbuf, v->v_realdata[i]); printnum(numbuf, v->v_realdata[i]);
(void) strcpy(buf, numbuf); (void) strcpy(buf, numbuf);
out_send(buf); out_send(buf);
ll += strlen(buf);
ll += (int) strlen(buf);
ll = (ll + 7) / 8; ll = (ll + 7) / 8;
ll = ll * 8 + 1; ll = ll * 8 + 1;
if (ll > 60) { if (ll > 60) {
@ -206,7 +206,7 @@ com_print(wordlist *wl)
numbuf, numbuf,
numbuf2); numbuf2);
out_send(buf); out_send(buf);
ll += strlen(buf);
ll += (int) strlen(buf);
ll = (ll + 7) / 8; ll = (ll + 7) / 8;
ll = ll * 8 + 1; ll = ll * 8 + 1;
if (ll > 60) { if (ll > 60) {
@ -270,7 +270,7 @@ nextpage:
out_send("\n"); out_send("\n");
out_send(buf2); out_send(buf2);
(void) sprintf(buf, "%s %s", p->pl_name, p->pl_date); (void) sprintf(buf, "%s %s", p->pl_name, p->pl_date);
j = (width - strlen(buf)) / 2;
j = (width - (int) strlen(buf)) / 2;
out_send(buf); out_send(buf);
out_send("\n"); out_send("\n");
for (i = 0; i < width; i++) for (i = 0; i < width; i++)

7
src/misc/dstring.c

@ -4,7 +4,10 @@ DESCRIPTION:This file contains the routines for manipulating dynamic strings.
CONTENTS: CONTENTS:
DATE: Wed Mar 24 18:38:28 CDT 2010 DATE: Wed Mar 24 18:38:28 CDT 2010
REVISIONS: $Log$ REVISIONS: $Log$
REVISIONS: Revision 1.5 2010-11-06 16:54:11 rlar
REVISIONS: Revision 1.6 2010-11-06 20:17:20 rlar
REVISIONS: add `int' casts to some strlen() expressions, and center labels on a xlog scale
REVISIONS:
REVISIONS: Revision 1.5 2010/11/06 16:54:11 rlar
REVISIONS: (int) cast the return value of some strlen() invocations REVISIONS: (int) cast the return value of some strlen() invocations
REVISIONS: REVISIONS:
REVISIONS: Revision 1.4 2010/10/28 19:32:34 rlar REVISIONS: Revision 1.4 2010/10/28 19:32:34 rlar
@ -169,7 +172,7 @@ static int spice_format_length( va_list args, char *fmt )
case 's': case 's':
s = va_arg(args, char *) ; s = va_arg(args, char *) ;
if( s ){ if( s ){
len += strlen(s) ;
len += (int) strlen(s) ;
} }
found_special = TRUE ; found_special = TRUE ;
break ; break ;

2
src/spicelib/parser/inp2r.c

@ -134,7 +134,7 @@ void INP2R(CKTcircuit *ckt, INPtables * tab, card * current)
} }
/* copy first part of line */ /* copy first part of line */
i -= strlen(t);
i -= (int) strlen(t);
strncpy(line, current->line, (size_t) i); strncpy(line, current->line, (size_t) i);
line[i] = '\0'; /* terminate */ line[i] = '\0'; /* terminate */

2
src/spicelib/parser/inpgmod.c

@ -504,7 +504,7 @@ INPfindParm( char *name, IFparm *table, int numParms )
bestMatch = 0; bestMatch = 0;
for ( test = 0; test < numParms; test++ ) { for ( test = 0; test < numParms; test++ ) {
match = cimatch( name, table[test].keyword ); match = cimatch( name, table[test].keyword );
if ( (match == length) && (match == strlen(table[test].keyword)) ) {
if ( (match == length) && (match == (int) strlen(table[test].keyword)) ) {
/* exact match */ /* exact match */
best = test; best = test;
/* all done */ /* all done */

Loading…
Cancel
Save