Browse Source

graph.h, grid.c, enforce consistent string buffer size (plot "units", LABEL_CHARS)

pre-master-46
rlar 11 years ago
parent
commit
2b3220086d
  1. 9
      src/frontend/plotting/grid.c
  2. 7
      src/include/ngspice/graph.h

9
src/frontend/plotting/grid.c

@ -16,7 +16,6 @@ Modified: 2001 AlansFixes
#include "../display.h"
#define RAD_TO_DEG (180.0 / M_PI)
#define LABEL_CHARS 16
typedef enum { x_axis, y_axis } Axis;
@ -230,7 +229,7 @@ lingrid(GRAPH *graph, double lo, double hi, double delta, int type, Axis axis)
int max;
static double dd[2];
int mult = 1;
char buf[LABEL_CHARS], *s;
char buf[GRAPH_UNITS_LENGTH], *s;
int slim, digits;
if (axis == y_axis && graph->grid.ysized) {
@ -495,7 +494,7 @@ drawlingrid(GRAPH *graph, char *units, int spacing, int nsp, double dst, double
{
int i, j;
double m, step;
char buf[LABEL_CHARS];
char buf[GRAPH_UNITS_LENGTH];
NG_IGNORE(onedec);
NG_IGNORE(mult);
@ -563,7 +562,7 @@ loggrid(GRAPH *graph, double lo, double hi, int type, Axis axis)
int i, j;
double k;
double decs;
char buf[LABEL_CHARS], *s;
char buf[GRAPH_UNITS_LENGTH], *s;
if (axis == x_axis && graph->grid.xsized) {
lmt = graph->grid.xaxis.log.lmt;
@ -663,7 +662,7 @@ drawloggrid(GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, in
{
int i, j, k, m;
double t;
char buf[LABEL_CHARS];
char buf[GRAPH_UNITS_LENGTH];
/* Now plot every pp'th decade line, with subs lines between them. */
if (subs > 1)

7
src/include/ngspice/graph.h

@ -17,6 +17,7 @@ Author: 1988 Jeffrey M. Hsu
struct _keyed;
#define GRAPH_UNITS_LENGTH 16
/* Device-independent data structure for plots. */
@ -68,7 +69,7 @@ struct graph {
int circular; /* TRUE if circular plot area */
union {
struct {
char units[16]; /* unit labels */
char units[GRAPH_UNITS_LENGTH]; /* unit labels */
int spacing, numspace;
double distance, lowlimit, highlimit;
int mult;
@ -79,11 +80,11 @@ struct graph {
int digits;
} lin;
struct {
char units[16]; /* unit labels */
char units[GRAPH_UNITS_LENGTH]; /* unit labels */
int hmt, lmt, decsp, subs, pp;
} log;
struct {
char units[16]; /* unit labels */
char units[GRAPH_UNITS_LENGTH]; /* unit labels */
int radius, center;
double mrad;
int lmt;

Loading…
Cancel
Save