summaryrefslogtreecommitdiff
path: root/apps/pdfclean.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2010-05-23 16:08:09 +0200
committerSebastian Rasmussen <sebras@hotmail.com>2010-05-23 16:08:09 +0200
commitf644a2757a409149c1afddb7f9a4b2460c1793c4 (patch)
tree94b81b7ddc6b2692609f40593fe4d2c8b9f2f841 /apps/pdfclean.c
parent04919492a855ebac7ab1e8909ca77f36ff26d5fa (diff)
downloadmupdf-f644a2757a409149c1afddb7f9a4b2460c1793c4.tar.xz
Globally rename oid to num to fit with fz_tonum().
Diffstat (limited to 'apps/pdfclean.c')
-rw-r--r--apps/pdfclean.c106
1 files changed, 53 insertions, 53 deletions
diff --git a/apps/pdfclean.c b/apps/pdfclean.c
index a763ba44..ec8cd217 100644
--- a/apps/pdfclean.c
+++ b/apps/pdfclean.c
@@ -59,21 +59,21 @@ static fz_error sweepref(pdf_xref *xref, fz_obj *obj)
{
fz_error error;
fz_obj *len;
- int oid, gen;
+ int num, gen;
- oid = fz_tonum(obj);
+ num = fz_tonum(obj);
gen = fz_tonum(obj);
- if (oid < 0 || oid >= xref->len)
- return fz_throw("object out of range (%d %d R)", oid, gen);
+ if (num < 0 || num >= xref->len)
+ return fz_throw("object out of range (%d %d R)", num, gen);
- if (uselist[oid])
+ if (uselist[num])
return fz_okay;
- uselist[oid] = 1;
+ uselist[num] = 1;
/* Bake in /Length in stream objects */
- if (xref->table[oid].stmofs)
+ if (xref->table[num].stmofs)
{
len = fz_dictgets(obj, "Length");
if (fz_isindirect(len))
@@ -94,13 +94,13 @@ static void preloadobjstms(void)
{
fz_error error;
fz_obj *obj;
- int oid;
+ int num;
- for (oid = 0; oid < xref->len; oid++)
+ for (num = 0; num < xref->len; num++)
{
- if (xref->table[oid].type == 'o')
+ if (xref->table[num].type == 'o')
{
- error = pdf_loadobject(&obj, xref, oid, 0);
+ error = pdf_loadobject(&obj, xref, num, 0);
if (error)
die(error);
fz_dropobj(obj);
@@ -108,16 +108,16 @@ static void preloadobjstms(void)
}
}
-static void copystream(fz_obj *obj, int oid, int gen)
+static void copystream(fz_obj *obj, int num, int gen)
{
fz_error error;
fz_buffer *buf;
- error = pdf_loadrawstream(&buf, xref, oid, gen);
+ error = pdf_loadrawstream(&buf, xref, num, gen);
if (error)
die(error);
- fprintf(out, "%d %d obj\n", oid, gen);
+ fprintf(out, "%d %d obj\n", num, gen);
fz_fprintobj(out, obj, !doexpand);
fprintf(out, "stream\n");
fwrite(buf->rp, 1, buf->wp - buf->rp, out);
@@ -126,13 +126,13 @@ static void copystream(fz_obj *obj, int oid, int gen)
fz_dropbuffer(buf);
}
-static void expandstream(fz_obj *obj, int oid, int gen)
+static void expandstream(fz_obj *obj, int num, int gen)
{
fz_error error;
fz_buffer *buf;
fz_obj *newdict, *newlen;
- error = pdf_loadstream(&buf, xref, oid, gen);
+ error = pdf_loadstream(&buf, xref, num, gen);
if (error)
die(error);
@@ -144,7 +144,7 @@ static void expandstream(fz_obj *obj, int oid, int gen)
fz_dictputs(newdict, "Length", newlen);
fz_dropobj(newlen);
- fprintf(out, "%d %d obj\n", oid, gen);
+ fprintf(out, "%d %d obj\n", num, gen);
fz_fprintobj(out, newdict, !doexpand);
fprintf(out, "stream\n");
fwrite(buf->rp, 1, buf->wp - buf->rp, out);
@@ -155,13 +155,13 @@ static void expandstream(fz_obj *obj, int oid, int gen)
fz_dropbuffer(buf);
}
-static void saveobject(int oid, int gen)
+static void saveobject(int num, int gen)
{
fz_error error;
fz_obj *obj;
fz_obj *type;
- error = pdf_loadobject(&obj, xref, oid, gen);
+ error = pdf_loadobject(&obj, xref, num, gen);
if (error)
die(error);
@@ -171,31 +171,31 @@ static void saveobject(int oid, int gen)
type = fz_dictgets(obj, "Type");
if (fz_isname(type) && !strcmp(fz_toname(type), "ObjStm"))
{
- uselist[oid] = 0;
+ uselist[num] = 0;
fz_dropobj(obj);
return;
}
if (fz_isname(type) && !strcmp(fz_toname(type), "XRef"))
{
- uselist[oid] = 0;
+ uselist[num] = 0;
fz_dropobj(obj);
return;
}
}
- if (!xref->table[oid].stmofs)
+ if (!xref->table[num].stmofs)
{
- fprintf(out, "%d %d obj\n", oid, gen);
+ fprintf(out, "%d %d obj\n", num, gen);
fz_fprintobj(out, obj, !doexpand);
fprintf(out, "endobj\n\n");
}
else
{
if (doexpand)
- expandstream(obj, oid, gen);
+ expandstream(obj, num, gen);
else
- copystream(obj, oid, gen);
+ copystream(obj, num, gen);
}
@@ -207,17 +207,17 @@ static void savexref(void)
fz_obj *trailer;
fz_obj *obj;
int startxref;
- int oid;
+ int num;
startxref = ftell(out);
fprintf(out, "xref\n0 %d\n", xref->len);
- for (oid = 0; oid < xref->len; oid++)
+ for (num = 0; num < xref->len; num++)
{
- if (uselist[oid])
- fprintf(out, "%010d %05d n \n", ofslist[oid], genlist[oid]);
+ if (uselist[num])
+ fprintf(out, "%010d %05d n \n", ofslist[num], genlist[num]);
else
- fprintf(out, "%010d %05d f \n", ofslist[oid], genlist[oid]);
+ fprintf(out, "%010d %05d f \n", ofslist[num], genlist[num]);
}
fprintf(out, "\n");
@@ -262,7 +262,7 @@ int main(int argc, char **argv)
char *outfile = "out.pdf";
char *password = "";
fz_error error;
- int c, oid;
+ int c, num;
int lastfree;
int subset;
@@ -305,11 +305,11 @@ int main(int argc, char **argv)
ofslist = malloc(sizeof (int) * (xref->len + 1));
genlist = malloc(sizeof (int) * (xref->len + 1));
- for (oid = 0; oid < xref->len; oid++)
+ for (num = 0; num < xref->len; num++)
{
- uselist[oid] = 0;
- ofslist[oid] = 0;
- genlist[oid] = 0;
+ uselist[num] = 0;
+ ofslist[num] = 0;
+ genlist[num] = 0;
}
/* Make sure any objects hidden in compressed streams have been loaded */
@@ -404,37 +404,37 @@ int main(int argc, char **argv)
if (error)
die(fz_rethrow(error, "cannot mark used objects"));
- for (oid = 0; oid < xref->len; oid++)
+ for (num = 0; num < xref->len; num++)
{
- if (xref->table[oid].type == 'f')
- uselist[oid] = 0;
+ if (xref->table[num].type == 'f')
+ uselist[num] = 0;
- if (xref->table[oid].type == 'f')
- genlist[oid] = xref->table[oid].gen;
- if (xref->table[oid].type == 'n')
- genlist[oid] = xref->table[oid].gen;
- if (xref->table[oid].type == 'o')
- genlist[oid] = 0;
+ if (xref->table[num].type == 'f')
+ genlist[num] = xref->table[num].gen;
+ if (xref->table[num].type == 'n')
+ genlist[num] = xref->table[num].gen;
+ if (xref->table[num].type == 'o')
+ genlist[num] = 0;
- if (dogarbage && !uselist[oid])
+ if (dogarbage && !uselist[num])
continue;
- if (xref->table[oid].type == 'n' || xref->table[oid].type == 'o')
+ if (xref->table[num].type == 'n' || xref->table[num].type == 'o')
{
- ofslist[oid] = ftell(out);
- saveobject(oid, genlist[oid]);
+ ofslist[num] = ftell(out);
+ saveobject(num, genlist[num]);
}
}
/* Construct linked list of free object slots */
lastfree = 0;
- for (oid = 0; oid < xref->len; oid++)
+ for (num = 0; num < xref->len; num++)
{
- if (!uselist[oid])
+ if (!uselist[num])
{
- genlist[oid]++;
- ofslist[lastfree] = oid;
- lastfree = oid;
+ genlist[num]++;
+ ofslist[lastfree] = num;
+ lastfree = num;
}
}