- if (pattern != NULL && *pattern == '.') {
- pattern = NULL;
- }
- if (pattern == NULL && patternindex.maxballs == 0) {
- /* pattern list needs indexing */
- int nelements = XtNumber(portfolio);
- int numpat = 0;
-
- /* sort according to number of balls */
- qsort((void*)portfolio, nelements,
- sizeof(portfolio[1]), compare_num_balls);
-
- /* last pattern has most balls */
- patternindex.maxballs = get_num_balls(portfolio[nelements - 1].pattern);
- /* run through sorted list, indexing start of each group
- and number in group */
- patternindex.maxballs = 1;
- for (i = 0; i < nelements; i++) {
- int b = get_num_balls(portfolio[i].pattern);
- if (b > patternindex.maxballs) {
- patternindex.index[patternindex.maxballs].number = numpat;
- if(numpat == 0) patternindex.minballs = b;
- patternindex.maxballs = b;
- numpat = 1;
- patternindex.index[patternindex.maxballs].start = i;
- } else {
- numpat++;
- }
- }
- patternindex.index[patternindex.maxballs].number = numpat;
- }
-
- /* Clean up the Screen. Don't use MI_CLEARWINDOW(mi), since we may
- only be resizing and then we won't all those special effects. */
- XClearWindow(MI_DISPLAY(mi), MI_WINDOW(mi));
-
- if (juggles == NULL) { /* First-time initialisation */
-
- /* allocate jugglestruct */
- if ((juggles =
- (jugglestruct *)calloc(MI_NUM_SCREENS(mi),
- sizeof (jugglestruct))) == NULL) {
- release_juggle(mi);
- return;
- }
-
- sp = &juggles[MI_SCREEN(mi)];