[gimp/metadata-browser] file-compressor: Rewrite code for students who didn't like sitting in Dijkstra's class
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] file-compressor: Rewrite code for students who didn't like sitting in Dijkstra's class
- Date: Wed, 12 Sep 2012 22:39:44 +0000 (UTC)
commit 84471d3356cc7e69c2671dceec3ddaead9427d3b
Author: Mukund Sivaraman <muks banu com>
Date: Thu Jan 12 05:54:18 2012 +0530
file-compressor: Rewrite code for students who didn't like sitting in Dijkstra's class
plug-ins/file-compressor/file-compressor.c | 160 +++++++++++++---------------
1 files changed, 74 insertions(+), 86 deletions(-)
---
diff --git a/plug-ins/file-compressor/file-compressor.c b/plug-ins/file-compressor/file-compressor.c
index 39dc9aa..e9b562a 100644
--- a/plug-ins/file-compressor/file-compressor.c
+++ b/plug-ins/file-compressor/file-compressor.c
@@ -539,34 +539,31 @@ gzip_load (const char *infile,
in = NULL;
out = NULL;
- do
+ in = gzopen (infile, "rb");
+ if (!in)
+ goto out;
+
+ out = fopen (outfile, "wb");
+ if (!out)
+ goto out;
+
+ while (TRUE)
{
- in = gzopen (infile, "rb");
- if (!in)
- break;
+ len = gzread (in, buf, sizeof buf);
- out = fopen (outfile, "wb");
- if (!out)
+ if (len < 0)
break;
-
- while (TRUE)
+ else if (len == 0)
{
- len = gzread (in, buf, sizeof buf);
-
- if (len < 0)
- break;
- else if (len == 0)
- {
- ret = TRUE;
- break;
- }
-
- if (fwrite(buf, 1, len, out) != len)
- break;
+ ret = TRUE;
+ break;
}
+
+ if (fwrite(buf, 1, len, out) != len)
+ break;
}
- while (0);
+ out:
if (in)
if (gzclose (in) != Z_OK)
ret = FALSE;
@@ -591,36 +588,33 @@ gzip_save (const char *infile,
in = NULL;
out = NULL;
- do
+ in = fopen (infile, "rb");
+ if (!in)
+ goto out;
+
+ out = gzopen (outfile, "wb");
+ if (!out)
+ goto out;
+
+ while (TRUE)
{
- in = fopen (infile, "rb");
- if (!in)
+ len = fread (buf, 1, sizeof buf, in);
+ if (ferror (in))
break;
- out = gzopen (outfile, "wb");
- if (!out)
+ if (len < 0)
break;
-
- while (TRUE)
+ else if (len == 0)
{
- len = fread (buf, 1, sizeof buf, in);
- if (ferror (in))
- break;
-
- if (len < 0)
- break;
- else if (len == 0)
- {
- ret = TRUE;
- break;
- }
-
- if (gzwrite (out, buf, len) != len)
- break;
+ ret = TRUE;
+ break;
}
+
+ if (gzwrite (out, buf, len) != len)
+ break;
}
- while (0);
+ out:
if (in)
fclose (in);
@@ -645,34 +639,31 @@ bzip2_load (const char *infile,
in = NULL;
out = NULL;
- do
+ in = BZ2_bzopen (infile, "rb");
+ if (!in)
+ goto out;
+
+ out = fopen (outfile, "wb");
+ if (!out)
+ goto out;
+
+ while (TRUE)
{
- in = BZ2_bzopen (infile, "rb");
- if (!in)
- break;
+ len = BZ2_bzread (in, buf, sizeof buf);
- out = fopen (outfile, "wb");
- if (!out)
+ if (len < 0)
break;
-
- while (TRUE)
+ else if (len == 0)
{
- len = BZ2_bzread (in, buf, sizeof buf);
-
- if (len < 0)
- break;
- else if (len == 0)
- {
- ret = TRUE;
- break;
- }
-
- if (fwrite(buf, 1, len, out) != len)
- break;
+ ret = TRUE;
+ break;
}
+
+ if (fwrite(buf, 1, len, out) != len)
+ break;
}
- while (0);
+ out:
if (in)
BZ2_bzclose (in);
@@ -696,36 +687,33 @@ bzip2_save (const char *infile,
in = NULL;
out = NULL;
- do
+ in = fopen (infile, "rb");
+ if (!in)
+ goto out;
+
+ out = BZ2_bzopen (outfile, "wb");
+ if (!out)
+ goto out;
+
+ while (TRUE)
{
- in = fopen (infile, "rb");
- if (!in)
+ len = fread (buf, 1, sizeof buf, in);
+ if (ferror (in))
break;
- out = BZ2_bzopen (outfile, "wb");
- if (!out)
+ if (len < 0)
break;
-
- while (TRUE)
+ else if (len == 0)
{
- len = fread (buf, 1, sizeof buf, in);
- if (ferror (in))
- break;
-
- if (len < 0)
- break;
- else if (len == 0)
- {
- ret = TRUE;
- break;
- }
-
- if (BZ2_bzwrite (out, buf, len) != len)
- break;
+ ret = TRUE;
+ break;
}
+
+ if (BZ2_bzwrite (out, buf, len) != len)
+ break;
}
- while (0);
+ out:
if (in)
fclose (in);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]