Date: Sat, 18 Aug 2012 17:18:01 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r240499 - in soc2012/jhagewood: diff sdiff Message-ID: <20120818171801.BC371106566B@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhagewood Date: Sat Aug 18 17:18:01 2012 New Revision: 240499 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240499 Log: Fixed file decompression Modified: soc2012/jhagewood/diff/decompress.c soc2012/jhagewood/sdiff/decompress.c Modified: soc2012/jhagewood/diff/decompress.c ============================================================================== --- soc2012/jhagewood/diff/decompress.c Sat Aug 18 16:14:50 2012 (r240498) +++ soc2012/jhagewood/diff/decompress.c Sat Aug 18 17:18:01 2012 (r240499) @@ -63,13 +63,25 @@ { FILE *file; - char *buf = ""; + char buf[MAXBUFSIZE]; + char ch; + int i = 0; + int length; gzFile comprfile; - if (comprfile = gzopen(filename, mode) == Z_NULL) - err(1, "Could not open compressed file %s.", filename); - gzread(comprfile, buf, MAXBUFSIZE); - fputs(buf, file); + file = fopen("./temp", "r+w"); + comprfile = gzopen(filename, mode); + + if (comprfile == Z_NULL) + err(1, "Could not open compressed file."); + + for (ch = '\0'; ch != NULL; ch = gzgetc(comprfile)) { + buf[i] = ch; + i++; + } + for (i = 0; buf[i] != EOF; i++) { + fputs(buf, file); + } return file; } Modified: soc2012/jhagewood/sdiff/decompress.c ============================================================================== --- soc2012/jhagewood/sdiff/decompress.c Sat Aug 18 16:14:50 2012 (r240498) +++ soc2012/jhagewood/sdiff/decompress.c Sat Aug 18 17:18:01 2012 (r240499) @@ -62,13 +62,25 @@ { FILE *file; - char *buf = ""; + char buf[MAXBUFSIZE]; + char ch; + int i = 0; + int length; gzFile comprfile; - if (comprfile = gzopen(filename, mode) == Z_NULL) - err(1, "Could not open compressed file %s.", filename); - gzread(comprfile, buf, MAXBUFSIZE); - fputs(buf, file); + file = fopen("./temp", "r+w"); + comprfile = gzopen(filename, mode); + + if (comprfile == Z_NULL) + err(1, "Could not open compressed file."); + + for (ch = '\0'; ch != NULL; ch = gzgetc(comprfile)) { + buf[i] = ch; + i++; + } + for (i = 0; buf[i] != EOF; i++) { + fputs(buf, file); + } return file; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120818171801.BC371106566B>