From 65380452435ae8efa090be5648f4ec8e9e7b9b30 Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 23 Nov 2011 16:54:17 +0000 Subject: [PATCH] the number of COMPUTE rpn nodes is architecture dependent. calculate the right number and complain otherwise. Fix for #300. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2219 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_rpncalc.c | 10 ++++++---- program/src/rrd_rpncalc.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/program/src/rrd_rpncalc.c b/program/src/rrd_rpncalc.c index 25f52841..7a9a2d12 100644 --- a/program/src/rrd_rpncalc.c +++ b/program/src/rrd_rpncalc.c @@ -33,8 +33,8 @@ short rpn_compact( while (rpnp[*count].op != OP_END) (*count)++; if (++(*count) > DS_CDEF_MAX_RPN_NODES) { - rrd_set_error("Maximum %d RPN nodes permitted", - DS_CDEF_MAX_RPN_NODES); + rrd_set_error("Maximum %d RPN nodes permitted. Got %d RPN nodes at present.", + DS_CDEF_MAX_RPN_NODES-1,(*count)-1); return -1; } @@ -236,9 +236,11 @@ void parseCDEF_DS( * occur too often. */ for (i = 0; rpnp[i].op != OP_END; i++) { if (rpnp[i].op == OP_TIME || rpnp[i].op == OP_LTIME || - rpnp[i].op == OP_PREV || rpnp[i].op == OP_COUNT) { + rpnp[i].op == OP_PREV || rpnp[i].op == OP_COUNT || + rpnp[i].op == OP_TREND || rpnp[i].op == OP_TRENDNAN || + rpnp[i].op == OP_PREDICT || rpnp[i].op == OP_PREDICTSIGMA ) { rrd_set_error - ("operators time, ltime, prev and count not supported with DS COMPUTE"); + ("operators TIME, LTIME, PREV COUNT TREND TRENDNAN PREDICT PREDICTSIGMA are not supported with DS COMPUTE"); free(rpnp); return; } diff --git a/program/src/rrd_rpncalc.h b/program/src/rrd_rpncalc.h index d104b8e8..1ddf2af1 100644 --- a/program/src/rrd_rpncalc.h +++ b/program/src/rrd_rpncalc.h @@ -41,7 +41,7 @@ typedef struct rpn_cdefds_t { #define DEF_NAM_FMT "%255[-_A-Za-z0-9]" /* limit imposed by sizeof(rpn_cdefs_t) and rrd.ds_def.par */ -#define DS_CDEF_MAX_RPN_NODES 26 +#define DS_CDEF_MAX_RPN_NODES (int)(sizeof(unival)*10 / sizeof(rpn_cdefds_t)) typedef struct rpnstack_t { double *s; -- 2.30.2