summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-11-25 05:39:23 +0100
committerTor Andersson <tor@ghostscript.com>2004-11-25 05:39:23 +0100
commit3e799920074ffaa718dfa671f3ed424f80c71b71 (patch)
treea26ef07f12f05303f4c28c7ce8e41355793bba24 /filter
parentdf6694f58a91f3a9229e55c335b61fcbaf10ef1d (diff)
downloadmupdf-3e799920074ffaa718dfa671f3ed424f80c71b71.tar.xz
fix case where setbits would touch one byte too much
Diffstat (limited to 'filter')
-rw-r--r--filter/faxc.h27
1 files changed, 18 insertions, 9 deletions
diff --git a/filter/faxc.h b/filter/faxc.h
index caf29df0..14cae13f 100644
--- a/filter/faxc.h
+++ b/filter/faxc.h
@@ -4,7 +4,8 @@ static inline void
printbits(FILE *f, int code, int nbits)
{
int n, b;
- for (n = nbits - 1; n >= 0; n--) {
+ for (n = nbits - 1; n >= 0; n--)
+ {
b = (code >> n) & 1;
fprintf(f, "%c", b ? '1' : '0');
}
@@ -35,7 +36,8 @@ getrun(const unsigned char *line, int x, int w, int c)
x = 0;
z = x;
- while (z < w) {
+ while (z < w)
+ {
b = getbit(line, z);
if (c != b)
break;
@@ -53,16 +55,19 @@ findchanging(const unsigned char *line, int x, int w)
if (line == 0)
return w;
- if (x == -1) {
+ if (x == -1)
+ {
a = 0;
x = 0;
}
- else {
+ else
+ {
a = getbit(line, x);
x++;
}
- while (x < w) {
+ while (x < w)
+ {
b = getbit(line, x);
if (a != b)
break;
@@ -103,14 +108,18 @@ setbits(unsigned char *line, int x0, int x1)
b0 = x0 & 7;
b1 = x1 & 7;
- if (a0 == a1) {
- line[a0] |= lm[b0] & rm[b1];
+ if (a0 == a1)
+ {
+ if (b1)
+ line[a0] |= lm[b0] & rm[b1];
}
- else {
+ else
+ {
line[a0] |= lm[b0];
for (a = a0 + 1; a < a1; a++)
line[a] = 0xFF;
- line[a1] |= rm[b1];
+ if (b1)
+ line[a1] |= rm[b1];
}
}