diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/xtools/ranges/rgmerge.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/xtools/ranges/rgmerge.x')
-rw-r--r-- | pkg/xtools/ranges/rgmerge.x | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pkg/xtools/ranges/rgmerge.x b/pkg/xtools/ranges/rgmerge.x new file mode 100644 index 00000000..2cb5034a --- /dev/null +++ b/pkg/xtools/ranges/rgmerge.x @@ -0,0 +1,38 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <pkg/rg.h> + +# RG_MERGE -- Merge overlapping ranges in set of ordered ranges. + +procedure rg_merge (rg) + +pointer rg # Ranges + +int new, old + +begin + # Error check the range pointer. + + if (rg == NULL) + call error (0, "Range descriptor undefined") + if (RG_NRGS(rg) == 0) + return + + # Eliminate overlapping ranges and count the number of new ranges. + + new = 1 + do old = 2, RG_NRGS(rg) + if (RG_X1(rg, old) > RG_X2(rg, new) + 1) { + new = new + 1 + RG_X1(rg, new) = RG_X1(rg, old) + RG_X2(rg, new) = RG_X2(rg, old) + } else + RG_X2(rg, new) = max (RG_X2(rg, old), RG_X2(rg, new)) + + call realloc (rg, LEN_RG + 2 * new, TY_STRUCT) + + RG_NPTS(rg) = 0 + RG_NRGS(rg) = new + do new = 1, RG_NRGS(rg) + RG_NPTS(rg) = RG_NPTS(rg) + RG_X2(rg, new) - RG_X1(rg, new) + 1 +end |