X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/d02adaeecaf5e03a84fecc369105cb618a3eb046..fef03d51453b511c6355d53f1c4f5d06f1e8519e:/src/blocksorting/bs.c diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 93b7bb5..a1e14a2 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -1,6 +1,7 @@ #include "bs.h" #include +#include /* Block Sorting Optimizado en memoria! */ @@ -140,12 +141,48 @@ void bs_destroy(t_BlockSort *bs) free(bs); } + +void bs_EOL(char *data, Uint32 pagesize, Uint32 *j) +{ + /* Trato de agregar 4 espacios antes y 4 despues de un \n */ + int i = (*j); + + /* Verifico poder hacerlo */ + if ((i+9) >= pagesize) return; /* No pude! */ + + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + + (*j) += 9; +} + int bs_readblock(FILE *fp, char *data, Uint32 pagesize) { Uint32 i=0; - + char c; while ((!feof(fp)) && (i < pagesize)) { - data[i++] = fgetc(fp); + c = fgetc(fp); +/* if (c != '\n')*/ + if (c == '\0') { + /* Debo encodear el \0 para que no complique */ + data[i++] = 0x00; + data[i++] = 0xFF; + } + if (isupper(c)) { + data[i++] = '\0'; + data[i++] = tolower(c); + } else { + data[i++] = c; + } +/* else + bs_EOL(data, pagesize, &i);*/ } /* Saco un EOF que lee de mas */