From: Ricardo Markiewicz Date: Mon, 21 Jun 2004 20:28:30 +0000 (+0000) Subject: Algunas mejoras, comentarios y arreglos X-Git-Tag: svn_import~105 X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/commitdiff_plain/784073eb4d4dba1995c35bf35d479c04e5f96e66?ds=inline;hp=d69c7c58de649932f607cbfb6e7f44a1364078f5 Algunas mejoras, comentarios y arreglos --- diff --git a/src/Makefile b/src/Makefile index fd18b1e..a046cde 100644 --- a/src/Makefile +++ b/src/Makefile @@ -47,13 +47,11 @@ clean: jacu.o: statichuff/statichuff.h /usr/include/stdio.h /usr/include/features.h jacu.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h -jacu.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h jacu.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h jacu.o: /usr/include/bits/typesizes.h /usr/include/libio.h jacu.o: /usr/include/_G_config.h /usr/include/wchar.h jacu.o: /usr/include/bits/wchar.h /usr/include/gconv.h -jacu.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h jacu.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h jacu.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h jacu.o: /usr/include/bits/confname.h blocksorting/bs.h /usr/include/string.h -jacu.o: /usr/include/stdlib.h mtf/mtf.h +jacu.o: /usr/include/stdlib.h mtf/mtf.h vfile/vfile.h diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 64ea8ab..9463b43 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -100,8 +100,8 @@ void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsign (*k) = generar_salida(in, bs, out); /* Guardo el k y el tamaño en el array */ - memcpy(out, k, sizeof(unsigned long int)); - memcpy(out+sizeof(unsigned long int), &leido, sizeof(unsigned long int)); + memcpy(out, &leido, sizeof(unsigned long int)); + memcpy(out+sizeof(unsigned long int), k, sizeof(unsigned long int)); bs->len = l; } diff --git a/src/jacu.c b/src/jacu.c index 8e74812..21f31c5 100644 --- a/src/jacu.c +++ b/src/jacu.c @@ -58,14 +58,16 @@ int main(int argc, char* argv[]) /* No me gusta el tmpfile ... es para probar como anda todo junto */ FILE *fp, *fp_out; unsigned long int i, j, total, k; - int *mtf; + char *mtf; char *salida, *data, c; data = malloc(sizeof(char)*pagesize); - /* Reservo lugar tambien para guardar el k */ + /* Reservo lugar tambien para guardar el k y el tamaño */ salida = malloc(sizeof(char)*(pagesize)+sizeof(unsigned long int)*2); bs = bs_create(pagesize); + fp = fopen(argv[optind], "rb"); fp_out = fopen("tmp.comp", "wb"); + c = fgetc(fp); total = 0; while (!feof(fp)) { @@ -75,17 +77,25 @@ int main(int argc, char* argv[]) c = fgetc(fp); total++; } + /* Hago el BS */ bs_solve(data, salida, bs, &k, i); - /* Le aplico el MTF */ - mtf = jacu_mtf(salida, i+sizeof(unsigned long int)*2); + + /* Le aplico el MTF, salteo el tamaño del bloque para que no se pierda. */ + mtf = jacu_mtf(salida+sizeof(unsigned long int), i+sizeof(unsigned long int)); for(j=0; j #include -int *jacu_mtf(char *datos, int len); +char *jacu_mtf(char *datos, int len); char *jacu_mtf_inv(char *z, int *pos, int len);