diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-19 19:57:44 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-19 19:57:44 +0100 |
| commit | c28c561ad3ee95c351391c90e985a4c93e11d21f (patch) | |
| tree | ba95eef4ded9976252fbcbed46f276005650e8d8 /src/pnmcurve.c | |
| parent | e28f19882c19b7e307856c0901800e96ae1132a1 (diff) | |
fix use of strsep
Diffstat (limited to 'src/pnmcurve.c')
| -rw-r--r-- | src/pnmcurve.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pnmcurve.c b/src/pnmcurve.c index c043566..24a0098 100644 --- a/src/pnmcurve.c +++ b/src/pnmcurve.c @@ -146,13 +146,14 @@ pam_transform(FILE *in_fp, FILE *out_fp, static table_t* buildCurve(const char *ctrl_points, int resolution, int maxval) { table_t *table; - char *pstr, *buf = strdup(ctrl_points); + char *buf = strdup(ctrl_points); + char *pstr = buf; int i, n = 0; double X[MAX_CTRL], Y[MAX_CTRL]; gsl_interp_accel *acc; gsl_spline *spline; - while (pstr = strsep(&buf, ",")) { + while (pstr = strsep(&pstr, ",")) { if (n >= MAX_CTRL) { fprintf(stderr, "maximum number of control points (%d) reached.\n", MAX_CTRL); @@ -160,7 +161,8 @@ buildCurve(const char *ctrl_points, int resolution, int maxval) { } if (sscanf(pstr, "%lf:%lf", &X[n], &Y[n]) != 2 || - X[n] < 0.0 || X[n] > 1.0 || Y[n] < 0.0 || Y[n] > 1.0) { + X[n] < 0.0 || X[n] > 1.0 || Y[n] < 0.0 || Y[n] > 1.0 || + (n > 0 && X[n] <= X[n - 1])) { fprintf(stderr, "could not parse control point %s.\n", pstr); free(buf); return NULL; |
