249{
250 Int offset, j0, j1, templatewidth0, templatewidth1, nbcol0, nbcol1;
252 assert(type == 'c' || type == 'r');
253 nbcol0 = (type ==
'c' ? ma->
nbcol : ma->
nbrow);
254 nbcol1 = (type ==
'c' ? mb->
nbcol : mb->
nbrow);
255 templatewidth0 = q0 * nbcol0;
256 templatewidth1 = q1 * nbcol1;
257 {
260 j0 =
SHIFT(col0, sp0, q0) * nbcol0 - ja;
261 j1 =
SHIFT(col1, sp1, q1) * nbcol1 - jb;
262 }
263 offset = 0;
264 l = 0;
265
266
267
268 assert(j0 + nbcol0 > 0);
269 assert(j1 + nbcol1 > 0);
270 while ((j0 < n) && (j1 < n)) {
273 end0 = j0 + nbcol0;
274 end1 = j1 + nbcol1;
275 if (end0 <= j1) {
276 j0 += templatewidth0;
277 l += nbcol0;
278 continue;
279 }
280 if (end1 <= j0) {
281 j1 += templatewidth1;
282 continue;
283 }
284
286 start =
max(start, 0);
287
288 result[offset].
gstart = start;
289 end =
min(end0, end1);
290 if (end0 == end) {
291 j0 += templatewidth0;
292 l += nbcol0;
293 }
294 if (end1 == end)
295 j1 += templatewidth1;
296
298 assert(end > start);
299
300
301
302
303
304
305 result[offset].
len = end - start;
306 offset += 1;
307 }
308 return offset;
309}
#define SHIFT(row, sprow, nbrow)