summaryrefslogtreecommitdiff
path: root/src/pnmcurve.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pnmcurve.c')
-rw-r--r--src/pnmcurve.c8
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;