HTML automatically generated with rman
Table of Contents


drange, irange - parser of ascii string into an array of values


int drange (n, rval, rexp)int    *n;double rval[];char   *rexp[];int irange
(n, rval, rexp)int  *n;int  rval[];char *rexp[];


corona:/usr/pjt/clib    source


The range(3) routines parse a string rexp containing a list of numbers into an array rval of n values. The list must be a comma-separated list of numbers. Each number however can consist of an implied do-loop, where the initial, final and optional the decrement (defaulted to 1 if absent) are separated by a colon. The routines are very forgiving with respect to the usage of spaces and tabs.


The string 1,10:20:2,100 gets parsed into an array of values 1 10 12 14 16 18 20 100.

See Also



Low-level catastrophies (eg, parsing errors, wrong delimiters) generate messages via error(3) .


A string like 1,,2 translates into an array of values 1,0,2, i.e. an empty slot (which could be interpreted as a default value) will be parsed as a zero.

At the moment a space character is treated as an end-of-string, instead of a string delimiter. One could think of reasons to change this, especially when the range(3) -routines are used in other-than-getparam(3) environments.


Peter Teuben

Update History

16-Mar-87    created (PJT)
5-Aug-87    made skipping spaces and tabs more general (PJT)