int __compare(const void *d1, const void *d2) {
t_BlockSortData *s1, *s2;
- char i;
s1 = (t_BlockSortData *)d1;
s2 = (t_BlockSortData *)d2;
- i = es_menor(s1->bs->data, s1->bs, s1->pos_inicial, s2->pos_inicial);
-
-/* if (i == 0) {*/
- /* si ambos strings son iguales, fuerzo a que d1 quede primero */
- /*return -1;
- }*/
- return i;
+ return es_menor(s1->bs->data, s1->bs, s1->pos_inicial, s2->pos_inicial);
}
char es_menor(char *data, t_BlockSort *bs, int i, int j)
}
/* Son iguales! */
- /* Hack */
return 0;
}
qsort(bs->array, bs->len, sizeof(t_BlockSortData), __compare);
}
-void print_(char *data, Uint32 pos, Uint32 len)
-{
- Uint32 i;
-
- for(i=0; i<len; i++)
- fprintf(stderr, "%c", data[(pos+i)%len]);
- fprintf(stderr, "\n");
-}
-
int generar_salida(char *data, t_BlockSort *bs, char *salida)
{
Uint32 i, k;
k=-1;
for(i=0; i<bs->len; i++) {
- /* print_(data, bs->array[i].pos_inicial, bs->len); */
out[i] = data[bs->array[i].pos_final];
if (bs->array[i].ord == 1) k = i;
}
current = in[current].sig;
} while (current != k);
free(in);
-
- if (i < len) printf("Noo %ld != %ld\n", i, len);
}
t_BlockSort *bs_create(Uint32 len)