File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ typedef int IndexRange;
154
154
#define lfirst_irange (lc ) ((IndexRange)(lc)->data.int_value)
155
155
#define lappend_irange (list , irange ) (lappend_int((list), (int)(irange)))
156
156
#define list_make1_irange (irange ) lcons_int((int)(irange), NIL)
157
-
157
+ #define llast_irange ( l ) (IndexRange)lfirst_int(list_tail(l))
158
158
159
159
/* rangeset.c */
160
160
bool irange_intersects (IndexRange a , IndexRange b );
Original file line number Diff line number Diff line change @@ -125,7 +125,28 @@ irange_list_intersect(List *a, List *b)
125
125
ra = lfirst_irange (ca );
126
126
rb = lfirst_irange (cb );
127
127
if (irange_intersects (ra , rb ))
128
- result = lappend_irange (result , irange_intersect (ra , rb ));
128
+ {
129
+ IndexRange intersect , last ;
130
+
131
+ intersect = irange_intersect (ra , rb );
132
+ if (result != NIL )
133
+ {
134
+ last = llast_irange (result );
135
+ if (irange_conjuncted (last , intersent ) &&
136
+ irange_is_lossy (last ) == irange_is_lossy (intersect ))
137
+ {
138
+ llast_int (result ) = irange_union (last , intersect );
139
+ }
140
+ else
141
+ {
142
+ result = lappend_irange (result , intersect );
143
+ }
144
+ }
145
+ else
146
+ {
147
+ result = lappend_irange (result , intersect );
148
+ }
149
+ }
129
150
130
151
if (irange_lower (ra ) <= irange_lower (rb ))
131
152
ca = lnext (ca );
You can’t perform that action at this time.
0 commit comments