socsvn commit: r240503 - in soc2012/jhagewood: diff sdiff

jhagewood at FreeBSD.org jhagewood at FreeBSD.org
Sat Aug 18 19:25:03 UTC 2012


Author: jhagewood
Date: Sat Aug 18 19:25:00 2012
New Revision: 240503
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240503

Log:
  working 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 18:26:25 2012	(r240502)
+++ soc2012/jhagewood/diff/decompress.c	Sat Aug 18 19:25:00 2012	(r240503)
@@ -66,23 +66,24 @@
 	char buf[MAXBUFSIZE];
 	char ch;
 	int i = 0;
-	int length;
-	gzFile comprfile; 
+	gzFile *comprfile; 
 	
-	file = tmpfile();
+	file = fopen("/tmp/zdiff.XXXXXXXX", "w+");
 	comprfile = gzopen(filename, mode);
 	
 	if (comprfile == Z_NULL)
 		err(1, "Could not open compressed file.");
-
-	for (ch = '\0'; ch != NULL; ch = gzgetc(comprfile)) {
+	
+	for (ch = '\0'; ch != EOF ; ch = gzgetc(comprfile)) {
 		buf[i] = ch;
 		i++;
 	}
+	
 	for (i = 0; buf[i] != EOF; i++) {
-		fputs(buf, file);
-	} 
-	 
+		fputc(buf[i], file);
+	}
+	rewind(file);
+	
 	return file;
 }
 

Modified: soc2012/jhagewood/sdiff/decompress.c
==============================================================================
--- soc2012/jhagewood/sdiff/decompress.c	Sat Aug 18 18:26:25 2012	(r240502)
+++ soc2012/jhagewood/sdiff/decompress.c	Sat Aug 18 19:25:00 2012	(r240503)
@@ -65,23 +65,24 @@
 	char buf[MAXBUFSIZE];
 	char ch;
 	int i = 0;
-	int length;
-	gzFile comprfile; 
+	gzFile *comprfile; 
 	
-	file = tmpfile();
+	file = fopen("/tmp/zdiff.XXXXXXXX", "w+");
 	comprfile = gzopen(filename, mode);
 	
 	if (comprfile == Z_NULL)
 		err(1, "Could not open compressed file.");
-
-	for (ch = '\0'; ch != NULL; ch = gzgetc(comprfile)) {
+	
+	for (ch = '\0'; ch != EOF ; ch = gzgetc(comprfile)) {
 		buf[i] = ch;
 		i++;
 	}
+	
 	for (i = 0; buf[i] != EOF; i++) {
-		fputs(buf, file);
-	} 
-	 
+		fputc(buf[i], file);
+	}
+	rewind(file);
+	
 	return file;
 }
 


More information about the svn-soc-all mailing list