<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -31,13 +31,14 @@ __FBSDID(&quot;$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c,v 1.1 2005/08/06 01:59:05
 #include &lt;sys/types.h&gt;
 
 #include &lt;bzlib.h&gt;
-#include &lt;err.h&gt;
 #include &lt;fcntl.h&gt;
 #include &lt;stdio.h&gt;
 #include &lt;stdlib.h&gt;
 #include &lt;string.h&gt;
 #include &lt;unistd.h&gt;
 
+#include  &lt;ruby.h&gt;
+
 #define MIN(x,y) (((x)&lt;(y)) ? (x) : (y))
 
 static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h)
@@ -221,10 +222,12 @@ int bsdiff_files(const char *oldfile, const char *newfile, const char *patchfile
 		((old=malloc(oldsize+1))==NULL) ||
 		(lseek(fd,0,SEEK_SET)!=0) ||
 		(read(fd,old,oldsize)!=oldsize) ||
-		(close(fd)==-1)) err(1,&quot;%s&quot;,oldfile);
+		(close(fd)==-1)) {
+    rb_raise(rb_eRuntimeError, &quot;%s&quot;,oldfile);
+  }
 
 	if(((I=malloc((oldsize+1)*sizeof(off_t)))==NULL) ||
-		((V=malloc((oldsize+1)*sizeof(off_t)))==NULL)) err(1,NULL);
+		((V=malloc((oldsize+1)*sizeof(off_t)))==NULL)) rb_raise(rb_eRuntimeError, &quot;malloc error&quot;);
 
 	qsufsort(I,V,old,oldsize);
 
@@ -237,16 +240,16 @@ int bsdiff_files(const char *oldfile, const char *newfile, const char *patchfile
 		((new=malloc(newsize+1))==NULL) ||
 		(lseek(fd,0,SEEK_SET)!=0) ||
 		(read(fd,new,newsize)!=newsize) ||
-		(close(fd)==-1)) err(1,&quot;%s&quot;,newfile);
+		(close(fd)==-1)) rb_raise(rb_eRuntimeError, &quot;%s&quot;,newfile);
 
 	if(((db=malloc(newsize+1))==NULL) ||
-		((eb=malloc(newsize+1))==NULL)) err(1,NULL);
+		((eb=malloc(newsize+1))==NULL)) rb_raise(rb_eRuntimeError,&quot;malloc error&quot;);
 	dblen=0;
 	eblen=0;
 
 	/* Create the patch file */
 	if ((pf = fopen(patchfile, &quot;w&quot;)) == NULL)
-		err(1, &quot;%s&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;%s&quot;, patchfile);
 
 	/* Header is
 		0	8	 &quot;BSDIFF40&quot;
@@ -263,11 +266,11 @@ int bsdiff_files(const char *oldfile, const char *newfile, const char *patchfile
 	offtout(0, header + 16);
 	offtout(newsize, header + 24);
 	if (fwrite(header, 32, 1, pf) != 1)
-		err(1, &quot;fwrite(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fwrite(%s)&quot;, patchfile);
 
 	/* Compute the differences, writing ctrl as we go */
 	if ((pfbz2 = BZ2_bzWriteOpen(&amp;bz2err, pf, 9, 0, 0)) == NULL)
