X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/d69c7c58de649932f607cbfb6e7f44a1364078f5..5cde90ce82c099520a3cfe2f0bc533b65216137a:/src/zerogrouping/zg.c?ds=inline diff --git a/src/zerogrouping/zg.c b/src/zerogrouping/zg.c index a3ef8e2..7d93343 100644 --- a/src/zerogrouping/zg.c +++ b/src/zerogrouping/zg.c @@ -22,7 +22,7 @@ * Autores: Leandro Lucarella *---------------------------------------------------------------------------- * - * $Id: vfile.c 748 2004-06-21 00:46:08Z llucare $ + * $Id$ * */ @@ -36,25 +36,17 @@ * */ -int main(int argc, char* argv[]) +int main() { - size_t pagesize = BUFSIZ; size_t len; - char* page; - char* pageout; - if (argc > 1) pagesize = atoi(argv[1]); - if (!(page = malloc(pagesize))) return 1; - if (!(pageout = malloc(pagesize/2+pagesize+1))) /* por si se expande */ + char buff[2]; + int c; + ZG zg; + zg_init(&zg); + while ((c = getchar()) != EOF) { - free(page); - return 1; + if ((len = zg_group(&zg, buff, c))) fwrite(buff, 1, len, stdout); } - while ((len = fread(page, 1, pagesize, stdin))) - { - len = zg_group(pageout, page, len); - fwrite(pageout, 1, len, stdout); - } - free(page); return 0; }