DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦12d982183⟧ TextFile

    Length: 529 (0x211)
    Types: TextFile
    Notes: UNIX file
    Names: »shellsort.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libc/gen/shellsort.c« 

TextFile

/*
 * Shell sort with the calling sequence of
 * qsort.
 */

#define A(v,i)  ((v)+((i)*size))

shellsort(v, n, size, compar)
register char *v;
int (*compar)();
{
	int gap, i;
	register j;

	for (gap = n/2; gap > 0; gap /= 2)
		for (i = gap; i < n; i++)
			for (j = i-gap; j>=0; j -= gap) {
				if ((*compar)(A(v,j), A(v,j+gap)) <= 0)
					break;
				qexch(A(v,j), A(v,j+gap), size);
			}
}

static
qexch(p1, p2, n)
register char *p1, *p2, n;
{
	int t;

	if (n)
		do {
			t = *p1;
			*p1++ = *p2;
			*p2++ = t;
		} while (--n);
}