-		errx(1, &quot;BZ2_bzWriteOpen, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWriteOpen, bz2err = %d&quot;, bz2err);
 	scan=0;len=0;
 	lastscan=0;lastpos=0;lastoffset=0;
 	while(scan&lt;newsize) {
@@ -333,17 +336,17 @@ int bsdiff_files(const char *oldfile, const char *newfile, const char *patchfile
 			offtout(lenf,buf);
 			BZ2_bzWrite(&amp;bz2err, pfbz2, buf, 8);
 			if (bz2err != BZ_OK)
-				errx(1, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
+				rb_raise(rb_eRuntimeError, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
 
 			offtout((scan-lenb)-(lastscan+lenf),buf);
 			BZ2_bzWrite(&amp;bz2err, pfbz2, buf, 8);
 			if (bz2err != BZ_OK)
-				errx(1, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
+				rb_raise(rb_eRuntimeError, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
 
 			offtout((pos-lenb)-(lastpos+lenf),buf);
 			BZ2_bzWrite(&amp;bz2err, pfbz2, buf, 8);
 			if (bz2err != BZ_OK)
-				errx(1, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
+				rb_raise(rb_eRuntimeError, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
 
 			lastscan=scan-lenb;
 			lastpos=pos-lenb;
@@ -352,45 +355,45 @@ int bsdiff_files(const char *oldfile, const char *newfile, const char *patchfile
 	};
 	BZ2_bzWriteClose(&amp;bz2err, pfbz2, 0, NULL, NULL);
 	if (bz2err != BZ_OK)
-		errx(1, &quot;BZ2_bzWriteClose, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWriteClose, bz2err = %d&quot;, bz2err);
 
 	/* Compute size of compressed ctrl data */
 	if ((len = ftello(pf)) == -1)
-		err(1, &quot;ftello&quot;);
+		rb_raise(rb_eRuntimeError, &quot;ftello&quot;);
 	offtout(len-32, header + 8);
 
 	/* Write compressed diff data */
 	if ((pfbz2 = BZ2_bzWriteOpen(&amp;bz2err, pf, 9, 0, 0)) == NULL)
-		errx(1, &quot;BZ2_bzWriteOpen, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWriteOpen, bz2err = %d&quot;, bz2err);
 	BZ2_bzWrite(&amp;bz2err, pfbz2, db, dblen);
 	if (bz2err != BZ_OK)
-		errx(1, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
 	BZ2_bzWriteClose(&amp;bz2err, pfbz2, 0, NULL, NULL);
 	if (bz2err != BZ_OK)
-		errx(1, &quot;BZ2_bzWriteClose, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWriteClose, bz2err = %d&quot;, bz2err);
 
 	/* Compute size of compressed diff data */
 	if ((newsize = ftello(pf)) == -1)
-		err(1, &quot;ftello&quot;);
+		rb_raise(rb_eRuntimeError, &quot;ftello&quot;);
 	offtout(newsize - len, header + 16);
 
 	/* Write compressed extra data */
 	if ((pfbz2 = BZ2_bzWriteOpen(&amp;bz2err, pf, 9, 0, 0)) == NULL)
-		errx(1, &quot;BZ2_bzWriteOpen, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWriteOpen, bz2err = %d&quot;, bz2err);
 	BZ2_bzWrite(&amp;bz2err, pfbz2, eb, eblen);
 	if (bz2err != BZ_OK)
-		errx(1, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWrite, bz2err = %d&quot;, bz2err);
 	BZ2_bzWriteClose(&amp;bz2err, pfbz2, 0, NULL, NULL);
 	if (bz2err != BZ_OK)
-		errx(1, &quot;BZ2_bzWriteClose, bz2err = %d&quot;, bz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzWriteClose, bz2err = %d&quot;, bz2err);
 
 	/* Seek to the beginning, write the header, and close the file */
 	if (fseeko(pf, 0, SEEK_SET))
-		err(1, &quot;fseeko&quot;);
+		rb_raise(rb_eRuntimeError, &quot;fseeko&quot;);
 	if (fwrite(header, 32, 1, pf) != 1)
-		err(1, &quot;fwrite(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fwrite(%s)&quot;, patchfile);
 	if (fclose(pf))
-		err(1, &quot;fclose&quot;);
+		rb_raise(rb_eRuntimeError, &quot;fclose&quot;);
 
 	/* Free the memory we used */
 	free(db);</diff>
      <filename>ext/bsdiff.c</filename>
    </modified>
    <modified>
      <diff>@@ -32,11 +32,10 @@ __FBSDID(&quot;$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:
 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 #include &lt;string.h&gt;
-#include &lt;err.h&gt;
 #include &lt;unistd.h&gt;
 #include &lt;fcntl.h&gt;
 
-const char *foobar = &quot;hello world&quot;;
+#include &lt;ruby.h&gt;
 
 static off_t offtin(u_char *buf)
 {
@@ -73,7 +72,7 @@ int bspatch_files(const char *oldfile, const char *newfile, const char *patchfil
 
 	/* Open patch file */
 	if ((f = fopen(patchfile, &quot;r&quot;)) == NULL)
-		err(1, &quot;fopen(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fopen(%s)&quot;, patchfile);
 
 	/*
 	File format:
@@ -92,53 +91,53 @@ int bspatch_files(const char *oldfile, const char *newfile, const char *patchfil
 	/* Read header */
 	if (fread(header, 1, 32, f) &lt; 32) {
 		if (feof(f))
-			errx(1, &quot;Corrupt patch\n&quot;);
-		err(1, &quot;fread(%s)&quot;, patchfile);
+			rb_raise(rb_eRuntimeError,&quot;Corrupt patch\n&quot;);
+		 rb_raise(rb_eRuntimeError, &quot;fread(%s)&quot;, patchfile);
 	}
 
 	/* Check for appropriate magic */
 	if (memcmp(header, &quot;BSDIFF40&quot;, 8) != 0)
-		errx(1, &quot;Corrupt patch\n&quot;);
+		rb_raise(rb_eRuntimeError, &quot;Corrupt patch\n&quot;);
 
 	/* Read lengths from header */
 	bzctrllen=offtin(header+8);
 	bzdatalen=offtin(header+16);
 	newsize=offtin(header+24);
 	if((bzctrllen&lt;0) || (bzdatalen&lt;0) || (newsize&lt;0))
-		errx(1,&quot;Corrupt patch\n&quot;);
+		rb_raise(rb_eRuntimeError,&quot;Corrupt patch\n&quot;);
 
 	/* Close patch file and re-open it via libbzip2 at the right places */
 	if (fclose(f))
-		err(1, &quot;fclose(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fclose(%s)&quot;, patchfile);
 	if ((cpf = fopen(patchfile, &quot;r&quot;)) == NULL)
-		err(1, &quot;fopen(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fopen(%s)&quot;, patchfile);
 	if (fseeko(cpf, 32, SEEK_SET))
-		err(1, &quot;fseeko(%s, %lld)&quot;, patchfile,
+		rb_raise(rb_eRuntimeError, &quot;fseeko(%s, %lld)&quot;, patchfile,
 		    (long long)32);
 	if ((cpfbz2 = BZ2_bzReadOpen(&amp;cbz2err, cpf, 0, 0, NULL, 0)) == NULL)
-		errx(1, &quot;BZ2_bzReadOpen, bz2err = %d&quot;, cbz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzReadOpen, bz2err = %d&quot;, cbz2err);
 	if ((dpf = fopen(patchfile, &quot;r&quot;)) == NULL)
-		err(1, &quot;fopen(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fopen(%s)&quot;, patchfile);
 	if (fseeko(dpf, 32 + bzctrllen, SEEK_SET))
-		err(1, &quot;fseeko(%s, %lld)&quot;, patchfile,
+		rb_raise(rb_eRuntimeError, &quot;fseeko(%s, %lld)&quot;, patchfile,
 		    (long long)(32 + bzctrllen));
 	if ((dpfbz2 = BZ2_bzReadOpen(&amp;dbz2err, dpf, 0, 0, NULL, 0)) == NULL)
-		errx(1, &quot;BZ2_bzReadOpen, bz2err = %d&quot;, dbz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzReadOpen, bz2err = %d&quot;, dbz2err);
 	if ((epf = fopen(patchfile, &quot;r&quot;)) == NULL)
-		err(1, &quot;fopen(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fopen(%s)&quot;, patchfile);
 	if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET))
-		err(1, &quot;fseeko(%s, %lld)&quot;, patchfile,
+		rb_raise(rb_eRuntimeError, &quot;fseeko(%s, %lld)&quot;, patchfile,
 		    (long long)(32 + bzctrllen + bzdatalen));
 	if ((epfbz2 = BZ2_bzReadOpen(&amp;ebz2err, epf, 0, 0, NULL, 0)) == NULL)
-		errx(1, &quot;BZ2_bzReadOpen, bz2err = %d&quot;, ebz2err);
+		rb_raise(rb_eRuntimeError, &quot;BZ2_bzReadOpen, bz2err = %d&quot;, ebz2err);
 
 	if(((fd=open(oldfile,O_RDONLY,0))&lt;0) ||
 		((oldsize=lseek(fd,0,SEEK_END))==-1) ||
 		((old=malloc(oldsize+1))==NULL) ||
 		(lseek(fd,0,SEEK_SET)!=0) ||
 		(read(fd,old,oldsize)!=oldsize) ||
-		(close(fd)==-1)) err(1,&quot;%s&quot;,oldfile);
-	if((new=malloc(newsize+1))==NULL) err(1,NULL);
+		(close(fd)==-1)) rb_raise(rb_eRuntimeError,&quot;%s&quot;,oldfile);
+	if((new=malloc(newsize+1))==NULL) rb_raise(rb_eRuntimeError,&quot;malloc&quot;);
 
 	oldpos=0;newpos=0;
 	while(newpos&lt;newsize) {
@@ -147,19 +146,19 @@ int bspatch_files(const char *oldfile, const char *newfile, const char *patchfil
 			lenread = BZ2_bzRead(&amp;cbz2err, cpfbz2, buf, 8);
 			if ((lenread &lt; 8) || ((cbz2err != BZ_OK) &amp;&amp;
 			    (cbz2err != BZ_STREAM_END)))
-				errx(1, &quot;Corrupt patch\n&quot;);
+				rb_raise(rb_eRuntimeError, &quot;Corrupt patch\n&quot;);
 			ctrl[i]=offtin(buf);
 		};
 
 		/* Sanity-check */
 		if(newpos+ctrl[0]&gt;newsize)
-			errx(1,&quot;Corrupt patch\n&quot;);
+			rb_raise(rb_eRuntimeError,&quot;Corrupt patch\n&quot;);
 
 		/* Read diff string */
 		lenread = BZ2_bzRead(&amp;dbz2err, dpfbz2, new + newpos, ctrl[0]);
 		if ((lenread &lt; ctrl[0]) ||
 		    ((dbz2err != BZ_OK) &amp;&amp; (dbz2err != BZ_STREAM_END)))
-			errx(1, &quot;Corrupt patch\n&quot;);
+			rb_raise(rb_eRuntimeError, &quot;Corrupt patch\n&quot;);
 
 		/* Add old data to diff string */
 		for(i=0;i&lt;ctrl[0];i++)
@@ -172,13 +171,13 @@ int bspatch_files(const char *oldfile, const char *newfile, const char *patchfil
 
 		/* Sanity-check */
 		if(newpos+ctrl[1]&gt;newsize)
-			errx(1,&quot;Corrupt patch\n&quot;);
+			rb_raise(rb_eRuntimeError,&quot;Corrupt patch\n&quot;);
 
 		/* Read extra string */
 		lenread = BZ2_bzRead(&amp;ebz2err, epfbz2, new + newpos, ctrl[1]);
 		if ((lenread &lt; ctrl[1]) ||
 		    ((ebz2err != BZ_OK) &amp;&amp; (ebz2err != BZ_STREAM_END)))
-			errx(1, &quot;Corrupt patch\n&quot;);
+			rb_raise(rb_eRuntimeError, &quot;Corrupt patch\n&quot;);
 
 		/* Adjust pointers */
 		newpos+=ctrl[1];
@@ -190,24 +189,15 @@ int bspatch_files(const char *oldfile, const char *newfile, const char *patchfil
 	BZ2_bzReadClose(&amp;dbz2err, dpfbz2);
 	BZ2_bzReadClose(&amp;ebz2err, epfbz2);
 	if (fclose(cpf) || fclose(dpf) || fclose(epf))
-		err(1, &quot;fclose(%s)&quot;, patchfile);
+		rb_raise(rb_eRuntimeError, &quot;fclose(%s)&quot;, patchfile);
 
 	/* Write the new file */
 	if(((fd=open(newfile,O_CREAT|O_TRUNC|O_WRONLY,0666))&lt;0) ||
 		(write(fd,new,newsize)!=newsize) || (close(fd)==-1))
-		err(1,&quot;%s&quot;,newfile);
+		rb_raise(rb_eRuntimeError,&quot;%s&quot;,newfile);
 
 	free(new);
 	free(old);
 
 	return 0;
 }
-
-#if 0
-int main(int argc,char * argv[])
-{
-
-	if(argc!=4) errx(1,&quot;usage: %s oldfile newfile patchfile\n&quot;,argv[0]);
-
-}
-#endif</diff>
      <filename>ext/bspatch.c</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,6 @@ require 'mkmf'
 
 dir_config('bsdiff')
 fail unless have_header('unistd.h')
-fail unless have_header('err.h')
 fail unless have_header('bzlib.h')
 fail unless have_library('bz2')
 fail unless have_func('BZ2_bzWrite','bzlib.h')</diff>
      <filename>ext/extconf.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>88f4418f50253fd3b1c807988a0c4a76bdba9ca6</id>
    </parent>
  </parents>
  <author>
    <name>Todd Fisher</name>
    <email>taf2@spin.localdomain</email>
  </author>
  <url>http://github.com/taf2/rb-bsdiff/commit/8bf73f8542093b23d9f7bd43d8948dc3435283f8</url>
  <id>8bf73f8542093b23d9f7bd43d8948dc3435283f8</id>
  <committed-date>2009-05-24T09:03:01-07:00</committed-date>
  <authored-date>2009-05-24T09:03:01-07:00</authored-date>
  <message>raise execptions instead of killing the process</message>
  <tree>2a91f8b6dbf7b9865f0878234fffc2eba609443a</tree>
  <committer>
    <name>Todd Fisher</name>
    <email>taf2@spin.localdomain</email>
  </committer>
</commit>
