summaryrefslogtreecommitdiff
path: root/pxl
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-19 23:49:56 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-19 23:49:56 +0200
commit781969994b5381ba4bed03beef217f9bde6e7c58 (patch)
treeaede27c7532f0fbe82f03dc0c04c9316be510fd5 /pxl
parent0b17959f31afe3baffbc328e7f92e88e634ad8b8 (diff)
Indent with spaces and strip trailing whitespace.
Diffstat (limited to 'pxl')
-rw-r--r--pxl/pxasm.ps8
-rw-r--r--pxl/pxbfont.c148
-rw-r--r--pxl/pxbfont.ps25
-rw-r--r--pxl/pxerrors.h4
-rw-r--r--pxl/pxffont.c116
-rw-r--r--pxl/pxfont.c10
-rw-r--r--pxl/pxgstate.c941
-rw-r--r--pxl/pxgstate.h18
-rw-r--r--pxl/pximage.c768
-rw-r--r--pxl/pximpl.c6
-rw-r--r--pxl/pxink.c2
-rw-r--r--pxl/pxoper.h2
-rw-r--r--pxl/pxpaint.c945
-rw-r--r--pxl/pxparse.c1349
-rw-r--r--pxl/pxparse.h8
-rw-r--r--pxl/pxpthr.c4
-rw-r--r--pxl/pxsessio.c854
-rw-r--r--pxl/pxstate.c26
-rw-r--r--pxl/pxstate.h38
-rw-r--r--pxl/pxstream.c6
-rw-r--r--pxl/pxsymbol.ps4
-rw-r--r--pxl/pxtop.c650
-rw-r--r--pxl/pxvalue.c42
-rw-r--r--pxl/pxvalue.h4
24 files changed, 2974 insertions, 3004 deletions
diff --git a/pxl/pxasm.ps b/pxl/pxasm.ps
index 8c8e73450..115993560 100644
--- a/pxl/pxasm.ps
+++ b/pxl/pxasm.ps
@@ -43,7 +43,7 @@ bind def
( pxa) anchorsearch
{ pop ( = ) search
{ exch pop exch (,) search pop exch pop exch pop cvi
- 3 -1 roll pop exch
+ 3 -1 roll pop exch
}
{ (,) search pop exch pop exch pop
}
@@ -65,13 +65,13 @@ loop pop closefile
(,) search { exch pop exch pop } if
dup ( e) anchorsearch
{ pop pop token pop exch
- % Stack: file value name rest
+ % Stack: file value name rest
token
{ % The token must be an '='.
- pop token pop exch pop 3 -1 roll pop exch
+ pop token pop exch pop 3 -1 roll pop exch
}
if
- % Stack: file value name
+ % Stack: file value name
1 index .defenum 1 add
}
{ pop pop
diff --git a/pxl/pxbfont.c b/pxl/pxbfont.c
index d48664542..250f9a0f2 100644
--- a/pxl/pxbfont.c
+++ b/pxl/pxbfont.c
@@ -15,7 +15,7 @@
#include "pxbfont.h"
const byte px_bitmap_font_char_data[] = {
- 34 /* " */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 23, 0, 14, 0, 92,
+ 34 /* " */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 23, 0, 14, 0, 92,
1,252,254,
1,252,254,
0,248,124,
@@ -30,7 +30,7 @@ const byte px_bitmap_font_char_data[] = {
0,112,56,
0,112,56,
0,112,56,
- 40 /* ( */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 23, 0, 36, 0, 92,
+ 40 /* ( */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 23, 0, 36, 0, 92,
0,0,6,
0,0,14,
0,0,12,
@@ -67,7 +67,7 @@ const byte px_bitmap_font_char_data[] = {
0,0,12,
0,0,14,
0,0,6,
- 41 /* ) */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 16, 0, 36, 0, 64,
+ 41 /* ) */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 16, 0, 36, 0, 64,
1,128,
0,192,
0,224,
@@ -104,10 +104,10 @@ const byte px_bitmap_font_char_data[] = {
0,224,
0,192,
1,128,
- 45 /* - */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 15, 0, 26, 0, 2, 0, 104,
+ 45 /* - */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 15, 0, 26, 0, 2, 0, 104,
15,255,255,192,
15,255,255,192,
- 47 /* / */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 33, 0, 24, 0, 37, 0, 96,
+ 47 /* / */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 33, 0, 24, 0, 37, 0, 96,
0,0,3,
0,0,3,
0,0,7,
@@ -145,7 +145,7 @@ const byte px_bitmap_font_char_data[] = {
3,128,0,
3,0,0,
3,0,0,
- 48 /* 0 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 24, 0, 32, 0, 96,
+ 48 /* 0 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 24, 0, 32, 0, 96,
0,15,192,
0,63,240,
0,120,120,
@@ -178,7 +178,7 @@ const byte px_bitmap_font_char_data[] = {
0,120,120,
0,31,224,
0,15,192,
- 49 /* 1 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 24, 0, 30, 0, 96,
+ 49 /* 1 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 24, 0, 30, 0, 96,
0,7,0,
0,127,0,
3,251,0,
@@ -209,7 +209,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,
3,255,255,
3,255,255,
- 50 /* 2 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 24, 0, 31, 0, 96,
+ 50 /* 2 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 24, 0, 31, 0, 96,
0,15,128,
0,127,240,
0,240,120,
@@ -241,7 +241,7 @@ const byte px_bitmap_font_char_data[] = {
12,0,3,
15,255,255,
15,255,255,
- 51 /* 3 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 25, 0, 32, 0, 100,
+ 51 /* 3 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 25, 0, 32, 0, 100,
0,15,192,0,
0,127,240,0,
0,240,60,0,
@@ -274,7 +274,7 @@ const byte px_bitmap_font_char_data[] = {
1,224,124,0,
0,127,240,0,
0,31,192,0,
- 52 /* 4 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 24, 0, 30, 0, 96,
+ 52 /* 4 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 24, 0, 30, 0, 96,
0,0,248,
0,0,248,
0,1,152,
@@ -305,7 +305,7 @@ const byte px_bitmap_font_char_data[] = {
0,0,24,
0,3,255,
0,3,255,
- 53 /* 5 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 25, 0, 31, 0, 100,
+ 53 /* 5 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 25, 0, 31, 0, 100,
1,255,254,0,
1,255,254,0,
1,128,0,0,
@@ -337,7 +337,7 @@ const byte px_bitmap_font_char_data[] = {
1,240,56,0,
0,127,240,0,
0,15,192,0,
- 54 /* 6 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 25, 0, 32, 0, 100,
+ 54 /* 6 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 25, 0, 32, 0, 100,
0,0,63,0,
0,1,255,128,
0,3,193,128,
@@ -370,7 +370,7 @@ const byte px_bitmap_font_char_data[] = {
0,28,28,0,
0,15,248,0,
0,3,240,0,
- 55 /* 7 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 24, 0, 30, 0, 96,
+ 55 /* 7 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 24, 0, 30, 0, 96,
7,255,255,
7,255,255,
6,0,3,
@@ -401,7 +401,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,
0,3,0,
0,3,0,
- 56 /* 8 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 24, 0, 32, 0, 96,
+ 56 /* 8 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 24, 0, 32, 0, 96,
0,15,192,
0,63,240,
0,112,56,
@@ -434,7 +434,7 @@ const byte px_bitmap_font_char_data[] = {
0,112,56,
0,63,240,
0,15,192,
- 57 /* 9 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 26, 0, 32, 0, 104,
+ 57 /* 9 */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 26, 0, 32, 0, 104,
0,7,192,0,
0,31,240,0,
0,56,56,0,
@@ -467,7 +467,7 @@ const byte px_bitmap_font_char_data[] = {
1,131,192,0,
1,255,128,0,
0,124,0,0,
- 58 /* : */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 19, 0, 22, 0, 76,
+ 58 /* : */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 19, 0, 22, 0, 76,
0,7,128,
0,15,192,
0,31,224,
@@ -490,7 +490,7 @@ const byte px_bitmap_font_char_data[] = {
0,31,224,
0,15,192,
0,7,128,
- 59 /* ; */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 17, 0, 28, 0, 68,
+ 59 /* ; */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 17, 0, 28, 0, 68,
0,15,0,
0,31,128,
0,63,128,
@@ -519,7 +519,7 @@ const byte px_bitmap_font_char_data[] = {
1,224,0,
1,192,0,
1,192,0,
- 63 /* ? */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 24, 0, 30, 0, 96,
+ 63 /* ? */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 24, 0, 30, 0, 96,
0,15,224,
0,127,248,
1,240,60,
@@ -550,7 +550,7 @@ const byte px_bitmap_font_char_data[] = {
0,15,224,
0,15,192,
0,7,128,
- 65 /* A */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
+ 65 /* A */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
7,255,128,0,
7,255,128,0,
0,13,128,0,
@@ -579,7 +579,7 @@ const byte px_bitmap_font_char_data[] = {
12,0,0,192,
127,192,31,248,
127,224,31,248,
- 66 /* B */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
+ 66 /* B */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
63,255,240,0,
63,255,252,0,
3,0,30,0,
@@ -608,7 +608,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,7,128,
63,255,255,0,
63,255,252,0,
- 67 /* C */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 27, 0, 30, 0, 108,
+ 67 /* C */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 27, 0, 30, 0, 108,
0,15,224,0,
0,63,248,192,
0,240,62,192,
@@ -639,7 +639,7 @@ const byte px_bitmap_font_char_data[] = {
0,120,30,0,
0,63,252,0,
0,7,224,0,
- 68 /* D */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
+ 68 /* D */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
63,255,192,0,
63,255,240,0,
6,0,56,0,
@@ -668,7 +668,7 @@ const byte px_bitmap_font_char_data[] = {
6,0,120,0,
63,255,240,0,
63,255,192,0,
- 69 /* E */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
+ 69 /* E */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
63,255,255,128,
63,255,255,128,
3,0,1,128,
@@ -697,7 +697,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,0,192,
63,255,255,192,
63,255,255,192,
- 70 /* F */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
+ 70 /* F */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
63,255,255,192,
63,255,255,192,
3,0,0,192,
@@ -726,7 +726,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,0,0,
63,255,128,0,
63,255,128,0,
- 71 /* G */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 28, 0, 30, 0, 112,
+ 71 /* G */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 28, 0, 30, 0, 112,
0,15,224,0,
0,63,252,192,
0,248,30,192,
@@ -757,7 +757,7 @@ const byte px_bitmap_font_char_data[] = {
0,248,15,128,
0,63,254,0,
0,7,240,0,
- 72 /* H */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
+ 72 /* H */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
15,240,63,192,
15,240,63,192,
3,0,3,0,
@@ -786,7 +786,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,3,0,
31,240,63,224,
31,240,63,224,
- 73 /* I */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 24, 0, 28, 0, 96,
+ 73 /* I */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 24, 0, 28, 0, 96,
3,255,255,
3,255,255,
0,3,0,
@@ -815,7 +815,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,
3,255,255,
3,255,255,
- 74 /* J */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 29, 0, 116,
+ 74 /* J */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 29, 0, 116,
0,15,255,248,
0,15,255,248,
0,0,6,0,
@@ -845,7 +845,7 @@ const byte px_bitmap_font_char_data[] = {
1,224,240,0,
0,255,224,0,
0,63,128,0,
- 75 /* K */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 28, 0, 112,
+ 75 /* K */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 28, 0, 112,
63,248,31,224,
63,248,31,224,
3,0,3,128,
@@ -874,7 +874,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,3,0,
63,248,3,240,
63,248,1,240,
- 76 /* L */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
+ 76 /* L */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
31,255,128,0,
31,255,128,0,
0,96,0,0,
@@ -903,7 +903,7 @@ const byte px_bitmap_font_char_data[] = {
0,96,0,96,
31,255,255,224,
31,255,255,224,
- 77 /* M */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
+ 77 /* M */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
127,0,1,248,
127,0,3,248,
15,0,3,96,
@@ -932,7 +932,7 @@ const byte px_bitmap_font_char_data[] = {
12,0,0,96,
127,224,15,248,
127,224,15,248,
- 78 /* N */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 28, 0, 112,
+ 78 /* N */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 28, 0, 112,
127,0,63,240,
127,128,63,240,
7,128,1,128,
@@ -961,7 +961,7 @@ const byte px_bitmap_font_char_data[] = {
6,0,7,128,
63,240,3,128,
63,240,3,128,
- 79 /* O */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 27, 0, 30, 0, 108,
+ 79 /* O */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 27, 0, 30, 0, 108,
0,15,192,0,
0,63,240,0,
0,240,60,0,
@@ -992,7 +992,7 @@ const byte px_bitmap_font_char_data[] = {
0,240,60,0,
0,63,240,0,
0,15,192,0,
- 80 /* P */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 25, 0, 28, 0, 100,
+ 80 /* P */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 25, 0, 28, 0, 100,
63,255,224,0,
63,255,248,0,
3,0,28,0,
@@ -1021,7 +1021,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,0,0,
63,255,0,0,
63,255,0,0,
- 81 /* Q */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 27, 0, 35, 0, 108,
+ 81 /* Q */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 27, 0, 35, 0, 108,
0,15,192,0,
0,63,240,0,
0,240,60,0,
@@ -1057,7 +1057,7 @@ const byte px_bitmap_font_char_data[] = {
0,255,248,224,
1,248,63,192,
0,128,15,0,
- 82 /* R */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
+ 82 /* R */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
63,255,224,0,
63,255,248,0,
3,0,30,0,
@@ -1086,7 +1086,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,0,192,
63,248,0,248,
63,248,0,120,
- 83 /* S */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 25, 0, 30, 0, 100,
+ 83 /* S */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 29, 0, 25, 0, 30, 0, 100,
0,15,192,0,
0,63,243,0,
0,240,59,0,
@@ -1117,7 +1117,7 @@ const byte px_bitmap_font_char_data[] = {
6,240,60,0,
6,63,248,0,
0,15,224,0,
- 84 /* T */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
+ 84 /* T */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 26, 0, 28, 0, 104,
15,255,255,192,
15,255,255,192,
12,3,0,192,
@@ -1146,7 +1146,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,0,
0,255,252,0,
0,255,252,0,
- 85 /* U */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 29, 0, 112,
+ 85 /* U */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 29, 0, 112,
63,240,63,240,
63,240,63,240,
6,0,1,128,
@@ -1176,7 +1176,7 @@ const byte px_bitmap_font_char_data[] = {
0,240,60,0,
0,63,240,0,
0,15,192,0,
- 86 /* V */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
+ 86 /* V */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
127,224,31,248,
127,192,15,248,
12,0,0,192,
@@ -1205,7 +1205,7 @@ const byte px_bitmap_font_char_data[] = {
0,15,128,0,
0,7,128,0,
0,7,0,0,
- 87 /* W */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
+ 87 /* W */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 29, 0, 28, 0, 116,
127,224,31,248,
127,224,31,248,
24,0,0,96,
@@ -1234,7 +1234,7 @@ const byte px_bitmap_font_char_data[] = {
3,192,15,0,
3,192,15,0,
3,128,15,0,
- 88 /* X */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 28, 0, 112,
+ 88 /* X */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 28, 0, 28, 0, 112,
31,224,31,224,
31,224,31,224,
7,0,3,128,
@@ -1263,7 +1263,7 @@ const byte px_bitmap_font_char_data[] = {
6,0,1,128,
63,224,31,240,
63,224,31,240,
- 89 /* Y */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
+ 89 /* Y */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 27, 0, 28, 0, 108,
31,224,31,224,
31,224,31,224,
7,0,3,128,
@@ -1292,7 +1292,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,0,
0,255,252,0,
0,255,254,0,
- 90 /* Z */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 25, 0, 28, 0, 100,
+ 90 /* Z */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 25, 0, 28, 0, 100,
3,255,255,0,
3,255,255,0,
3,0,7,0,
@@ -1321,10 +1321,10 @@ const byte px_bitmap_font_char_data[] = {
6,0,1,128,
7,255,255,128,
7,255,255,128,
- 95 /* _ */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 252, 0, 31, 0, 2, 0, 124,
+ 95 /* _ */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 252, 0, 31, 0, 2, 0, 124,
255,255,255,254,
255,255,255,254,
- 97 /* a */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 23, 0, 108,
+ 97 /* a */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 23, 0, 108,
0,15,192,0,
0,255,240,0,
3,248,120,0,
@@ -1348,7 +1348,7 @@ const byte px_bitmap_font_char_data[] = {
7,131,231,224,
3,255,135,224,
0,254,0,0,
- 98 /* b */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 31, 0, 108,
+ 98 /* b */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 31, 0, 108,
126,0,0,0,
126,0,0,0,
6,0,0,0,
@@ -1380,7 +1380,7 @@ const byte px_bitmap_font_char_data[] = {
126,56,30,0,
126,31,252,0,
0,7,224,0,
- 99 /* c */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 23, 0, 108,
+ 99 /* c */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 23, 0, 108,
0,15,224,0,
0,63,252,192,
0,248,62,192,
@@ -1404,7 +1404,7 @@ const byte px_bitmap_font_char_data[] = {
0,248,31,0,
0,127,252,0,
0,31,240,0,
- 100 /* d */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 29, 0, 31, 0, 116,
+ 100 /* d */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 29, 0, 31, 0, 116,
0,0,31,128,
0,0,31,128,
0,0,1,128,
@@ -1436,7 +1436,7 @@ const byte px_bitmap_font_char_data[] = {
1,224,113,248,
0,127,225,248,
0,31,128,0,
- 101 /* e */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 26, 0, 23, 0, 104,
+ 101 /* e */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 26, 0, 23, 0, 104,
0,31,192,0,
0,127,240,0,
1,240,124,0,
@@ -1460,7 +1460,7 @@ const byte px_bitmap_font_char_data[] = {
0,240,63,0,
0,127,252,0,
0,31,240,0,
- 102 /* f */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 30, 0, 108,
+ 102 /* f */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 30, 0, 108,
0,0,255,128,
0,3,255,224,
0,7,0,0,
@@ -1491,7 +1491,7 @@ const byte px_bitmap_font_char_data[] = {
0,12,0,0,
7,255,255,0,
7,255,255,0,
- 103 /* g */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 28, 0, 31, 0, 112,
+ 103 /* g */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 28, 0, 31, 0, 112,
0,63,0,0,
0,255,195,240,
1,224,243,240,
@@ -1523,7 +1523,7 @@ const byte px_bitmap_font_char_data[] = {
0,0,60,0,
0,127,248,0,
0,127,224,0,
- 104 /* h */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 30, 0, 108,
+ 104 /* h */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 30, 0, 108,
63,0,0,0,
63,0,0,0,
3,0,0,0,
@@ -1554,7 +1554,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,3,0,
31,240,63,224,
31,240,63,224,
- 105 /* i */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 25, 0, 31, 0, 100,
+ 105 /* i */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 25, 0, 31, 0, 100,
0,6,0,0,
0,6,0,0,
0,6,0,0,
@@ -1586,7 +1586,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,0,
7,255,255,128,
7,255,255,128,
- 106 /* j */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 23, 0, 40, 0, 92,
+ 106 /* j */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 31, 0, 23, 0, 40, 0, 92,
0,0,48,
0,0,48,
0,0,48,
@@ -1627,7 +1627,7 @@ const byte px_bitmap_font_char_data[] = {
0,0,56,
0,255,240,
1,255,192,
- 107 /* k */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 30, 0, 108,
+ 107 /* k */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 27, 0, 30, 0, 108,
31,128,0,0,
31,128,0,0,
1,128,0,0,
@@ -1658,7 +1658,7 @@ const byte px_bitmap_font_char_data[] = {
1,128,14,0,
31,128,63,224,
31,128,63,224,
- 108 /* l */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 25, 0, 30, 0, 100,
+ 108 /* l */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 30, 0, 25, 0, 30, 0, 100,
1,255,0,0,
1,255,0,0,
0,3,0,0,
@@ -1689,7 +1689,7 @@ const byte px_bitmap_font_char_data[] = {
0,3,0,0,
7,255,255,128,
7,255,255,128,
- 109 /* m */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 30, 0, 22, 0, 120,
+ 109 /* m */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 30, 0, 22, 0, 120,
0,48,15,0,
124,252,63,128,
125,198,113,192,
@@ -1712,7 +1712,7 @@ const byte px_bitmap_font_char_data[] = {
12,1,128,96,
127,1,224,124,
127,1,224,124,
- 110 /* n */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 22, 0, 108,
+ 110 /* n */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 22, 0, 108,
0,1,128,0,
31,15,240,0,
31,60,60,0,
@@ -1735,7 +1735,7 @@ const byte px_bitmap_font_char_data[] = {
3,0,3,0,
31,240,31,224,
31,240,31,224,
- 111 /* o */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 26, 0, 23, 0, 104,
+ 111 /* o */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 26, 0, 23, 0, 104,
0,31,224,0,
0,127,248,0,
0,240,124,0,
@@ -1759,7 +1759,7 @@ const byte px_bitmap_font_char_data[] = {
0,240,60,0,
0,127,248,0,
0,31,224,0,
- 112 /* p */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 31, 0, 108,
+ 112 /* p */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 31, 0, 108,
30,7,224,0,
126,31,252,0,
126,120,30,0,
@@ -1791,7 +1791,7 @@ const byte px_bitmap_font_char_data[] = {
6,0,0,0,
127,248,0,0,
127,248,0,0,
- 113 /* q */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 29, 0, 31, 0, 116,
+ 113 /* q */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 29, 0, 31, 0, 116,
0,31,128,0,
0,127,225,248,
1,224,121,248,
@@ -1823,7 +1823,7 @@ const byte px_bitmap_font_char_data[] = {
0,0,1,128,
0,0,127,248,
0,0,127,248,
- 114 /* r */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 22, 0, 108,
+ 114 /* r */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 27, 0, 22, 0, 108,
0,16,31,0,
7,240,63,128,
7,240,241,192,
@@ -1846,7 +1846,7 @@ const byte px_bitmap_font_char_data[] = {
0,48,0,0,
15,255,254,0,
15,255,254,0,
- 115 /* s */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 25, 0, 23, 0, 100,
+ 115 /* s */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 22, 0, 25, 0, 23, 0, 100,
0,31,192,0,
0,127,243,0,
0,240,63,0,
@@ -1870,7 +1870,7 @@ const byte px_bitmap_font_char_data[] = {
7,240,62,0,
6,127,252,0,
0,31,224,0,
- 116 /* t */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 25, 0, 29, 0, 100,
+ 116 /* t */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 28, 0, 25, 0, 29, 0, 100,
1,128,0,0,
1,128,0,0,
1,128,0,0,
@@ -1900,7 +1900,7 @@ const byte px_bitmap_font_char_data[] = {
0,240,31,0,
0,63,252,0,
0,15,224,0,
- 117 /* u */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 27, 0, 22, 0, 108,
+ 117 /* u */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 27, 0, 22, 0, 108,
63,0,127,0,
63,0,127,0,
3,0,3,0,
@@ -1923,7 +1923,7 @@ const byte px_bitmap_font_char_data[] = {
1,224,243,224,
0,127,195,224,
0,31,0,0,
- 118 /* v */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 28, 0, 21, 0, 112,
+ 118 /* v */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 28, 0, 21, 0, 112,
63,240,63,240,
63,240,63,240,
6,0,1,128,
@@ -1945,7 +1945,7 @@ const byte px_bitmap_font_char_data[] = {
0,12,192,0,
0,7,128,0,
0,7,128,0,
- 119 /* w */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 28, 0, 21, 0, 112,
+ 119 /* w */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 28, 0, 21, 0, 112,
63,192,15,240,
63,192,15,240,
12,0,0,192,
@@ -1967,7 +1967,7 @@ const byte px_bitmap_font_char_data[] = {
1,224,30,0,
0,224,28,0,
0,224,28,0,
- 120 /* x */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 27, 0, 21, 0, 108,
+ 120 /* x */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 27, 0, 21, 0, 108,
15,240,63,192,
15,240,63,192,
3,128,7,0,
@@ -1989,7 +1989,7 @@ const byte px_bitmap_font_char_data[] = {
7,0,3,128,
31,240,63,224,
31,240,63,224,
- 121 /* y */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 27, 0, 30, 0, 108,
+ 121 /* y */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 27, 0, 30, 0, 108,
31,224,31,224,
31,224,31,224,
6,0,1,128,
@@ -2020,7 +2020,7 @@ const byte px_bitmap_font_char_data[] = {
0,24,0,0,
31,255,128,0,
31,255,128,0,
- 122 /* z */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 24, 0, 21, 0, 96,
+ 122 /* z */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 21, 0, 24, 0, 21, 0, 96,
3,255,254,
3,255,254,
3,0,14,
@@ -2042,8 +2042,8 @@ const byte px_bitmap_font_char_data[] = {
3,128,3,
3,255,255,
3,255,255,
- 32 /* */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 64,
- 0
+ 32 /* */, 4, 0, 14, 1, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 64,
+ 0
};
const int px_bitmap_font_point_size = 24;
@@ -2051,7 +2051,7 @@ const int px_bitmap_font_resolution = 150;
const byte px_bitmap_font_header[] = {
0, 0, 0, 14, 254, 0, 0, 72,
'B', 'R', 0, 0, 0, 4,
- 0, 150, 0, 150,
+ 0, 150, 0, 150,
0xff, 0xff, 0, 0, 0, 0
};
const uint px_bitmap_font_header_size = sizeof(px_bitmap_font_header);
diff --git a/pxl/pxbfont.ps b/pxl/pxbfont.ps
index c2f0ee075..ce841c380 100644
--- a/pxl/pxbfont.ps
+++ b/pxl/pxbfont.ps
@@ -6,7 +6,6 @@
% /usr/bin/gs -I/usr/lib/ghostscript -q -dNODISPLAY pxbfont.ps >pxbfont.c
-
% Put space last so we can fake the width.
/Chars
@@ -48,28 +47,28 @@ Chars
{ 1 string dup 0 4 -1 roll put /Ch exch def
erasepage 0 36 moveto Ch show
0 Res
- % Remove blank lines at bottom.
+ % Remove blank lines at bottom.
{ 2 copy eq { exit } if
dup 1 sub ID exch Row copyscanlines ZRow ne { exit } if
1 sub
}
loop
- % Remove blank lines at top.
+ % Remove blank lines at top.
{ 2 copy eq { exit } if
1 index ID exch Row copyscanlines ZRow ne { exit } if
exch 1 add exch
}
loop
- % Determine the character width.
+ % Determine the character width.
/B 0 def
/W 0 def
2 copy 1 sub 1 exch
{ ID exch Row copyscanlines pop
Row length 1 sub -1 W
{ Row 1 index get dup 0 ne
- { 1 index W eq { B or } if /B exch def /W exch def exit
- }
- if pop pop
+ { 1 index W eq { B or } if /B exch def /W exch def exit
+ }
+ if pop pop
}
for
}
@@ -83,17 +82,17 @@ Chars
2 copy eq { pop pop Base dup } if % empty character
/Asc Asc Base 4 index sub max def
/Desc Desc 2 index Base sub max def
- % Write the character code.
+ % Write the character code.
(\t) print Ch 0 get =only ( /* ) print Ch =only ( */, ) print
- % Write the character header.
- % We use the PCL5 format, rather than the PCL XL format,
- % so that we can represent the inter-character spacing.
+ % Write the character header.
+ % We use the PCL5 format, rather than the PCL XL format,
+ % so that we can represent the inter-character spacing.
(4, 0, 14, 1, 0, 0, 0, 0, ) =only
Base 2 index sub print16 (, ) print
WB print16 (, ) print
2 copy exch sub print16 (, ) print
WB 4 mul print16 (,) =
- % Write the bits.
+ % Write the bits.
1 sub 1 exch
{ ID exch Row copyscanlines 0 W 1 add getinterval
{ =only (,) print
@@ -114,7 +113,7 @@ const int px_bitmap_font_resolution = ) print Res =only (;
(const byte px_bitmap_font_header[] = {
0, 0, 0, 14, 254, 0, 0, ) print Chars length =only (,
'B', 'R', 0, 0, 0, 4,
- 0, ) print Res =only (, 0, ) print Res =only (,
+ 0, ) print Res =only (, 0, ) print Res =only (,
0xff, 0xff, 0, 0, 0, 0
};
const uint px_bitmap_font_header_size = sizeof(px_bitmap_font_header);
diff --git a/pxl/pxerrors.h b/pxl/pxerrors.h
index 5da6f4a58..6249459b7 100644
--- a/pxl/pxerrors.h
+++ b/pxl/pxerrors.h
@@ -150,8 +150,8 @@ typedef enum {
_e_(errorUnsupportedProtocol, "UnsupportedProtocol")
_e_(errorIllegalStreamHeader, "IllegalStreamHeader")
- /* We define a special "error" that EndSession returns */
- /* to indicate that there were warnings to report. */
+ /* We define a special "error" that EndSession returns */
+ /* to indicate that there were warnings to report. */
_e_(errorWarningsReported, "WarningsReported")
diff --git a/pxl/pxffont.c b/pxl/pxffont.c
index f544e42e7..a39cfb5ba 100644
--- a/pxl/pxffont.c
+++ b/pxl/pxffont.c
@@ -42,37 +42,37 @@ static int
px_widen_font_name(px_value_t *pfnv, px_state_t *pxs)
{ uint type = pfnv->type;
- if ( (type & (pxd_uint16 | pxd_big_endian)) ==
- (pxd_uint16 | pxd_native_byte_order)
- )
- return 0; /* already in correct format */
- { byte *old_data = (byte *)pfnv->value.array.data; /* break const */
- uint size = pfnv->value.array.size;
- char16 *new_data;
- uint i;
-
- if ( type & pxd_on_heap )
- old_data = (byte *)
- (new_data =
- (char16 *)gs_resize_object(pxs->memory, old_data,
- size * 2, "px_widen_font_name"));
- else
- new_data =
- (char16 *)gs_alloc_byte_array(pxs->memory, size, sizeof(char16),
- "px_widen_font_name");
- if ( new_data == 0 )
- return_error(errorInsufficientMemory);
- for ( i = size; i; )
- { --i;
- new_data[i] =
- (type & pxd_ubyte ? old_data[i] :
- uint16at(old_data + i * 2, type & pxd_big_endian));
- }
- pfnv->value.array.data = (byte *)new_data;
- }
- pfnv->type = (type & ~(pxd_ubyte | pxd_big_endian)) |
- (pxd_uint16 | pxd_native_byte_order | pxd_on_heap);
- return 0;
+ if ( (type & (pxd_uint16 | pxd_big_endian)) ==
+ (pxd_uint16 | pxd_native_byte_order)
+ )
+ return 0; /* already in correct format */
+ { byte *old_data = (byte *)pfnv->value.array.data; /* break const */
+ uint size = pfnv->value.array.size;
+ char16 *new_data;
+ uint i;
+
+ if ( type & pxd_on_heap )
+ old_data = (byte *)
+ (new_data =
+ (char16 *)gs_resize_object(pxs->memory, old_data,
+ size * 2, "px_widen_font_name"));
+ else
+ new_data =
+ (char16 *)gs_alloc_byte_array(pxs->memory, size, sizeof(char16),
+ "px_widen_font_name");
+ if ( new_data == 0 )
+ return_error(errorInsufficientMemory);
+ for ( i = size; i; )
+ { --i;
+ new_data[i] =
+ (type & pxd_ubyte ? old_data[i] :
+ uint16at(old_data + i * 2, type & pxd_big_endian));
+ }
+ pfnv->value.array.data = (byte *)new_data;
+ }
+ pfnv->type = (type & ~(pxd_ubyte | pxd_big_endian)) |
+ (pxd_uint16 | pxd_native_byte_order | pxd_on_heap);
+ return 0;
}
/* ---------------- Operator implementations ---------------- */
@@ -87,31 +87,31 @@ px_find_existing_font(px_value_t *pfnv, px_font_t **ppxfont,
{ int code;
void *pxfont;
- /* Normalize the font name to Unicode. */
- code = px_widen_font_name(pfnv, pxs);
- if ( code < 0 )
- return code;
-
- if ( px_dict_find(&pxs->font_dict, pfnv, &pxfont) ) {
- /* Make sure this isn't a partially defined font */
- if ( ((px_font_t *)pxfont)->pfont )
- *ppxfont = pxfont;
- else {
- /* in the process of being downloaded. */
- dprintf("font is being downloaded???\n");
- return -1;
- }
- } else if ( px_dict_find(&pxs->builtin_font_dict, pfnv, &pxfont) )
- if ( ((px_font_t *)pxfont)->pfont )
- *ppxfont = pxfont;
- else {
- dprintf("corrupt pxl builtin font\n");
- return -1;
- }
- else
- return -1; /* font not found or corrupt builtin font */
-
- return 0;
+ /* Normalize the font name to Unicode. */
+ code = px_widen_font_name(pfnv, pxs);
+ if ( code < 0 )
+ return code;
+
+ if ( px_dict_find(&pxs->font_dict, pfnv, &pxfont) ) {
+ /* Make sure this isn't a partially defined font */
+ if ( ((px_font_t *)pxfont)->pfont )
+ *ppxfont = pxfont;
+ else {
+ /* in the process of being downloaded. */
+ dprintf("font is being downloaded???\n");
+ return -1;
+ }
+ } else if ( px_dict_find(&pxs->builtin_font_dict, pfnv, &pxfont) )
+ if ( ((px_font_t *)pxfont)->pfont )
+ *ppxfont = pxfont;
+ else {
+ dprintf("corrupt pxl builtin font\n");
+ return -1;
+ }
+ else
+ return -1; /* font not found or corrupt builtin font */
+
+ return 0;
}
/* Look up a font name and return a font, possibly with substitution. */
@@ -148,7 +148,7 @@ px_find_font(px_value_t *pfnv, uint symbol_set, px_font_t **ppxfont,
code = px_record_warning(message, false, pxs);
}
if ( code >= 0 )
- return pl_load_resident_font_data_from_file(pxs->memory, *ppxfont);
+ return pl_load_resident_font_data_from_file(pxs->memory, *ppxfont);
else
- return code;
+ return code;
}
diff --git a/pxl/pxfont.c b/pxl/pxfont.c
index c652c3243..b04dce91f 100644
--- a/pxl/pxfont.c
+++ b/pxl/pxfont.c
@@ -62,7 +62,6 @@ pxl_find_symbol_map(uint symbol_set)
return (*ppsm ? *ppsm : NULL);
}
-
/* Compute the symbol map from the font and symbol set. */
void
set_symbol_map(px_state_t *pxs, bool wide16)
@@ -386,7 +385,7 @@ px_text(px_args_t *par, px_state_t *pxs, bool to_path)
&cmat);
gs_setcharmatrix(pgs, &cmat);
}
-
+
/* The character matrix is not visible to devices. High level
devices get character scaling information from the font's
matrix (FontMatrix). */
@@ -452,7 +451,6 @@ px_text(px_args_t *par, px_state_t *pxs, bool to_path)
gs_note_error(errorBadFontData) : code);
}
-
/* ---------------- Operators ---------------- */
const byte apxSetFont[] = {
@@ -648,12 +646,12 @@ const byte apxReadChar[] = {
};
int
pxReadChar(px_args_t *par, px_state_t *pxs)
-{
+{
uint char_code = par->pv[0]->value.i;
uint size = par->pv[1]->value.i;
uint pos = par->source.position;
- if ( pos == 0 ) {
+ if ( pos == 0 ) {
/* We're starting a character definition. */
byte *def;
@@ -667,7 +665,7 @@ pxReadChar(px_args_t *par, px_state_t *pxs)
pxs->download_bytes.data = def;
pxs->download_bytes.size = size;
}
- while ( pos < size ) {
+ while ( pos < size ) {
uint copy = min(par->source.available, size - pos);
if ( copy == 0 )
return pxNeedData;
diff --git a/pxl/pxgstate.c b/pxl/pxgstate.c
index e2536227d..516a30ce9 100644
--- a/pxl/pxgstate.c
+++ b/pxl/pxgstate.c
@@ -59,7 +59,6 @@ px_operator_proc(pxRectanglePath);
/* Forward references */
px_operator_proc(pxSetClipIntersect);
-
/* Imported color space types */
extern const gs_color_space_type gs_color_space_type_Indexed; /* gscolor2.c */
extern const gs_color_space_type gs_color_space_type_Pattern; /* gspcolor.c */
@@ -70,38 +69,38 @@ extern const gs_color_space_type gs_color_space_type_Pattern; /* gspcolor.c */
void
px_paint_rc_adjust(px_paint_t *ppt, int delta, gs_memory_t *mem)
{ if ( ppt->type == pxpPattern )
- { /*
- * There is no public API for adjusting the reference count of a
- * gs_client_color, and even the private API requires having a
- * color space available. We'll need to fix this properly
- * sooner or later, but for the moment, fake it.
- */
- gs_color_space cspace;
-
- /*
- * Even though this is a colored Pattern, and hence does have a
- * base space, we set has_base_space to false to prevent the
- * adjust_color_count procedure from trying to call the
- * adjustment procedures for the base space.
- */
- cspace.type = &gs_color_space_type_Pattern;
- cspace.params.pattern.has_base_space = false;
- (*cspace.type->adjust_color_count)(&ppt->value.pattern.color,
- &cspace, delta);
- rc_adjust_only(ppt->value.pattern.pattern, delta,
- "px_paint_rc_adjust");
- }
+ { /*
+ * There is no public API for adjusting the reference count of a
+ * gs_client_color, and even the private API requires having a
+ * color space available. We'll need to fix this properly
+ * sooner or later, but for the moment, fake it.
+ */
+ gs_color_space cspace;
+
+ /*
+ * Even though this is a colored Pattern, and hence does have a
+ * base space, we set has_base_space to false to prevent the
+ * adjust_color_count procedure from trying to call the
+ * adjustment procedures for the base space.
+ */
+ cspace.type = &gs_color_space_type_Pattern;
+ cspace.params.pattern.has_base_space = false;
+ (*cspace.type->adjust_color_count)(&ppt->value.pattern.color,
+ &cspace, delta);
+ rc_adjust_only(ppt->value.pattern.pattern, delta,
+ "px_paint_rc_adjust");
+ }
}
void
px_gstate_rc_adjust(px_gstate_t *pxgs, int delta, gs_memory_t *mem)
{ px_paint_rc_adjust(&pxgs->pen, delta, mem);
- px_paint_rc_adjust(&pxgs->brush, delta, mem);
+ px_paint_rc_adjust(&pxgs->brush, delta, mem);
}
static void *
px_gstate_client_alloc(gs_memory_t *mem)
-{
- px_gstate_t *pxgs =
- (px_gstate_t *)gs_alloc_bytes(mem,
+{
+ px_gstate_t *pxgs =
+ (px_gstate_t *)gs_alloc_bytes(mem,
sizeof(px_gstate_t),
"px_gstate_alloc");
@@ -124,69 +123,69 @@ px_gstate_client_copy_for(void *to, void *from, gs_state_copy_reason_t reason)
{
#define pxfrom ((px_gstate_t *)from)
#define pxto ((px_gstate_t *)to)
- px_gstate_rc_adjust(pxfrom, 1, pxfrom->memory);
- px_gstate_rc_adjust(pxto, -1, pxto->memory);
- /*
- * In the context of the PCL XL code, this routine may be called for
- * gsave, grestore, or gstate (copying the gstate for makepattern
- * or Pattern rendering). See gxstate.h for details of the 'from'
- * and 'to' arguments for each of these cases.
- *
- * We have some structures that belong to the individual gstates for
- * storage management purposes. Currently these are:
- * dither_matrix, temp_pattern_dict
- * px_gstate_client_alloc initializes them to an empty state.
- * For gsave and gstate, the new current gstate or copied gstate
- * respectively should have the empty structure. For grestore,
- * we want to swap the structures, because we will then free the
- * saved gstate (and release the structure that was in the current
- * gstate before the grestore).
- *
- * halftone.thresholds is a different special case. We need to
- * copy it for gsave and gstate, and free it on grestore.
- */
- { gs_string tmat;
- gs_string thtt;
- pl_dict_t tdict;
- gs_string *phtt;
-
- tmat = pxto->dither_matrix;
- thtt = pxto->halftone.thresholds;
- tdict = pxto->temp_pattern_dict;
- *pxto = *pxfrom;
- switch ( reason )
- {
- case copy_for_gstate:
- /* Just put back the (empty) 'to' structures. */
- pxto->dither_matrix = tmat;
- pxto->temp_pattern_dict = tdict;
- phtt = &pxto->halftone.thresholds;
- goto copy;
- case copy_for_gsave:
- /* Swap the structures, but set the parent of the new */
- /* (empty) dictionary to the old one. */
- pxfrom->dither_matrix = tmat;
- pxfrom->temp_pattern_dict = tdict;
- pl_dict_set_parent(&pxfrom->temp_pattern_dict,
- &pxto->temp_pattern_dict);
- phtt = &pxfrom->halftone.thresholds;
+ px_gstate_rc_adjust(pxfrom, 1, pxfrom->memory);
+ px_gstate_rc_adjust(pxto, -1, pxto->memory);
+ /*
+ * In the context of the PCL XL code, this routine may be called for
+ * gsave, grestore, or gstate (copying the gstate for makepattern
+ * or Pattern rendering). See gxstate.h for details of the 'from'
+ * and 'to' arguments for each of these cases.
+ *
+ * We have some structures that belong to the individual gstates for
+ * storage management purposes. Currently these are:
+ * dither_matrix, temp_pattern_dict
+ * px_gstate_client_alloc initializes them to an empty state.
+ * For gsave and gstate, the new current gstate or copied gstate
+ * respectively should have the empty structure. For grestore,
+ * we want to swap the structures, because we will then free the
+ * saved gstate (and release the structure that was in the current
+ * gstate before the grestore).
+ *
+ * halftone.thresholds is a different special case. We need to
+ * copy it for gsave and gstate, and free it on grestore.
+ */
+ { gs_string tmat;
+ gs_string thtt;
+ pl_dict_t tdict;
+ gs_string *phtt;
+
+ tmat = pxto->dither_matrix;
+ thtt = pxto->halftone.thresholds;
+ tdict = pxto->temp_pattern_dict;
+ *pxto = *pxfrom;
+ switch ( reason )
+ {
+ case copy_for_gstate:
+ /* Just put back the (empty) 'to' structures. */
+ pxto->dither_matrix = tmat;
+ pxto->temp_pattern_dict = tdict;
+ phtt = &pxto->halftone.thresholds;
+ goto copy;
+ case copy_for_gsave:
+ /* Swap the structures, but set the parent of the new */
+ /* (empty) dictionary to the old one. */
+ pxfrom->dither_matrix = tmat;
+ pxfrom->temp_pattern_dict = tdict;
+ pl_dict_set_parent(&pxfrom->temp_pattern_dict,
+ &pxto->temp_pattern_dict);
+ phtt = &pxfrom->halftone.thresholds;
copy: if ( phtt->data )
- { byte *str = gs_alloc_string(pxfrom->memory, phtt->size,
- "px_gstate_client_copy(thresholds)");
- if ( str == 0 )
- return_error(errorInsufficientMemory);
- memcpy(str, phtt->data, phtt->size);
- phtt->data = str;
- }
- break;
- default: /* copy_for_grestore */
- /* Swap the structures. */
- pxfrom->dither_matrix = tmat;
- pxfrom->halftone.thresholds = thtt;
- pxfrom->temp_pattern_dict = tdict;
- }
- }
- return 0;
+ { byte *str = gs_alloc_string(pxfrom->memory, phtt->size,
+ "px_gstate_client_copy(thresholds)");
+ if ( str == 0 )
+ return_error(errorInsufficientMemory);
+ memcpy(str, phtt->data, phtt->size);
+ phtt->data = str;
+ }
+ break;
+ default: /* copy_for_grestore */
+ /* Swap the structures. */
+ pxfrom->dither_matrix = tmat;
+ pxfrom->halftone.thresholds = thtt;
+ pxfrom->temp_pattern_dict = tdict;
+ }
+ }
+ return 0;
#undef pxfrom
#undef pxto
}
@@ -194,17 +193,17 @@ static void
px_gstate_client_free(void *old, gs_memory_t *mem)
{ px_gstate_t *pxgs = old;
- px_dict_release(&pxgs->temp_pattern_dict);
- if ( pxgs->halftone.thresholds.data )
+ px_dict_release(&pxgs->temp_pattern_dict);
+ if ( pxgs->halftone.thresholds.data )
gs_free_string(mem, (byte *)pxgs->halftone.thresholds.data,
- pxgs->halftone.thresholds.size,
- "px_gstate_free(halftone.thresholds)");
- if ( pxgs->dither_matrix.data )
+ pxgs->halftone.thresholds.size,
+ "px_gstate_free(halftone.thresholds)");
+ if ( pxgs->dither_matrix.data )
gs_free_string(mem, (byte *)pxgs->dither_matrix.data,
- pxgs->dither_matrix.size,
- "px_gstate_free(dither_matrix)");
- px_gstate_rc_adjust(old, -1, mem);
- gs_free_object(mem, old, "px_gstate_free");
+ pxgs->dither_matrix.size,
+ "px_gstate_free(dither_matrix)");
+ px_gstate_rc_adjust(old, -1, mem);
+ gs_free_object(mem, old, "px_gstate_free");
}
static const gs_state_client_procs px_gstate_procs = {
px_gstate_client_alloc,
@@ -220,23 +219,23 @@ px_gstate_t *
px_gstate_alloc(gs_memory_t *mem)
{ px_gstate_t *pxgs = px_gstate_client_alloc(mem);
- if ( pxgs == 0 )
- return 0;
- pxgs->stack_depth = 0;
- px_gstate_init(pxgs, NULL);
- return pxgs;
+ if ( pxgs == 0 )
+ return 0;
+ pxgs->stack_depth = 0;
+ px_gstate_init(pxgs, NULL);
+ return pxgs;
}
/* Initialize a px_gstate_t. */
void
px_gstate_init(px_gstate_t *pxgs, gs_state *pgs)
{ pxgs->halftone.method = eDeviceBest;
- pxgs->halftone.set = false;
- pxgs->halftone.origin.x = pxgs->halftone.origin.y = 0;
- /* halftone.thresholds was initialized at alloc time */
- px_gstate_reset(pxgs);
- if ( pgs )
- gs_state_set_client(pgs, pxgs, &px_gstate_procs, false);
+ pxgs->halftone.set = false;
+ pxgs->halftone.origin.x = pxgs->halftone.origin.y = 0;
+ /* halftone.thresholds was initialized at alloc time */
+ px_gstate_reset(pxgs);
+ if ( pgs )
+ gs_state_set_client(pgs, pxgs, &px_gstate_procs, false);
}
/* Initialize the graphics state for a page. */
@@ -245,68 +244,68 @@ int
px_initgraphics(px_state_t *pxs)
{ gs_state *pgs = pxs->pgs;
- px_gstate_reset(pxs->pxgs);
- gs_initgraphics(pgs);
+ px_gstate_reset(pxs->pxgs);
+ gs_initgraphics(pgs);
- gs_setfilladjust(pgs, 0.5, 0.5);
+ gs_setfilladjust(pgs, 0.5, 0.5);
- { gs_point inch;
- float dpi;
+ { gs_point inch;
+ float dpi;
- gs_dtransform(pgs, 72.0, 0.0, &inch);
- dpi = fabs(inch.x) + fabs(inch.y);
+ gs_dtransform(pgs, 72.0, 0.0, &inch);
+ dpi = fabs(inch.x) + fabs(inch.y);
- /* Stroke adjustment leads to anomalies at high resolutions. */
- if ( dpi >= 150 )
- gs_setstrokeadjust(pgs, false);
+ /* Stroke adjustment leads to anomalies at high resolutions. */
+ if ( dpi >= 150 )
+ gs_setstrokeadjust(pgs, false);
- /* We need the H-P interpretation of zero-length lines */
- /* and of using bevel joins for the segments of flattened curves. */
- gs_setdotlength(pgs, 72.0 / 300, true);
- }
- /* we always clamp coordinates hp does not seem to report
+ /* We need the H-P interpretation of zero-length lines */
+ /* and of using bevel joins for the segments of flattened curves. */
+ gs_setdotlength(pgs, 72.0 / 300, true);
+ }
+ /* we always clamp coordinates hp does not seem to report
limit checks in paths */
- gs_setlimitclamp(pgs, true);
- return 0;
+ gs_setlimitclamp(pgs, true);
+ return 0;
}
/* Reset a px_gstate_t, initially or at the beginning of a page. */
void
px_gstate_reset(px_gstate_t *pxgs)
{ pxgs->brush.type = pxpGray;
- pxgs->brush.value.gray = 0;
- pxgs->char_angle = 0;
- pxgs->char_bold_value = 0;
- pxgs->char_scale.x = pxgs->char_scale.y = 1;
- pxgs->char_shear.x = pxgs->char_shear.y = 0;
- /* The order of transforms is arbitrary, */
- /* because the transforms are all no-ops. */
- pxgs->char_transforms[0] = pxct_rotate;
- pxgs->char_transforms[1] = pxct_shear;
- pxgs->char_transforms[2] = pxct_scale;
- pxgs->char_sub_mode = eNoSubstitution;
- pxgs->clip_mode = eNonZeroWinding;
- pxgs->color_space = eRGB;
- pxgs->palette.size = 0;
- pxgs->palette.data = 0;
- pxgs->palette_is_shared = false;
- pxgs->base_font = 0;
- /* halftone_method was set above. */
- pxgs->fill_mode = eNonZeroWinding;
- pxgs->dashed = false;
- pxgs->pen.type = pxpGray;
- pxgs->pen.value.gray = 0;
- /* temp_pattern_dict was set at allocation time. */
- gs_make_identity(&pxgs->text_ctm);
- pxgs->char_matrix_set = false;
- pxgs->symbol_map = 0;
- pxgs->writing_mode = eHorizontal;
+ pxgs->brush.value.gray = 0;
+ pxgs->char_angle = 0;
+ pxgs->char_bold_value = 0;
+ pxgs->char_scale.x = pxgs->char_scale.y = 1;
+ pxgs->char_shear.x = pxgs->char_shear.y = 0;
+ /* The order of transforms is arbitrary, */
+ /* because the transforms are all no-ops. */
+ pxgs->char_transforms[0] = pxct_rotate;
+ pxgs->char_transforms[1] = pxct_shear;
+ pxgs->char_transforms[2] = pxct_scale;
+ pxgs->char_sub_mode = eNoSubstitution;
+ pxgs->clip_mode = eNonZeroWinding;
+ pxgs->color_space = eRGB;
+ pxgs->palette.size = 0;
+ pxgs->palette.data = 0;
+ pxgs->palette_is_shared = false;
+ pxgs->base_font = 0;
+ /* halftone_method was set above. */
+ pxgs->fill_mode = eNonZeroWinding;
+ pxgs->dashed = false;
+ pxgs->pen.type = pxpGray;
+ pxgs->pen.value.gray = 0;
+ /* temp_pattern_dict was set at allocation time. */
+ gs_make_identity(&pxgs->text_ctm);
+ pxgs->char_matrix_set = false;
+ pxgs->symbol_map = 0;
+ pxgs->writing_mode = eHorizontal;
}
/* initial clip region note, we don't use gs_initclip() because we
give special handling for the XL 1/6" border */
int
-px_initclip(px_state_t *pxs)
+px_initclip(px_state_t *pxs)
{
return gs_initclip(pxs->pgs);
}
@@ -322,7 +321,7 @@ int
px_image_color_space(gs_image_t *pim,
const px_bitmap_params_t *params, const gs_string *palette,
const gs_state *pgs)
-{
+{
int depth = params->depth;
gs_color_space *pbase_pcs = NULL;
@@ -331,11 +330,11 @@ px_image_color_space(gs_image_t *pim,
int code = 0;
switch ( params->color_space ) {
case eGray:
- pbase_pcs = gs_cspace_new_DeviceGray(pgs->memory);
+ pbase_pcs = gs_cspace_new_DeviceGray(pgs->memory);
pbase_pcs->cmm_icc_profile_data = pgs->icc_manager->default_gray;
pbase_pcs->type = &gs_color_space_type_ICC;
rc_increment(pbase_pcs->cmm_icc_profile_data);
- break;
+ break;
case eRGB:
pbase_pcs = gs_cspace_new_DeviceRGB(pgs->memory);
pbase_pcs->cmm_icc_profile_data = pgs->icc_manager->default_rgb;
@@ -351,23 +350,23 @@ px_image_color_space(gs_image_t *pim,
pbase_pcs->cmm_icc_profile_data = pgs->icc_manager->default_rgb;
pbase_pcs->type = &gs_color_space_type_ICC;
rc_increment(pbase_pcs->cmm_icc_profile_data);
- break;
+ break;
default:
- return_error(errorIllegalAttributeValue);
+ return_error(errorIllegalAttributeValue);
}
if (pbase_pcs == NULL)
return_error(errorInsufficientMemory);
- if ( params->indexed ) {
+ if ( params->indexed ) {
pcs = gs_cspace_alloc(pgs->memory, &gs_color_space_type_Indexed);
if ( pcs == NULL ) {
/* free the base space also */
rc_decrement(pbase_pcs, "px_image_color_space");
return_error(errorInsufficientMemory);
}
- pcs->base_space = pbase_pcs;
- pcs->params.indexed.hival = (1 << depth) - 1;
- pcs->params.indexed.lookup.table.size = palette->size;
+ pcs->base_space = pbase_pcs;
+ pcs->params.indexed.hival = (1 << depth) - 1;
+ pcs->params.indexed.lookup.table.size = palette->size;
{
uint n = palette->size;
byte *p = gs_alloc_string(pgs->memory, n,
@@ -380,7 +379,7 @@ px_image_color_space(gs_image_t *pim,
memcpy(p, palette->data, n);
pcs->params.indexed.lookup.table.data = p;
}
- pcs->params.indexed.use_proc = 0;
+ pcs->params.indexed.use_proc = 0;
} else {
pcs = pbase_pcs;
}
@@ -388,7 +387,7 @@ px_image_color_space(gs_image_t *pim,
pim->ColorSpace = pcs;
pim->BitsPerComponent = depth;
if ( params->indexed )
- pim->Decode[1] = (1 << depth) - 1;
+ pim->Decode[1] = (1 << depth) - 1;
/* NB - this needs investigation */
if (cie_space && !px_is_currentcolor_pattern(pgs)) {
code = pl_setSRGBcolor((gs_state *)pgs, 0.0, 0.0, 0.0);
@@ -405,13 +404,13 @@ px_image_color_space(gs_image_t *pim,
static void
add_char_transform(px_gstate_t *pxgs, px_char_transform_t trans)
{ /* Promote this transformation to the head of the list. */
- if ( pxgs->char_transforms[2] == trans )
- pxgs->char_transforms[2] = pxgs->char_transforms[1],
- pxgs->char_transforms[1] = pxgs->char_transforms[0];
- else if ( pxgs->char_transforms[1] == trans )
- pxgs->char_transforms[1] = pxgs->char_transforms[0];
- pxgs->char_transforms[0] = trans;
- pxgs->char_matrix_set = false;
+ if ( pxgs->char_transforms[2] == trans )
+ pxgs->char_transforms[2] = pxgs->char_transforms[1],
+ pxgs->char_transforms[1] = pxgs->char_transforms[0];
+ else if ( pxgs->char_transforms[1] == trans )
+ pxgs->char_transforms[1] = pxgs->char_transforms[0];
+ pxgs->char_transforms[0] = trans;
+ pxgs->char_matrix_set = false;
}
/* ---------------- Operators ---------------- */
@@ -420,41 +419,41 @@ const byte apxPopGS[] = {0, 0};
int
pxPopGS(px_args_t *par, px_state_t *pxs)
{ gs_state *pgs = pxs->pgs;
- px_gstate_t *pxgs = pxs->pxgs;
- int code;
-
- /*
- * Even though the H-P documentation says that a PopGS with an
- * empty stack is illegal, the implementations apparently simply
- * do nothing in this case.
- */
- if ( pxgs->stack_depth == 0 )
- return 0;
- if ( pxgs->palette.data && !pxgs->palette_is_shared ) {
+ px_gstate_t *pxgs = pxs->pxgs;
+ int code;
+
+ /*
+ * Even though the H-P documentation says that a PopGS with an
+ * empty stack is illegal, the implementations apparently simply
+ * do nothing in this case.
+ */
+ if ( pxgs->stack_depth == 0 )
+ return 0;
+ if ( pxgs->palette.data && !pxgs->palette_is_shared ) {
gs_free_string(pxs->memory, (byte *)pxgs->palette.data,
- pxgs->palette.size, "pxPopGS(palette)");
- pxgs->palette.data = 0;
- }
- px_purge_pattern_cache(pxs, eTempPattern);
- code = gs_grestore(pgs);
- pxs->pxgs = gs_state_client_data(pgs);
- return code;
+ pxgs->palette.size, "pxPopGS(palette)");
+ pxgs->palette.data = 0;
+ }
+ px_purge_pattern_cache(pxs, eTempPattern);
+ code = gs_grestore(pgs);
+ pxs->pxgs = gs_state_client_data(pgs);
+ return code;
}
const byte apxPushGS[] = {0, 0};
int
pxPushGS(px_args_t *par, px_state_t *pxs)
{ gs_state *pgs = pxs->pgs;
- int code = gs_gsave(pgs);
- px_gstate_t *pxgs;
-
- if ( code < 0 )
- return code;
- pxgs = pxs->pxgs = gs_state_client_data(pgs);
- if ( pxgs->palette.data )
- pxgs->palette_is_shared = true;
- ++(pxgs->stack_depth);
- return code;
+ int code = gs_gsave(pgs);
+ px_gstate_t *pxgs;
+
+ if ( code < 0 )
+ return code;
+ pxgs = pxs->pxgs = gs_state_client_data(pgs);
+ if ( pxgs->palette.data )
+ pxgs->palette_is_shared = true;
+ ++(pxgs->stack_depth);
+ return code;
}
/* To restore the interpreters to default state we assemble the
@@ -533,7 +532,6 @@ static const byte pxSetDefaultGSstr[] = {
84,127,105,133,192,0,248,70,110
};
-
const byte apxSetDefaultGS[] = {0, 0};
int
pxSetDefaultGS(px_args_t *par, px_state_t *pxs)
@@ -564,10 +562,10 @@ int
pxSetClipReplace(px_args_t *par, px_state_t *pxs)
{ int code;
- check_clip_region(par, pxs);
- if ( (code = px_initclip(pxs)) < 0 )
- return code;
- return pxSetClipIntersect(par, pxs);
+ check_clip_region(par, pxs);
+ if ( (code = px_initclip(pxs)) < 0 )
+ return code;
+ return pxSetClipIntersect(par, pxs);
}
const byte apxSetCharAngle[] = {
@@ -576,15 +574,15 @@ const byte apxSetCharAngle[] = {
int
pxSetCharAngle(px_args_t *par, px_state_t *pxs)
{ real angle = real_value(par->pv[0], 0);
- px_gstate_t *pxgs = pxs->pxgs;
-
- if ( angle != pxgs->char_angle ||
- pxgs->char_transforms[0] != pxct_rotate
- )
- { pxgs->char_angle = angle;
- add_char_transform(pxgs, pxct_rotate);
- }
- return 0;
+ px_gstate_t *pxgs = pxs->pxgs;
+
+ if ( angle != pxgs->char_angle ||
+ pxgs->char_transforms[0] != pxct_rotate
+ )
+ { pxgs->char_angle = angle;
+ add_char_transform(pxgs, pxct_rotate);
+ }
+ return 0;
}
/* confusion in the 3.0 spec - this argument identifier WritingMode
@@ -609,17 +607,17 @@ const byte apxSetCharScale[] = {
int
pxSetCharScale(px_args_t *par, px_state_t *pxs)
{ real x_scale = real_value(par->pv[0], 0);
- real y_scale = real_value(par->pv[0], 1);
- px_gstate_t *pxgs = pxs->pxgs;
-
- if ( x_scale != pxgs->char_scale.x || y_scale != pxgs->char_scale.y ||
- pxgs->char_transforms[0] != pxct_scale
- )
- { pxgs->char_scale.x = x_scale;
- pxgs->char_scale.y = y_scale;
- add_char_transform(pxgs, pxct_scale);
- }
- return 0;
+ real y_scale = real_value(par->pv[0], 1);
+ px_gstate_t *pxgs = pxs->pxgs;
+
+ if ( x_scale != pxgs->char_scale.x || y_scale != pxgs->char_scale.y ||
+ pxgs->char_transforms[0] != pxct_scale
+ )
+ { pxgs->char_scale.x = x_scale;
+ pxgs->char_scale.y = y_scale;
+ add_char_transform(pxgs, pxct_scale);
+ }
+ return 0;
}
const byte apxSetCharShear[] = {
@@ -635,20 +633,20 @@ const byte apxSetCharShear[] = {
int
pxSetCharShear(px_args_t *par, px_state_t *pxs)
{ real x_shear = real_value(par->pv[0], 0);
- real y_shear = real_value(par->pv[0], 1);
- px_gstate_t *pxgs = pxs->pxgs;
+ real y_shear = real_value(par->pv[0], 1);
+ px_gstate_t *pxgs = pxs->pxgs;
x_shear = x_shear > SHEAR_LIMIT ? SHEAR_LIMIT : x_shear;
y_shear = y_shear > SHEAR_LIMIT ? SHEAR_LIMIT : y_shear;
- if ( x_shear != pxgs->char_shear.x || y_shear != pxgs->char_shear.y ||
- pxgs->char_transforms[0] != pxct_shear
- )
- { pxgs->char_shear.x = x_shear;
- pxgs->char_shear.y = y_shear;
- add_char_transform(pxgs, pxct_shear);
- }
- return 0;
+ if ( x_shear != pxgs->char_shear.x || y_shear != pxgs->char_shear.y ||
+ pxgs->char_transforms[0] != pxct_shear
+ )
+ { pxgs->char_shear.x = x_shear;
+ pxgs->char_shear.y = y_shear;
+ add_char_transform(pxgs, pxct_shear);
+ }
+ return 0;
}
const byte apxSetClipIntersect[] = {
@@ -657,54 +655,54 @@ const byte apxSetClipIntersect[] = {
int
pxSetClipIntersect(px_args_t *par, px_state_t *pxs)
{ gs_state *pgs = pxs->pgs;
- pxeClipRegion_t clip_region = par->pv[0]->value.i;
- int code;
-
- check_clip_region(par, pxs);
- /*
- * The discussion of ClipMode and ClipRegion in the published
- * specification is confused and incorrect. Based on testing with
- * the LaserJet 6MP, we believe that ClipMode works just like
- * PostScript clip and eoclip, and that ClipRegion applies only to
- * the *current* path (i.e., support for "outside clipping" in the
- * library is unnecessary). If we had only known....
- */
+ pxeClipRegion_t clip_region = par->pv[0]->value.i;
+ int code;
+
+ check_clip_region(par, pxs);
+ /*
+ * The discussion of ClipMode and ClipRegion in the published
+ * specification is confused and incorrect. Based on testing with
+ * the LaserJet 6MP, we believe that ClipMode works just like
+ * PostScript clip and eoclip, and that ClipRegion applies only to
+ * the *current* path (i.e., support for "outside clipping" in the
+ * library is unnecessary). If we had only known....
+ */
#if 0
- gs_setclipoutside(pgs, false);
+ gs_setclipoutside(pgs, false);
#endif
- if ( clip_region == eExterior )
- { /*
- * We know clip_mode is eEvenOdd, so we can complement the
- * region defined by the current path by just adding a
- * rectangle that encloses the entire page.
- */
- gs_rect bbox;
-
- code = gs_gsave(pgs);
- if ( code < 0 )
- return code;
- px_initclip(pxs);
- if ( (code = gs_clippath(pgs)) < 0 ||
- (code = gs_pathbbox(pgs, &bbox)) < 0
- )
- DO_NOTHING;
- gs_grestore(pgs);
- if ( code < 0 ||
- (code = gs_rectappend(pgs, &bbox, 1)) < 0
- )
- return code;
+ if ( clip_region == eExterior )
+ { /*
+ * We know clip_mode is eEvenOdd, so we can complement the
+ * region defined by the current path by just adding a
+ * rectangle that encloses the entire page.
+ */
+ gs_rect bbox;
+
+ code = gs_gsave(pgs);
+ if ( code < 0 )
+ return code;
+ px_initclip(pxs);
+ if ( (code = gs_clippath(pgs)) < 0 ||
+ (code = gs_pathbbox(pgs, &bbox)) < 0
+ )
+ DO_NOTHING;
+ gs_grestore(pgs);
+ if ( code < 0 ||
+ (code = gs_rectappend(pgs, &bbox, 1)) < 0
+ )
+ return code;
#ifdef CLIP_INTERSECT_EXTERIOR_REPLACES
- px_initclip(pxs);
+ px_initclip(pxs);
#endif
- }
- code =
- (pxs->pxgs->clip_mode == eEvenOdd ? gs_eoclip(pgs) : gs_clip(pgs));
- if ( code < 0 )
- return code;
+ }
+ code =
+ (pxs->pxgs->clip_mode == eEvenOdd ? gs_eoclip(pgs) : gs_clip(pgs));
+ if ( code < 0 )
+ return code;
#if 0
- gs_setclipoutside(pgs, clip_region == eExterior);
+ gs_setclipoutside(pgs, clip_region == eExterior);
#endif
- return gs_newpath(pgs);
+ return gs_newpath(pgs);
}
const byte apxSetClipRectangle[] = {
@@ -713,22 +711,22 @@ const byte apxSetClipRectangle[] = {
int
pxSetClipRectangle(px_args_t *par, px_state_t *pxs)
{ px_args_t args;
- gs_state *pgs = pxs->pgs;
- int code;
-
- check_clip_region(par, pxs);
- gs_newpath(pgs);
- args.pv[0] = par->pv[1];
- if ( (code = pxRectanglePath(&args, pxs)) < 0 )
- return code;
- return pxSetClipReplace(par, pxs);
+ gs_state *pgs = pxs->pgs;
+ int code;
+
+ check_clip_region(par, pxs);
+ gs_newpath(pgs);
+ args.pv[0] = par->pv[1];
+ if ( (code = pxRectanglePath(&args, pxs)) < 0 )
+ return code;
+ return pxSetClipReplace(par, pxs);
}
const byte apxSetClipToPage[] = {0, 0};
int
pxSetClipToPage(px_args_t *par, px_state_t *pxs)
{ gs_newpath(pxs->pgs);
- return px_initclip(pxs);
+ return px_initclip(pxs);
}
const byte apxSetCursor[] = {
@@ -737,7 +735,7 @@ const byte apxSetCursor[] = {
int
pxSetCursor(px_args_t *par, px_state_t *pxs)
{ return gs_moveto(pxs->pgs, real_value(par->pv[0], 0),
- real_value(par->pv[0], 1));
+ real_value(par->pv[0], 1));
}
const byte apxSetCursorRel[] = {
@@ -746,7 +744,7 @@ const byte apxSetCursorRel[] = {
int
pxSetCursorRel(px_args_t *par, px_state_t *pxs)
{ return gs_rmoveto(pxs->pgs, real_value(par->pv[0], 0),
- real_value(par->pv[0], 1));;
+ real_value(par->pv[0], 1));;
}
/* SetHalftoneMethod is in pxink.c */
@@ -757,7 +755,7 @@ const byte apxSetFillMode[] = {
int
pxSetFillMode(px_args_t *par, px_state_t *pxs)
{ pxs->pxgs->fill_mode = par->pv[0]->value.i;
- return 0;
+ return 0;
}
/* SetFont is in pxfont.c */
@@ -768,140 +766,140 @@ const byte apxSetLineDash[] = {
int
pxSetLineDash(px_args_t *par, px_state_t *pxs)
{ px_gstate_t *pxgs = pxs->pxgs;
- gs_state *pgs = pxs->pgs;
-
- if ( par->pv[0] )
- { float pattern[MAX_DASH_ELEMENTS * 2];
- uint size = par->pv[0]->value.array.size;
- real offset = (par->pv[1] ? real_value(par->pv[1], 0) : 0.0);
- int code;
-
- if ( par->pv[2] )
- return_error(errorIllegalAttributeCombination);
- if ( size > MAX_DASH_ELEMENTS )
- return_error(errorIllegalArraySize);
-
- /*
- * The H-P documentation gives no clue about what a negative
- * dash pattern element is supposed to do. The H-P printers
- * apparently interpret it as drawing a line backwards in the
- * current direction (which may extend outside the original
- * subpath) with the caps inside the line instead of outside; a
- * dash pattern with a negative total length crashes the LJ 6MP
- * firmware so badly the printer has to be power cycled! We
- * take a different approach here: we compensate for negative
- * elements by propagating them to adjacent positive ones. This
- * doesn't produce quite the same output as the H-P printers do,
- * but this is such an obscure feature that we don't think it's
- * worth the trouble to emulate exactly.
- */
- { uint orig_size = size;
- int i;
-
- /* Acquire the pattern, duplicating it if the length is odd. */
- if ( size & 1 )
- size <<= 1;
- for ( i = 0; i < size; ++i )
- pattern[i] = real_elt(par->pv[0], i % orig_size);
- /* Get rid of negative draws. */
- if ( pattern[0] < 0 )
- offset -= pattern[0],
- pattern[size - 1] += pattern[0],
- pattern[1] += pattern[0],
- pattern[0] = -pattern[0];
- for ( i = 2; i < size; i += 2 )
- if ( pattern[i] < 0 )
- pattern[i - 1] += pattern[i],
- pattern[i + 1] += pattern[i],
- pattern[i] = -pattern[i];
- /*
- * Now propagate negative skips iteratively. Since each step
- * decreases either the remaining total of negative skips or
- * the total number of pattern elements, the process is
- * guaranteed to terminate.
- */
+ gs_state *pgs = pxs->pgs;
+
+ if ( par->pv[0] )
+ { float pattern[MAX_DASH_ELEMENTS * 2];
+ uint size = par->pv[0]->value.array.size;
+ real offset = (par->pv[1] ? real_value(par->pv[1], 0) : 0.0);
+ int code;
+
+ if ( par->pv[2] )
+ return_error(errorIllegalAttributeCombination);
+ if ( size > MAX_DASH_ELEMENTS )
+ return_error(errorIllegalArraySize);
+
+ /*
+ * The H-P documentation gives no clue about what a negative
+ * dash pattern element is supposed to do. The H-P printers
+ * apparently interpret it as drawing a line backwards in the
+ * current direction (which may extend outside the original
+ * subpath) with the caps inside the line instead of outside; a
+ * dash pattern with a negative total length crashes the LJ 6MP
+ * firmware so badly the printer has to be power cycled! We
+ * take a different approach here: we compensate for negative
+ * elements by propagating them to adjacent positive ones. This
+ * doesn't produce quite the same output as the H-P printers do,
+ * but this is such an obscure feature that we don't think it's
+ * worth the trouble to emulate exactly.
+ */
+ { uint orig_size = size;
+ int i;
+
+ /* Acquire the pattern, duplicating it if the length is odd. */
+ if ( size & 1 )
+ size <<= 1;
+ for ( i = 0; i < size; ++i )
+ pattern[i] = real_elt(par->pv[0], i % orig_size);
+ /* Get rid of negative draws. */
+ if ( pattern[0] < 0 )
+ offset -= pattern[0],
+ pattern[size - 1] += pattern[0],
+ pattern[1] += pattern[0],
+ pattern[0] = -pattern[0];
+ for ( i = 2; i < size; i += 2 )
+ if ( pattern[i] < 0 )
+ pattern[i - 1] += pattern[i],
+ pattern[i + 1] += pattern[i],
+ pattern[i] = -pattern[i];
+ /*
+ * Now propagate negative skips iteratively. Since each step
+ * decreases either the remaining total of negative skips or
+ * the total number of pattern elements, the process is
+ * guaranteed to terminate.
+ */
elim: for ( i = 0; i < size; i += 2 )
- { float draw = pattern[i], skip = pattern[i + 1];
- int inext, iprev;
- float next, prev;
-
- if ( skip > 0 )
- continue;
- if ( size == 2 ) /* => i == 0 */
- { if ( (pattern[0] = draw + skip) <= 0 )
- pattern[0] = -pattern[0];
- pattern[1] = 0;
- break;
- }
- inext = (i == size - 2 ? 0 : i + 2);
- next = pattern[inext];
- /*
- * Consider the sequence D, -S, E, where D and E are draws
- * and -S is a negative skip. If S <= D, replace the 3
- * elements with D - S + E.
- */
- if ( draw + skip >= 0 )
- { next += draw + skip;
- goto shrink;
- }
- /*
- * Otherwise, let T be the skip preceding D. Replace T
- * with T + D - S. If S > E, replace D, -S, E with E, S -
- * (D + E), D; otherwise, replace D, -S, E with E. In
- * both cases, net progress has occurred.
- */
- iprev = (i == 0 ? size - 1 : i - 1);
- prev = pattern[iprev];
- pattern[iprev] = prev + draw + skip;
- if ( -skip > next )
- { pattern[i] = next;
- pattern[i + 1] = -(skip + draw + next);
- pattern[i + 2] = draw;
- goto elim;
- }
+ { float draw = pattern[i], skip = pattern[i + 1];
+ int inext, iprev;
+ float next, prev;
+
+ if ( skip > 0 )
+ continue;
+ if ( size == 2 ) /* => i == 0 */
+ { if ( (pattern[0] = draw + skip) <= 0 )
+ pattern[0] = -pattern[0];
+ pattern[1] = 0;
+ break;
+ }
+ inext = (i == size - 2 ? 0 : i + 2);
+ next = pattern[inext];
+ /*
+ * Consider the sequence D, -S, E, where D and E are draws
+ * and -S is a negative skip. If S <= D, replace the 3
+ * elements with D - S + E.
+ */
+ if ( draw + skip >= 0 )
+ { next += draw + skip;
+ goto shrink;
+ }
+ /*
+ * Otherwise, let T be the skip preceding D. Replace T
+ * with T + D - S. If S > E, replace D, -S, E with E, S -
+ * (D + E), D; otherwise, replace D, -S, E with E. In
+ * both cases, net progress has occurred.
+ */
+ iprev = (i == 0 ? size - 1 : i - 1);
+ prev = pattern[iprev];
+ pattern[iprev] = prev + draw + skip;
+ if ( -skip > next )
+ { pattern[i] = next;
+ pattern[i + 1] = -(skip + draw + next);
+ pattern[i + 2] = draw;
+ goto elim;
+ }
shrink: if ( inext == 0 )
- { offset += next - pattern[0];
- pattern[0] = next;
- }
- else
- { pattern[i] = next;
- memmove(&pattern[i + 1], &pattern[i + 3],
- (size - (i + 3)) * sizeof(pattern[0]));
- }
- size -= 2;
- goto elim;
- }
- }
- code = gs_setdash(pgs, pattern, size, offset);
- if ( code < 0 )
- return code;
- /* patterns with 0 total skip length are treated as solid
+ { offset += next - pattern[0];
+ pattern[0] = next;
+ }
+ else
+ { pattern[i] = next;
+ memmove(&pattern[i + 1], &pattern[i + 3],
+ (size - (i + 3)) * sizeof(pattern[0]));
+ }
+ size -= 2;
+ goto elim;
+ }
+ }
+ code = gs_setdash(pgs, pattern, size, offset);
+ if ( code < 0 )
+ return code;
+ /* patterns with 0 total skip length are treated as solid
line pattern on the LJ6 */
- {
- bool skips_have_length = false;
- int i;
- for ( i = 0; i < size; i += 2 )
- if ( pattern[i + 1] != 0 ) {
- skips_have_length = true;
- break;
- }
- if ( skips_have_length == false ) {
- pxgs->dashed = false;
- return gs_setdash(pgs, NULL, 0, 0.0);
- }
- pxgs->dashed = (size != 0);
- }
- gs_currentmatrix(pgs, &pxgs->dash_matrix);
- return 0;
- }
- else if ( par->pv[2] )
- { if ( par->pv[1] )
- return_error(errorIllegalAttributeCombination);
- pxgs->dashed = false;
- return gs_setdash(pgs, NULL, 0, 0.0);
- }
- else
- return_error(errorMissingAttribute);
+ {
+ bool skips_have_length = false;
+ int i;
+ for ( i = 0; i < size; i += 2 )
+ if ( pattern[i + 1] != 0 ) {
+ skips_have_length = true;
+ break;
+ }
+ if ( skips_have_length == false ) {
+ pxgs->dashed = false;
+ return gs_setdash(pgs, NULL, 0, 0.0);
+ }
+ pxgs->dashed = (size != 0);
+ }
+ gs_currentmatrix(pgs, &pxgs->dash_matrix);
+ return 0;
+ }
+ else if ( par->pv[2] )
+ { if ( par->pv[1] )
+ return_error(errorIllegalAttributeCombination);
+ pxgs->dashed = false;
+ return gs_setdash(pgs, NULL, 0, 0.0);
+ }
+ else
+ return_error(errorMissingAttribute);
}
const byte apxSetLineCap[] = {
@@ -910,7 +908,7 @@ const byte apxSetLineCap[] = {
int
pxSetLineCap(px_args_t *par, px_state_t *pxs)
{ static const gs_line_cap cap_map[] = pxeLineCap_to_library;
- return gs_setlinecap(pxs->pgs, cap_map[par->pv[0]->value.i]);
+ return gs_setlinecap(pxs->pgs, cap_map[par->pv[0]->value.i]);
}
const byte apxBeginUserDefinedLineCap[] = { 0, 0 };
@@ -922,7 +920,6 @@ pxBeginUserDefinedLineCap(px_args_t *par, px_state_t *pxs)
return 0;
}
-
const byte apxEndUserDefinedLineCap[] = { 0, 0 };
int
pxEndUserDefinedLineCap(px_args_t *par, px_state_t *pxs)
@@ -938,7 +935,7 @@ const byte apxSetLineJoin[] = {
int
pxSetLineJoin(px_args_t *par, px_state_t *pxs)
{ static const gs_line_join join_map[] = pxeLineJoin_to_library;
- return gs_setlinejoin(pxs->pgs, join_map[par->pv[0]->value.i]);
+ return gs_setlinejoin(pxs->pgs, join_map[par->pv[0]->value.i]);
}
const byte apxSetMiterLimit[] = {
@@ -948,26 +945,26 @@ int
pxSetMiterLimit(px_args_t *par, px_state_t *pxs)
{ float limit = real_value(par->pv[0], 0);
- if ( limit == 0 )
- { /*
- * H-P printers interpret this to mean use the default value
- * of 10, even though nothing in the documentation says or
- * implies this.
- */
- limit = 10;
- }
- else
- { /* PCL XL, but not the library, allows limit values <1. */
- if ( limit < 1 ) limit = 1;
- }
- return gs_setmiterlimit(pxs->pgs, limit);
+ if ( limit == 0 )
+ { /*
+ * H-P printers interpret this to mean use the default value
+ * of 10, even though nothing in the documentation says or
+ * implies this.
+ */
+ limit = 10;
+ }
+ else
+ { /* PCL XL, but not the library, allows limit values <1. */
+ if ( limit < 1 ) limit = 1;
+ }
+ return gs_setmiterlimit(pxs->pgs, limit);
}
const byte apxSetPageDefaultCTM[] = {0, 0};
int
pxSetPageDefaultCTM(px_args_t *par, px_state_t *pxs)
{ gs_make_identity(&pxs->pxgs->text_ctm);
- return gs_setmatrix(pxs->pgs, &pxs->initial_matrix);
+ return gs_setmatrix(pxs->pgs, &pxs->initial_matrix);
}
const byte apxSetPageOrigin[] = {
@@ -976,7 +973,7 @@ const byte apxSetPageOrigin[] = {
int
pxSetPageOrigin(px_args_t *par, px_state_t *pxs)
{ return gs_translate(pxs->pgs, real_value(par->pv[0], 0),
- real_value(par->pv[0], 1));
+ real_value(par->pv[0], 1));
}
const byte apxSetPageRotation[] = {
@@ -985,20 +982,20 @@ const byte apxSetPageRotation[] = {
int
pxSetPageRotation(px_args_t *par, px_state_t *pxs)
{ /* Since the Y coordinate of user space is inverted, */
- /* we must negate rotation angles. */
- real angle = -real_value(par->pv[0], 0);
- int code = gs_rotate(pxs->pgs, angle);
-
- if ( code < 0 )
- return code;
- /* Post-multiply the text CTM by the rotation matrix. */
- { gs_matrix rmat;
- px_gstate_t *pxgs = pxs->pxgs;
-
- gs_make_rotation(angle, &rmat);
- gs_matrix_multiply(&pxgs->text_ctm, &rmat, &pxgs->text_ctm);
- }
- return 0;
+ /* we must negate rotation angles. */
+ real angle = -real_value(par->pv[0], 0);
+ int code = gs_rotate(pxs->pgs, angle);
+
+ if ( code < 0 )
+ return code;
+ /* Post-multiply the text CTM by the rotation matrix. */
+ { gs_matrix rmat;
+ px_gstate_t *pxgs = pxs->pxgs;
+
+ gs_make_rotation(angle, &rmat);
+ gs_matrix_multiply(&pxgs->text_ctm, &rmat, &pxgs->text_ctm);
+ }
+ return 0;
}
const byte apxSetPageScale[] = {
@@ -1007,14 +1004,14 @@ const byte apxSetPageScale[] = {
int
pxSetPageScale(px_args_t *par, px_state_t *pxs)
-{
+{
int code;
real sx = 1;
real sy = 1;
static const real units_conversion_table[3][3] = {
{ 1, 25.4, 254 }, /* in -> in, mill, 1/10 mill */
{ 0.0394, 1, 10 }, /* mill -> in, mill, 1/10 mill */
- { 0.00394, .1, 1 } /* 1/10 mill -> in, mill, 1/10 mill */
+ { 0.00394, .1, 1 } /* 1/10 mill -> in, mill, 1/10 mill */
};
/* measuure and units of measure. Actually session user units
@@ -1034,8 +1031,8 @@ pxSetPageScale(px_args_t *par, px_state_t *pxs)
sy = pxs->units_per_measure.y / suy;
/* check for overflow. NB we should do a better job here */
if ( fabs(sx) > 1000.0 ) {
- dprintf2("warning probable overflow avoided for scaling factors %f %f\n",
- sx, sy );
+ dprintf2("warning probable overflow avoided for scaling factors %f %f\n",
+ sx, sy );
sx = sy = 1;
}
}
@@ -1047,7 +1044,7 @@ pxSetPageScale(px_args_t *par, px_state_t *pxs)
if ( code < 0 )
return code;
/* Post-multiply the text CTM by the scale matrix. */
- {
+ {
gs_matrix smat;
px_gstate_t *pxgs = pxs->pxgs;
gs_make_scaling(sx, sy, &smat);
@@ -1062,7 +1059,7 @@ const byte apxSetPaintTxMode[] = {
int
pxSetPaintTxMode(px_args_t *par, px_state_t *pxs)
{ gs_settexturetransparent(pxs->pgs, par->pv[0]->value.i == eTransparent);
- return 0;
+ return 0;
}
const byte apxSetPenWidth[] = {
@@ -1079,7 +1076,7 @@ const byte apxSetROP[] = {
int
pxSetROP(px_args_t *par, px_state_t *pxs)
{ gs_setrasterop(pxs->pgs, (gs_rop3_t)(par->pv[0]->value.i));
- return 0;
+ return 0;
}
const byte apxSetSourceTxMode[] = {
@@ -1088,7 +1085,7 @@ const byte apxSetSourceTxMode[] = {
int
pxSetSourceTxMode(px_args_t *par, px_state_t *pxs)
{ gs_setsourcetransparent(pxs->pgs, par->pv[0]->value.i == eTransparent);
- return 0;
+ return 0;
}
const byte apxSetCharBoldValue[] = {
@@ -1096,7 +1093,7 @@ const byte apxSetCharBoldValue[] = {
};
int
pxSetCharBoldValue(px_args_t *par, px_state_t *pxs)
-{
+{
float arg = real_value(par->pv[0], 0);
pxs->pxgs->char_bold_value = arg;
return 0;
@@ -1108,7 +1105,7 @@ const byte apxSetClipMode[] = {
int
pxSetClipMode(px_args_t *par, px_state_t *pxs)
{ pxs->pxgs->clip_mode = par->pv[0]->value.i;
- return 0;
+ return 0;
}
const byte apxSetPathToClip[] = {0, 0};
@@ -1123,21 +1120,21 @@ const byte apxSetCharSubMode[] = {
int
pxSetCharSubMode(px_args_t *par, px_state_t *pxs)
{ /*
- * It isn't clear from the documentation why the attribute is an
- * array rather than just a Boolean, but we have to assume there
- * is some reason for this.
- */
- const px_value_t *psubs = par->pv[0];
+ * It isn't clear from the documentation why the attribute is an
+ * array rather than just a Boolean, but we have to assume there
+ * is some reason for this.
+ */
+ const px_value_t *psubs = par->pv[0];
pxeCharSubModeArray_t arg;
- if ( psubs->value.array.size != 1 ||
- psubs->value.array.data[0] >= pxeCharSubModeArray_next
- )
- return_error(errorIllegalAttributeValue);
+ if ( psubs->value.array.size != 1 ||
+ psubs->value.array.data[0] >= pxeCharSubModeArray_next
+ )
+ return_error(errorIllegalAttributeValue);
arg = psubs->value.array.data[0];
if (pxs->pxgs->char_sub_mode != arg) {
pxs->pxgs->char_sub_mode = arg;
px_purge_character_cache(pxs);
}
- return 0;
+ return 0;
}
diff --git a/pxl/pxgstate.h b/pxl/pxgstate.h
index 4ef8f4a7d..e3b191df5 100644
--- a/pxl/pxgstate.h
+++ b/pxl/pxgstate.h
@@ -57,11 +57,11 @@ typedef struct px_bitmap_params_s {
/* Define the structure for downloaded raster patterns. */
typedef struct px_pattern_s {
rc_header rc; /* counts refs from gstates, dicts */
- /* Original parameters */
+ /* Original parameters */
px_bitmap_params_t params;
gs_string palette; /* copy of palette if indexed color */
byte *data; /* raster data */
- /* Internal values */
+ /* Internal values */
gx_bitmap_id id; /* PCL XL ID * #persistence + persistence */
} px_pattern_t;
#define private_st_px_pattern() /* in pximage.c */\
@@ -110,10 +110,10 @@ typedef enum {
/* Define the PCL XL extension of the PostScript graphics state. */
typedef struct px_gstate_s {
gs_memory_t *memory;
- /* Since this is what the 'client data' of the gs_state points to, */
- /* we need a pointer back to the px_state_t. */
+ /* Since this is what the 'client data' of the gs_state points to, */
+ /* we need a pointer back to the px_state_t. */
px_state_t *pxs;
- /* State information */
+ /* State information */
px_paint_t brush;
float char_angle;
float char_bold_value;
@@ -138,7 +138,7 @@ typedef struct px_gstate_s {
struct ht_ {
pxeDitherMatrix_t method;
bool set; /* true if we have done gs_sethalftone */
- /* with these parameters */
+ /* with these parameters */
uint width;
uint height;
gs_point origin;
@@ -149,11 +149,11 @@ typedef struct px_gstate_s {
bool dashed;
gs_matrix dash_matrix;
px_paint_t pen;
- /* Pattern dictionary */
+ /* Pattern dictionary */
px_dict_t temp_pattern_dict;
- /* Cached values */
+ /* Cached values */
gs_matrix text_ctm; /* scale/rotate transformations applied in */
- /* the reverse order */
+ /* the reverse order */
gs_matrix char_matrix; /* char_size+angle+scale+shear */
bool char_matrix_set;
int stack_depth; /* # of unmatched PushGS */
diff --git a/pxl/pximage.c b/pxl/pximage.c
index 091210ace..ceab23f04 100644
--- a/pxl/pximage.c
+++ b/pxl/pximage.c
@@ -51,17 +51,17 @@
void
px_free_pattern(gs_memory_t *mem, void *vptr, client_name_t cname)
{ px_pattern_t *pattern = vptr;
- rc_decrement(pattern, cname);
+ rc_decrement(pattern, cname);
}
/* Define the real freeing procedure for patterns. */
static void
rc_free_px_pattern(gs_memory_t *mem, void *vptr, client_name_t cname)
{ px_pattern_t *pattern = vptr;
- gs_free_string(mem, (void *)pattern->palette.data, pattern->palette.size,
- cname);
- gs_free_object(mem, pattern->data, cname);
- gs_free_object(mem, pattern, cname);
+ gs_free_string(mem, (void *)pattern->palette.data, pattern->palette.size,
+ cname);
+ gs_free_object(mem, pattern->data, cname);
+ gs_free_object(mem, pattern, cname);
}
/* Define the purging procedure for the Pattern cache. */
/* The proc_data points to a pxePatternPersistence_t that specifies */
@@ -69,16 +69,15 @@ rc_free_px_pattern(gs_memory_t *mem, void *vptr, client_name_t cname)
static bool
px_pattern_purge_proc(gx_color_tile *ctile, void *proc_data)
{ return ctile->uid.id % pxePatternPersistence_next <=
- *(pxePatternPersistence_t *)proc_data;
+ *(pxePatternPersistence_t *)proc_data;
}
void
px_purge_pattern_cache(px_state_t *pxs, pxePatternPersistence_t max_persist)
{ gx_pattern_cache_winnow(gstate_pattern_cache(pxs->pgs),
- px_pattern_purge_proc,
- (void *)&max_persist);
+ px_pattern_purge_proc,
+ (void *)&max_persist);
}
-
/* pxl delta row decompression state machine states */
typedef enum {
next_is_bytecount,
@@ -92,8 +91,8 @@ typedef enum {
typedef struct deltarow_state_s {
deltarow_parse_state_t state;
uint row_byte_count;
- uint short_cnt;
- uint short_offset;
+ uint short_cnt;
+ uint short_offset;
byte *seedrow;
uint rowwritten;
} deltarow_state_t;
@@ -135,30 +134,30 @@ static int
begin_bitmap(px_bitmap_params_t *params, px_bitmap_enum_t *benum,
const px_args_t *par, const px_state_t *pxs)
{ px_gstate_t *pxgs = pxs->pxgs;
- int depth = "\001\004\010"[par->pv[1]->value.i];
- int num_components = (pxgs->color_space == eGray ? 1 : 3);
-
- params->width = par->pv[2]->value.i;
- params->height = par->pv[3]->value.i;
- params->depth = depth;
- params->color_space = pxgs->color_space;
- if ( par->pv[0]->value.i == eIndexedPixel )
- { if ( pxgs->palette.data == 0 )
- return_error(errorMissingPalette);
- if ( pxgs->palette.size != (1 << depth) * num_components )
- return_error( errorImagePaletteMismatch);
- params->indexed = true;
- num_components = 1;
- }
- else
- params->indexed = false;
- params->dest_width = real_value(par->pv[4], 0);
- params->dest_height = real_value(par->pv[4], 1);
- benum->data_per_row =
- round_up(params->width * params->depth * num_components, 8) >> 3;
- benum->mem = pxs->memory;
- benum->initialized = false;
- return 0;
+ int depth = "\001\004\010"[par->pv[1]->value.i];
+ int num_components = (pxgs->color_space == eGray ? 1 : 3);
+
+ params->width = par->pv[2]->value.i;
+ params->height = par->pv[3]->value.i;
+ params->depth = depth;
+ params->color_space = pxgs->color_space;
+ if ( par->pv[0]->value.i == eIndexedPixel )
+ { if ( pxgs->palette.data == 0 )
+ return_error(errorMissingPalette);
+ if ( pxgs->palette.size != (1 << depth) * num_components )
+ return_error( errorImagePaletteMismatch);
+ params->indexed = true;
+ num_components = 1;
+ }
+ else
+ params->indexed = false;
+ params->dest_width = real_value(par->pv[4], 0);
+ params->dest_height = real_value(par->pv[4], 1);
+ benum->data_per_row =
+ round_up(params->width * params->depth * num_components, 8) >> 3;
+ benum->mem = pxs->memory;
+ benum->initialized = false;
+ return 0;
}
static int
@@ -168,7 +167,6 @@ stream_error(stream_state * st, const char *str)
return 0;
}
-
static int
read_jpeg_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
{
@@ -248,12 +246,12 @@ read_uncompressed_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *
if ( par->source.position >= data_per_row_padded * par->pv[1]->value.i )
return 0;
- if ( avail >= data_per_row_padded && pos_in_row == 0 ) {
+ if ( avail >= data_per_row_padded && pos_in_row == 0 ) {
/* Use the data directly from the input buffer. */
*pdata = (byte *)data;
used = data_per_row_padded;
code = 1;
- } else {
+ } else {
used = min(avail, data_per_row_padded - pos_in_row);
if ( pos_in_row < data_per_row )
memcpy(*pdata + pos_in_row, data,
@@ -296,7 +294,7 @@ read_rle_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
}
r.ptr = data - 1;
r.limit = r.ptr + avail;
- if ( pos_in_row < data_per_row ) {
+ if ( pos_in_row < data_per_row ) {
/* Read more of the current row. */
byte *data = *pdata;
@@ -310,7 +308,7 @@ read_rle_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
if ( pos_in_row >= data_per_row && pos_in_row < data_per_row_padded )
{ /* We've read all the real data; skip the padding. */
byte pad[3]; /* maximum padding per row */
-
+
w.ptr = pad - 1;
w.limit = w.ptr + data_per_row_padded - pos_in_row;
(*s_RLD_template.process)((stream_state *)ss, &r, &w, false);
@@ -325,9 +323,9 @@ read_rle_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
return (pos_in_row < data_per_row_padded ? pxNeedData : 1);
}
-/** PCL XL delta row decompression
+/** PCL XL delta row decompression
*
- * delta row Algorithm:
+ * delta row Algorithm:
*
* Seed Row is initialized with zeros.
*
@@ -337,42 +335,42 @@ read_rle_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
*
* if row byte count is zero duplicate previous row
* if row byte count doesn't fill row duplicate remainder and end the row (undocumented)
- *
+ *
* delta row data: command byte, optional extra offset bytes, delta raster snippit
- * command byte 7-5 delta raster length: 4-0 offset
+ * command byte 7-5 delta raster length: 4-0 offset
*
* offset = bits 4-0;
- * if offset == 31 then do { add next byte } repeat while next byte was 0xFF
+ * if offset == 31 then do { add next byte } repeat while next byte was 0xFF
* example offset = 31 + 255 + 255 + 255 + 4
*
- * delta length = bits 5-7 + 1; range 1 to 8 bytes.
- *
+ * delta length = bits 5-7 + 1; range 1 to 8 bytes.
+ *
* output raster is:
* last position + offset; "copies" old data
- * copy delta length bytes from input to output
- *
+ * copy delta length bytes from input to output
+ *
* Internal Algorithm:
- *
+ *
* No row padding is used.
- * State is need since available data can be short at any time.
- * read = *pin++; // out of data? save state, return eNeedData
- *
+ * State is need since available data can be short at any time.
+ * read = *pin++; // out of data? save state, return eNeedData
+ *
* deltarow.state maintains state between requests for more data
* state : description
* -> next state
- * ---------------------------------------
- * next_is_bytecount : lsb of row bytecount
+ * ---------------------------------------
+ * next_is_bytecount : lsb of row bytecount
* -> partial_bytecount
* partial_bytecount : msb of row bytecount
* -> next_is_cmd
* next_is_cmd : 1 byte cmd contains cnt and partial offset
* -> partial_offset or partial_cnt
- * partial_offset : accumulates extra offset bytes, moves output by offset
+ * partial_offset : accumulates extra offset bytes, moves output by offset
* -> partial_offset or partial_cnt
* partial_cnt : copies cnt bytes one at a time from input
- * -> partial_cnt or next_is_cmd or (next_bytecount && end_of_row)
+ * -> partial_cnt or next_is_cmd or (next_bytecount && end_of_row)
*
- * RETURN values:
+ * RETURN values:
* 0 == end of image // end of row returns, next call returns end of image.
* 1 == end of row
* eNeedData == on need more input
@@ -393,7 +391,7 @@ read_deltarow_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
}
/* initialize at begin of image */
- if ( !benum->initialized ) {
+ if ( !benum->initialized ) {
/* zero seed row */
deltarow->seedrow = gs_alloc_bytes(benum->mem, benum->data_per_row, "read_deltarow_bitmap_data");
memset(deltarow->seedrow, 0, benum->data_per_row);
@@ -404,36 +402,36 @@ read_deltarow_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
deltarow->rowwritten = 0;
benum->initialized = true;
}
-
+
if (deltarow->row_byte_count == 0) {
memcpy(*pdata, deltarow->seedrow, benum->data_per_row);
}
-
+
/* one byte at a time until end of input or end of row */
while (avail && !end_of_row) {
switch ( deltarow->state ) {
case next_is_bytecount:{
- deltarow->short_cnt = *pin++;
- --avail;
+ deltarow->short_cnt = *pin++;
+ --avail;
deltarow->state = partial_bytecount;
break;
}
-
+
case partial_bytecount: {
deltarow->row_byte_count = deltarow->short_cnt + ((*pin++) << 8 );
--avail;
-
+
if ( deltarow->row_byte_count == 0 ) {
- /* duplicate the row */
- deltarow->state = next_is_bytecount;
- end_of_row = true;
+ /* duplicate the row */
+ deltarow->state = next_is_bytecount;
+ end_of_row = true;
}
else
- deltarow->state = next_is_cmd;
+ deltarow->state = next_is_cmd;
break;
}
-
+
case next_is_cmd: {
uint val = *pin++;
@@ -441,11 +439,11 @@ read_deltarow_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
deltarow->row_byte_count--;
deltarow->short_cnt = (val >> 5) + 1; /* 1 to 8 new bytes to copy */
deltarow->short_offset = val & 0x1f; /* num to retain from last row, skip */
- if (deltarow->short_offset == 0x1f)
- deltarow->state = partial_offset; /* accumulate more offset */
+ if (deltarow->short_offset == 0x1f)
+ deltarow->state = partial_offset; /* accumulate more offset */
else {
- pout += deltarow->short_offset; /* skip keeps old data in row */
- deltarow->state = partial_cnt; /* done with offset do count */
+ pout += deltarow->short_offset; /* skip keeps old data in row */
+ deltarow->state = partial_cnt; /* done with offset do count */
}
break;
}
@@ -454,14 +452,14 @@ read_deltarow_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
uint offset = *pin++;
avail--;
deltarow->row_byte_count--;
-
+
deltarow->short_offset += offset;
-
- if (offset == 0xff)
- deltarow->state = partial_offset; /* 0x1f + ff ff ff ff ff + 1 */
+
+ if (offset == 0xff)
+ deltarow->state = partial_offset; /* 0x1f + ff ff ff ff ff + 1 */
else {
- pout += deltarow->short_offset; /* skip keeps old data in row */
- deltarow->state = partial_cnt; /* done with offset do count */
+ pout += deltarow->short_offset; /* skip keeps old data in row */
+ deltarow->state = partial_cnt; /* done with offset do count */
}
break;
}
@@ -474,27 +472,26 @@ read_deltarow_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
avail--;
deltarow->row_byte_count--;
deltarow->short_cnt--;
-
- if (deltarow->row_byte_count == 0) {
- end_of_row = true;
- deltarow->state = next_is_bytecount;
+
+ if (deltarow->row_byte_count == 0) {
+ end_of_row = true;
+ deltarow->state = next_is_bytecount;
}
- else if (deltarow->short_cnt == 0)
- deltarow->state = next_is_cmd;
+ else if (deltarow->short_cnt == 0)
+ deltarow->state = next_is_cmd;
/* else more bytes to copy */
break;
}
} /* end switch */
} /* end of while */
-
par->source.available -= pin - par->source.data; /* subract comressed data used */
par->source.data = pin; /* new compressed data position */
if (end_of_row) {
/* uncompressed raster position */
- par->source.position =
+ par->source.position =
(par->source.position / benum->data_per_row + 1) * benum->data_per_row;
deltarow->rowwritten++;
memcpy(deltarow->seedrow, *pdata, benum->data_per_row);
@@ -517,7 +514,7 @@ read_deltarow_bitmap_data(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
*/
static int
read_bitmap(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
-{
+{
benum->compress_type = par->pv[2]->value.i;
switch( benum->compress_type ) {
case eRLECompression:
@@ -534,7 +531,6 @@ read_bitmap(px_bitmap_enum_t *benum, byte **pdata, px_args_t *par)
return -1;
}
-
/* ---------------- Image operators ---------------- */
const byte apxBeginImage[] = {
@@ -544,88 +540,88 @@ const byte apxBeginImage[] = {
int
pxBeginImage(px_args_t *par, px_state_t *pxs)
{ gs_point origin;
- px_bitmap_params_t params;
- px_bitmap_enum_t benum;
- gs_state *pgs = pxs->pgs;
- px_gstate_t *pxgs = pxs->pxgs;
- px_image_enum_t *pxenum;
- int code;
-
- if ( gs_currentpoint(pgs, &origin) < 0 )
- return_error(errorCurrentCursorUndefined);
- /*
- * If the current logical operation doesn't involve the texture,
- * don't set a null brush, which would cause the image not to
- * appear.
- */
- if ( pxs->pxgs->brush.type == pxpNull &&
- !rop3_uses_T(gs_currentrasterop(pgs))
+ px_bitmap_params_t params;
+ px_bitmap_enum_t benum;
+ gs_state *pgs = pxs->pgs;
+ px_gstate_t *pxgs = pxs->pxgs;
+ px_image_enum_t *pxenum;
+ int code;
+
+ if ( gs_currentpoint(pgs, &origin) < 0 )
+ return_error(errorCurrentCursorUndefined);
+ /*
+ * If the current logical operation doesn't involve the texture,
+ * don't set a null brush, which would cause the image not to
+ * appear.
+ */
+ if ( pxs->pxgs->brush.type == pxpNull &&
+ !rop3_uses_T(gs_currentrasterop(pgs))
) {
if ( pxs->useciecolor )
code = pl_setSRGBcolor(pgs, 0.0, 0.0, 0.0);
else
code = gs_setgray(pgs, 0.0);
}
- else
- code = px_set_paint(&pxgs->brush, pxs);
- if ( code < 0 )
- return code;
- /*
- * Make sure the proper halftone is current.
- */
- code = px_set_halftone(pxs);
- if ( code < 0 )
- return code;
- code = begin_bitmap(&params, &benum, par, pxs);
- if ( code < 0 )
- return code;
- pxenum =
- gs_alloc_struct(pxs->memory, px_image_enum_t,
- &st_px_image_enum, "setup_bitmap(pxenum)");
-
- if ( pxenum == 0 )
- return_error(errorInsufficientMemory);
- {
+ else
+ code = px_set_paint(&pxgs->brush, pxs);
+ if ( code < 0 )
+ return code;
+ /*
+ * Make sure the proper halftone is current.
+ */
+ code = px_set_halftone(pxs);
+ if ( code < 0 )
+ return code;
+ code = begin_bitmap(&params, &benum, par, pxs);
+ if ( code < 0 )
+ return code;
+ pxenum =
+ gs_alloc_struct(pxs->memory, px_image_enum_t,
+ &st_px_image_enum, "setup_bitmap(pxenum)");
+
+ if ( pxenum == 0 )
+ return_error(errorInsufficientMemory);
+ {
pxenum->raster = round_up(benum.data_per_row, align_bitmap_mod);
pxenum->row = gs_alloc_byte_array(pxs->memory, 1, pxenum->raster,
"pxReadImage(row)");
- if ( pxenum->row == 0 )
- code = gs_note_error(errorInsufficientMemory);
- else
- code = px_image_color_space(&pxenum->image, &params, (const gs_string *)&pxgs->palette, pgs);
- }
- if ( code < 0 )
- { gs_free_object(pxs->memory, pxenum->row, "pxReadImage(row)");
- gs_free_object(pxs->memory, pxenum, "pxReadImage(pxenum)");
- return code;
- }
- /* Set up the image parameters. */
- pxenum->image.Width = params.width;
- pxenum->image.Height = params.height;
- { gs_matrix imat, dmat;
- /* We need the cast because height is unsigned. */
- /* We also need to account for the upside-down H-P */
- /* coordinate system. */
- gs_make_scaling(params.width, params.height, &imat);
- gs_make_translation(origin.x, origin.y, &dmat);
- gs_matrix_scale(&dmat, params.dest_width, params.dest_height,
- &dmat);
- /* The ImageMatrix is dmat' * imat. */
- gs_matrix_invert(&dmat, &dmat);
- gs_matrix_multiply(&dmat, &imat, &pxenum->image.ImageMatrix);
- }
- pxenum->image.CombineWithColor = true;
+ if ( pxenum->row == 0 )
+ code = gs_note_error(errorInsufficientMemory);
+ else
+ code = px_image_color_space(&pxenum->image, &params, (const gs_string *)&pxgs->palette, pgs);
+ }
+ if ( code < 0 )
+ { gs_free_object(pxs->memory, pxenum->row, "pxReadImage(row)");
+ gs_free_object(pxs->memory, pxenum, "pxReadImage(pxenum)");
+ return code;
+ }
+ /* Set up the image parameters. */
+ pxenum->image.Width = params.width;
+ pxenum->image.Height = params.height;
+ { gs_matrix imat, dmat;
+ /* We need the cast because height is unsigned. */
+ /* We also need to account for the upside-down H-P */
+ /* coordinate system. */
+ gs_make_scaling(params.width, params.height, &imat);
+ gs_make_translation(origin.x, origin.y, &dmat);
+ gs_matrix_scale(&dmat, params.dest_width, params.dest_height,
+ &dmat);
+ /* The ImageMatrix is dmat' * imat. */
+ gs_matrix_invert(&dmat, &dmat);
+ gs_matrix_multiply(&dmat, &imat, &pxenum->image.ImageMatrix);
+ }
+ pxenum->image.CombineWithColor = true;
pxenum->image.Interpolate = pxs->interpolate;
- code = pl_begin_image(pgs, &pxenum->image, &pxenum->info);
- if ( code < 0 )
- { gs_free_object(pxs->memory, pxenum->row, "pxReadImage(row)");
- gs_free_object(pxs->memory, pxenum, "pxBeginImage(pxenum)");
- return code;
- }
- pxenum->benum = benum;
- pxs->image_enum = pxenum;
- return 0;
+ code = pl_begin_image(pgs, &pxenum->image, &pxenum->info);
+ if ( code < 0 )
+ { gs_free_object(pxs->memory, pxenum->row, "pxReadImage(row)");
+ gs_free_object(pxs->memory, pxenum, "pxBeginImage(pxenum)");
+ return code;
+ }
+ pxenum->benum = benum;
+ pxs->image_enum = pxenum;
+ return 0;
}
const byte apxReadImage[] = {
@@ -634,10 +630,10 @@ const byte apxReadImage[] = {
int
pxReadImage(px_args_t *par, px_state_t *pxs)
-{
+{
px_image_enum_t *pxenum = pxs->image_enum;
gx_device *dev = gs_currentdevice(pxs->pgs);
-
+
if ( par->pv[1]->value.i == 0 )
return 0; /* no data */
/* Make a quick check for the first call, when no data is available. */
@@ -660,7 +656,7 @@ pxReadImage(px_args_t *par, px_state_t *pxs)
const byte apxEndImage[] = {0, 0};
int
pxEndImage(px_args_t *par, px_state_t *pxs)
-{
+{
gx_device *dev = gs_currentdevice(pxs->pgs);
px_image_enum_t *pxenum = pxs->image_enum;
px_bitmap_enum_t *pbenum = &pxenum->benum;
@@ -699,55 +695,55 @@ const byte apxBeginRastPattern[] = {
int
pxBeginRastPattern(px_args_t *par, px_state_t *pxs)
{ gs_memory_t *mem = pxs->memory;
- px_bitmap_params_t params;
- px_pattern_t *pattern;
- px_pattern_enum_t *pxenum;
- px_bitmap_enum_t benum;
- byte *data;
- uint psize;
- byte *pdata;
- int code = begin_bitmap(&params, &benum, par, pxs);
- static const gs_memory_struct_type_t st_px_pattern =
+ px_bitmap_params_t params;
+ px_pattern_t *pattern;
+ px_pattern_enum_t *pxenum;
+ px_bitmap_enum_t benum;
+ byte *data;
+ uint psize;
+ byte *pdata;
+ int code = begin_bitmap(&params, &benum, par, pxs);
+ static const gs_memory_struct_type_t st_px_pattern =
{sizeof(px_pattern_t), "", 0, 0, 0, 0, 0};
- if ( code < 0 )
- return code;
- rc_alloc_struct_1(pattern, px_pattern_t, &st_px_pattern, mem,
- return_error(errorInsufficientMemory),
- "raster pattern");
- pattern->rc.free = rc_free_px_pattern;
- data = gs_alloc_byte_array(mem, params.height, benum.data_per_row,
- "raster pattern data");
- if ( params.indexed )
- { psize = pxs->pxgs->palette.size;
- pdata = gs_alloc_string(mem, psize, "raster pattern palette");
- if ( pdata != 0 )
- memcpy(pdata, pxs->pxgs->palette.data, psize);
- }
- else
- { psize = 0;
- pdata = 0;
- }
- pxenum = gs_alloc_struct(mem, px_pattern_enum_t, &st_px_pattern_enum,
- "raster pattern enum");
- if ( data == 0 || (params.indexed && pdata == 0) || pxenum == 0 )
- { gs_free_object(mem, pxenum, "raster pattern enum");
- gs_free_string(mem, pdata, psize, "raster pattern palette");
- gs_free_object(mem, data, "raster pattern data");
- gs_free_object(mem, pattern, "raster pattern");
- return_error(errorInsufficientMemory);
- }
- pxenum->benum = benum;
- pxenum->pattern_id = par->pv[5]->value.i;
- pxenum->persistence = par->pv[6]->value.i;
- pattern->params = params;
- pattern->palette.data = pdata;
- pattern->palette.size = psize;
- pattern->data = data;
- pattern->id = gs_next_ids(mem, 1);
- pxenum->pattern = pattern;
- pxs->pattern_enum = pxenum;
- return 0;
+ if ( code < 0 )
+ return code;
+ rc_alloc_struct_1(pattern, px_pattern_t, &st_px_pattern, mem,
+ return_error(errorInsufficientMemory),
+ "raster pattern");
+ pattern->rc.free = rc_free_px_pattern;
+ data = gs_alloc_byte_array(mem, params.height, benum.data_per_row,
+ "raster pattern data");
+ if ( params.indexed )
+ { psize = pxs->pxgs->palette.size;
+ pdata = gs_alloc_string(mem, psize, "raster pattern palette");
+ if ( pdata != 0 )
+ memcpy(pdata, pxs->pxgs->palette.data, psize);
+ }
+ else
+ { psize = 0;
+ pdata = 0;
+ }
+ pxenum = gs_alloc_struct(mem, px_pattern_enum_t, &st_px_pattern_enum,
+ "raster pattern enum");
+ if ( data == 0 || (params.indexed && pdata == 0) || pxenum == 0 )
+ { gs_free_object(mem, pxenum, "raster pattern enum");
+ gs_free_string(mem, pdata, psize, "raster pattern palette");
+ gs_free_object(mem, data, "raster pattern data");
+ gs_free_object(mem, pattern, "raster pattern");
+ return_error(errorInsufficientMemory);
+ }
+ pxenum->benum = benum;
+ pxenum->pattern_id = par->pv[5]->value.i;
+ pxenum->persistence = par->pv[6]->value.i;
+ pattern->params = params;
+ pattern->palette.data = pdata;
+ pattern->palette.size = psize;
+ pattern->data = data;
+ pattern->id = gs_next_ids(mem, 1);
+ pxenum->pattern = pattern;
+ pxs->pattern_enum = pxenum;
+ return 0;
}
const byte apxReadRastPattern[] = {
@@ -757,66 +753,66 @@ const byte apxReadRastPattern[] = {
int
pxReadRastPattern(px_args_t *par, px_state_t *pxs)
{ px_pattern_enum_t *pxenum = pxs->pattern_enum;
- int code;
- uint input_per_row = round_up(pxenum->benum.data_per_row, 4);
- if ( par->pv[3] )
- input_per_row = round_up(pxenum->benum.data_per_row, par->pv[3]->value.i);
- /* Make a quick check for the first call, when no data is available. */
- if ( par->source.available == 0 && par->pv[1]->value.i != 0 )
- return pxNeedData;
+ int code;
+ uint input_per_row = round_up(pxenum->benum.data_per_row, 4);
+ if ( par->pv[3] )
+ input_per_row = round_up(pxenum->benum.data_per_row, par->pv[3]->value.i);
+ /* Make a quick check for the first call, when no data is available. */
+ if ( par->source.available == 0 && par->pv[1]->value.i != 0 )
+ return pxNeedData;
/* emulate hp bug */
{
pxeCompressMode_t c = par->pv[2]->value.i;
if ( c == eDeltaRowCompression || c == eJPEGCompression )
input_per_row = pxenum->benum.data_per_row;
}
- for ( ; ; )
- {
- byte *data = pxenum->pattern->data +
- (par->pv[0]->value.i +
- par->source.position / input_per_row)
- * pxenum->benum.data_per_row;
- byte *rdata = data;
-
- code = read_bitmap(&pxenum->benum, &rdata, par);
- if ( code != 1 )
- break;
- if ( rdata != data )
- memcpy(data, rdata, pxenum->benum.data_per_row);
- }
- return code;
+ for ( ; ; )
+ {
+ byte *data = pxenum->pattern->data +
+ (par->pv[0]->value.i +
+ par->source.position / input_per_row)
+ * pxenum->benum.data_per_row;
+ byte *rdata = data;
+
+ code = read_bitmap(&pxenum->benum, &rdata, par);
+ if ( code != 1 )
+ break;
+ if ( rdata != data )
+ memcpy(data, rdata, pxenum->benum.data_per_row);
+ }
+ return code;
}
const byte apxEndRastPattern[] = {0, 0};
int
pxEndRastPattern(px_args_t *par, px_state_t *pxs)
{ px_pattern_enum_t *pxenum = pxs->pattern_enum;
- /* We extract the key and value from the pattern_enum structure */
- /* and then free the structure, to encourage LIFO allocation. */
- px_pattern_t *pattern = pxenum->pattern;
- int32_t id = pxenum->pattern_id;
- px_value_t key;
- px_dict_t *pdict;
-
- switch ( pxenum->persistence )
- {
- case eTempPattern:
- pdict = &pxs->pxgs->temp_pattern_dict;
- break;
- case ePagePattern:
- pdict = &pxs->page_pattern_dict;
- break;
- case eSessionPattern:
- pdict = &pxs->session_pattern_dict;
- break;
- default: /* can't happen */
- return_error(errorIllegalAttributeValue);
- }
- key.type = pxd_array | pxd_ubyte;
- key.value.array.data = (byte *)&id;
- key.value.array.size = sizeof(id);
- gs_free_object(pxs->memory, pxenum, "pxEndRastPattern(pxenum)");
- return px_dict_put(pdict, &key, pattern);
+ /* We extract the key and value from the pattern_enum structure */
+ /* and then free the structure, to encourage LIFO allocation. */
+ px_pattern_t *pattern = pxenum->pattern;
+ int32_t id = pxenum->pattern_id;
+ px_value_t key;
+ px_dict_t *pdict;
+
+ switch ( pxenum->persistence )
+ {
+ case eTempPattern:
+ pdict = &pxs->pxgs->temp_pattern_dict;
+ break;
+ case ePagePattern:
+ pdict = &pxs->page_pattern_dict;
+ break;
+ case eSessionPattern:
+ pdict = &pxs->session_pattern_dict;
+ break;
+ default: /* can't happen */
+ return_error(errorIllegalAttributeValue);
+ }
+ key.type = pxd_array | pxd_ubyte;
+ key.value.array.data = (byte *)&id;
+ key.value.array.size = sizeof(id);
+ gs_free_object(pxs->memory, pxenum, "pxEndRastPattern(pxenum)");
+ return px_dict_put(pdict, &key, pattern);
}
/* ---------------- Scan line operators ---------------- */
@@ -826,10 +822,10 @@ int
pxBeginScan(px_args_t *par, px_state_t *pxs)
{ int code = px_set_paint(&pxs->pxgs->brush, pxs);
- if ( code < 0 )
- return code;
- /* We may as well reset the path now instead of at the end. */
- return gs_newpath(pxs->pgs);
+ if ( code < 0 )
+ return code;
+ /* We may as well reset the path now instead of at the end. */
+ return gs_newpath(pxs->pgs);
}
const byte apxEndScan[] = {0, 0};
@@ -844,128 +840,128 @@ const byte apxScanLineRel[] = {
int
pxScanLineRel(px_args_t *par, px_state_t *pxs)
{ /*
- * In order to keep the number of intermediate states down to a
- * reasonable number, we require enough data to be present to be
- * able to read the control information for each line, or an entire
- * x-pair. Initially, source.position is zero. As soon as we have
- * read the X/YStart type byte, we change it to:
- * (X/YStart type) << 28 + (x-pair type << 24) +
- * (# of full or partial scan lines left to process) + 1
- * We use the separate variable source.count to keep track of
- * the number of x-pairs left in the scan line.
- */
- gs_state *pgs = pxs->pgs;
- bool big_endian = pxs->data_source_big_endian;
- const byte *data = par->source.data;
- pxeDataType_t
- xystart_type = (par->source.position >> 28) & 0xf,
- xpair_type = (par->source.position >> 24) & 0xf;
- int code = 0;
- int rcount;
- gs_rect rlist[20]; /* 20 is arbitrary */
-
- /* Check for initial state. */
- if ( par->source.position == 0 )
- { /* Read XStart/YStart data type. */
- if ( par->source.available < 1 )
- return pxNeedData;
- xystart_type = data[0];
- if ( xystart_type != eSInt16 )
- return_error(errorIllegalDataValue);
- par->source.position =
- ((ulong)xystart_type << 28) +
- (par->pv[0] ? par->pv[0]->value.i : 1) + 1;
- par->source.data = data += 1;
- par->source.available -= 1;
- par->source.count = 0;
- }
- for ( rcount = 0; ; )
- {
-
- /* Check for start of scan line. */
- if ( par->source.count == 0 )
- { int ystart;
-
- if ( (par->source.position & 0xffffff) == 1 )
- { code = 0;
- break;
- }
- /* Read XStart and YStart values. */
- /* We know that eSInt16 is the only possible data type. */
- if ( par->source.available < 7 )
- { code = pxNeedData;
- break;
- }
- pxs->scan_point.x = sint16at(data, big_endian);
- ystart = sint16at(data + 2, big_endian);
- pxs->scan_point.y0 = ystart - 0.5;
- pxs->scan_point.y1 = ystart + 0.5;
- par->source.count = uint16at(data + 4, big_endian);
- if ( par->source.count == 0 )
- { code = gs_note_error(errorIllegalDataValue);
- break;
- }
- xpair_type = data[6];
- par->source.position =
- (par->source.position & 0xf0ffffff) +
- ((ulong)xpair_type << 24);
- par->source.data = data += 7;
- par->source.available -= 7;
- }
- /* Read and process one x-pair. */
- { uint x0, x1;
- uint used;
-
- switch ( xpair_type )
- {
- case eUByte:
- if ( par->source.available < 2 )
- { code = pxNeedData;
- goto out; /* 2-level break */
- }
- x0 = data[0];
- x1 = data[1];
- used = 2;
- break;
- case eUInt16:
- if ( par->source.available < 4 )
- { code = pxNeedData;
- goto out; /* 2-level break */
- }
- x0 = uint16at(data, big_endian);
- x1 = uint16at(data + 2, big_endian);
- used = 4;
- break;
- default:
- code = gs_note_error(errorIllegalDataValue);
- goto out; /* 2-level break; */
- }
- if ( rcount == countof(rlist) )
- { code = gs_rectfill(pgs, rlist, rcount);
- rcount = 0;
- pxs->have_page = true;
- if ( code < 0 )
- break;
- }
- { gs_rect *pr = &rlist[rcount++];
-
- pr->p.x = pxs->scan_point.x += x0;
- pr->p.y = pxs->scan_point.y0;
- pr->q.x = pxs->scan_point.x += x1;
- pr->q.y = pxs->scan_point.y1;
- }
- par->source.data = data += used;
- par->source.available -= used;
- }
- if ( !--(par->source.count) )
- --(par->source.position);
- }
+ * In order to keep the number of intermediate states down to a
+ * reasonable number, we require enough data to be present to be
+ * able to read the control information for each line, or an entire
+ * x-pair. Initially, source.position is zero. As soon as we have
+ * read the X/YStart type byte, we change it to:
+ * (X/YStart type) << 28 + (x-pair type << 24) +
+ * (# of full or partial scan lines left to process) + 1
+ * We use the separate variable source.count to keep track of
+ * the number of x-pairs left in the scan line.
+ */
+ gs_state *pgs = pxs->pgs;
+ bool big_endian = pxs->data_source_big_endian;
+ const byte *data = par->source.data;
+ pxeDataType_t
+ xystart_type = (par->source.position >> 28) & 0xf,
+ xpair_type = (par->source.position >> 24) & 0xf;
+ int code = 0;
+ int rcount;
+ gs_rect rlist[20]; /* 20 is arbitrary */
+
+ /* Check for initial state. */
+ if ( par->source.position == 0 )
+ { /* Read XStart/YStart data type. */
+ if ( par->source.available < 1 )
+ return pxNeedData;
+ xystart_type = data[0];
+ if ( xystart_type != eSInt16 )
+ return_error(errorIllegalDataValue);
+ par->source.position =
+ ((ulong)xystart_type << 28) +
+ (par->pv[0] ? par->pv[0]->value.i : 1) + 1;
+ par->source.data = data += 1;
+ par->source.available -= 1;
+ par->source.count = 0;
+ }
+ for ( rcount = 0; ; )
+ {
+
+ /* Check for start of scan line. */
+ if ( par->source.count == 0 )
+ { int ystart;
+
+ if ( (par->source.position & 0xffffff) == 1 )
+ { code = 0;
+ break;
+ }
+ /* Read XStart and YStart values. */
+ /* We know that eSInt16 is the only possible data type. */
+ if ( par->source.available < 7 )
+ { code = pxNeedData;
+ break;
+ }
+ pxs->scan_point.x = sint16at(data, big_endian);
+ ystart = sint16at(data + 2, big_endian);
+ pxs->scan_point.y0 = ystart - 0.5;
+ pxs->scan_point.y1 = ystart + 0.5;
+ par->source.count = uint16at(data + 4, big_endian);
+ if ( par->source.count == 0 )
+ { code = gs_note_error(errorIllegalDataValue);
+ break;
+ }
+ xpair_type = data[6];
+ par->source.position =
+ (par->source.position & 0xf0ffffff) +
+ ((ulong)xpair_type << 24);
+ par->source.data = data += 7;
+ par->source.available -= 7;
+ }
+ /* Read and process one x-pair. */
+ { uint x0, x1;
+ uint used;
+
+ switch ( xpair_type )
+ {
+ case eUByte:
+ if ( par->source.available < 2 )
+ { code = pxNeedData;
+ goto out; /* 2-level break */
+ }
+ x0 = data[0];
+ x1 = data[1];
+ used = 2;
+ break;
+ case eUInt16:
+ if ( par->source.available < 4 )
+ { code = pxNeedData;
+ goto out; /* 2-level break */
+ }
+ x0 = uint16at(data, big_endian);
+ x1 = uint16at(data + 2, big_endian);
+ used = 4;
+ break;
+ default:
+ code = gs_note_error(errorIllegalDataValue);
+ goto out; /* 2-level break; */
+ }
+ if ( rcount == countof(rlist) )
+ { code = gs_rectfill(pgs, rlist, rcount);
+ rcount = 0;
+ pxs->have_page = true;
+ if ( code < 0 )
+ break;
+ }
+ { gs_rect *pr = &rlist[rcount++];
+
+ pr->p.x = pxs->scan_point.x += x0;
+ pr->p.y = pxs->scan_point.y0;
+ pr->q.x = pxs->scan_point.x += x1;
+ pr->q.y = pxs->scan_point.y1;
+ }
+ par->source.data = data += used;
+ par->source.available -= used;
+ }
+ if ( !--(par->source.count) )
+ --(par->source.position);
+ }
out:
- if ( rcount > 0 && code >= 0 )
- { int rcode = gs_rectfill(pgs, rlist, rcount);
- pxs->have_page = true;
- if ( rcode < 0 )
- code = rcode;
- }
- return code;
+ if ( rcount > 0 && code >= 0 )
+ { int rcode = gs_rectfill(pgs, rlist, rcount);
+ pxs->have_page = true;
+ if ( rcode < 0 )
+ code = rcode;
+ }
+ return code;
}
diff --git a/pxl/pximpl.c b/pxl/pximpl.c
index 8bcddb065..453162661 100644
--- a/pxl/pximpl.c
+++ b/pxl/pximpl.c
@@ -23,8 +23,6 @@ extern const pl_interp_implementation_t pxl_implementation;
/* Zero-terminated list of pointers to implementations */
pl_interp_implementation_t const * const pdl_implementation[] = {
- &pxl_implementation,
- 0
+ &pxl_implementation,
+ 0
};
-
-
diff --git a/pxl/pxink.c b/pxl/pxink.c
index 7e202a5fc..70707120d 100644
--- a/pxl/pxink.c
+++ b/pxl/pxink.c
@@ -412,7 +412,6 @@ fraction_value(const px_value_t *pv, int i)
return (v < 0 ? 0 : v / int_type_max(type));
}
-
/* we use an enumeration instead of index numbers improve readability in this
"very busy" routine */
typedef enum {
@@ -859,4 +858,3 @@ pxSetAdaptiveHalftoning(px_args_t *par, px_state_t *pxs)
{
return 0;
}
-
diff --git a/pxl/pxoper.h b/pxl/pxoper.h
index 2579481c5..cd488556e 100644
--- a/pxl/pxoper.h
+++ b/pxl/pxoper.h
@@ -79,7 +79,7 @@ typedef struct px_parser_state_s px_parser_state_t;
typedef struct px_args_s {
struct ds_ {
ulong position; /* position in data block, initially 0, */
- /* provided for the operator's convenience */
+ /* provided for the operator's convenience */
uint count; /* another variable for the operators */
uint available; /* amount of data available in block */
bool phase; /* upon first call of the operator this will be 0. */
diff --git a/pxl/pxpaint.c b/pxl/pxpaint.c
index b70188e08..bdd6df9c8 100644
--- a/pxl/pxpaint.c
+++ b/pxl/pxpaint.c
@@ -74,58 +74,58 @@ add_lines(px_args_t *par, px_state_t *pxs,
int (*line_proc)(gs_state *, floatp, floatp))
{ int code = 0;
- if ( par->pv[0] )
- { /* Single segment, specified as argument. */
- if ( par->pv[1] || par->pv[2] )
- return_error(errorIllegalAttributeCombination);
- return (*line_proc)(pxs->pgs, real_value(par->pv[0], 0),
- real_value(par->pv[0], 1));
- }
- /* Multiple segments, specified in source data. */
- if ( !(par->pv[1] && par->pv[2]) )
- return_error(errorMissingAttribute);
- { int32_t num_points = par->pv[1]->value.i;
- pxeDataType_t type = (pxeDataType_t)par->pv[2]->value.i;
- int point_size = (type == eUByte || type == eSByte ? 2 : 4);
-
- while ( par->source.position < num_points * point_size )
- { const byte *dp = par->source.data;
- int px, py;
-
- if ( par->source.available < point_size )
- { /* We don't even have one point's worth of source data. */
- return pxNeedData;
- }
- switch ( type )
- {
- case eUByte:
- px = dp[0];
- py = dp[1];
- break;
- case eSByte:
- px = (int)(dp[0] ^ 0x80) - 0x80;
- py = (int)(dp[1] ^ 0x80) - 0x80;
- break;
- case eUInt16:
- px = uint16at(dp, pxs->data_source_big_endian);
- py = uint16at(dp + 2, pxs->data_source_big_endian);
- break;
- case eSInt16:
- px = sint16at(dp, pxs->data_source_big_endian);
- py = sint16at(dp + 2, pxs->data_source_big_endian);
- break;
- default: /* can't happen, pacify compiler */
- return_error(errorIllegalAttributeValue);
- }
- code = (*line_proc)(pxs->pgs, (floatp)px, (floatp)py);
- if ( code < 0 )
- break;
- par->source.position += point_size;
- par->source.available -= point_size;
- par->source.data += point_size;
- }
- }
- return code;
+ if ( par->pv[0] )
+ { /* Single segment, specified as argument. */
+ if ( par->pv[1] || par->pv[2] )
+ return_error(errorIllegalAttributeCombination);
+ return (*line_proc)(pxs->pgs, real_value(par->pv[0], 0),
+ real_value(par->pv[0], 1));
+ }
+ /* Multiple segments, specified in source data. */
+ if ( !(par->pv[1] && par->pv[2]) )
+ return_error(errorMissingAttribute);
+ { int32_t num_points = par->pv[1]->value.i;
+ pxeDataType_t type = (pxeDataType_t)par->pv[2]->value.i;
+ int point_size = (type == eUByte || type == eSByte ? 2 : 4);
+
+ while ( par->source.position < num_points * point_size )
+ { const byte *dp = par->source.data;
+ int px, py;
+
+ if ( par->source.available < point_size )
+ { /* We don't even have one point's worth of source data. */
+ return pxNeedData;
+ }
+ switch ( type )
+ {
+ case eUByte:
+ px = dp[0];
+ py = dp[1];
+ break;
+ case eSByte:
+ px = (int)(dp[0] ^ 0x80) - 0x80;
+ py = (int)(dp[1] ^ 0x80) - 0x80;
+ break;
+ case eUInt16:
+ px = uint16at(dp, pxs->data_source_big_endian);
+ py = uint16at(dp + 2, pxs->data_source_big_endian);
+ break;
+ case eSInt16:
+ px = sint16at(dp, pxs->data_source_big_endian);
+ py = sint16at(dp + 2, pxs->data_source_big_endian);
+ break;
+ default: /* can't happen, pacify compiler */
+ return_error(errorIllegalAttributeValue);
+ }
+ code = (*line_proc)(pxs->pgs, (floatp)px, (floatp)py);
+ if ( code < 0 )
+ break;
+ par->source.position += point_size;
+ par->source.available -= point_size;
+ par->source.data += point_size;
+ }
+ }
+ return code;
}
/* Add Bezier curves to the path. curve_proc is gs_curveto or gs_rcurveto. */
@@ -136,75 +136,75 @@ add_curves(px_args_t *par, px_state_t *pxs,
int (*curve_proc)(gs_state *, floatp, floatp, floatp, floatp, floatp, floatp))
{ int code = 0;
- if ( par->pv[2] && par->pv[3] && par->pv[4] )
- { /* Single curve, specified as argument. */
- if ( par->pv[0] || par->pv[1] )
- return_error(errorIllegalAttributeCombination);
- return (*curve_proc)(pxs->pgs, real_value(par->pv[2], 0),
- real_value(par->pv[2], 1),
- real_value(par->pv[3], 0),
- real_value(par->pv[3], 1),
- real_value(par->pv[4], 0),
- real_value(par->pv[4], 1));
- }
- /* Multiple segments, specified in source data. */
- else if ( par->pv[0] && par->pv[1] )
- { if ( par->pv[2] || par->pv[3] || par->pv[4] )
- return_error(errorIllegalAttributeCombination);
- }
- else
- return_error(errorMissingAttribute);
- { int32_t num_points = par->pv[0]->value.i;
- pxeDataType_t type = (pxeDataType_t)par->pv[1]->value.i;
- int point_size = (type == eUByte || type == eSByte ? 2 : 4);
- int segment_size = point_size * 3;
-
- if ( num_points % 3 )
- return_error(errorIllegalDataLength);
- while ( par->source.position < num_points * point_size )
- { const byte *dp = par->source.data;
- int points[6];
- int i;
-
- if ( par->source.available < point_size * 3 )
- { /* We don't even have one point's worth of source data. */
- return pxNeedData;
- }
- switch ( type )
- {
- case eUByte:
- for ( i = 0; i < 6; ++i )
- points[i] = dp[i];
- break;
- case eSByte:
- for ( i = 0; i < 6; ++i )
- points[i] = (int)(dp[i] ^ 0x80) - 0x80;
- break;
- case eUInt16:
- for ( i = 0; i < 12; i += 2 )
- points[i >> 1] =
- uint16at(dp + i, pxs->data_source_big_endian);
- break;
- case eSInt16:
- for ( i = 0; i < 12; i += 2 )
- points[i >> 1]
- = sint16at(dp + i, pxs->data_source_big_endian);
- break;
- default: /* can't happen, pacify compiler */
- return_error(errorIllegalAttributeValue);
- }
- code = (*curve_proc)(pxs->pgs,
- (floatp)points[0], (floatp)points[1],
- (floatp)points[2], (floatp)points[3],
- (floatp)points[4], (floatp)points[5]);
- if ( code < 0 )
- break;
- par->source.position += segment_size;
- par->source.available -= segment_size;
- par->source.data += segment_size;
- }
- }
- return code;
+ if ( par->pv[2] && par->pv[3] && par->pv[4] )
+ { /* Single curve, specified as argument. */
+ if ( par->pv[0] || par->pv[1] )
+ return_error(errorIllegalAttributeCombination);
+ return (*curve_proc)(pxs->pgs, real_value(par->pv[2], 0),
+ real_value(par->pv[2], 1),
+ real_value(par->pv[3], 0),
+ real_value(par->pv[3], 1),
+ real_value(par->pv[4], 0),
+ real_value(par->pv[4], 1));
+ }
+ /* Multiple segments, specified in source data. */
+ else if ( par->pv[0] && par->pv[1] )
+ { if ( par->pv[2] || par->pv[3] || par->pv[4] )
+ return_error(errorIllegalAttributeCombination);
+ }
+ else
+ return_error(errorMissingAttribute);
+ { int32_t num_points = par->pv[0]->value.i;
+ pxeDataType_t type = (pxeDataType_t)par->pv[1]->value.i;
+ int point_size = (type == eUByte || type == eSByte ? 2 : 4);
+ int segment_size = point_size * 3;
+
+ if ( num_points % 3 )
+ return_error(errorIllegalDataLength);
+ while ( par->source.position < num_points * point_size )
+ { const byte *dp = par->source.data;
+ int points[6];
+ int i;
+
+ if ( par->source.available < point_size * 3 )
+ { /* We don't even have one point's worth of source data. */
+ return pxNeedData;
+ }
+ switch ( type )
+ {
+ case eUByte:
+ for ( i = 0; i < 6; ++i )
+ points[i] = dp[i];
+ break;
+ case eSByte:
+ for ( i = 0; i < 6; ++i )
+ points[i] = (int)(dp[i] ^ 0x80) - 0x80;
+ break;
+ case eUInt16:
+ for ( i = 0; i < 12; i += 2 )
+ points[i >> 1] =
+ uint16at(dp + i, pxs->data_source_big_endian);
+ break;
+ case eSInt16:
+ for ( i = 0; i < 12; i += 2 )
+ points[i >> 1]
+ = sint16at(dp + i, pxs->data_source_big_endian);
+ break;
+ default: /* can't happen, pacify compiler */
+ return_error(errorIllegalAttributeValue);
+ }
+ code = (*curve_proc)(pxs->pgs,
+ (floatp)points[0], (floatp)points[1],
+ (floatp)points[2], (floatp)points[3],
+ (floatp)points[4], (floatp)points[5]);
+ if ( code < 0 )
+ break;
+ par->source.position += segment_size;
+ par->source.available -= segment_size;
+ par->source.data += segment_size;
+ }
+ }
+ return code;
}
/*
@@ -242,86 +242,86 @@ static int /* px_arc_type_t or error code */
setup_arc(px_arc_params_t *params, const px_value_t *pbox,
const px_value_t *pp3, const px_value_t *pp4, const px_state_t *pxs, bool ellipse)
{ real x1 = real_value(pbox, 0);
- real y1 = real_value(pbox, 1);
- real x2 = real_value(pbox, 2);
- real y2 = real_value(pbox, 3);
- real xc = (x1 + x2) * 0.5;
- real yc = (y1 + y2) * 0.5;
- real xr, yr;
- bool rotated;
- int code;
+ real y1 = real_value(pbox, 1);
+ real x2 = real_value(pbox, 2);
+ real y2 = real_value(pbox, 3);
+ real xc = (x1 + x2) * 0.5;
+ real yc = (y1 + y2) * 0.5;
+ real xr, yr;
+ bool rotated;
+ int code;
#ifdef REFLECT_NEGATIVE_ARCS
- rotated = x1 > x2;
- params->reversed = rotated ^ (y1 > y2);
+ rotated = x1 > x2;
+ params->reversed = rotated ^ (y1 > y2);
#else
- rotated = false;
- params->reversed = false;
+ rotated = false;
+ params->reversed = false;
#endif
- if ( x1 > x2 )
- { real temp = x1; x1 = x2; x2 = temp;
- }
- if ( y1 > y2 )
- { real temp = y1; y1 = y2; y2 = temp;
- }
- params->origin.x = x1;
- params->origin.y = y1;
- xr = (x2 - x1) * 0.5;
- yr = (y2 - y1) * 0.5;
- /* From what we can gather ellipses are degenerate if both
+ if ( x1 > x2 )
+ { real temp = x1; x1 = x2; x2 = temp;
+ }
+ if ( y1 > y2 )
+ { real temp = y1; y1 = y2; y2 = temp;
+ }
+ params->origin.x = x1;
+ params->origin.y = y1;
+ xr = (x2 - x1) * 0.5;
+ yr = (y2 - y1) * 0.5;
+ /* From what we can gather ellipses are degenerate if both
width and height of the bounding box are 0. Other objects
behave as expected. A 0 area bounding box is degenerate */
- if ( ellipse ) {
- /* The bounding box is degenerate, set what we can and exit. */
- if ( xr == 0 && yr == 0 ) {
- params->center.x = xc;
- params->center.y = yc;
- return arc_degenerate;
- }
- } else {
- if ( xr == 0 || yr == 0 ) {
- params->center.x = xc;
- params->center.y = yc;
- return arc_degenerate;
- }
- }
-
- if ( pp3 && pp4 )
- { real dx3 = real_value(pp3, 0) - xc;
- real dy3 = real_value(pp3, 1) - yc;
- real dx4 = real_value(pp4, 0) - xc;
- real dy4 = real_value(pp4, 1) - yc;
-
- if ( (dx3 == 0 && dy3 == 0) || (dx4 == 0 && dy4 == 0) )
- return_error(errorIllegalAttributeValue);
- { double ang3 = atan2(dy3 * xr, dx3 * yr) * radians_to_degrees;
- double ang4 = atan2(dy4 * xr, dx4 * yr) * radians_to_degrees;
-
- if ( rotated )
- ang3 += 180, ang4 += 180;
- params->ang3 = ang3;
- params->ang4 = ang4;
- }
- }
- params->radius = yr;
- if ( xr == yr )
- { params->center.x = xc;
- params->center.y = yc;
- return arc_square;
- }
- else
- { /* Must adjust the CTM. Move the origin to (xc,yc) */
- /* for simplicity. */
- if ( (code = gs_currentmatrix(pxs->pgs, &params->save_ctm)) < 0 ||
- (code = gs_translate(pxs->pgs, xc, yc)) < 0 ||
- (code = gs_scale(pxs->pgs, xr, yr)) < 0
- )
- return code;
- params->center.x = 0;
- params->center.y = 0;
- params->radius = 1.0;
- return arc_rectangular;
- }
+ if ( ellipse ) {
+ /* The bounding box is degenerate, set what we can and exit. */
+ if ( xr == 0 && yr == 0 ) {
+ params->center.x = xc;
+ params->center.y = yc;
+ return arc_degenerate;
+ }
+ } else {
+ if ( xr == 0 || yr == 0 ) {
+ params->center.x = xc;
+ params->center.y = yc;
+ return arc_degenerate;
+ }
+ }
+
+ if ( pp3 && pp4 )
+ { real dx3 = real_value(pp3, 0) - xc;
+ real dy3 = real_value(pp3, 1) - yc;
+ real dx4 = real_value(pp4, 0) - xc;
+ real dy4 = real_value(pp4, 1) - yc;
+
+ if ( (dx3 == 0 && dy3 == 0) || (dx4 == 0 && dy4 == 0) )
+ return_error(errorIllegalAttributeValue);
+ { double ang3 = atan2(dy3 * xr, dx3 * yr) * radians_to_degrees;
+ double ang4 = atan2(dy4 * xr, dx4 * yr) * radians_to_degrees;
+
+ if ( rotated )
+ ang3 += 180, ang4 += 180;
+ params->ang3 = ang3;
+ params->ang4 = ang4;
+ }
+ }
+ params->radius = yr;
+ if ( xr == yr )
+ { params->center.x = xc;
+ params->center.y = yc;
+ return arc_square;
+ }
+ else
+ { /* Must adjust the CTM. Move the origin to (xc,yc) */
+ /* for simplicity. */
+ if ( (code = gs_currentmatrix(pxs->pgs, &params->save_ctm)) < 0 ||
+ (code = gs_translate(pxs->pgs, xc, yc)) < 0 ||
+ (code = gs_scale(pxs->pgs, xr, yr)) < 0
+ )
+ return code;
+ params->center.x = 0;
+ params->center.y = 0;
+ params->radius = 1.0;
+ return arc_rectangular;
+ }
}
/* per the nonsense in 5.7.3 (The ROP3 Operands) from the pxl
@@ -339,99 +339,99 @@ pxl_allow_rop_for_stroke(gs_state *pgs)
static int
paint_path(px_state_t *pxs, bool reset)
{ gs_state *pgs = pxs->pgs;
- gx_path *ppath = gx_current_path(pgs);
- px_gstate_t *pxgs = pxs->pxgs;
- bool will_stroke = pxgs->pen.type != pxpNull;
- gs_point cursor;
- int code = 0;
- gx_path *save_path = 0;
-
- if ( gx_path_is_void(ppath) )
- return 0; /* nothing to draw */
+ gx_path *ppath = gx_current_path(pgs);
+ px_gstate_t *pxgs = pxs->pxgs;
+ bool will_stroke = pxgs->pen.type != pxpNull;
+ gs_point cursor;
+ int code = 0;
+ gx_path *save_path = 0;
+
+ if ( gx_path_is_void(ppath) )
+ return 0; /* nothing to draw */
#ifdef NO_SCALE_DASH_PATTERN
# define save_for_stroke (!reset || pxgs->dashed)
#else
# define save_for_stroke (!reset)
#endif
- if ( pxgs->brush.type != pxpNull )
- { int (*fill_proc)(gs_state *) =
- (pxgs->fill_mode == eEvenOdd ? gs_eofill : gs_fill);
-
- if ( (code = px_set_paint(&pxgs->brush, pxs)) < 0 )
- return code;
- pxs->have_page = true;
- if ( !will_stroke && reset )
- { gs_currentpoint(pgs, &cursor);
- code = (*fill_proc)(pgs);
- gs_moveto(pgs, cursor.x, cursor.y);
- return code;
- }
- save_path = gx_path_alloc(pxs->memory, "paint_path(save_path)");
- if ( save_path == 0 )
- return_error(errorInsufficientMemory);
- gx_path_assign_preserve(save_path, ppath);
- code = (*fill_proc)(pgs);
- if ( code < 0 )
- goto rx;
- if ( !will_stroke )
- goto rx;
- if ( save_for_stroke )
- gx_path_assign_preserve(ppath, save_path);
- else {
- gx_path_assign_free(ppath, save_path);
+ if ( pxgs->brush.type != pxpNull )
+ { int (*fill_proc)(gs_state *) =
+ (pxgs->fill_mode == eEvenOdd ? gs_eofill : gs_fill);
+
+ if ( (code = px_set_paint(&pxgs->brush, pxs)) < 0 )
+ return code;
+ pxs->have_page = true;
+ if ( !will_stroke && reset )
+ { gs_currentpoint(pgs, &cursor);
+ code = (*fill_proc)(pgs);
+ gs_moveto(pgs, cursor.x, cursor.y);
+ return code;
+ }
+ save_path = gx_path_alloc(pxs->memory, "paint_path(save_path)");
+ if ( save_path == 0 )
+ return_error(errorInsufficientMemory);
+ gx_path_assign_preserve(save_path, ppath);
+ code = (*fill_proc)(pgs);
+ if ( code < 0 )
+ goto rx;
+ if ( !will_stroke )
+ goto rx;
+ if ( save_for_stroke )
+ gx_path_assign_preserve(ppath, save_path);
+ else {
+ gx_path_assign_free(ppath, save_path);
gx_setcurrentpoint_from_path((gs_imager_state *)pgs, ppath);
- gs_currentpoint(pgs, &cursor);
- save_path = 0;
- }
- }
- else if ( !will_stroke )
- return 0;
- else if ( save_for_stroke )
- { save_path =
- gx_path_alloc(pxs->memory, "paint_path(save_path)");
- if ( save_path == 0 )
- return_error(errorInsufficientMemory);
- gx_path_assign_preserve(save_path, ppath);
- }
- else
- gs_currentpoint(pgs, &cursor);
- /*
- * The PCL XL documentation from H-P says that dash lengths do not
- * scale according to the CTM, but according to H-P developer
- * support, this isn't true. We went to the trouble of implementing
- * the published specification, so if it turns out to be right after
- * all, we execute the following block of code.
- */
+ gs_currentpoint(pgs, &cursor);
+ save_path = 0;
+ }
+ }
+ else if ( !will_stroke )
+ return 0;
+ else if ( save_for_stroke )
+ { save_path =
+ gx_path_alloc(pxs->memory, "paint_path(save_path)");
+ if ( save_path == 0 )
+ return_error(errorInsufficientMemory);
+ gx_path_assign_preserve(save_path, ppath);
+ }
+ else
+ gs_currentpoint(pgs, &cursor);
+ /*
+ * The PCL XL documentation from H-P says that dash lengths do not
+ * scale according to the CTM, but according to H-P developer
+ * support, this isn't true. We went to the trouble of implementing
+ * the published specification, so if it turns out to be right after
+ * all, we execute the following block of code.
+ */
#ifdef NO_SCALE_DASH_PATTERN
- /*
- * If we have a dash pattern that was defined with a different
- * CTM than the current one, we must pre-expand the dashes.
- * (Eventually we should expand the library API to handle this.)
- */
- if ( pxgs->dashed )
- { gs_matrix mat;
- gs_currentmatrix(pgs, &mat);
- if ( mat.xx != pxgs->dash_matrix.xx ||
- mat.xy != pxgs->dash_matrix.xy ||
- mat.yx != pxgs->dash_matrix.yx ||
- mat.yy != pxgs->dash_matrix.yy
- )
- { code = gs_flattenpath(pgs);
- if ( code < 0 )
- goto rx;
- gs_setmatrix(pgs, &pxgs->dash_matrix);
- code = gs_dashpath(pgs);
- gs_setmatrix(pgs, &mat);
- if ( code < 0 )
- goto rx;
- }
- }
+ /*
+ * If we have a dash pattern that was defined with a different
+ * CTM than the current one, we must pre-expand the dashes.
+ * (Eventually we should expand the library API to handle this.)
+ */
+ if ( pxgs->dashed )
+ { gs_matrix mat;
+ gs_currentmatrix(pgs, &mat);
+ if ( mat.xx != pxgs->dash_matrix.xx ||
+ mat.xy != pxgs->dash_matrix.xy ||
+ mat.yx != pxgs->dash_matrix.yx ||
+ mat.yy != pxgs->dash_matrix.yy
+ )
+ { code = gs_flattenpath(pgs);
+ if ( code < 0 )
+ goto rx;
+ gs_setmatrix(pgs, &pxgs->dash_matrix);
+ code = gs_dashpath(pgs);
+ gs_setmatrix(pgs, &mat);
+ if ( code < 0 )
+ goto rx;
+ }
+ }
#endif
- /*
- * Per the description in the PCL XL reference documentation,
- * set a standard logical operation and transparency for stroking.
- */
- {
+ /*
+ * Per the description in the PCL XL reference documentation,
+ * set a standard logical operation and transparency for stroking.
+ */
+ {
gs_rop3_t save_rop = gs_currentrasterop(pgs);
bool save_transparent = gs_currenttexturetransparent(pgs);
bool need_restore_rop = false;
@@ -452,27 +452,27 @@ paint_path(px_state_t *pxs, bool reset)
}
}
rx: if ( save_path ) {
- gx_path_assign_free(ppath, save_path); /* path without a Current point! */
- gx_setcurrentpoint_from_path((gs_imager_state *)pgs, ppath);
- }
- else /* Iff save_path is NULL, set currentpoint back to original */
- gs_moveto(pgs, cursor.x, cursor.y);
- return code;
+ gx_path_assign_free(ppath, save_path); /* path without a Current point! */
+ gx_setcurrentpoint_from_path((gs_imager_state *)pgs, ppath);
+ }
+ else /* Iff save_path is NULL, set currentpoint back to original */
+ gs_moveto(pgs, cursor.x, cursor.y);
+ return code;
}
/* Paint a shape defined by a one-operator path. */
static int
paint_shape(px_args_t *par, px_state_t *pxs, px_operator_proc((*path_op)))
{ int code;
- if ( (code = pxNewPath(par, pxs)) < 0 ||
- (code = (*path_op)(par, pxs)) < 0
- )
- return code;
- /* See the beginning of the file regarding the following. */
+ if ( (code = pxNewPath(par, pxs)) < 0 ||
+ (code = (*path_op)(par, pxs)) < 0
+ )
+ return code;
+ /* See the beginning of the file regarding the following. */
#ifdef NEWPATH_AFTER_PAINT_SHAPE
- return paint_path(pxs, true);
+ return paint_path(pxs, true);
#else
- return paint_path(pxs, false);
+ return paint_path(pxs, false);
#endif
}
@@ -503,33 +503,33 @@ const byte apxArcPath[] = {
int
pxArcPath(px_args_t *par, px_state_t *pxs)
{ /*
- * Note that "clockwise" in user space is counter-clockwise on
- * the page, because the Y coordinate is inverted.
- */
- bool clockwise =
- (par->pv[3] != 0 && par->pv[3]->value.i == eClockWise);
- px_arc_params_t params;
- int code = setup_arc(&params, par->pv[0], par->pv[1], par->pv[2], pxs, false);
- int rcode = code;
-
- if ( code >= 0 && code != arc_degenerate )
- { bool closed = params.ang3 == params.ang4;
- clockwise ^= params.reversed;
- if ( closed )
- { if ( clockwise ) params.ang4 += 360;
- else params.ang3 += 360;
- }
- code = gs_arc_add(pxs->pgs, !clockwise, params.center.x,
- params.center.y, params.radius, params.ang3,
- params.ang4, false);
- if ( code >= 0 && closed )
- { /* We have to close the path explicitly. */
- code = gs_closepath(pxs->pgs);
- }
- }
- if ( rcode == arc_rectangular )
- gs_setmatrix(pxs->pgs, &params.save_ctm);
- return code;
+ * Note that "clockwise" in user space is counter-clockwise on
+ * the page, because the Y coordinate is inverted.
+ */
+ bool clockwise =
+ (par->pv[3] != 0 && par->pv[3]->value.i == eClockWise);
+ px_arc_params_t params;
+ int code = setup_arc(&params, par->pv[0], par->pv[1], par->pv[2], pxs, false);
+ int rcode = code;
+
+ if ( code >= 0 && code != arc_degenerate )
+ { bool closed = params.ang3 == params.ang4;
+ clockwise ^= params.reversed;
+ if ( closed )
+ { if ( clockwise ) params.ang4 += 360;
+ else params.ang3 += 360;
+ }
+ code = gs_arc_add(pxs->pgs, !clockwise, params.center.x,
+ params.center.y, params.radius, params.ang3,
+ params.ang4, false);
+ if ( code >= 0 && closed )
+ { /* We have to close the path explicitly. */
+ code = gs_closepath(pxs->pgs);
+ }
+ }
+ if ( rcode == arc_rectangular )
+ gs_setmatrix(pxs->pgs, &params.save_ctm);
+ return code;
}
const byte apxBezierPath[] = {
@@ -565,25 +565,25 @@ const byte apxChordPath[] = {
int
pxChordPath(px_args_t *par, px_state_t *pxs)
{ px_arc_params_t params;
- int code = setup_arc(&params, par->pv[0], par->pv[1], par->pv[2], pxs, false);
- int rcode = code;
-
- /* See ArcPath above for the meaning of "clockwise". */
- if ( code >= 0 && code != arc_degenerate )
- { if ( params.ang3 == params.ang4 )
- params.ang3 += 360;
- code = gs_arc_add(pxs->pgs, !params.reversed,
- params.center.x, params.center.y,
- params.radius, params.ang3, params.ang4,
- false);
- if ( code >= 0 )
- code = gs_closepath(pxs->pgs);
- }
- if ( rcode == arc_rectangular )
- gs_setmatrix(pxs->pgs, &params.save_ctm);
- if ( code >= 0 )
- code = gs_moveto(pxs->pgs, params.origin.x, params.origin.y);
- return code;
+ int code = setup_arc(&params, par->pv[0], par->pv[1], par->pv[2], pxs, false);
+ int rcode = code;
+
+ /* See ArcPath above for the meaning of "clockwise". */
+ if ( code >= 0 && code != arc_degenerate )
+ { if ( params.ang3 == params.ang4 )
+ params.ang3 += 360;
+ code = gs_arc_add(pxs->pgs, !params.reversed,
+ params.center.x, params.center.y,
+ params.radius, params.ang3, params.ang4,
+ false);
+ if ( code >= 0 )
+ code = gs_closepath(pxs->pgs);
+ }
+ if ( rcode == arc_rectangular )
+ gs_setmatrix(pxs->pgs, &params.save_ctm);
+ if ( code >= 0 )
+ code = gs_moveto(pxs->pgs, params.origin.x, params.origin.y);
+ return code;
}
@@ -602,30 +602,30 @@ const byte apxEllipsePath[] = {
int
pxEllipsePath(px_args_t *par, px_state_t *pxs)
{ px_arc_params_t params;
- int code = setup_arc(&params, par->pv[0], NULL, NULL, pxs, true);
- int rcode = code;
- real a_start = 180.0;
- real a_end = -180.0;
-
- /* swap start and end angles if counter clockwise ellipse */
- if ( params.reversed )
- { a_start = -180.0;
- a_end = 180.0;
- }
- /* See ArcPath above for the meaning of "clockwise". */
- if ( code < 0 || code == arc_degenerate ||
- (code = gs_arc_add(pxs->pgs, !params.reversed,
- params.center.x, params.center.y,
- params.radius, a_start, a_end, false)) < 0 ||
- /* We have to close the path explicitly. */
- (code = gs_closepath(pxs->pgs)) < 0
- )
- DO_NOTHING;
- if ( rcode == arc_rectangular )
- gs_setmatrix(pxs->pgs, &params.save_ctm);
- if ( code >= 0 )
- code = gs_moveto(pxs->pgs, params.origin.x, params.origin.y);
- return code;
+ int code = setup_arc(&params, par->pv[0], NULL, NULL, pxs, true);
+ int rcode = code;
+ real a_start = 180.0;
+ real a_end = -180.0;
+
+ /* swap start and end angles if counter clockwise ellipse */
+ if ( params.reversed )
+ { a_start = -180.0;
+ a_end = 180.0;
+ }
+ /* See ArcPath above for the meaning of "clockwise". */
+ if ( code < 0 || code == arc_degenerate ||
+ (code = gs_arc_add(pxs->pgs, !params.reversed,
+ params.center.x, params.center.y,
+ params.radius, a_start, a_end, false)) < 0 ||
+ /* We have to close the path explicitly. */
+ (code = gs_closepath(pxs->pgs)) < 0
+ )
+ DO_NOTHING;
+ if ( rcode == arc_rectangular )
+ gs_setmatrix(pxs->pgs, &params.save_ctm);
+ if ( code >= 0 )
+ code = gs_moveto(pxs->pgs, params.origin.x, params.origin.y);
+ return code;
}
const byte apxLinePath[] = {
@@ -659,29 +659,29 @@ const byte apxPiePath[] = {
int
pxPiePath(px_args_t *par, px_state_t *pxs)
{ px_arc_params_t params;
- int code = setup_arc(&params, par->pv[0], par->pv[1], par->pv[2], pxs, false);
- int rcode = code;
-
- /* See ArcPath above for the meaning of "clockwise". */
- if ( code >= 0 && code != arc_degenerate )
- { if ( params.ang3 == params.ang4 )
- params.ang3 += 360;
- code = gs_moveto(pxs->pgs, params.center.x, params.center.y);
- if ( code >= 0 )
- { code = gs_arc_add(pxs->pgs, !params.reversed,
- params.center.x, params.center.y,
- params.radius, params.ang3, params.ang4,
- true);
- }
- }
- if ( rcode == arc_rectangular )
- gs_setmatrix(pxs->pgs, &params.save_ctm);
- if ( code < 0 || rcode == arc_degenerate ||
- (code = gs_closepath(pxs->pgs)) < 0 ||
- (code = gs_moveto(pxs->pgs, params.origin.x, params.origin.y)) < 0
- )
- DO_NOTHING;
- return code;
+ int code = setup_arc(&params, par->pv[0], par->pv[1], par->pv[2], pxs, false);
+ int rcode = code;
+
+ /* See ArcPath above for the meaning of "clockwise". */
+ if ( code >= 0 && code != arc_degenerate )
+ { if ( params.ang3 == params.ang4 )
+ params.ang3 += 360;
+ code = gs_moveto(pxs->pgs, params.center.x, params.center.y);
+ if ( code >= 0 )
+ { code = gs_arc_add(pxs->pgs, !params.reversed,
+ params.center.x, params.center.y,
+ params.radius, params.ang3, params.ang4,
+ true);
+ }
+ }
+ if ( rcode == arc_rectangular )
+ gs_setmatrix(pxs->pgs, &params.save_ctm);
+ if ( code < 0 || rcode == arc_degenerate ||
+ (code = gs_closepath(pxs->pgs)) < 0 ||
+ (code = gs_moveto(pxs->pgs, params.origin.x, params.origin.y)) < 0
+ )
+ DO_NOTHING;
+ return code;
}
const byte apxRectangle[] = {
@@ -699,45 +699,45 @@ const byte apxRectanglePath[] = {
int
pxRectanglePath(px_args_t *par, px_state_t *pxs)
{ floatp x1, y1, x2, y2;
- gs_fixed_point p1;
- gs_state *pgs = pxs->pgs;
- gx_path *ppath = gx_current_path(pgs);
- gs_fixed_point lines[3];
+ gs_fixed_point p1;
+ gs_state *pgs = pxs->pgs;
+ gx_path *ppath = gx_current_path(pgs);
+ gs_fixed_point lines[3];
#define p2 lines[1]
#define pctm (&((const gs_imager_state *)pgs)->ctm)
- int code;
-
- set_box_value(x1, y1, x2, y2, par->pv[0]);
- /*
- * Rectangles are always drawn in a canonical order.
- */
- if ( x1 > x2 )
- { floatp t = x1; x1 = x2; x2 = t; }
- if ( y1 > y2 )
- { floatp t = y1; y1 = y2; y2 = t; }
- if ( (code = gs_point_transform2fixed(pctm, x1, y1, &p1)) < 0 ||
- (code = gs_point_transform2fixed(pctm, x2, y2, &p2)) < 0 ||
- (code = gs_moveto(pgs, x1, y1)) < 0
- )
- return code;
+ int code;
+
+ set_box_value(x1, y1, x2, y2, par->pv[0]);
+ /*
+ * Rectangles are always drawn in a canonical order.
+ */
+ if ( x1 > x2 )
+ { floatp t = x1; x1 = x2; x2 = t; }
+ if ( y1 > y2 )
+ { floatp t = y1; y1 = y2; y2 = t; }
+ if ( (code = gs_point_transform2fixed(pctm, x1, y1, &p1)) < 0 ||
+ (code = gs_point_transform2fixed(pctm, x2, y2, &p2)) < 0 ||
+ (code = gs_moveto(pgs, x1, y1)) < 0
+ )
+ return code;
#ifdef DRAW_RECTANGLES_CLOCKWISE
- /*
- * DRAW_RECTANGLES_CLOCKWISE means clockwise on the page, which is
- * counter-clockwise in user space.
- */
- if ( (code = gs_point_transform2fixed(pctm, x2, y1, &lines[0])) < 0 ||
- (code = gs_point_transform2fixed(pctm, x1, y2, &lines[2])) < 0
- )
- return code;
+ /*
+ * DRAW_RECTANGLES_CLOCKWISE means clockwise on the page, which is
+ * counter-clockwise in user space.
+ */
+ if ( (code = gs_point_transform2fixed(pctm, x2, y1, &lines[0])) < 0 ||
+ (code = gs_point_transform2fixed(pctm, x1, y2, &lines[2])) < 0
+ )
+ return code;
#else
- if ( (code = gs_point_transform2fixed(pctm, x1, y2, &lines[0])) < 0 ||
- (code = gs_point_transform2fixed(pctm, x2, y1, &lines[2])) < 0
- )
- return code;
+ if ( (code = gs_point_transform2fixed(pctm, x1, y2, &lines[0])) < 0 ||
+ (code = gs_point_transform2fixed(pctm, x2, y1, &lines[2])) < 0
+ )
+ return code;
#endif
- if ( (code = gx_path_add_lines(ppath, lines, 3)) < 0 )
- return code;
- return gs_closepath(pgs);
+ if ( (code = gx_path_add_lines(ppath, lines, 3)) < 0 )
+ return code;
+ return gs_closepath(pgs);
#undef pctm
#undef p2
}
@@ -757,50 +757,50 @@ const byte apxRoundRectanglePath[] = {
int
pxRoundRectanglePath(px_args_t *par, px_state_t *pxs)
{ floatp x1, y1, x2, y2;
- real xr = real_value(par->pv[1], 0) * 0.5;
- real yr = real_value(par->pv[1], 1) * 0.5;
- real xd, yd;
- gs_matrix save_ctm;
- gs_state *pgs = pxs->pgs;
- int code;
-
- set_box_value(x1, y1, x2, y2, par->pv[0]);
- xd = x2 - x1;
- yd = y2 - y1;
- /*
- * H-P printers give an error if the points are specified out
- * of order.
- */
- if ( xd < 0 || yd < 0 )
- return_error(errorIllegalAttributeValue);
- if ( xr == 0 || yr == 0 )
- return pxRectanglePath(par, pxs);
- gs_currentmatrix(pgs, &save_ctm);
- gs_translate(pgs, x1, y1);
- if ( xr != yr )
- { /* Change coordinates so the arcs are circular. */
- double scale = xr / yr;
- if ( (code = gs_scale(pgs, scale, 1.0)) < 0 )
- return code;
- xd *= yr / xr;
- }
+ real xr = real_value(par->pv[1], 0) * 0.5;
+ real yr = real_value(par->pv[1], 1) * 0.5;
+ real xd, yd;
+ gs_matrix save_ctm;
+ gs_state *pgs = pxs->pgs;
+ int code;
+
+ set_box_value(x1, y1, x2, y2, par->pv[0]);
+ xd = x2 - x1;
+ yd = y2 - y1;
+ /*
+ * H-P printers give an error if the points are specified out
+ * of order.
+ */
+ if ( xd < 0 || yd < 0 )
+ return_error(errorIllegalAttributeValue);
+ if ( xr == 0 || yr == 0 )
+ return pxRectanglePath(par, pxs);
+ gs_currentmatrix(pgs, &save_ctm);
+ gs_translate(pgs, x1, y1);
+ if ( xr != yr )
+ { /* Change coordinates so the arcs are circular. */
+ double scale = xr / yr;
+ if ( (code = gs_scale(pgs, scale, 1.0)) < 0 )
+ return code;
+ xd *= yr / xr;
+ }
#define r yr
- /*
- * Draw the rectangle counter-clockwise on the page, which is
- * clockwise in user space. (This may be reversed if the
- * coordinates are specified in a non-standard order.)
- */
- if ( (code = gs_moveto(pgs, 0.0, r)) < 0 ||
- (code = gs_arcn(pgs, r, yd - r, r, 180.0, 90.0)) < 0 ||
- (code = gs_arcn(pgs, xd - r, yd - r, r, 90.0, 0.0)) < 0 ||
- (code = gs_arcn(pgs, xd - r, r, r, 0.0, 270.0)) < 0 ||
- (code = gs_arcn(pgs, r, r, r, 270.0, 180.0)) < 0 ||
- (code = gs_closepath(pgs)) < 0 ||
- (code = gs_moveto(pgs, 0.0, 0.0)) < 0
- )
- return code;
+ /*
+ * Draw the rectangle counter-clockwise on the page, which is
+ * clockwise in user space. (This may be reversed if the
+ * coordinates are specified in a non-standard order.)
+ */
+ if ( (code = gs_moveto(pgs, 0.0, r)) < 0 ||
+ (code = gs_arcn(pgs, r, yd - r, r, 180.0, 90.0)) < 0 ||
+ (code = gs_arcn(pgs, xd - r, yd - r, r, 90.0, 0.0)) < 0 ||
+ (code = gs_arcn(pgs, xd - r, r, r, 0.0, 270.0)) < 0 ||
+ (code = gs_arcn(pgs, r, r, r, 270.0, 180.0)) < 0 ||
+ (code = gs_closepath(pgs)) < 0 ||
+ (code = gs_moveto(pgs, 0.0, 0.0)) < 0
+ )
+ return code;
#undef r
- return gs_setmatrix(pgs, &save_ctm);
+ return gs_setmatrix(pgs, &save_ctm);
}
const byte apxText[] = {
@@ -809,14 +809,14 @@ const byte apxText[] = {
int
pxText(px_args_t *par, px_state_t *pxs)
{ { int code = px_set_paint(&pxs->pxgs->brush, pxs);
- if ( code < 0 )
- return code;
- }
- if ( par->pv[0]->value.array.size != 0 &&
- pxs->pxgs->brush.type != pxpNull
- )
- pxs->have_page = true;
- return px_text(par, pxs, false);
+ if ( code < 0 )
+ return code;
+ }
+ if ( par->pv[0]->value.array.size != 0 &&
+ pxs->pxgs->brush.type != pxpNull
+ )
+ pxs->have_page = true;
+ return px_text(par, pxs, false);
}
const byte apxTextPath[] = {
@@ -824,16 +824,15 @@ const byte apxTextPath[] = {
};
int
pxTextPath(px_args_t *par, px_state_t *pxs)
-{
+{
int code = px_set_paint(&pxs->pxgs->pen, pxs);
if ( code < 0 )
return code;
/* NB this should be refactored with pxText (immediately above)
and it is not a good heuristic for detecting a marked page. */
if ( par->pv[0]->value.array.size != 0 &&
- pxs->pxgs->pen.type != pxpNull
+ pxs->pxgs->pen.type != pxpNull
)
pxs->have_page = true;
return px_text(par, pxs, true);
}
-
diff --git a/pxl/pxparse.c b/pxl/pxparse.c
index 6ffb10d39..ae462070b 100644
--- a/pxl/pxparse.c
+++ b/pxl/pxparse.c
@@ -37,36 +37,36 @@ gs_private_st_composite(st_px_parser_state, px_parser_state_t,
"px_parser_state_t", parser_state_enum_ptrs, parser_state_reloc_ptrs);
#define st ((px_parser_state_t *)vptr)
static ENUM_PTRS_BEGIN(parser_state_enum_ptrs)
- /* Mark from array pointers on the stack. */
- if ( index < st->stack_count )
- { px_value_t *pv = &st->stack[index];
- ENUM_RETURN((!(~pv->type & (pxd_array | pxd_on_heap)) ?
- pv->value.array.data : 0));
- }
- return 0;
+ /* Mark from array pointers on the stack. */
+ if ( index < st->stack_count )
+ { px_value_t *pv = &st->stack[index];
+ ENUM_RETURN((!(~pv->type & (pxd_array | pxd_on_heap)) ?
+ pv->value.array.data : 0));
+ }
+ return 0;
ENUM_PTRS_END
static RELOC_PTRS_BEGIN(parser_state_reloc_ptrs) {
- px_parser_state_t *st_new =
- (*gc_proc(gcst, reloc_struct_ptr))((const void *)st, gcst);
- long diff = (byte *)st_new - (byte *)st;
-
- /* Relocate array pointers on the stack. */
- { px_value_t *pv = &st->stack[0];
- int i;
-
- for ( i = 0; i < st->stack_count; ++pv, ++i )
- if ( !(~pv->type & (pxd_array | pxd_on_heap)) )
- RELOC_OBJ_VAR(pv->value.array.data);
- }
- /* Relocate the pointers from the args. */
- st->args.parser = st_new;
- { px_value_t **ppv = &st->args.pv[0];
- int i;
-
- for ( i = 0; i < max_px_args; ++ppv, ++i )
- if ( *ppv )
- *ppv = (px_value_t *)((byte *)*ppv + diff);
- }
+ px_parser_state_t *st_new =
+ (*gc_proc(gcst, reloc_struct_ptr))((const void *)st, gcst);
+ long diff = (byte *)st_new - (byte *)st;
+
+ /* Relocate array pointers on the stack. */
+ { px_value_t *pv = &st->stack[0];
+ int i;
+
+ for ( i = 0; i < st->stack_count; ++pv, ++i )
+ if ( !(~pv->type & (pxd_array | pxd_on_heap)) )
+ RELOC_OBJ_VAR(pv->value.array.data);
+ }
+ /* Relocate the pointers from the args. */
+ st->args.parser = st_new;
+ { px_value_t **ppv = &st->args.pv[0];
+ int i;
+
+ for ( i = 0; i < max_px_args; ++ppv, ++i )
+ if ( *ppv )
+ *ppv = (px_value_t *)((byte *)*ppv + diff);
+ }
} RELOC_PTRS_END
#undef st
@@ -173,13 +173,13 @@ static const px_tag_syntax_t tag_syntax[256] = {
px_parser_state_t *
px_process_alloc(gs_memory_t *memory)
{ px_parser_state_t *st = gs_alloc_struct(memory, px_parser_state_t,
- &st_px_parser_state,
- "px_process_alloc");
- if ( st == 0 )
- return 0;
- st->memory = memory;
- px_process_init(st, true);
- return st;
+ &st_px_parser_state,
+ "px_process_alloc");
+ if ( st == 0 )
+ return 0;
+ st->memory = memory;
+ px_process_init(st, true);
+ return st;
}
/* Release a parser state. */
@@ -192,20 +192,20 @@ px_process_release(px_parser_state_t *st)
void
px_process_init(px_parser_state_t *st, bool big_endian)
{ st->big_endian = big_endian;
- st->operator_count = 0;
- st->parent_operator_count = 0;
- st->last_operator = pxtNull;
- st->saved_count = 0;
- st->data_left = 0;
- st->macro_state = ptsInitial;
- st->stack_count = 0;
- st->data_proc = 0;
- { int i;
- for ( i = 0; i < max_px_args; ++i )
- st->args.pv[i] = 0;
- }
- st->args.parser = 0; /* for garbage collector */
- memset(st->attribute_indices, 0, px_attribute_next);
+ st->operator_count = 0;
+ st->parent_operator_count = 0;
+ st->last_operator = pxtNull;
+ st->saved_count = 0;
+ st->data_left = 0;
+ st->macro_state = ptsInitial;
+ st->stack_count = 0;
+ st->data_proc = 0;
+ { int i;
+ for ( i = 0; i < max_px_args; ++i )
+ st->args.pv[i] = 0;
+ }
+ st->args.parser = 0; /* for garbage collector */
+ memset(st->attribute_indices, 0, px_attribute_next);
}
/* Get numeric values from the input. */
@@ -221,87 +221,87 @@ static int
px_save_array(px_value_t *pv, px_state_t *pxs, client_name_t cname,
uint nbytes)
{ if ( pv->type & pxd_on_heap )
- { /* Turn off the "on heap" bit, to prevent freeing. */
- pv->type &= ~pxd_on_heap;
- }
- else
- { /* Allocate a heap copy. Only the first nbytes bytes */
- /* of the data are valid. */
- uint num_elements = pv->value.array.size;
- uint elt_size = value_size(pv);
-
- byte *copy = gs_alloc_byte_array(pxs->memory, num_elements,
- elt_size, cname);
- if ( copy == 0 )
- return_error(errorInsufficientMemory);
- memcpy(copy, pv->value.array.data, nbytes);
- pv->value.array.data = copy;
- }
- return 0;
+ { /* Turn off the "on heap" bit, to prevent freeing. */
+ pv->type &= ~pxd_on_heap;
+ }
+ else
+ { /* Allocate a heap copy. Only the first nbytes bytes */
+ /* of the data are valid. */
+ uint num_elements = pv->value.array.size;
+ uint elt_size = value_size(pv);
+
+ byte *copy = gs_alloc_byte_array(pxs->memory, num_elements,
+ elt_size, cname);
+ if ( copy == 0 )
+ return_error(errorInsufficientMemory);
+ memcpy(copy, pv->value.array.data, nbytes);
+ pv->value.array.data = copy;
+ }
+ return 0;
}
/* Clear the stack and the attribute indices, */
/* and free heap-allocated arrays. */
#define clear_stack()\
- for ( ; sp > st->stack; --sp )\
- { if ( sp->type & pxd_on_heap )\
- gs_free_object(memory, (void *)sp->value.array.data,\
- "px stack pop");\
- st->attribute_indices[sp->attribute] = 0;\
- }
+ for ( ; sp > st->stack; --sp )\
+ { if ( sp->type & pxd_on_heap )\
+ gs_free_object(memory, (void *)sp->value.array.data,\
+ "px stack pop");\
+ st->attribute_indices[sp->attribute] = 0;\
+ }
/* Define data tracing if debugging. */
#ifdef DEBUG
# define trace_data(format, cast, ptr, count)\
- do\
- { uint i_;\
- for ( i_ = 0; i_ < count; ++i_ )\
- dprintf1(format, (cast)((ptr)[i_]));\
- dputc('\n');\
- }\
- while (0)
+ do\
+ { uint i_;\
+ for ( i_ = 0; i_ < count; ++i_ )\
+ dprintf1(format, (cast)((ptr)[i_]));\
+ dputc('\n');\
+ }\
+ while (0)
static void
trace_array_data(const char *label, const px_value_t *pav)
{ px_data_type_t type = pav->type;
- const byte *ptr = pav->value.array.data;
- uint count = pav->value.array.size;
- bool big_endian = (type & pxd_big_endian) != 0;
- bool text = (type & pxd_ubyte) != 0;
- uint i;
-
- dputs(label);
- dputs((type & pxd_ubyte ? " <" : " {"));
- for ( i = 0; i < count; ++i )
- { if ( !(i & 15) && i )
- { const char *p;
- dputs("\n ");
- for ( p = label; *p; ++p )
- dputc(' ');
- }
- if ( type & pxd_ubyte )
- { dprintf1("%02x ", ptr[i]);
- if ( ptr[i] < 32 || ptr[i] > 126 )
- text = false;
- }
- else if ( type & pxd_uint16 )
- dprintf1("%u ", uint16at(ptr + i * 2, big_endian));
- else if ( type & pxd_sint16 )
- dprintf1("%d ", sint16at(ptr + i * 2, big_endian));
- else if ( type & pxd_uint32 )
- dprintf1("%lu ", (ulong)uint32at(ptr + i * 4, big_endian));
- else if ( type & pxd_sint32 )
- dprintf1("%ld ", (long)sint32at(ptr + i * 4, big_endian));
- else if ( type & pxd_real32 )
- dprintf1("%g ", real32at(ptr + i * 4, big_endian));
- else
- dputs("? ");
- }
- dputs((type & pxd_ubyte ? ">\n" : "}\n"));
- if ( text )
- { dputs("%chars: \"");
- debug_print_string(ptr, count);
- dputs("\"\n");
- }
+ const byte *ptr = pav->value.array.data;
+ uint count = pav->value.array.size;
+ bool big_endian = (type & pxd_big_endian) != 0;
+ bool text = (type & pxd_ubyte) != 0;
+ uint i;
+
+ dputs(label);
+ dputs((type & pxd_ubyte ? " <" : " {"));
+ for ( i = 0; i < count; ++i )
+ { if ( !(i & 15) && i )
+ { const char *p;
+ dputs("\n ");
+ for ( p = label; *p; ++p )
+ dputc(' ');
+ }
+ if ( type & pxd_ubyte )
+ { dprintf1("%02x ", ptr[i]);
+ if ( ptr[i] < 32 || ptr[i] > 126 )
+ text = false;
+ }
+ else if ( type & pxd_uint16 )
+ dprintf1("%u ", uint16at(ptr + i * 2, big_endian));
+ else if ( type & pxd_sint16 )
+ dprintf1("%d ", sint16at(ptr + i * 2, big_endian));
+ else if ( type & pxd_uint32 )
+ dprintf1("%lu ", (ulong)uint32at(ptr + i * 4, big_endian));
+ else if ( type & pxd_sint32 )
+ dprintf1("%ld ", (long)sint32at(ptr + i * 4, big_endian));
+ else if ( type & pxd_real32 )
+ dprintf1("%g ", real32at(ptr + i * 4, big_endian));
+ else
+ dputs("? ");
+ }
+ dputs((type & pxd_ubyte ? ">\n" : "}\n"));
+ if ( text )
+ { dputs("%chars: \"");
+ debug_print_string(ptr, count);
+ dputs("\"\n");
+ }
}
# define trace_array(pav)\
if ( gs_debug_c('I') )\
@@ -315,241 +315,241 @@ trace_array_data(const char *label, const px_value_t *pav)
int
px_process(px_parser_state_t *st, px_state_t *pxs, stream_cursor_read *pr)
{ const byte *orig_p = pr->ptr;
- const byte *next_p = orig_p; /* start of data not copied to saved */
- const byte *p;
- const byte *rlimit;
- px_value_t *sp = &st->stack[st->stack_count];
+ const byte *next_p = orig_p; /* start of data not copied to saved */
+ const byte *p;
+ const byte *rlimit;
+ px_value_t *sp = &st->stack[st->stack_count];
#define stack_limit &st->stack[max_stack - 1]
- gs_memory_t *memory = st->memory;
- int code = 0;
- uint left;
- uint min_left;
- px_tag_t tag;
- const px_tag_syntax_t *syntax = 0;
-
- st->args.parser = st;
- st->parent_operator_count = 0; /* in case of error */
- /* Check for leftover data from the previous call. */
+ gs_memory_t *memory = st->memory;
+ int code = 0;
+ uint left;
+ uint min_left;
+ px_tag_t tag;
+ const px_tag_syntax_t *syntax = 0;
+
+ st->args.parser = st;
+ st->parent_operator_count = 0; /* in case of error */
+ /* Check for leftover data from the previous call. */
parse: if ( st->saved_count )
- { /* Fill up the saved buffer so we can make progress. */
- int move = min(sizeof(st->saved) - st->saved_count,
- pr->limit - next_p);
- memcpy(&st->saved[st->saved_count], next_p + 1, move);
- next_p += move;
- p = st->saved - 1;
- rlimit = p + st->saved_count + move;
- }
- else
- { /* No leftover data, just read from the input. */
- p = next_p;
- rlimit = pr->limit;
- }
+ { /* Fill up the saved buffer so we can make progress. */
+ int move = min(sizeof(st->saved) - st->saved_count,
+ pr->limit - next_p);
+ memcpy(&st->saved[st->saved_count], next_p + 1, move);
+ next_p += move;
+ p = st->saved - 1;
+ rlimit = p + st->saved_count + move;
+ }
+ else
+ { /* No leftover data, just read from the input. */
+ p = next_p;
+ rlimit = pr->limit;
+ }
top: if ( st->data_left )
- { /* We're in the middle of reading an array or data block. */
- if ( st->data_proc )
- { /* This is a data block. */
- uint avail = min(rlimit - p, st->data_left);
- uint used;
-
- st->args.source.available = avail;
- st->args.source.data = p + 1;
- code = (*st->data_proc)(&st->args, pxs);
- used = st->args.source.data - (p + 1);
+ { /* We're in the middle of reading an array or data block. */
+ if ( st->data_proc )
+ { /* This is a data block. */
+ uint avail = min(rlimit - p, st->data_left);
+ uint used;
+
+ st->args.source.available = avail;
+ st->args.source.data = p + 1;
+ code = (*st->data_proc)(&st->args, pxs);
+ used = st->args.source.data - (p + 1);
#ifdef DEBUG
- if ( gs_debug_c('I') )
- { px_value_t data_array;
- data_array.type = pxd_ubyte;
- data_array.value.array.data = p + 1;
- data_array.value.array.size = used;
- trace_array_data("data:", &data_array);
- }
+ if ( gs_debug_c('I') )
+ { px_value_t data_array;
+ data_array.type = pxd_ubyte;
+ data_array.value.array.data = p + 1;
+ data_array.value.array.size = used;
+ trace_array_data("data:", &data_array);
+ }
#endif
- p = st->args.source.data - 1;
- st->data_left -= used;
- if ( code < 0 )
- { st->args.source.position = 0;
- goto x;
- }
- else if ( ( code == pxNeedData ) || ( code == pxPassThrough && st->data_left != 0 ) )
- { code = 0; /* exit for more data */
- goto x;
- }
- else
- { st->args.source.position = 0;
- st->data_proc = 0;
- if ( st->data_left != 0 )
- { code = gs_note_error(errorExtraData);
- goto x;
- }
- clear_stack();
- }
- }
- else
- { /* This is an array. */
- uint size = sp->value.array.size;
- uint scale = value_size(sp);
- uint nbytes = size * scale;
- byte *dest =
- (byte *)sp->value.array.data + nbytes - st->data_left;
-
- left = rlimit - p;
- if ( left < st->data_left )
- { /* We still don't have enough data to fill the array. */
- memcpy(dest, p + 1, left);
- st->data_left -= left;
- p = rlimit;
- code = 0;
- goto x;
- }
- /* Complete the array and continue parsing. */
- memcpy(dest, p + 1, st->data_left);
- trace_array(sp);
- p += st->data_left;
- }
- st->data_left = 0;
- }
- else if ( st->data_proc )
- { /* An operator is awaiting data. */
- /* Skip white space until we find some. */
- code = 0; /* in case we exit */
- while ( (left = rlimit - p) != 0 )
- { switch ( (tag = p[1]) )
- {
- case pxtNull:
- case pxtHT: case pxtLF: case pxtVT: case pxtFF: case pxtCR:
- ++p;
- continue;
- case pxt_dataLength:
- if ( left < 5 )
- goto x; /* can't look ahead */
- st->data_left = get_uint32(st, p + 2);
- if_debug2('i', "tag= 0x%2x data, length %u\n",
- p[1], st->data_left);
- p += 5;
- goto top;
- case pxt_dataLengthByte:
- if ( left < 2 )
- goto x; /* can't look ahead */
- st->data_left = p[2];
- if_debug2('i', "tag= 0x%2x data, length %u\n",
- p[1], st->data_left);
- p += 2;
- goto top;
- default:
- { code = gs_note_error(errorMissingData);
- goto x;
- }
- }
- }
- }
- st->args.source.position = 0;
- st->args.source.available = 0;
- while ( (left = rlimit - p) != 0 &&
- left >= (min_left = (syntax = &tag_syntax[tag = p[1]])->min_input)
- )
- { int count;
+ p = st->args.source.data - 1;
+ st->data_left -= used;
+ if ( code < 0 )
+ { st->args.source.position = 0;
+ goto x;
+ }
+ else if ( ( code == pxNeedData ) || ( code == pxPassThrough && st->data_left != 0 ) )
+ { code = 0; /* exit for more data */
+ goto x;
+ }
+ else
+ { st->args.source.position = 0;
+ st->data_proc = 0;
+ if ( st->data_left != 0 )
+ { code = gs_note_error(errorExtraData);
+ goto x;
+ }
+ clear_stack();
+ }
+ }
+ else
+ { /* This is an array. */
+ uint size = sp->value.array.size;
+ uint scale = value_size(sp);
+ uint nbytes = size * scale;
+ byte *dest =
+ (byte *)sp->value.array.data + nbytes - st->data_left;
+
+ left = rlimit - p;
+ if ( left < st->data_left )
+ { /* We still don't have enough data to fill the array. */
+ memcpy(dest, p + 1, left);
+ st->data_left -= left;
+ p = rlimit;
+ code = 0;
+ goto x;
+ }
+ /* Complete the array and continue parsing. */
+ memcpy(dest, p + 1, st->data_left);
+ trace_array(sp);
+ p += st->data_left;
+ }
+ st->data_left = 0;
+ }
+ else if ( st->data_proc )
+ { /* An operator is awaiting data. */
+ /* Skip white space until we find some. */
+ code = 0; /* in case we exit */
+ while ( (left = rlimit - p) != 0 )
+ { switch ( (tag = p[1]) )
+ {
+ case pxtNull:
+ case pxtHT: case pxtLF: case pxtVT: case pxtFF: case pxtCR:
+ ++p;
+ continue;
+ case pxt_dataLength:
+ if ( left < 5 )
+ goto x; /* can't look ahead */
+ st->data_left = get_uint32(st, p + 2);
+ if_debug2('i', "tag= 0x%2x data, length %u\n",
+ p[1], st->data_left);
+ p += 5;
+ goto top;
+ case pxt_dataLengthByte:
+ if ( left < 2 )
+ goto x; /* can't look ahead */
+ st->data_left = p[2];
+ if_debug2('i', "tag= 0x%2x data, length %u\n",
+ p[1], st->data_left);
+ p += 2;
+ goto top;
+ default:
+ { code = gs_note_error(errorMissingData);
+ goto x;
+ }
+ }
+ }
+ }
+ st->args.source.position = 0;
+ st->args.source.available = 0;
+ while ( (left = rlimit - p) != 0 &&
+ left >= (min_left = (syntax = &tag_syntax[tag = p[1]])->min_input)
+ )
+ { int count;
#ifdef DEBUG
- if ( gs_debug_c('i') )
- { dprintf1("tag= 0x%02x ", tag);
- if ( tag == pxt_attr_ubyte || tag == pxt_attr_uint16 )
- { px_attribute_t attr =
- (tag == pxt_attr_ubyte ? p[2] : get_uint16(st, p + 2));
- const char *aname = px_attribute_names[attr];
- if ( aname )
- dprintf1(" @%s\n", aname);
- else
- dprintf1(" attribute %u ???\n", attr);
- }
- else
- { const char *format;
- const char *tname;
+ if ( gs_debug_c('i') )
+ { dprintf1("tag= 0x%02x ", tag);
+ if ( tag == pxt_attr_ubyte || tag == pxt_attr_uint16 )
+ { px_attribute_t attr =
+ (tag == pxt_attr_ubyte ? p[2] : get_uint16(st, p + 2));
+ const char *aname = px_attribute_names[attr];
+ if ( aname )
+ dprintf1(" @%s\n", aname);
+ else
+ dprintf1(" attribute %u ???\n", attr);
+ }
+ else
+ { const char *format;
+ const char *tname;
bool operator = false;
- if ( tag < 0x40 )
- format = "%s\n", tname = px_tag_0_names[tag];
- else if ( tag < 0xc0 )
- format = "%s", tname = px_operator_names[tag - 0x40],
+ if ( tag < 0x40 )
+ format = "%s\n", tname = px_tag_0_names[tag];
+ else if ( tag < 0xc0 )
+ format = "%s", tname = px_operator_names[tag - 0x40],
operator = true;
- else
- { tname = px_tag_c0_names[tag - 0xc0];
- if ( tag < 0xf0 )
- format = " %s"; /* data values follow */
- else
- format = "%s\n";
- }
- if ( tname ) {
- dprintf1(format, tname);
+ else
+ { tname = px_tag_c0_names[tag - 0xc0];
+ if ( tag < 0xf0 )
+ format = " %s"; /* data values follow */
+ else
+ format = "%s\n";
+ }
+ if ( tname ) {
+ dprintf1(format, tname);
if (operator)
dprintf1(" (%ld)\n", st->operator_count+1);
}
- else
- dputs("???\n");
- }
- }
+ else
+ dputs("???\n");
+ }
+ }
#endif
- if ( (st->macro_state & syntax->state_mask) != syntax->state_value )
- { /*
- * We should probably distinguish here between
- * out-of-context operators and illegal tags, but it's too
- * much trouble.
- */
- code = gs_note_error(errorIllegalOperatorSequence);
- if ( tag >= 0x40 && tag < 0xc0 )
- st->last_operator = tag;
- goto x;
- }
- st->macro_state ^= syntax->state_transition;
- switch ( tag >> 3 )
- {
- case 0:
- switch ( tag )
- {
- case pxtNull: ++p; continue;
- default: break;
- }
- break;
- case 1:
- switch ( tag )
- {
- case pxtHT: case pxtLF: case pxtVT: case pxtFF: case pxtCR:
- ++p;
- continue;
- default:
- break;
- }
- break;
- case 3:
- if ( tag == pxt1b ) /* ESC */
- { /* Check for UEL */
- if ( memcmp(p + 1, "\033%-12345X", min(left, 9)) )
- break; /* not UEL, error */
- if ( left < 9 )
- goto x; /* need more data */
- p += 9;
- code = e_ExitLanguage;
- goto x;
- }
- break;
- case 4:
- switch ( tag )
- {
- case pxtSpace:
- /* break; will error, compatible with lj */
- /* ++p;continue; silently ignores the space */
- ++p;
- continue;
- default: break;
- }
- break;
- case 8: case 9:
- case 10: case 11: case 12: case 13: case 14:
- case 15: case 16: case 17: case 18: case 19:
- case 20: case 21: case 22: case 23:
- /* Operators */
- /* Make sure that we have all the required attributes, */
- /* and no attributes that are neither required nor */
- /* optional. (It's up to the operator to make any */
- /* more precise checks than this. */
- st->operator_count++;
+ if ( (st->macro_state & syntax->state_mask) != syntax->state_value )
+ { /*
+ * We should probably distinguish here between
+ * out-of-context operators and illegal tags, but it's too
+ * much trouble.
+ */
+ code = gs_note_error(errorIllegalOperatorSequence);
+ if ( tag >= 0x40 && tag < 0xc0 )
+ st->last_operator = tag;
+ goto x;
+ }
+ st->macro_state ^= syntax->state_transition;
+ switch ( tag >> 3 )
+ {
+ case 0:
+ switch ( tag )
+ {
+ case pxtNull: ++p; continue;
+ default: break;
+ }
+ break;
+ case 1:
+ switch ( tag )
+ {
+ case pxtHT: case pxtLF: case pxtVT: case pxtFF: case pxtCR:
+ ++p;
+ continue;
+ default:
+ break;
+ }
+ break;
+ case 3:
+ if ( tag == pxt1b ) /* ESC */
+ { /* Check for UEL */
+ if ( memcmp(p + 1, "\033%-12345X", min(left, 9)) )
+ break; /* not UEL, error */
+ if ( left < 9 )
+ goto x; /* need more data */
+ p += 9;
+ code = e_ExitLanguage;
+ goto x;
+ }
+ break;
+ case 4:
+ switch ( tag )
+ {
+ case pxtSpace:
+ /* break; will error, compatible with lj */
+ /* ++p;continue; silently ignores the space */
+ ++p;
+ continue;
+ default: break;
+ }
+ break;
+ case 8: case 9:
+ case 10: case 11: case 12: case 13: case 14:
+ case 15: case 16: case 17: case 18: case 19:
+ case 20: case 21: case 22: case 23:
+ /* Operators */
+ /* Make sure that we have all the required attributes, */
+ /* and no attributes that are neither required nor */
+ /* optional. (It's up to the operator to make any */
+ /* more precise checks than this. */
+ st->operator_count++;
/* if this is a passthrough operator we have to tell
the passthrough module if this operator was
preceded by another passthrough operator or a
@@ -557,356 +557,356 @@ top: if ( st->data_left )
if (tag == pxtPassThrough) {
pxpcl_passthroughcontiguous(st->last_operator == tag);
} else if ( st->last_operator == pxtPassThrough ) {
- pxpcl_endpassthroughcontiguous(pxs);
- }
-
- st->last_operator = tag;
- { const px_operator_definition_t *pod =
- &px_operator_definitions[tag - 0x40];
- int left = sp - st->stack;
- const byte /*px_attribute_t*/ *pal = pod->attrs;
- px_value_t **ppv = st->args.pv;
- bool required = true;
-
- code = 0;
- /*
- * Scan the attributes. Illegal attributes take priority
- * over missing attributes, which in turn take priority
- * over illegal data types.
- */
- for ( ; ; ++pal, ++ppv )
- { px_attribute_t attr = *pal;
- uint index;
-
- if ( !attr )
- { /*
- * We've reached the end of either the required or
- * the optional attribute list.
- */
- if ( !required )
- break;
- required = false;
- --ppv; /* cancel incrementing */
- continue;
- }
- if ( (index = st->attribute_indices[attr]) == 0 )
- { if ( required )
- code = gs_note_error(errorMissingAttribute);
- else
- *ppv = 0;
- }
- else
- { /* Check the attribute data type and value. */
- px_value_t *pv = *ppv = &st->stack[index];
- const px_attr_value_type_t *pavt =
- &px_attr_value_types[attr];
- int acode;
-
- if ( (~pavt->mask & pv->type &
- (pxd_structure | pxd_representation)) ||
- (pavt->mask == (pxd_scalar | pxd_ubyte) &&
- (pv->value.i < 0 || pv->value.i > pavt->limit))
- )
- { if ( code >= 0 )
- code = gs_note_error(errorIllegalAttributeDataType);
- }
- if ( pavt->proc != 0 && (acode = (*pavt->proc)(pv)) < 0 )
- { if ( code >= 0 )
- code = acode;
- }
- --left;
- }
- }
+ pxpcl_endpassthroughcontiguous(pxs);
+ }
+
+ st->last_operator = tag;
+ { const px_operator_definition_t *pod =
+ &px_operator_definitions[tag - 0x40];
+ int left = sp - st->stack;
+ const byte /*px_attribute_t*/ *pal = pod->attrs;
+ px_value_t **ppv = st->args.pv;
+ bool required = true;
+
+ code = 0;
+ /*
+ * Scan the attributes. Illegal attributes take priority
+ * over missing attributes, which in turn take priority
+ * over illegal data types.
+ */
+ for ( ; ; ++pal, ++ppv )
+ { px_attribute_t attr = *pal;
+ uint index;
+
+ if ( !attr )
+ { /*
+ * We've reached the end of either the required or
+ * the optional attribute list.
+ */
+ if ( !required )
+ break;
+ required = false;
+ --ppv; /* cancel incrementing */
+ continue;
+ }
+ if ( (index = st->attribute_indices[attr]) == 0 )
+ { if ( required )
+ code = gs_note_error(errorMissingAttribute);
+ else
+ *ppv = 0;
+ }
+ else
+ { /* Check the attribute data type and value. */
+ px_value_t *pv = *ppv = &st->stack[index];
+ const px_attr_value_type_t *pavt =
+ &px_attr_value_types[attr];
+ int acode;
+
+ if ( (~pavt->mask & pv->type &
+ (pxd_structure | pxd_representation)) ||
+ (pavt->mask == (pxd_scalar | pxd_ubyte) &&
+ (pv->value.i < 0 || pv->value.i > pavt->limit))
+ )
+ { if ( code >= 0 )
+ code = gs_note_error(errorIllegalAttributeDataType);
+ }
+ if ( pavt->proc != 0 && (acode = (*pavt->proc)(pv)) < 0 )
+ { if ( code >= 0 )
+ code = acode;
+ }
+ --left;
+ }
+ }
- /* Make sure there are no attributes left over. */
- if ( left )
- code = gs_note_error(errorIllegalAttribute);
- if ( code >= 0 ) {
+ /* Make sure there are no attributes left over. */
+ if ( left )
+ code = gs_note_error(errorIllegalAttribute);
+ if ( code >= 0 ) {
st->args.source.phase = 0;
- code = (*pod->proc)(&st->args, pxs);
+ code = (*pod->proc)(&st->args, pxs);
}
- if ( code < 0 )
- goto x;
- /* Check whether the operator wanted source data. */
- if ( code == pxNeedData )
- { if ( !pxs->data_source_open )
- { code = gs_note_error(errorDataSourceNotOpen);
- goto x;
- }
- st->data_proc = pod->proc;
- ++p;
- goto top;
- }
- }
- clear_stack();
- ++p;
- continue;
- case 24: sp[1].type = pxd_scalar; count = 1; goto data;
- case 26: sp[1].type = pxd_xy; count = 2; goto data;
- case 28: sp[1].type = pxd_box; count = 4; goto data;
- /* Scalar, point, and box data */
+ if ( code < 0 )
+ goto x;
+ /* Check whether the operator wanted source data. */
+ if ( code == pxNeedData )
+ { if ( !pxs->data_source_open )
+ { code = gs_note_error(errorDataSourceNotOpen);
+ goto x;
+ }
+ st->data_proc = pod->proc;
+ ++p;
+ goto top;
+ }
+ }
+ clear_stack();
+ ++p;
+ continue;
+ case 24: sp[1].type = pxd_scalar; count = 1; goto data;
+ case 26: sp[1].type = pxd_xy; count = 2; goto data;
+ case 28: sp[1].type = pxd_box; count = 4; goto data;
+ /* Scalar, point, and box data */
data: { int i;
- if ( sp == stack_limit )
- { code = gs_note_error(errorInternalOverflow);
- goto x;
- }
- ++sp;
- sp->attribute = 0;
- p += 2;
+ if ( sp == stack_limit )
+ { code = gs_note_error(errorInternalOverflow);
+ goto x;
+ }
+ ++sp;
+ sp->attribute = 0;
+ p += 2;
#ifdef DEBUG
# define trace_scalar(format, cast, alt)\
- if ( gs_debug_c('i') )\
- trace_data(format, cast, sp->value.alt, count)
+ if ( gs_debug_c('i') )\
+ trace_data(format, cast, sp->value.alt, count)
#else
# define trace_scalar(format, cast, alt) DO_NOTHING
#endif
- switch ( tag & 7 )
- {
- case pxt_ubyte & 7:
- sp->type |= pxd_ubyte;
- for ( i = 0; i < count; ++p, ++i )
- sp->value.ia[i] = *p;
+ switch ( tag & 7 )
+ {
+ case pxt_ubyte & 7:
+ sp->type |= pxd_ubyte;
+ for ( i = 0; i < count; ++p, ++i )
+ sp->value.ia[i] = *p;
dux: trace_scalar(" %lu", ulong, ia);
- --p;
- continue;
- case pxt_uint16 & 7:
- sp->type |= pxd_uint16;
- for ( i = 0; i < count; p += 2, ++i )
- sp->value.ia[i] = get_uint16(st, p);
- goto dux;
- case pxt_uint32 & 7:
- sp->type |= pxd_uint32;
- for ( i = 0; i < count; p += 4, ++i )
- sp->value.ia[i] = get_uint32(st, p);
- goto dux;
- case pxt_sint16 & 7:
- sp->type |= pxd_sint16;
- for ( i = 0; i < count; p += 2, ++i )
- sp->value.ia[i] = get_sint16(st, p);
+ --p;
+ continue;
+ case pxt_uint16 & 7:
+ sp->type |= pxd_uint16;
+ for ( i = 0; i < count; p += 2, ++i )
+ sp->value.ia[i] = get_uint16(st, p);
+ goto dux;
+ case pxt_uint32 & 7:
+ sp->type |= pxd_uint32;
+ for ( i = 0; i < count; p += 4, ++i )
+ sp->value.ia[i] = get_uint32(st, p);
+ goto dux;
+ case pxt_sint16 & 7:
+ sp->type |= pxd_sint16;
+ for ( i = 0; i < count; p += 2, ++i )
+ sp->value.ia[i] = get_sint16(st, p);
dsx: trace_scalar(" %ld", long, ia);
- --p;
- continue;
- case pxt_sint32 & 7:
- sp->type |= pxd_sint32;
- for ( i = 0; i < count; p += 4, ++i )
- sp->value.ia[i] = get_sint32(st, p);
- goto dsx;
- case pxt_real32 & 7:
- sp->type |= pxd_real32;
- for ( i = 0; i < count; p += 4, ++i )
- sp->value.ra[i] = get_real32(st, p);
- trace_scalar(" %g", double, ra);
- --p;
- continue;
- default:
- break;
- }
- }
- break;
- case 25:
- /* Array data */
- { const byte *dp;
- uint nbytes;
- if ( sp == stack_limit )
- { code = gs_note_error(errorInternalOverflow);
- goto x;
- }
- switch ( p[2] )
- {
- case pxt_ubyte:
- sp[1].value.array.size = p[3];
- dp = p + 4;
- break;
- case pxt_uint16:
- if ( left < 4 )
- { if_debug0('i', "...\n");
- /* Undo the state transition. */
- st->macro_state ^= syntax->state_transition;
- goto x;
- }
- sp[1].value.array.size = get_uint16(st, p+3);
- dp = p + 5;
- break;
- default:
- st->last_operator = tag; /* for error message */
- code = gs_note_error(errorIllegalTag);
- goto x;
- }
- nbytes = sp[1].value.array.size;
- if_debug1('i', "[%u]\n", sp[1].value.array.size);
- switch ( tag )
- {
- case pxt_ubyte_array:
- sp[1].type = pxd_array | pxd_ubyte;
+ --p;
+ continue;
+ case pxt_sint32 & 7:
+ sp->type |= pxd_sint32;
+ for ( i = 0; i < count; p += 4, ++i )
+ sp->value.ia[i] = get_sint32(st, p);
+ goto dsx;
+ case pxt_real32 & 7:
+ sp->type |= pxd_real32;
+ for ( i = 0; i < count; p += 4, ++i )
+ sp->value.ra[i] = get_real32(st, p);
+ trace_scalar(" %g", double, ra);
+ --p;
+ continue;
+ default:
+ break;
+ }
+ }
+ break;
+ case 25:
+ /* Array data */
+ { const byte *dp;
+ uint nbytes;
+ if ( sp == stack_limit )
+ { code = gs_note_error(errorInternalOverflow);
+ goto x;
+ }
+ switch ( p[2] )
+ {
+ case pxt_ubyte:
+ sp[1].value.array.size = p[3];
+ dp = p + 4;
+ break;
+ case pxt_uint16:
+ if ( left < 4 )
+ { if_debug0('i', "...\n");
+ /* Undo the state transition. */
+ st->macro_state ^= syntax->state_transition;
+ goto x;
+ }
+ sp[1].value.array.size = get_uint16(st, p+3);
+ dp = p + 5;
+ break;
+ default:
+ st->last_operator = tag; /* for error message */
+ code = gs_note_error(errorIllegalTag);
+ goto x;
+ }
+ nbytes = sp[1].value.array.size;
+ if_debug1('i', "[%u]\n", sp[1].value.array.size);
+ switch ( tag )
+ {
+ case pxt_ubyte_array:
+ sp[1].type = pxd_array | pxd_ubyte;
array: ++sp;
- if ( st->big_endian )
- sp->type |= pxd_big_endian;
- sp->value.array.data = dp;
- sp->attribute = 0;
- /* Check whether we have enough data for the entire */
- /* array. */
- if ( rlimit + 1 - dp < nbytes )
- { /* Exit now, continue reading when we return. */
- uint avail = rlimit + 1 - dp;
-
- code = px_save_array(sp, pxs, "partial array",
- avail);
- if ( code < 0 )
- goto x;
- sp->type |= pxd_on_heap;
- st->data_left = nbytes - avail;
- st->data_proc = 0;
- p = rlimit;
- goto x;
- }
- p = dp + nbytes - 1;
- trace_array(sp);
- continue;
- case pxt_uint16_array:
- sp[1].type = pxd_array | pxd_uint16;
+ if ( st->big_endian )
+ sp->type |= pxd_big_endian;
+ sp->value.array.data = dp;
+ sp->attribute = 0;
+ /* Check whether we have enough data for the entire */
+ /* array. */
+ if ( rlimit + 1 - dp < nbytes )
+ { /* Exit now, continue reading when we return. */
+ uint avail = rlimit + 1 - dp;
+
+ code = px_save_array(sp, pxs, "partial array",
+ avail);
+ if ( code < 0 )
+ goto x;
+ sp->type |= pxd_on_heap;
+ st->data_left = nbytes - avail;
+ st->data_proc = 0;
+ p = rlimit;
+ goto x;
+ }
+ p = dp + nbytes - 1;
+ trace_array(sp);
+ continue;
+ case pxt_uint16_array:
+ sp[1].type = pxd_array | pxd_uint16;
a16: nbytes <<= 1;
- goto array;
- case pxt_uint32_array:
- sp[1].type = pxd_array | pxd_uint32;
+ goto array;
+ case pxt_uint32_array:
+ sp[1].type = pxd_array | pxd_uint32;
a32: nbytes <<= 2;
- goto array;
- case pxt_sint16_array:
- sp[1].type = pxd_array | pxd_sint16;
- goto a16;
- case pxt_sint32_array:
- sp[1].type = pxd_array | pxd_sint32;
- goto a32;
- case pxt_real32_array:
- sp[1].type = pxd_array | pxd_real32;
- goto a32;
- default:
- break;
- }
- break;
- }
- break;
- case 31:
- { px_attribute_t attr;
- const byte *pnext;
-
- switch ( tag )
- {
- case pxt_attr_ubyte:
- attr = p[2];
- pnext = p + 2;
- goto a;
- case pxt_attr_uint16:
- attr = get_uint16(st, p+2);
- pnext = p + 3;
+ goto array;
+ case pxt_sint16_array:
+ sp[1].type = pxd_array | pxd_sint16;
+ goto a16;
+ case pxt_sint32_array:
+ sp[1].type = pxd_array | pxd_sint32;
+ goto a32;
+ case pxt_real32_array:
+ sp[1].type = pxd_array | pxd_real32;
+ goto a32;
+ default:
+ break;
+ }
+ break;
+ }
+ break;
+ case 31:
+ { px_attribute_t attr;
+ const byte *pnext;
+
+ switch ( tag )
+ {
+ case pxt_attr_ubyte:
+ attr = p[2];
+ pnext = p + 2;
+ goto a;
+ case pxt_attr_uint16:
+ attr = get_uint16(st, p+2);
+ pnext = p + 3;
a: if ( attr >= px_attribute_next )
- break;
- /*
- * We could check the attribute value type here, but
- * in order to match the behavior of the H-P printers,
- * we don't do it until we see the operator.
- *
- * It is legal to specify the same attribute more than
- * once; the last value has priority. If this happens,
- * since the order of attributes doesn't matter, we can
- * just replace the former value on the stack.
- */
- sp->attribute = attr;
- if ( st->attribute_indices[attr] != 0 )
- { px_value_t *old_sp =
- &st->stack[st->attribute_indices[attr]];
- /* If the old value is on the heap, free it. */
- if ( old_sp->type & pxd_on_heap )
+ break;
+ /*
+ * We could check the attribute value type here, but
+ * in order to match the behavior of the H-P printers,
+ * we don't do it until we see the operator.
+ *
+ * It is legal to specify the same attribute more than
+ * once; the last value has priority. If this happens,
+ * since the order of attributes doesn't matter, we can
+ * just replace the former value on the stack.
+ */
+ sp->attribute = attr;
+ if ( st->attribute_indices[attr] != 0 )
+ { px_value_t *old_sp =
+ &st->stack[st->attribute_indices[attr]];
+ /* If the old value is on the heap, free it. */
+ if ( old_sp->type & pxd_on_heap )
gs_free_object(memory, (void *)old_sp->value.array.data,
- "old value for duplicate attribute");
- *old_sp = *sp--;
- }
- else
- st->attribute_indices[attr] = sp - st->stack;
- p = pnext;
- continue;
- case pxt_dataLength:
- /*
- * Unexpected data length operators are normally not
- * allowed, but there might be a zero-length data
- * block immediately following a zero-size image,
- * which doesn't ask for any data.
- */
- if ( uint32at(p + 2, true /*arbitrary*/) == 0 )
- { p += 5;
- continue;
- }
- break;
- case pxt_dataLengthByte:
- /* See the comment under pxt_dataLength above. */
- if ( p[2] == 0 )
- { p += 2;
- continue;
- }
- break;
- default:
- break;
- }
- }
- break;
- default:
- break;
- }
- /* Unknown tag value. Report an error. */
- st->last_operator = tag; /* for error message */
- code = gs_note_error(errorIllegalTag);
- break;
- }
+ "old value for duplicate attribute");
+ *old_sp = *sp--;
+ }
+ else
+ st->attribute_indices[attr] = sp - st->stack;
+ p = pnext;
+ continue;
+ case pxt_dataLength:
+ /*
+ * Unexpected data length operators are normally not
+ * allowed, but there might be a zero-length data
+ * block immediately following a zero-size image,
+ * which doesn't ask for any data.
+ */
+ if ( uint32at(p + 2, true /*arbitrary*/) == 0 )
+ { p += 5;
+ continue;
+ }
+ break;
+ case pxt_dataLengthByte:
+ /* See the comment under pxt_dataLength above. */
+ if ( p[2] == 0 )
+ { p += 2;
+ continue;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ /* Unknown tag value. Report an error. */
+ st->last_operator = tag; /* for error message */
+ code = gs_note_error(errorIllegalTag);
+ break;
+ }
x: /* Save any leftover input. */
- left = rlimit - p;
- if ( rlimit != pr->limit )
- { /* We were reading saved input. */
- if ( left <= next_p - orig_p )
- { /* We finished reading the previously saved input. */
- /* Continue reading current input, unless we got an error. */
- p = next_p -= left;
- rlimit = pr->limit;
- st->saved_count = 0;
- if ( code >= 0 )
- goto parse;
- }
- else
- { /* There's still some previously saved input left over. */
- memmove(st->saved, p + 1, st->saved_count = left);
- p = next_p;
- rlimit = pr->limit;
- left = rlimit - p;
- }
- }
- /* Except in case of error, save any remaining input. */
- if ( code >= 0 )
- { if ( left + st->saved_count > sizeof(st->saved) )
- { /* Fatal error -- shouldn't happen! */
- code = gs_note_error(errorInternalOverflow);
- st->saved_count = 0;
- }
- else
- { memcpy(&st->saved[st->saved_count], p + 1, left);
- st->saved_count += left;
- p = rlimit;
- }
- }
- pr->ptr = p;
- st->stack_count = sp - st->stack;
- /* Move to the heap any arrays whose data was being referenced */
- /* directly in the input buffer. */
- for ( ; sp > st->stack; --sp )
- if ( (sp->type & (pxd_array | pxd_on_heap)) == pxd_array )
- { int code = px_save_array(sp, pxs, "px stack array to heap",
- sp->value.array.size * value_size(sp));
- if ( code < 0 )
- break;
- sp->type |= pxd_on_heap;
- }
- if ( code < 0 && syntax != 0 )
- { /* Undo the state transition. */
- st->macro_state ^= syntax->state_transition;
- }
- return code;
+ left = rlimit - p;
+ if ( rlimit != pr->limit )
+ { /* We were reading saved input. */
+ if ( left <= next_p - orig_p )
+ { /* We finished reading the previously saved input. */
+ /* Continue reading current input, unless we got an error. */
+ p = next_p -= left;
+ rlimit = pr->limit;
+ st->saved_count = 0;
+ if ( code >= 0 )
+ goto parse;
+ }
+ else
+ { /* There's still some previously saved input left over. */
+ memmove(st->saved, p + 1, st->saved_count = left);
+ p = next_p;
+ rlimit = pr->limit;
+ left = rlimit - p;
+ }
+ }
+ /* Except in case of error, save any remaining input. */
+ if ( code >= 0 )
+ { if ( left + st->saved_count > sizeof(st->saved) )
+ { /* Fatal error -- shouldn't happen! */
+ code = gs_note_error(errorInternalOverflow);
+ st->saved_count = 0;
+ }
+ else
+ { memcpy(&st->saved[st->saved_count], p + 1, left);
+ st->saved_count += left;
+ p = rlimit;
+ }
+ }
+ pr->ptr = p;
+ st->stack_count = sp - st->stack;
+ /* Move to the heap any arrays whose data was being referenced */
+ /* directly in the input buffer. */
+ for ( ; sp > st->stack; --sp )
+ if ( (sp->type & (pxd_array | pxd_on_heap)) == pxd_array )
+ { int code = px_save_array(sp, pxs, "px stack array to heap",
+ sp->value.array.size * value_size(sp));
+ if ( code < 0 )
+ break;
+ sp->type |= pxd_on_heap;
+ }
+ if ( code < 0 && syntax != 0 )
+ { /* Undo the state transition. */
+ st->macro_state ^= syntax->state_transition;
+ }
+ return code;
}
uint
@@ -914,4 +914,3 @@ px_parser_data_left(px_parser_state_t *pxp)
{
return pxp->data_left;
}
-
diff --git a/pxl/pxparse.h b/pxl/pxparse.h
index b3ec1b8c1..5a4d358c2 100644
--- a/pxl/pxparse.h
+++ b/pxl/pxparse.h
@@ -59,14 +59,14 @@ typedef struct px_parser_state_s px_parser_state_t;
#endif
#define max_stack max_px_args /* must not exceed 256 */
struct px_parser_state_s {
- /* Set at initialization */
+ /* Set at initialization */
gs_memory_t *memory;
bool big_endian;
- /* Updated dynamically, for error reporting only */
+ /* Updated dynamically, for error reporting only */
long operator_count;
long parent_operator_count;
int /*px_tag_t*/ last_operator; /* pxtNull if none */
- /* Updated dynamically */
+ /* Updated dynamically */
int saved_count; /* amount of leftover input in saved */
uint data_left; /* amount left to read of data or array */
uint macro_state; /* mask for macro-state */
@@ -97,7 +97,7 @@ void px_process_init(px_parser_state_t *st, bool big_endian);
/* Process a buffer of PCL XL commands. */
int px_process(px_parser_state_t *st, px_state_t *pxs,
- stream_cursor_read *pr);
+ stream_cursor_read *pr);
/* unfortunately we have to export this for pass through mode, other
commands do not need to know how much data is left to parse. */
diff --git a/pxl/pxpthr.c b/pxl/pxpthr.c
index b22580885..fc63f9d6e 100644
--- a/pxl/pxpthr.c
+++ b/pxl/pxpthr.c
@@ -61,8 +61,6 @@ float global_char_bold_value;
void pxpcl_release(void);
void pxpcl_pagestatereset(void);
-
-
/* NB: tests for this function are used to flag pxl snippet mode
*/
static int
@@ -274,7 +272,6 @@ pxPassthrough(px_args_t *par, px_state_t *pxs)
}
}
-
void
pxpcl_pagestatereset()
{
@@ -400,7 +397,6 @@ int pxpcl_selectfont(px_args_t *par, px_state_t *pxs)
{
pl_font_t *plf = global_pcs->font;
-
/* unfortunately the storage identifier is inconsistent
between PCL and PCL XL, NB we should use the pxfont.h
enumerations pxfsInternal and pxfsDownloaded but there is a
diff --git a/pxl/pxsessio.c b/pxl/pxsessio.c
index 0ee0d6529..65c1c27c8 100644
--- a/pxl/pxsessio.c
+++ b/pxl/pxsessio.c
@@ -21,7 +21,7 @@
#include "pxpthr.h"
#include "pxstate.h"
#include "pxfont.h"
-#include "pjparse.h"
+#include "pjparse.h"
#include "gschar.h"
#include "gscoord.h"
#include "gserrors.h" /* for gs_error_undefined */
@@ -75,22 +75,21 @@ px_paper_string_to_media(pjl_envvar_t *paper_str)
/* table to map pjl paper type strings to pxl enums */
int i;
for (i = 0; i < countof(known_media); i++) {
- if ( !pjl_compare(paper_str, known_media[i].mname) )
- return known_media[i].ms_enum;
+ if ( !pjl_compare(paper_str, known_media[i].mname) )
+ return known_media[i].ms_enum;
}
/* not found return letter */
return eLetterPaper;
}
-
/* return the default media set up in the XL state */
-static px_media_t *
+static px_media_t *
px_get_default_media(px_state_t *pxs)
{
int i;
for (i = 0; i < countof(known_media); i++)
- if ( known_media[i].ms_enum == pxs->media_size )
- return &known_media[i];
+ if ( known_media[i].ms_enum == pxs->media_size )
+ return &known_media[i];
/* shouldn't get here but just in case we return letter. */
return &known_media[1];
}
@@ -107,35 +106,35 @@ px_get_default_media_size(px_state_t *pxs, gs_point *pt)
static int
px_put1(gx_device *dev, gs_c_param_list *plist, int ecode)
{ int code = ecode;
- if ( code >= 0 )
- { gs_c_param_list_read(plist);
- code = gs_putdeviceparams(dev, (gs_param_list *)plist);
- }
- gs_c_param_list_release(plist);
- return (code == 0 || code == gs_error_undefined ? ecode : code);
+ if ( code >= 0 )
+ { gs_c_param_list_read(plist);
+ code = gs_putdeviceparams(dev, (gs_param_list *)plist);
+ }
+ gs_c_param_list_release(plist);
+ return (code == 0 || code == gs_error_undefined ? ecode : code);
}
/* Adjust one scale factor to an integral value if we can. */
static double
px_adjust_scale(double value, double extent)
{ /* If we can make the value an integer with a total error */
- /* of less than 1/2 pixel over the entire page, we do it. */
- double int_value = floor(value + 0.5);
+ /* of less than 1/2 pixel over the entire page, we do it. */
+ double int_value = floor(value + 0.5);
- return (fabs((int_value - value) * extent) < 0.5 ? int_value : value);
+ return (fabs((int_value - value) * extent) < 0.5 ? int_value : value);
}
/* Clean up at the end of a page, but before rendering. */
static void
px_end_page_cleanup(px_state_t *pxs)
{ px_dict_release(&pxs->page_pattern_dict);
- /* Clean up stray gstate information. */
- while ( pxs->pxgs->stack_depth > 0 )
- pxPopGS(NULL, pxs);
- /* Pop an extra time to mirror the push in BeginPage. */
- pxs->pxgs->stack_depth++;
- pxPopGS(NULL, pxs);
- pxNewPath(NULL, pxs);
+ /* Clean up stray gstate information. */
+ while ( pxs->pxgs->stack_depth > 0 )
+ pxPopGS(NULL, pxs);
+ /* Pop an extra time to mirror the push in BeginPage. */
+ pxs->pxgs->stack_depth++;
+ pxPopGS(NULL, pxs);
+ pxNewPath(NULL, pxs);
px_purge_pattern_cache(pxs, ePagePattern);
pxpcl_pagestatereset();
}
@@ -143,7 +142,7 @@ px_end_page_cleanup(px_state_t *pxs)
/* Purge all */
static bool
purge_all(const gs_memory_t *mem, cached_char *cc, void *dummy)
-{
+{
return true;
}
@@ -152,9 +151,9 @@ purge_all(const gs_memory_t *mem, cached_char *cc, void *dummy)
static void
px_end_session_cleanup(px_state_t *pxs)
{ if ( pxs->data_source_open )
- pxCloseDataSource(NULL, pxs);
- px_purge_character_cache(pxs);
- px_dict_release(&pxs->session_pattern_dict);
+ pxCloseDataSource(NULL, pxs);
+ px_purge_character_cache(pxs);
+ px_dict_release(&pxs->session_pattern_dict);
if (gstate_pattern_cache(pxs->pgs)) {
(gstate_pattern_cache(pxs->pgs)->free_all)
(gstate_pattern_cache(pxs->pgs));
@@ -172,10 +171,10 @@ px_end_session_cleanup(px_state_t *pxs)
}
}
}
- /* We believe that streams do *not* persist across sessions.... */
- px_dict_release(&pxs->stream_dict);
- /* delete downloaded fonts on end of session */
- px_dict_release(&pxs->font_dict);
+ /* We believe that streams do *not* persist across sessions.... */
+ px_dict_release(&pxs->stream_dict);
+ /* delete downloaded fonts on end of session */
+ px_dict_release(&pxs->font_dict);
pxpcl_release();
}
@@ -184,8 +183,8 @@ px_end_session_cleanup(px_state_t *pxs)
/* Clean up after an error or UEL. */
void px_state_cleanup(px_state_t *pxs)
{ px_end_page_cleanup(pxs);
- px_end_session_cleanup(pxs);
- pxs->have_page = false;
+ px_end_session_cleanup(pxs);
+ pxs->have_page = false;
}
void px_purge_character_cache(px_state_t *pxs)
@@ -202,75 +201,75 @@ const byte apxBeginSession[] = {
int
pxBeginSession(px_args_t *par, px_state_t *pxs)
{ pxs->measure = par->pv[0]->value.i;
- pxs->units_per_measure.x = real_value(par->pv[1], 0);
- pxs->units_per_measure.y = real_value(par->pv[1], 1);
+ pxs->units_per_measure.x = real_value(par->pv[1], 0);
+ pxs->units_per_measure.y = real_value(par->pv[1], 1);
pxs->stream_level = 0;
- if ( par->pv[2] )
- pxs->error_report = par->pv[2]->value.i;
- else
- pxs->error_report = eNoReporting;
- px_dict_init(&pxs->session_pattern_dict, pxs->memory, px_free_pattern);
- /* Set media parameters to device defaults, in case BeginPage */
- /* doesn't specify valid ones. */
- /* This is obviously device-dependent. */
- /* get the pjl state */
- {
- pjl_envvar_t *pjl_psize = pjl_proc_get_envvar(pxs->pjls, "paper");
- /* NB. We are not sure about the interaction of pjl's
+ if ( par->pv[2] )
+ pxs->error_report = par->pv[2]->value.i;
+ else
+ pxs->error_report = eNoReporting;
+ px_dict_init(&pxs->session_pattern_dict, pxs->memory, px_free_pattern);
+ /* Set media parameters to device defaults, in case BeginPage */
+ /* doesn't specify valid ones. */
+ /* This is obviously device-dependent. */
+ /* get the pjl state */
+ {
+ pjl_envvar_t *pjl_psize = pjl_proc_get_envvar(pxs->pjls, "paper");
+ /* NB. We are not sure about the interaction of pjl's
wide a4 commands so we don't attempt to implement
it. */
- /* bool pjl_widea4
- = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "widea4"), "no"); */
- int pjl_copies
- = pjl_proc_vartoi(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "copies"));
- bool pjl_duplex
- = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "duplex"), "off");
- bool pjl_bindshort
- = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "binding"), "longedge");
- bool pjl_manualfeed
- = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "manualfeed"), "off");
- pxs->media_size = px_paper_string_to_media(pjl_psize);
- pxs->media_source = (pjl_manualfeed ? eManualFeed : eDefaultSource);
- pxs->duplex = pjl_duplex;
- pxs->duplex_page_mode = (pjl_bindshort ? eDuplexHorizontalBinding :
- eDuplexVerticalBinding);
- pxs->duplex_back_side = eFrontMediaSide;
- pxs->copies = pjl_copies;
- pxs->media_destination = eDefaultDestination;
- pxs->media_type = eDefaultType;
+ /* bool pjl_widea4
+ = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "widea4"), "no"); */
+ int pjl_copies
+ = pjl_proc_vartoi(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "copies"));
+ bool pjl_duplex
+ = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "duplex"), "off");
+ bool pjl_bindshort
+ = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "binding"), "longedge");
+ bool pjl_manualfeed
+ = pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "manualfeed"), "off");
+ pxs->media_size = px_paper_string_to_media(pjl_psize);
+ pxs->media_source = (pjl_manualfeed ? eManualFeed : eDefaultSource);
+ pxs->duplex = pjl_duplex;
+ pxs->duplex_page_mode = (pjl_bindshort ? eDuplexHorizontalBinding :
+ eDuplexVerticalBinding);
+ pxs->duplex_back_side = eFrontMediaSide;
+ pxs->copies = pjl_copies;
+ pxs->media_destination = eDefaultDestination;
+ pxs->media_type = eDefaultType;
pxs->useciecolor = !pjl_proc_compare(pxs->pjls,
pjl_proc_get_envvar(pxs->pjls, "useciecolor"), "on");
-
- if (!pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "orientation"), "LANDSCAPE"))
- pxs->orientation = eLandscapeOrientation;
- if (!pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "orientation"), "PORTRAIT"))
- pxs->orientation = ePortraitOrientation;
- /* NB reverse orientations missing */
-
- /* install the built in fonts */
- if ( pl_load_built_in_fonts(pjl_proc_fontsource_to_path(pxs->pjls, "I"),
- pxs->memory,
- &pxs->builtin_font_dict,
- pxs->font_dir,
- (int)pxfsInternal,
- true /* use unicode key names */) < 0 ) {
- dprintf("Fatal error - no resident fonts\n");
- return -1;
-
- }
- }
- return 0;
+
+ if (!pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "orientation"), "LANDSCAPE"))
+ pxs->orientation = eLandscapeOrientation;
+ if (!pjl_proc_compare(pxs->pjls, pjl_proc_get_envvar(pxs->pjls, "orientation"), "PORTRAIT"))
+ pxs->orientation = ePortraitOrientation;
+ /* NB reverse orientations missing */
+
+ /* install the built in fonts */
+ if ( pl_load_built_in_fonts(pjl_proc_fontsource_to_path(pxs->pjls, "I"),
+ pxs->memory,
+ &pxs->builtin_font_dict,
+ pxs->font_dir,
+ (int)pxfsInternal,
+ true /* use unicode key names */) < 0 ) {
+ dprintf("Fatal error - no resident fonts\n");
+ return -1;
+
+ }
+ }
+ return 0;
}
const byte apxEndSession[] = {0, 0};
int
pxEndSession(px_args_t *par, px_state_t *pxs)
{ px_end_session_cleanup(pxs);
- if ( pxs->warning_length )
- return_error(errorWarningsReported);
- return 0;
+ if ( pxs->warning_length )
+ return_error(errorWarningsReported);
+ return 0;
}
const byte apxBeginPage[] = {
@@ -282,10 +281,10 @@ const byte apxBeginPage[] = {
int
pxBeginPage(px_args_t *par, px_state_t *pxs)
{ gs_state *pgs = pxs->pgs;
- gx_device *dev = gs_currentdevice(pgs);
- gs_point page_size_pixels;
- gs_matrix points2device;
- bool no_pv_2 = false;
+ gx_device *dev = gs_currentdevice(pgs);
+ gs_point page_size_pixels;
+ gs_matrix points2device;
+ bool no_pv_2 = false;
/* check for 2.1 no parameter special cases */
{
@@ -298,7 +297,7 @@ pxBeginPage(px_args_t *par, px_state_t *pxs)
}
}
if ( have_params == false ) {
- if (par->pv[0]) {
+ if (par->pv[0]) {
int32_t orientation = par->pv[0]->value.i;
if ( orientation < 0 || orientation >= pxeOrientation_next )
{ px_record_warning("IllegalOrientation", true, pxs);
@@ -309,296 +308,294 @@ pxBeginPage(px_args_t *par, px_state_t *pxs)
goto setd;
}
}
- /* Check parameter presence for legal combinations. */
- if ( par->pv[2] )
- { if ( par->pv[3] || par->pv[4] )
- return_error(errorIllegalAttributeCombination);
- }
- else if ( par->pv[3] && par->pv[4] )
- { if ( par->pv[2] )
- return_error(errorIllegalAttributeCombination);
- }
- else {
- pxs->pm = px_get_default_media(pxs);
- no_pv_2 = true;
- }
- if ( par->pv[5] )
- { if ( par->pv[6] || par->pv[7] )
- return_error(errorIllegalAttributeCombination);
- }
- else if ( par->pv[6] )
- { if ( par->pv[5] )
- return_error(errorIllegalAttributeCombination);
- }
-
-
- /* Copy parameters to the PCL XL state. */
- /* For some reason, invalid Orientations only produces a warning. */
- if ( par->pv[0] ) {
- int32_t orientation = par->pv[0]->value.i;
- if ( orientation < 0 || orientation >= pxeOrientation_next ) {
- px_record_warning("IllegalOrientation", true, pxs);
- orientation = ePortraitOrientation;
- }
- pxs->orientation = (pxeOrientation_t)orientation;
- }
-
- if ( par->pv[1] )
- pxs->media_source = par->pv[1]->value.i;
- if ( par->pv[2] ) {
- /* default to letter */
- pxeMediaSize_t ms_enum = eLetterPaper;
- int i;
- /* could be an array or enumeration */
- if ( par->pv[2]->type & pxd_array ) {
- /* it's an array, so convert it to the associated
+ /* Check parameter presence for legal combinations. */
+ if ( par->pv[2] )
+ { if ( par->pv[3] || par->pv[4] )
+ return_error(errorIllegalAttributeCombination);
+ }
+ else if ( par->pv[3] && par->pv[4] )
+ { if ( par->pv[2] )
+ return_error(errorIllegalAttributeCombination);
+ }
+ else {
+ pxs->pm = px_get_default_media(pxs);
+ no_pv_2 = true;
+ }
+ if ( par->pv[5] )
+ { if ( par->pv[6] || par->pv[7] )
+ return_error(errorIllegalAttributeCombination);
+ }
+ else if ( par->pv[6] )
+ { if ( par->pv[5] )
+ return_error(errorIllegalAttributeCombination);
+ }
+
+ /* Copy parameters to the PCL XL state. */
+ /* For some reason, invalid Orientations only produces a warning. */
+ if ( par->pv[0] ) {
+ int32_t orientation = par->pv[0]->value.i;
+ if ( orientation < 0 || orientation >= pxeOrientation_next ) {
+ px_record_warning("IllegalOrientation", true, pxs);
+ orientation = ePortraitOrientation;
+ }
+ pxs->orientation = (pxeOrientation_t)orientation;
+ }
+
+ if ( par->pv[1] )
+ pxs->media_source = par->pv[1]->value.i;
+ if ( par->pv[2] ) {
+ /* default to letter */
+ pxeMediaSize_t ms_enum = eLetterPaper;
+ int i;
+ /* could be an array or enumeration */
+ if ( par->pv[2]->type & pxd_array ) {
+ /* it's an array, so convert it to the associated
enumeration */
- byte *str = gs_alloc_string(pxs->memory,
- array_value_size(par->pv[2]) + 1,
- "pxBeginPage");
- if ( str == 0 )
- return_error(errorInsufficientMemory);
- /* null terminate */
- memcpy(str, par->pv[2]->value.array.data, array_value_size(par->pv[2]));
- str[array_value_size(par->pv[2])] = '\0';
- ms_enum = px_paper_string_to_media(/* NB */(pjl_envvar_t *)str);
- gs_free_string(pxs->memory, str,
- array_value_size(par->pv[2]) + 1, "pxBeginPage");
-
- } else if ( par->pv[2]->value.i ) { /* it's an enumeration */
- ms_enum = par->pv[2]->value.i;
- }
- if ( ms_enum == eDefaultPaperSize ) {
- pxs->pm = px_get_default_media(pxs);
- }
- else {
+ byte *str = gs_alloc_string(pxs->memory,
+ array_value_size(par->pv[2]) + 1,
+ "pxBeginPage");
+ if ( str == 0 )
+ return_error(errorInsufficientMemory);
+ /* null terminate */
+ memcpy(str, par->pv[2]->value.array.data, array_value_size(par->pv[2]));
+ str[array_value_size(par->pv[2])] = '\0';
+ ms_enum = px_paper_string_to_media(/* NB */(pjl_envvar_t *)str);
+ gs_free_string(pxs->memory, str,
+ array_value_size(par->pv[2]) + 1, "pxBeginPage");
+
+ } else if ( par->pv[2]->value.i ) { /* it's an enumeration */
+ ms_enum = par->pv[2]->value.i;
+ }
+ if ( ms_enum == eDefaultPaperSize ) {
+ pxs->pm = px_get_default_media(pxs);
+ }
+ else {
bool found_media = false;
- for ( pxs->pm = known_media, i = 0; i < countof(known_media); ++pxs->pm, ++i )
- if ( pxs->pm->ms_enum == ms_enum ) {
+ for ( pxs->pm = known_media, i = 0; i < countof(known_media); ++pxs->pm, ++i )
+ if ( pxs->pm->ms_enum == ms_enum ) {
found_media = true;
break;
}
- if ( !found_media ) { /* No match, select default media. */
- pxs->pm = px_get_default_media(pxs);
- px_record_warning("IllegalMediaSize", false, pxs);
- }
- }
+ if ( !found_media ) { /* No match, select default media. */
+ pxs->pm = px_get_default_media(pxs);
+ px_record_warning("IllegalMediaSize", false, pxs);
+ }
+ }
media: pxs->media_size = pxs->pm->ms_enum;
- pxs->media_dims.x = pxs->pm->width * media_size_scale;
- pxs->media_dims.y = pxs->pm->height * media_size_scale;
- pxs->media_height = pxs->pm->height;
- pxs->media_width = pxs->pm->width;
- } else if ( no_pv_2 ) {
- goto media;
- } else { /* custom (!par->pv[2]) */
- double scale = measure_to_points[par->pv[4]->value.i];
- pxs->media_dims.x = real_value(par->pv[3], 0) * scale;
- pxs->media_dims.y = real_value(par->pv[3], 1) * scale;
- /*
- * Assume the unprintable margins for custom media are the same
- * as for the default media. This may not be right.
- */
- pxs->pm = px_get_default_media(pxs);
- pxs->media_height = pxs->media_dims.y / media_size_scale;
- pxs->media_width = pxs->media_dims.x / media_size_scale;
- }
- if ( par->pv[5] )
- { pxs->duplex = false;
- }
- else if ( par->pv[6] )
- { pxs->duplex = true;
- pxs->duplex_page_mode = par->pv[6]->value.i;
- if ( par->pv[7] )
- pxs->duplex_back_side = (par->pv[7]->value.i == eBackMediaSide);
- }
- if ( par->pv[8] )
- pxs->media_destination = par->pv[8]->value.i;
- if ( par->pv[9] )
- pxs->media_type = par->pv[9]->value.i;
-
- /* Pass the media parameters to the device. */
+ pxs->media_dims.x = pxs->pm->width * media_size_scale;
+ pxs->media_dims.y = pxs->pm->height * media_size_scale;
+ pxs->media_height = pxs->pm->height;
+ pxs->media_width = pxs->pm->width;
+ } else if ( no_pv_2 ) {
+ goto media;
+ } else { /* custom (!par->pv[2]) */
+ double scale = measure_to_points[par->pv[4]->value.i];
+ pxs->media_dims.x = real_value(par->pv[3], 0) * scale;
+ pxs->media_dims.y = real_value(par->pv[3], 1) * scale;
+ /*
+ * Assume the unprintable margins for custom media are the same
+ * as for the default media. This may not be right.
+ */
+ pxs->pm = px_get_default_media(pxs);
+ pxs->media_height = pxs->media_dims.y / media_size_scale;
+ pxs->media_width = pxs->media_dims.x / media_size_scale;
+ }
+ if ( par->pv[5] )
+ { pxs->duplex = false;
+ }
+ else if ( par->pv[6] )
+ { pxs->duplex = true;
+ pxs->duplex_page_mode = par->pv[6]->value.i;
+ if ( par->pv[7] )
+ pxs->duplex_back_side = (par->pv[7]->value.i == eBackMediaSide);
+ }
+ if ( par->pv[8] )
+ pxs->media_destination = par->pv[8]->value.i;
+ if ( par->pv[9] )
+ pxs->media_type = par->pv[9]->value.i;
+
+ /* Pass the media parameters to the device. */
setd: { gs_memory_t *mem = pxs->memory;
- gs_c_param_list list;
+ gs_c_param_list list;
#define plist ((gs_param_list *)&list)
- gs_param_float_array fa;
- float fv[4];
- int iv;
- bool bv;
- int ecode = 0;
- int code;
-
- fa.data = fv;
- fa.persistent = false;
-
- gs_c_param_list_write(&list, mem);
- iv = pxs->orientation; /* might not be an int */
- code = param_write_int(plist, "Orientation", &iv);
- ecode = px_put1(dev, &list, ecode);
-
- gs_c_param_list_write(&list, mem);
- fv[0] = pxs->media_dims.x;
- fv[1] = pxs->media_dims.y;
- fa.size = 2;
- code = param_write_float_array(plist, ".MediaSize", &fa);
- ecode = px_put1(dev, &list, ecode);
- gs_c_param_list_write(&list, mem);
-
- /* Set the mis-named "Margins" (actually the offset on the page) */
- /* to zero. */
- gs_c_param_list_write(&list, mem);
- fv[0] = 0;
- fv[1] = 0;
- fa.size = 2;
- code = param_write_float_array(plist, "Margins", &fa);
- ecode = px_put1(dev, &list, ecode);
-
- iv = pxs->media_source; /* might not be an int */
- if ( iv < 0 || iv >= pxeMediaSource_next )
- px_record_warning("IllegalMediaSource", false, pxs);
- else
- { gs_c_param_list_write(&list, mem);
- code = param_write_int(plist, ".MediaSource", &iv);
- ecode = px_put1(dev, &list, ecode);
- }
-
- gs_c_param_list_write(&list, mem);
- code = param_write_bool(plist, "Duplex", &pxs->duplex);
- ecode = px_put1(dev, &list, ecode);
-
- gs_c_param_list_write(&list, mem);
- bv = pxs->duplex_page_mode == eDuplexHorizontalBinding;
- code = param_write_bool(plist, "Tumble", &bv);
- ecode = px_put1(dev, &list, ecode);
-
- gs_c_param_list_write(&list, mem);
- bv = !pxs->duplex_back_side;
- code = param_write_bool(plist, "FirstSide", &bv);
- ecode = px_put1(dev, &list, ecode);
-
- gs_c_param_list_write(&list, mem);
- iv = pxs->media_destination; /* might not be an int */
- code = param_write_int(plist, ".MediaDestination", &iv);
- ecode = px_put1(dev, &list, ecode);
-
- gs_c_param_list_write(&list, mem);
- iv = pxs->media_type; /* might not be an int */
- code = param_write_int(plist, ".MediaType", &iv);
- ecode = px_put1(dev, &list, ecode);
-
- /*
- * We aren't sure what to do if the device rejects the parameter
- * value....
- */
- switch ( ecode )
- {
- case 1:
- code = gs_setdevice(pgs, dev);
- if ( code < 0 )
- return code;
- case 0:
- break;
- default:
- return_error(errorIllegalAttributeValue);
- }
+ gs_param_float_array fa;
+ float fv[4];
+ int iv;
+ bool bv;
+ int ecode = 0;
+ int code;
+
+ fa.data = fv;
+ fa.persistent = false;
+
+ gs_c_param_list_write(&list, mem);
+ iv = pxs->orientation; /* might not be an int */
+ code = param_write_int(plist, "Orientation", &iv);
+ ecode = px_put1(dev, &list, ecode);
+
+ gs_c_param_list_write(&list, mem);
+ fv[0] = pxs->media_dims.x;
+ fv[1] = pxs->media_dims.y;
+ fa.size = 2;
+ code = param_write_float_array(plist, ".MediaSize", &fa);
+ ecode = px_put1(dev, &list, ecode);
+ gs_c_param_list_write(&list, mem);
+
+ /* Set the mis-named "Margins" (actually the offset on the page) */
+ /* to zero. */
+ gs_c_param_list_write(&list, mem);
+ fv[0] = 0;
+ fv[1] = 0;
+ fa.size = 2;
+ code = param_write_float_array(plist, "Margins", &fa);
+ ecode = px_put1(dev, &list, ecode);
+
+ iv = pxs->media_source; /* might not be an int */
+ if ( iv < 0 || iv >= pxeMediaSource_next )
+ px_record_warning("IllegalMediaSource", false, pxs);
+ else
+ { gs_c_param_list_write(&list, mem);
+ code = param_write_int(plist, ".MediaSource", &iv);
+ ecode = px_put1(dev, &list, ecode);
+ }
+
+ gs_c_param_list_write(&list, mem);
+ code = param_write_bool(plist, "Duplex", &pxs->duplex);
+ ecode = px_put1(dev, &list, ecode);
+
+ gs_c_param_list_write(&list, mem);
+ bv = pxs->duplex_page_mode == eDuplexHorizontalBinding;
+ code = param_write_bool(plist, "Tumble", &bv);
+ ecode = px_put1(dev, &list, ecode);
+
+ gs_c_param_list_write(&list, mem);
+ bv = !pxs->duplex_back_side;
+ code = param_write_bool(plist, "FirstSide", &bv);
+ ecode = px_put1(dev, &list, ecode);
+
+ gs_c_param_list_write(&list, mem);
+ iv = pxs->media_destination; /* might not be an int */
+ code = param_write_int(plist, ".MediaDestination", &iv);
+ ecode = px_put1(dev, &list, ecode);
+
+ gs_c_param_list_write(&list, mem);
+ iv = pxs->media_type; /* might not be an int */
+ code = param_write_int(plist, ".MediaType", &iv);
+ ecode = px_put1(dev, &list, ecode);
+
+ /*
+ * We aren't sure what to do if the device rejects the parameter
+ * value....
+ */
+ switch ( ecode )
+ {
+ case 1:
+ code = gs_setdevice(pgs, dev);
+ if ( code < 0 )
+ return code;
+ case 0:
+ break;
+ default:
+ return_error(errorIllegalAttributeValue);
+ }
#undef plist
- }
- { int code;
-
- px_initgraphics(pxs);
- gs_currentmatrix(pgs, &points2device);
- gs_dtransform(pgs, pxs->media_dims.x, pxs->media_dims.y,
- &page_size_pixels);
- { /*
- * Put the origin at the upper left corner of the page;
- * also account for the orientation.
- */
- gs_matrix orient;
-
- orient.xx = orient.xy = orient.yx = orient.yy =
- orient.tx = orient.ty = 0;
- switch ( pxs->orientation )
- {
- case eDefaultOrientation:
- case ePortraitOrientation:
- code = gs_translate(pgs, 0.0, pxs->media_dims.y);
- orient.xx = 1, orient.yy = -1;
- break;
- case eLandscapeOrientation:
- code = 0;
- orient.xy = 1, orient.yx = 1;
- break;
- case eReversePortrait:
- code = gs_translate(pgs, pxs->media_dims.x, 0);
- orient.xx = -1, orient.yy = 1;
- break;
- case eReverseLandscape:
- code = gs_translate(pgs, pxs->media_dims.x, pxs->media_dims.y);
- orient.xy = -1, orient.yx = -1;
- break;
- default: /* can't happen */
- return_error(errorIllegalAttributeValue);
- }
- if ( code < 0 ||
- (code = gs_concat(pgs, &orient)) < 0
- )
- return code;
- }
- { /* Scale according to session parameters. */
- /* If we can make the scale integral safely, we do. */
- double scale = measure_to_points[pxs->measure];
- gs_matrix mat;
-
- if ( (code = gs_scale(pgs, scale / pxs->units_per_measure.x,
- scale / pxs->units_per_measure.y)) < 0
- )
- return code;
- gs_currentmatrix(pgs, &mat);
- mat.xx = px_adjust_scale(mat.xx, page_size_pixels.x);
- mat.xy = px_adjust_scale(mat.xy, page_size_pixels.y);
- mat.yx = px_adjust_scale(mat.yx, page_size_pixels.x);
- mat.yy = px_adjust_scale(mat.yy, page_size_pixels.y);
- gs_setmatrix(pgs, &mat);
- pxs->initial_matrix = mat;
- }
- }
- { /*
- * Set the default halftone method. We have to do this here,
- * rather than earlier, so that the origin is set correctly.
- */
- px_args_t args;
- px_value_t device_matrix;
+ }
+ { int code;
+
+ px_initgraphics(pxs);
+ gs_currentmatrix(pgs, &points2device);
+ gs_dtransform(pgs, pxs->media_dims.x, pxs->media_dims.y,
+ &page_size_pixels);
+ { /*
+ * Put the origin at the upper left corner of the page;
+ * also account for the orientation.
+ */
+ gs_matrix orient;
+
+ orient.xx = orient.xy = orient.yx = orient.yy =
+ orient.tx = orient.ty = 0;
+ switch ( pxs->orientation )
+ {
+ case eDefaultOrientation:
+ case ePortraitOrientation:
+ code = gs_translate(pgs, 0.0, pxs->media_dims.y);
+ orient.xx = 1, orient.yy = -1;
+ break;
+ case eLandscapeOrientation:
+ code = 0;
+ orient.xy = 1, orient.yx = 1;
+ break;
+ case eReversePortrait:
+ code = gs_translate(pgs, pxs->media_dims.x, 0);
+ orient.xx = -1, orient.yy = 1;
+ break;
+ case eReverseLandscape:
+ code = gs_translate(pgs, pxs->media_dims.x, pxs->media_dims.y);
+ orient.xy = -1, orient.yx = -1;
+ break;
+ default: /* can't happen */
+ return_error(errorIllegalAttributeValue);
+ }
+ if ( code < 0 ||
+ (code = gs_concat(pgs, &orient)) < 0
+ )
+ return code;
+ }
+ { /* Scale according to session parameters. */
+ /* If we can make the scale integral safely, we do. */
+ double scale = measure_to_points[pxs->measure];
+ gs_matrix mat;
+
+ if ( (code = gs_scale(pgs, scale / pxs->units_per_measure.x,
+ scale / pxs->units_per_measure.y)) < 0
+ )
+ return code;
+ gs_currentmatrix(pgs, &mat);
+ mat.xx = px_adjust_scale(mat.xx, page_size_pixels.x);
+ mat.xy = px_adjust_scale(mat.xy, page_size_pixels.y);
+ mat.yx = px_adjust_scale(mat.yx, page_size_pixels.x);
+ mat.yy = px_adjust_scale(mat.yy, page_size_pixels.y);
+ gs_setmatrix(pgs, &mat);
+ pxs->initial_matrix = mat;
+ }
+ }
+ { /*
+ * Set the default halftone method. We have to do this here,
+ * rather than earlier, so that the origin is set correctly.
+ */
+ px_args_t args;
+ px_value_t device_matrix;
memset(args.pv, 0, sizeof(args.pv));
- args.pv[1] = &device_matrix; /* DeviceMatrix */
- device_matrix.type = pxd_scalar | pxd_ubyte;
- device_matrix.value.i = eDeviceBest;
- pxSetHalftoneMethod(&args, pxs);
- }
- /* Initialize other parts of the PCL XL state. */
- px_dict_init(&pxs->page_pattern_dict, pxs->memory, px_free_pattern);
- gs_erasepage(pgs);
- pxs->have_page = false;
- /* Make sure there is a legitimate halftone installed. */
- { int code = px_set_halftone(pxs);
- if ( code < 0 )
- return code;
- }
- /*
- * Do a gsave so we can be sure to get rid of all page-related
- * state at the end of the page, but make sure PopGS doesn't pop
- * this state from the stack.
- */
- { int code = pxPushGS(NULL, pxs);
- if ( code < 0 )
- return code;
- pxs->pxgs->stack_depth--;
- return code;
- }
+ args.pv[1] = &device_matrix; /* DeviceMatrix */
+ device_matrix.type = pxd_scalar | pxd_ubyte;
+ device_matrix.value.i = eDeviceBest;
+ pxSetHalftoneMethod(&args, pxs);
+ }
+ /* Initialize other parts of the PCL XL state. */
+ px_dict_init(&pxs->page_pattern_dict, pxs->memory, px_free_pattern);
+ gs_erasepage(pgs);
+ pxs->have_page = false;
+ /* Make sure there is a legitimate halftone installed. */
+ { int code = px_set_halftone(pxs);
+ if ( code < 0 )
+ return code;
+ }
+ /*
+ * Do a gsave so we can be sure to get rid of all page-related
+ * state at the end of the page, but make sure PopGS doesn't pop
+ * this state from the stack.
+ */
+ { int code = pxPushGS(NULL, pxs);
+ if ( code < 0 )
+ return code;
+ pxs->pxgs->stack_depth--;
+ return code;
+ }
}
-
int
pxBeginPageFromPassthrough(px_state_t *pxs)
-{
+{
int code;
gs_state *pgs = pxs->pgs;
gx_device *dev = gs_currentdevice(pgs);
@@ -608,58 +605,58 @@ pxBeginPageFromPassthrough(px_state_t *pxs)
px_initgraphics(pxs);
gs_currentmatrix(pgs, &points2device);
gs_dtransform(pgs, pxs->media_dims.x, pxs->media_dims.y,
- &page_size_pixels);
+ &page_size_pixels);
{ /*
* Put the origin at the upper left corner of the page;
* also account for the orientation.
*/
- gs_matrix orient;
-
- orient.xx = orient.xy = orient.yx = orient.yy =
- orient.tx = orient.ty = 0;
- switch ( pxs->orientation )
- {
- case eDefaultOrientation:
- case ePortraitOrientation:
- code = gs_translate(pgs, 0.0, pxs->media_dims.y);
- orient.xx = 1, orient.yy = -1;
- break;
- case eLandscapeOrientation:
- code = 0;
- orient.xy = 1, orient.yx = 1;
- break;
- case eReversePortrait:
- code = gs_translate(pgs, pxs->media_dims.x, 0);
- orient.xx = -1, orient.yy = 1;
- break;
- case eReverseLandscape:
- code = gs_translate(pgs, pxs->media_dims.x, pxs->media_dims.y);
- orient.xy = -1, orient.yx = -1;
- break;
- default: /* can't happen */
- return_error(errorIllegalAttributeValue);
- }
- if ( code < 0 ||
- (code = gs_concat(pgs, &orient)) < 0
- )
- return code;
+ gs_matrix orient;
+
+ orient.xx = orient.xy = orient.yx = orient.yy =
+ orient.tx = orient.ty = 0;
+ switch ( pxs->orientation )
+ {
+ case eDefaultOrientation:
+ case ePortraitOrientation:
+ code = gs_translate(pgs, 0.0, pxs->media_dims.y);
+ orient.xx = 1, orient.yy = -1;
+ break;
+ case eLandscapeOrientation:
+ code = 0;
+ orient.xy = 1, orient.yx = 1;
+ break;
+ case eReversePortrait:
+ code = gs_translate(pgs, pxs->media_dims.x, 0);
+ orient.xx = -1, orient.yy = 1;
+ break;
+ case eReverseLandscape:
+ code = gs_translate(pgs, pxs->media_dims.x, pxs->media_dims.y);
+ orient.xy = -1, orient.yx = -1;
+ break;
+ default: /* can't happen */
+ return_error(errorIllegalAttributeValue);
+ }
+ if ( code < 0 ||
+ (code = gs_concat(pgs, &orient)) < 0
+ )
+ return code;
}
{ /* Scale according to session parameters. */
- /* If we can make the scale integral safely, we do. */
- double scale = measure_to_points[pxs->measure];
- gs_matrix mat;
-
- if ( (code = gs_scale(pgs, scale / pxs->units_per_measure.x,
- scale / pxs->units_per_measure.y)) < 0
- )
- return code;
- gs_currentmatrix(pgs, &mat);
- mat.xx = px_adjust_scale(mat.xx, page_size_pixels.x);
- mat.xy = px_adjust_scale(mat.xy, page_size_pixels.y);
- mat.yx = px_adjust_scale(mat.yx, page_size_pixels.x);
- mat.yy = px_adjust_scale(mat.yy, page_size_pixels.y);
- gs_setmatrix(pgs, &mat);
- pxs->initial_matrix = mat;
+ /* If we can make the scale integral safely, we do. */
+ double scale = measure_to_points[pxs->measure];
+ gs_matrix mat;
+
+ if ( (code = gs_scale(pgs, scale / pxs->units_per_measure.x,
+ scale / pxs->units_per_measure.y)) < 0
+ )
+ return code;
+ gs_currentmatrix(pgs, &mat);
+ mat.xx = px_adjust_scale(mat.xx, page_size_pixels.x);
+ mat.xy = px_adjust_scale(mat.xy, page_size_pixels.y);
+ mat.yx = px_adjust_scale(mat.yx, page_size_pixels.x);
+ mat.yy = px_adjust_scale(mat.yy, page_size_pixels.y);
+ gs_setmatrix(pgs, &mat);
+ pxs->initial_matrix = mat;
}
pxs->have_page = true;
return 0;
@@ -672,9 +669,9 @@ const byte apxEndPage[] = {
int
pxEndPage(px_args_t *par, px_state_t *pxs)
{ px_end_page_cleanup(pxs);
- (*pxs->end_page)(pxs, (par->pv[0] ? par->pv[0]->value.i : pxs->copies), 1);
- pxs->have_page = false;
- return 0;
+ (*pxs->end_page)(pxs, (par->pv[0] ? par->pv[0]->value.i : pxs->copies), 1);
+ pxs->have_page = false;
+ return 0;
}
/* The default end-page procedure just calls the device procedure. */
int
@@ -689,16 +686,14 @@ const byte apxVendorUnique[] = {
/** we do NOTHING with the vendor unique command.
* it is undocumented, but appears that it contains the sames color commands as the
* XL 2.1 spec. This is based on only finding it in hpclj 4500 driver output.
- * of course HP denys that the 4500 supports XL.
+ * of course HP denys that the 4500 supports XL.
*/
int
pxVendorUnique(px_args_t *par, px_state_t *pxs)
-{
+{
return 0;
}
-
-
const byte apxComment[] = {
0,
pxaCommentData, 0
@@ -714,17 +709,16 @@ const byte apxOpenDataSource[] = {
int
pxOpenDataSource(px_args_t *par, px_state_t *pxs)
{ if ( pxs->data_source_open )
- return_error(errorDataSourceNotClosed);
- pxs->data_source_open = true;
- pxs->data_source_big_endian =
- par->pv[1]->value.i == eBinaryHighByteFirst;
- return 0;
+ return_error(errorDataSourceNotClosed);
+ pxs->data_source_open = true;
+ pxs->data_source_big_endian =
+ par->pv[1]->value.i == eBinaryHighByteFirst;
+ return 0;
}
const byte apxCloseDataSource[] = {0, 0};
int
pxCloseDataSource(px_args_t *par, px_state_t *pxs)
{ pxs->data_source_open = false;
- return 0;
+ return 0;
}
-
diff --git a/pxl/pxstate.c b/pxl/pxstate.c
index 858e60f53..8f2b054f6 100644
--- a/pxl/pxstate.c
+++ b/pxl/pxstate.c
@@ -31,13 +31,13 @@ extern const px_init_proc px_init_table[];
/* Allocate a px_state_t. */
px_state_t *
px_state_alloc(gs_memory_t *memory)
-{
+{
px_state_t *pxs = (px_state_t *)gs_alloc_bytes(memory,
sizeof(px_state_t),
"px_state_alloc");
px_gstate_t *pxgs = px_gstate_alloc(memory);
- if ( pxs == 0 || pxgs == 0 ) {
+ if ( pxs == 0 || pxgs == 0 ) {
gs_free_object(memory, pxgs, "px_gstate_alloc");
gs_free_object(memory, pxs, "px_state_alloc");
return 0;
@@ -47,10 +47,10 @@ px_state_alloc(gs_memory_t *memory)
pxgs->pxs = pxs;
px_state_init(pxs, NULL);
/* Run module initialization code. */
- {
+ {
const px_init_proc *init;
for ( init = px_init_table; *init; ++init )
- (*init)(pxs);
+ (*init)(pxs);
}
return pxs;
}
@@ -70,17 +70,17 @@ px_state_release(px_state_t *pxs)
void
px_state_init(px_state_t *pxs, gs_state *pgs)
{ pxs->pgs = pgs;
- px_gstate_init(pxs->pxgs, pgs);
- pxs->error_report = eErrorPage; /* default before first session */
- pxs->end_page = px_default_end_page;
- pxs->data_source_open = false;
- px_dict_init(&pxs->stream_dict, pxs->memory, NULL);
- px_dict_init(&pxs->builtin_font_dict, pxs->memory, px_free_font);
- px_dict_init(&pxs->font_dict, pxs->memory, px_free_font);
+ px_gstate_init(pxs->pxgs, pgs);
+ pxs->error_report = eErrorPage; /* default before first session */
+ pxs->end_page = px_default_end_page;
+ pxs->data_source_open = false;
+ px_dict_init(&pxs->stream_dict, pxs->memory, NULL);
+ px_dict_init(&pxs->builtin_font_dict, pxs->memory, px_free_font);
+ px_dict_init(&pxs->font_dict, pxs->memory, px_free_font);
px_dict_init(&pxs->page_pattern_dict, pxs->memory, px_free_pattern);
px_dict_init(&pxs->session_pattern_dict, pxs->memory, px_free_pattern);
pxs->have_page = false;
- pxs->warning_length = 0;
+ pxs->warning_length = 0;
}
/* Do one-time finalization at the end of execution. */
@@ -88,6 +88,6 @@ void
px_state_finit(px_state_t *pxs)
{ /* If streams persisted across sessions, we would release them here. */
#if 0
- px_dict_release(&pxs->stream_dict);
+ px_dict_release(&pxs->stream_dict);
#endif
}
diff --git a/pxl/pxstate.h b/pxl/pxstate.h
index 233ca807c..51a07b2db 100644
--- a/pxl/pxstate.h
+++ b/pxl/pxstate.h
@@ -23,7 +23,7 @@
/* Define an abstract type for a font directory. */
#ifndef gs_font_dir_DEFINED
-# define gs_font_dir_DEFINED
+# define gs_font_dir_DEFINED
typedef struct gs_font_dir_s gs_font_dir;
#endif
@@ -65,21 +65,21 @@ typedef struct px_media_s {
struct px_state_s {
gs_memory_t *memory;
- /* Hook back to client data, for callback procedures */
+ /* Hook back to client data, for callback procedures */
void *client_data;
gs_id known_fonts_base_id;
- /* Session state */
+ /* Session state */
pxeMeasure_t measure;
gs_point units_per_measure;
pxeErrorReport_t error_report;
bool useciecolor;
- /* Pattern dictionary */
+ /* Pattern dictionary */
px_dict_t session_pattern_dict;
- /* Page state */
+ /* Page state */
pxeOrientation_t orientation;
pxeMediaSource_t media_source;
@@ -99,20 +99,20 @@ struct px_state_s {
short media_width;
int (*end_page)(px_state_t *pxs, int num_copies, int flush);
- /* Pattern dictionary */
+ /* Pattern dictionary */
px_dict_t page_pattern_dict;
- /* Internal variables */
+ /* Internal variables */
bool have_page; /* true if anything has been written on page */
- /* Cached values */
+ /* Cached values */
gs_matrix initial_matrix;
- /* Data source */
+ /* Data source */
bool data_source_open;
bool data_source_big_endian;
- /* Stream dictionary */
+ /* Stream dictionary */
px_dict_t stream_dict;
- /* Stream reading state */
+ /* Stream reading state */
gs_string stream_name;
int stream_level; /* recursion depth */
struct sd2_ {
@@ -120,25 +120,25 @@ struct px_state_s {
uint size;
} stream_def;
- /* Font dictionary */
+ /* Font dictionary */
px_dict_t font_dict;
px_dict_t builtin_font_dict;
- /* Font/character downloading state */
+ /* Font/character downloading state */
px_font_t *download_font;
int font_format;
- /* Global structures */
+ /* Global structures */
gs_font_dir *font_dir;
px_font_t *error_page_font;
- /* Graphics state */
+ /* Graphics state */
gs_state *pgs; /* PostScript graphics state */
px_gstate_t *pxgs;
- /* Image/pattern reading state */
+ /* Image/pattern reading state */
px_image_enum_t *image_enum;
px_pattern_enum_t *pattern_enum;
- /* Miscellaneous */
+ /* Miscellaneous */
bool interpolate; /* image interpolation */
struct db_ {
@@ -151,8 +151,8 @@ struct px_state_s {
double y0, y1;
} scan_point; /* position when reading scan lines */
- /* We put the warning table and error line buffer at the end */
- /* so that the offsets of the scalars will stay small. */
+ /* We put the warning table and error line buffer at the end */
+ /* so that the offsets of the scalars will stay small. */
#define px_max_error_line 120
char error_line[px_max_error_line + 1]; /* for errors with their own msg */
#define px_max_warning_message 500
diff --git a/pxl/pxstream.c b/pxl/pxstream.c
index e432a6653..a109795ad 100644
--- a/pxl/pxstream.c
+++ b/pxl/pxstream.c
@@ -102,14 +102,14 @@ const byte apxRemoveStream[] = {
int
pxRemoveStream(px_args_t *par, px_state_t *pxs)
-{
+{
gs_string str;
void *def;
int code = tag_stream_name(par->pv[0], &str, pxs->memory,
"pxExecStream(name)");
if ( code < 0 )
return code;
- {
+ {
bool found = pl_dict_find(&pxs->stream_dict, str.data, str.size,
&def);
if ( !found )
@@ -167,7 +167,7 @@ pxExecStream(px_args_t *par, px_state_t *pxs)
)
return_error(errorUnsupportedClassName);
/* support protocol level 1, 2 and 3 */
- if ( strncmp((const char *)def_data + 11, ";1;", 3) &&
+ if ( strncmp((const char *)def_data + 11, ";1;", 3) &&
strncmp((const char *)def_data + 11, ";2;", 3) &&
strncmp((const char *)def_data + 11, ";3;", 3) )
return_error(errorUnsupportedProtocol);
diff --git a/pxl/pxsymbol.ps b/pxl/pxsymbol.ps
index e8ccae018..dfc44417a 100644
--- a/pxl/pxsymbol.ps
+++ b/pxl/pxsymbol.ps
@@ -13,7 +13,7 @@
5 { pop dup token pop } repeat
}
if
- % stack: file token
+ % stack: file token
/Encoding resourcestatus
{ pop 2 ne
{ closefile }
@@ -95,7 +95,7 @@ const unsigned short px) print dup =only ([257] = {) print
) print
dup 1 exch 3 add
{ ( pxg_) print 2 copy get dup /.notdef eq { pop (_notdef) } if
- =only (,) print pop
+ =only (,) print pop
}
for
}
diff --git a/pxl/pxtop.c b/pxl/pxtop.c
index 4b1f9c30f..aab546420 100644
--- a/pxl/pxtop.c
+++ b/pxl/pxtop.c
@@ -61,81 +61,79 @@ px_operator_proc(pxBeginSession);
static int pxl_end_page_top(px_state_t *pxs, int num_copies, int flush);
static int px_top_init(px_parser_state_t *st, px_state_t *pxs, bool big_endian);
-
/* ------------ PCXL stream header processor ------- */
/* State used to process an XL stream header */
typedef struct px_stream_header_process_s {
- enum {PSHPReady, PSHPSkipping, PSHPDone} state;
- px_parser_state_t *st; /* parser state to refer to */
+ enum {PSHPReady, PSHPSkipping, PSHPDone} state;
+ px_parser_state_t *st; /* parser state to refer to */
px_state_t *pxs; /* xl state to refer to */
} px_stream_header_process_t;
-
/* Initialize stream header processor */
static void
px_stream_header_init(
- px_stream_header_process_t *process, /* header state to init */
- px_parser_state_t *st, /* parser state to refer to */
- px_state_t *pxs /* xl state to refer to */
+ px_stream_header_process_t *process, /* header state to init */
+ px_parser_state_t *st, /* parser state to refer to */
+ px_state_t *pxs /* xl state to refer to */
)
{
- process->state = PSHPReady;
- process->st = st;
- process->pxs = pxs;
+ process->state = PSHPReady;
+ process->st = st;
+ process->pxs = pxs;
}
/* Process stream header input */
static int /* ret -ve error, 0 if needs more input, 1 if done successfully */
px_stream_header_process(
- px_stream_header_process_t *process, /* header state to refer */
- stream_cursor_read *cursor /* cusor to read data */
+ px_stream_header_process_t *process, /* header state to refer */
+ stream_cursor_read *cursor /* cusor to read data */
)
{
- while (cursor->ptr != cursor->limit)
- {
- byte chr;
- switch (process->state)
- {
- case PSHPReady:
- process->state = PSHPSkipping; /* switch to next state */
- switch ( (chr = *++cursor->ptr) )
- {
- case '(':
- px_top_init(process->st, process->pxs, true);
- break;
- case ')':
- px_top_init(process->st, process->pxs, false);
- break;
- default:
- /* Initialize state to avoid confusion */
- px_top_init(process->st, process->pxs, true);
- return gs_note_error(errorUnsupportedBinding);
- }
- break;
- case PSHPSkipping:
- if ( (chr = *++cursor->ptr) == '\n' )
- {
- process->state = PSHPDone;
- return 1;
- }
- break;
- case PSHPDone:
- default:
- /* Shouldn't ever come here */
- return gs_note_error(errorIllegalStreamHeader);
- }
- }
-
- return 0; /* need more input */
+ while (cursor->ptr != cursor->limit)
+ {
+ byte chr;
+ switch (process->state)
+ {
+ case PSHPReady:
+ process->state = PSHPSkipping; /* switch to next state */
+ switch ( (chr = *++cursor->ptr) )
+ {
+ case '(':
+ px_top_init(process->st, process->pxs, true);
+ break;
+ case ')':
+ px_top_init(process->st, process->pxs, false);
+ break;
+ default:
+ /* Initialize state to avoid confusion */
+ px_top_init(process->st, process->pxs, true);
+ return gs_note_error(errorUnsupportedBinding);
+ }
+ break;
+ case PSHPSkipping:
+ if ( (chr = *++cursor->ptr) == '\n' )
+ {
+ process->state = PSHPDone;
+ return 1;
+ }
+ break;
+ case PSHPDone:
+ default:
+ /* Shouldn't ever come here */
+ return gs_note_error(errorIllegalStreamHeader);
+ }
+ }
+
+ return 0; /* need more input */
}
/* De-initialize stream header processor */
static void
px_stream_header_dnit(
- px_stream_header_process_t *process /* header state to dnit */
+ px_stream_header_process_t *process /* header state to dnit */
)
{
- /* empty proc */
+ /* empty proc */
}
/************************************************************/
@@ -169,7 +167,6 @@ typedef struct pxl_interp_instance_s {
headerState; /* used to decode stream header */
} pxl_interp_instance_t;
-
/* Get implemtation's characteristics */
static const pl_interp_characteristics_t * /* always returns a descriptor */
pxl_impl_characteristics(
@@ -198,11 +195,11 @@ pxl_impl_allocate_interp(
gs_memory_t *mem /* allocator to allocate interp from */
)
{
- static pl_interp_t pi; /* there's only one interpreter */
+ static pl_interp_t pi; /* there's only one interpreter */
- /* There's only one PXL interp, so return the static */
- *interp = &pi;
- return 0; /* success */
+ /* There's only one PXL interp, so return the static */
+ *interp = &pi;
+ return 0; /* success */
}
/* Do per-instance interpreter allocation/init. No device is set yet */
@@ -213,47 +210,47 @@ pxl_impl_allocate_interp_instance(
gs_memory_t *mem /* allocator to allocate instance from */
)
{
- /* Allocate everything up front */
- pxl_interp_instance_t *pxli /****** SHOULD HAVE A STRUCT DESCRIPTOR ******/
- = (pxl_interp_instance_t *)gs_alloc_bytes( mem,
- sizeof(pxl_interp_instance_t),
- "pxl_allocate_interp_instance(pxl_interp_instance_t)"
+ /* Allocate everything up front */
+ pxl_interp_instance_t *pxli /****** SHOULD HAVE A STRUCT DESCRIPTOR ******/
+ = (pxl_interp_instance_t *)gs_alloc_bytes( mem,
+ sizeof(pxl_interp_instance_t),
+ "pxl_allocate_interp_instance(pxl_interp_instance_t)"
);
- gs_state *pgs = gs_state_alloc(mem);
- px_parser_state_t *st = px_process_alloc(mem); /* parser init, cheap */
- px_state_t *pxs = px_state_alloc(mem); /* inits interp state, potentially expensive */
- /* If allocation error, deallocate & return */
- if (!pxli || !pgs || !st || !pxs) {
- if (pxli)
- gs_free_object(mem, pxli, "pxl_impl_allocate_interp_instance(pxl_interp_instance_t)");
- if (pgs)
- gs_state_free(pgs);
- if (st)
- px_process_release(st);
- if (pxs)
- px_state_release(pxs);
- return gs_error_VMerror;
- }
+ gs_state *pgs = gs_state_alloc(mem);
+ px_parser_state_t *st = px_process_alloc(mem); /* parser init, cheap */
+ px_state_t *pxs = px_state_alloc(mem); /* inits interp state, potentially expensive */
+ /* If allocation error, deallocate & return */
+ if (!pxli || !pgs || !st || !pxs) {
+ if (pxli)
+ gs_free_object(mem, pxli, "pxl_impl_allocate_interp_instance(pxl_interp_instance_t)");
+ if (pgs)
+ gs_state_free(pgs);
+ if (st)
+ px_process_release(st);
+ if (pxs)
+ px_state_release(pxs);
+ return gs_error_VMerror;
+ }
gsicc_init_iccmanager(pgs);
- /* Setup pointers to allocated mem within instance */
- pxli->memory = mem;
- pxli->pgs = pgs;
- pxli->pxs = pxs;
- pxli->st = st;
+ /* Setup pointers to allocated mem within instance */
+ pxli->memory = mem;
+ pxli->pgs = pgs;
+ pxli->pxs = pxs;
+ pxli->st = st;
- /* zero-init pre/post page actions for now */
- pxli->pre_page_action = 0;
- pxli->post_page_action = 0;
+ /* zero-init pre/post page actions for now */
+ pxli->pre_page_action = 0;
+ pxli->post_page_action = 0;
- /* General init of pxl_state */
- px_state_init(pxs, pgs); /*pgs only needed to set pxs as pgs' client */
- pxs->client_data = pxli;
- pxs->end_page = pxl_end_page_top; /* after px_state_init */
+ /* General init of pxl_state */
+ px_state_init(pxs, pgs); /*pgs only needed to set pxs as pgs' client */
+ pxs->client_data = pxli;
+ pxs->end_page = pxl_end_page_top; /* after px_state_init */
- /* Return success */
- *instance = (pl_interp_instance_t *)pxli;
- return 0;
+ /* Return success */
+ *instance = (pl_interp_instance_t *)pxli;
+ return 0;
}
/* Set a client language into an interperter instance */
@@ -264,13 +261,13 @@ pxl_impl_set_client_instance(
pl_interp_instance_clients_t which_client
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
if ( which_client == PCL_CLIENT )
pxli->pxs->pcls = client;
else if ( which_client == PJL_CLIENT )
pxli->pxs->pjls = client;
/* ignore unknown clients */
- return 0;
+ return 0;
}
/* Set an interpreter instance's pre-page action */
@@ -281,10 +278,10 @@ pxl_impl_set_pre_page_action(
void *closure /* closure to call action with */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- pxli->pre_page_action = action;
- pxli->pre_page_closure = closure;
- return 0;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ pxli->pre_page_action = action;
+ pxli->pre_page_closure = closure;
+ return 0;
}
/* Set an interpreter instance's post-page action */
@@ -295,10 +292,10 @@ pxl_impl_set_post_page_action(
void *closure /* closure to call action with */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- pxli->post_page_action = action;
- pxli->post_page_closure = closure;
- return 0;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ pxli->post_page_action = action;
+ pxli->post_page_closure = closure;
+ return 0;
}
static bool
@@ -314,71 +311,70 @@ pxl_impl_set_device(
gx_device *device /* device to set (open or closed) */
)
{
- int code;
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- px_state_t *pxs = pxli->pxs;
+ int code;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ px_state_t *pxs = pxli->pxs;
- enum {Sbegin, Ssetdevice, Sinitg, Sgsave, Serase, Sdone} stage;
- stage = Sbegin;
- gs_opendevice(device);
+ enum {Sbegin, Ssetdevice, Sinitg, Sgsave, Serase, Sdone} stage;
+ stage = Sbegin;
+ gs_opendevice(device);
pxs->interpolate = pxl_get_interpolation(instance);
- /* Set the device into the gstate */
- stage = Ssetdevice;
- if ((code = gs_setdevice_no_erase(pxli->pgs, device)) < 0) /* can't erase yet */
- goto pisdEnd;
+ /* Set the device into the gstate */
+ stage = Ssetdevice;
+ if ((code = gs_setdevice_no_erase(pxli->pgs, device)) < 0) /* can't erase yet */
+ goto pisdEnd;
/* Initialize device ICC profile */
code = gsicc_init_device_profile(pxli->pgs, device);
if (code < 0)
return code;
- /* Init XL graphics */
- stage = Sinitg;
- if ((code = px_initgraphics(pxli->pxs)) < 0)
- goto pisdEnd;
+ /* Init XL graphics */
+ stage = Sinitg;
+ if ((code = px_initgraphics(pxli->pxs)) < 0)
+ goto pisdEnd;
- /* Do inits of gstate that may be reset by setdevice */
- gs_setaccuratecurves(pxli->pgs, true); /* All H-P languages want accurate curves. */
+ /* Do inits of gstate that may be reset by setdevice */
+ gs_setaccuratecurves(pxli->pgs, true); /* All H-P languages want accurate curves. */
/* disable hinting at high res */
if (gs_currentdevice(pxli->pgs)->HWResolution[0] >= 300)
gs_setgridfittt(pxs->font_dir, 0);
+ /* gsave and grestore (among other places) assume that */
+ /* there are at least 2 gstates on the graphics stack. */
+ /* Ensure that now. */
+ stage = Sgsave;
+ if ( (code = gs_gsave(pxli->pgs)) < 0)
+ goto pisdEnd;
- /* gsave and grestore (among other places) assume that */
- /* there are at least 2 gstates on the graphics stack. */
- /* Ensure that now. */
- stage = Sgsave;
- if ( (code = gs_gsave(pxli->pgs)) < 0)
- goto pisdEnd;
-
- stage = Serase;
- if ( (code = gs_erasepage(pxli->pgs)) < 0 )
- goto pisdEnd;
+ stage = Serase;
+ if ( (code = gs_erasepage(pxli->pgs)) < 0 )
+ goto pisdEnd;
- stage = Sdone; /* success */
- /* Unwind any errors */
+ stage = Sdone; /* success */
+ /* Unwind any errors */
pisdEnd:
- switch (stage) {
- case Sdone: /* don't undo success */
- break;
-
- case Serase: /* gs_erasepage failed */
- /* undo gsave */
- gs_grestore_only(pxli->pgs); /* destroys gs_save stack */
- /* fall thru to next */
- case Sgsave: /* gsave failed */
- case Sinitg:
- /* undo setdevice */
- gs_nulldevice(pxli->pgs);
- /* fall thru to next */
-
- case Ssetdevice: /* gs_setdevice failed */
- case Sbegin: /* nothing left to undo */
- break;
- }
- return code;
+ switch (stage) {
+ case Sdone: /* don't undo success */
+ break;
+
+ case Serase: /* gs_erasepage failed */
+ /* undo gsave */
+ gs_grestore_only(pxli->pgs); /* destroys gs_save stack */
+ /* fall thru to next */
+ case Sgsave: /* gsave failed */
+ case Sinitg:
+ /* undo setdevice */
+ gs_nulldevice(pxli->pgs);
+ /* fall thru to next */
+
+ case Ssetdevice: /* gs_setdevice failed */
+ case Sbegin: /* nothing left to undo */
+ break;
+ }
+ return code;
}
-static int
+static int
pxl_impl_get_device_memory(
pl_interp_instance_t *instance, /* interp instance to use */
gs_memory_t **pmem)
@@ -389,175 +385,175 @@ pxl_impl_get_device_memory(
/* Prepare interp instance for the next "job" */
static int /* ret 0 ok, else -ve error code */
pxl_impl_init_job(
- pl_interp_instance_t *instance /* interp instance to start job in */
+ pl_interp_instance_t *instance /* interp instance to start job in */
)
{
- int code = 0;
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- px_reset_errors(pxli->pxs);
- px_process_init(pxli->st, true);
+ int code = 0;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ px_reset_errors(pxli->pxs);
+ px_process_init(pxli->st, true);
- /* set input status to: expecting stream header */
- px_stream_header_init(&pxli->headerState, pxli->st, pxli->pxs);
- pxli->processState = PSHeader;
+ /* set input status to: expecting stream header */
+ px_stream_header_init(&pxli->headerState, pxli->st, pxli->pxs);
+ pxli->processState = PSHeader;
- return code;
+ return code;
}
/* Parse a cursor-full of data */
static int /* ret 0 or +ve if ok, else -ve error code */
pxl_impl_process(
- pl_interp_instance_t *instance, /* interp instance to process data job in */
- stream_cursor_read *cursor /* data to process */
+ pl_interp_instance_t *instance, /* interp instance to process data job in */
+ stream_cursor_read *cursor /* data to process */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- int code;
-
- /* Process some input */
- switch (pxli->processState)
- {
- case PSDone:
- return e_ExitLanguage;
- case PSHeader: /* Input stream header */
- code = px_stream_header_process(&pxli->headerState, cursor);
- if (code == 0)
- break; /* need more input later */
- else
- /* stream header termination */
- if (code < 0)
- {
- pxli->processState = PSDone;
- return code; /* return error */
- }
- else
- {
- code = 0;
- pxli->processState = PSXL;
- }
- /* fall thru to PSXL */
- case PSXL: /* PCL XL */
- code = px_process(pxli->st, pxli->pxs, cursor);
- if ( code == e_ExitLanguage )
- { pxli->processState = PSDone;
- code = 0;
- }
- else if ( code == errorWarningsReported )
- { /* The parser doesn't skip over the EndSession */
- /* operator, because an "error" occurred. */
- cursor->ptr++;
- }
- else if (code < 0)
- /* Map library error codes to PCL XL codes when possible. */
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ int code;
+
+ /* Process some input */
+ switch (pxli->processState)
+ {
+ case PSDone:
+ return e_ExitLanguage;
+ case PSHeader: /* Input stream header */
+ code = px_stream_header_process(&pxli->headerState, cursor);
+ if (code == 0)
+ break; /* need more input later */
+ else
+ /* stream header termination */
+ if (code < 0)
+ {
+ pxli->processState = PSDone;
+ return code; /* return error */
+ }
+ else
+ {
+ code = 0;
+ pxli->processState = PSXL;
+ }
+ /* fall thru to PSXL */
+ case PSXL: /* PCL XL */
+ code = px_process(pxli->st, pxli->pxs, cursor);
+ if ( code == e_ExitLanguage )
+ { pxli->processState = PSDone;
+ code = 0;
+ }
+ else if ( code == errorWarningsReported )
+ { /* The parser doesn't skip over the EndSession */
+ /* operator, because an "error" occurred. */
+ cursor->ptr++;
+ }
+ else if (code < 0)
+ /* Map library error codes to PCL XL codes when possible. */
switch ( code )
- {
+ {
#define subst(gs_error, px_error)\
case gs_error: code = px_error; break
- subst(gs_error_invalidfont, errorIllegalFontData);
- subst(gs_error_limitcheck, errorInternalOverflow);
- subst(gs_error_nocurrentpoint, errorCurrentCursorUndefined);
- subst(gs_error_rangecheck, errorIllegalAttributeValue);
- subst(gs_error_VMerror, errorInsufficientMemory);
+ subst(gs_error_invalidfont, errorIllegalFontData);
+ subst(gs_error_limitcheck, errorInternalOverflow);
+ subst(gs_error_nocurrentpoint, errorCurrentCursorUndefined);
+ subst(gs_error_rangecheck, errorIllegalAttributeValue);
+ subst(gs_error_VMerror, errorInsufficientMemory);
#undef subst
- }
- break; /* may need more input later */
- }
+ }
+ break; /* may need more input later */
+ }
- return code;
+ return code;
}
/* Skip to end of job ret 1 if done, 0 ok but EOJ not found, else -ve error code */
static int
pxl_impl_flush_to_eoj(
- pl_interp_instance_t *instance, /* interp instance to flush for */
- stream_cursor_read *cursor /* data to process */
+ pl_interp_instance_t *instance, /* interp instance to flush for */
+ stream_cursor_read *cursor /* data to process */
)
{
- const byte *p = cursor->ptr;
- const byte *rlimit = cursor->limit;
-
- /* Skip to, but leave UEL in buffer for PJL to find later */
- for (; p < rlimit; ++p)
- if (p[1] == '\033') {
- uint avail = rlimit - p;
-
- if (memcmp(p + 1, "\033%-12345X", min(avail, 9)))
- continue;
- if (avail < 9)
- break;
- cursor->ptr = p;
- return 1; /* found eoj */
- }
- cursor->ptr = p;
- return 0; /* need more */
+ const byte *p = cursor->ptr;
+ const byte *rlimit = cursor->limit;
+
+ /* Skip to, but leave UEL in buffer for PJL to find later */
+ for (; p < rlimit; ++p)
+ if (p[1] == '\033') {
+ uint avail = rlimit - p;
+
+ if (memcmp(p + 1, "\033%-12345X", min(avail, 9)))
+ continue;
+ if (avail < 9)
+ break;
+ cursor->ptr = p;
+ return 1; /* found eoj */
+ }
+ cursor->ptr = p;
+ return 0; /* need more */
}
/* Parser action for end-of-file */
static int /* ret 0 or +ve if ok, else -ve error code */
pxl_impl_process_eof(
- pl_interp_instance_t *instance /* interp instance to process data job in */
+ pl_interp_instance_t *instance /* interp instance to process data job in */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- px_state_cleanup(pxli->pxs);
+ px_state_cleanup(pxli->pxs);
- return 0;
+ return 0;
}
/* Report any errors after running a job */
static int /* ret 0 ok, else -ve error code */
pxl_impl_report_errors(
- pl_interp_instance_t *instance, /* interp instance to wrap up job in */
+ pl_interp_instance_t *instance, /* interp instance to wrap up job in */
int code, /* prev termination status */
long file_position, /* file position of error, -1 if unknown */
bool force_to_cout /* force errors to cout */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- px_parser_state_t *st = pxli->st;
- px_state_t *pxs = pxli->pxs;
- int report = pxs->error_report;
- const char *subsystem =
- (code <= px_error_next ? "KERNEL" : "GRAPHICS");
- char message[px_max_error_line+1];
- int N = 0;
- int y;
-
- if (code >= 0)
- return code; /* not really an error */
- if ( report & eErrorPage )
- y = px_begin_error_page(pxs);
- while ( (N = px_error_message_line(message, N, subsystem,
- code, st, pxs)) >= 0
- )
- { if ( (report & eBackChannel) || force_to_cout )
- errprintf(pxli->memory, message);
- if ( report & eErrorPage )
- y = px_error_page_show(message, y, pxs);
- }
- if ( ((report & pxeErrorReport_next) && file_position != -1L) || force_to_cout )
- errprintf(pxli->memory, "file position of error = %ld\n", file_position);
- if ( report & eErrorPage )
- { px_args_t args;
- args.pv[0] = 0;
- pxEndPage(&args, pxs);
- }
- px_reset_errors(pxs);
-
- return code;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ px_parser_state_t *st = pxli->st;
+ px_state_t *pxs = pxli->pxs;
+ int report = pxs->error_report;
+ const char *subsystem =
+ (code <= px_error_next ? "KERNEL" : "GRAPHICS");
+ char message[px_max_error_line+1];
+ int N = 0;
+ int y;
+
+ if (code >= 0)
+ return code; /* not really an error */
+ if ( report & eErrorPage )
+ y = px_begin_error_page(pxs);
+ while ( (N = px_error_message_line(message, N, subsystem,
+ code, st, pxs)) >= 0
+ )
+ { if ( (report & eBackChannel) || force_to_cout )
+ errprintf(pxli->memory, message);
+ if ( report & eErrorPage )
+ y = px_error_page_show(message, y, pxs);
+ }
+ if ( ((report & pxeErrorReport_next) && file_position != -1L) || force_to_cout )
+ errprintf(pxli->memory, "file position of error = %ld\n", file_position);
+ if ( report & eErrorPage )
+ { px_args_t args;
+ args.pv[0] = 0;
+ pxEndPage(&args, pxs);
+ }
+ px_reset_errors(pxs);
+
+ return code;
}
/* Wrap up interp instance after a "job" */
static int /* ret 0 ok, else -ve error code */
pxl_impl_dnit_job(
- pl_interp_instance_t *instance /* interp instance to wrap up job in */
+ pl_interp_instance_t *instance /* interp instance to wrap up job in */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- px_stream_header_dnit(&pxli->headerState);
- px_state_cleanup(pxli->pxs);
- return 0;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ px_stream_header_dnit(&pxli->headerState);
+ px_state_cleanup(pxli->pxs);
+ return 0;
}
/* Remove a device from an interperter instance */
@@ -566,18 +562,18 @@ pxl_impl_remove_device(
pl_interp_instance_t *instance /* interp instance to use */
)
{
- int code = 0; /* first error status encountered */
- int error;
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- /* return to original gstate */
- gs_grestore_only(pxli->pgs); /* destroys gs_save stack */
- /* Deselect device */
- /* NB */
- error = gs_nulldevice(pxli->pgs);
- if (code >= 0)
- code = error;
-
- return code;
+ int code = 0; /* first error status encountered */
+ int error;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ /* return to original gstate */
+ gs_grestore_only(pxli->pgs); /* destroys gs_save stack */
+ /* Deselect device */
+ /* NB */
+ error = gs_nulldevice(pxli->pgs);
+ if (code >= 0)
+ code = error;
+
+ return code;
}
/* Deallocate a interpreter instance */
@@ -586,19 +582,19 @@ pxl_impl_deallocate_interp_instance(
pl_interp_instance_t *instance /* instance to dealloc */
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
- gs_memory_t *mem = pxli->memory;
-
- px_dict_release(&pxli->pxs->font_dict);
- px_dict_release(&pxli->pxs->builtin_font_dict);
- /* do total dnit of interp state */
- px_state_finit(pxli->pxs);
- /* free halftone cache */
- gs_state_free(pxli->pgs);
- px_process_release(pxli->st);
- px_state_release(pxli->pxs);
- gs_free_object(mem, pxli, "pxl_impl_deallocate_interp_instance(pxl_interp_instance_t)");
- return 0;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)instance;
+ gs_memory_t *mem = pxli->memory;
+
+ px_dict_release(&pxli->pxs->font_dict);
+ px_dict_release(&pxli->pxs->builtin_font_dict);
+ /* do total dnit of interp state */
+ px_state_finit(pxli->pxs);
+ /* free halftone cache */
+ gs_state_free(pxli->pgs);
+ px_process_release(pxli->st);
+ px_state_release(pxli->pxs);
+ gs_free_object(mem, pxli, "pxl_impl_deallocate_interp_instance(pxl_interp_instance_t)");
+ return 0;
}
/* Do static deinit of PXL interpreter */
@@ -607,11 +603,11 @@ pxl_impl_deallocate_interp(
pl_interp_t *interp /* interpreter to deallocate */
)
{
- /* nothing to do */
- return 0;
+ /* nothing to do */
+ return 0;
}
-/*
+/*
* End-of-page called back by PXL
*/
static int
@@ -621,34 +617,34 @@ pxl_end_page_top(
int flush
)
{
- pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)(pxls->client_data);
- pl_interp_instance_t *instance = (pl_interp_instance_t *)pxli;
- int code = 0;
-
- /* do pre-page action */
- if (pxli->pre_page_action)
- {
- code = pxli->pre_page_action(instance, pxli->pre_page_closure);
- if (code < 0)
- return code;
- if (code != 0)
- return 0; /* code > 0 means abort w/no error */
- }
-
- /* output the page */
- code = gs_output_page(pxli->pgs, num_copies, flush);
- if (code < 0)
- return code;
-
- /* do post-page action */
- if (pxli->post_page_action)
- {
- code = pxli->post_page_action(instance, pxli->post_page_closure);
- if (code < 0)
- return code;
- }
-
- return 0;
+ pxl_interp_instance_t *pxli = (pxl_interp_instance_t *)(pxls->client_data);
+ pl_interp_instance_t *instance = (pl_interp_instance_t *)pxli;
+ int code = 0;
+
+ /* do pre-page action */
+ if (pxli->pre_page_action)
+ {
+ code = pxli->pre_page_action(instance, pxli->pre_page_closure);
+ if (code < 0)
+ return code;
+ if (code != 0)
+ return 0; /* code > 0 means abort w/no error */
+ }
+
+ /* output the page */
+ code = gs_output_page(pxli->pgs, num_copies, flush);
+ if (code < 0)
+ return code;
+
+ /* do post-page action */
+ if (pxli->post_page_action)
+ {
+ code = pxli->post_page_action(instance, pxli->post_page_closure);
+ if (code < 0)
+ return code;
+ }
+
+ return 0;
}
/* Parser implementation descriptor */
@@ -697,9 +693,9 @@ px_top_init(px_parser_state_t *st, px_state_t *pxs, bool big_endian)
v[2].value.i = eErrorPage;
args.pv[2] = &v[2];
{
- int code = pxBeginSession(&args, pxs);
- if ( code < 0 )
- return code;
+ int code = pxBeginSession(&args, pxs);
+ if ( code < 0 )
+ return code;
}
return 0;
}
diff --git a/pxl/pxvalue.c b/pxl/pxvalue.c
index 77f743d15..474b1240f 100644
--- a/pxl/pxvalue.c
+++ b/pxl/pxvalue.c
@@ -30,9 +30,9 @@ sint16at(const byte *p, bool big_endian)
int32_t
uint32at(const byte *p, bool big_endian)
{ return
- (big_endian ?
- ((int32_t)((p[0] << 8) + p[1]) << 16) + (p[2] << 8) + p[3] :
- ((int32_t)((p[3] << 8) + p[2]) << 16) + (p[1] << 8) + p[0]);
+ (big_endian ?
+ ((int32_t)((p[0] << 8) + p[1]) << 16) + (p[2] << 8) + p[3] :
+ ((int32_t)((p[3] << 8) + p[2]) << 16) + (p[1] << 8) + p[0]);
}
int32_t
sint32at(const byte *p, bool big_endian)
@@ -40,7 +40,7 @@ sint32at(const byte *p, bool big_endian)
}
real
real32at(const byte *p, bool big_endian)
-{
+{
union {
float f;
int32_t d;
@@ -55,26 +55,26 @@ real32at(const byte *p, bool big_endian)
int32_t
integer_elt(const px_value_t *pav, uint index)
{ px_data_type_t type = pav->type;
- const byte *base = pav->value.array.data;
- bool big_endian;
+ const byte *base = pav->value.array.data;
+ bool big_endian;
- if ( type & pxd_ubyte )
- return base[index];
- big_endian = (type & pxd_big_endian) != 0;
- if ( type & pxd_uint16 )
- return uint16at(base + (index << 1), big_endian);
- else if ( type & pxd_sint16 )
- return sint16at(base + (index << 1), big_endian);
- else if ( type & pxd_uint32 )
- return uint32at(base + (index << 2), big_endian);
- else /* ( type & pxd_sint32 ) */
- return sint32at(base + (index << 2), big_endian);
+ if ( type & pxd_ubyte )
+ return base[index];
+ big_endian = (type & pxd_big_endian) != 0;
+ if ( type & pxd_uint16 )
+ return uint16at(base + (index << 1), big_endian);
+ else if ( type & pxd_sint16 )
+ return sint16at(base + (index << 1), big_endian);
+ else if ( type & pxd_uint32 )
+ return uint32at(base + (index << 2), big_endian);
+ else /* ( type & pxd_sint32 ) */
+ return sint32at(base + (index << 2), big_endian);
}
real
real_elt(const px_value_t *pav, uint index)
{ return
- (pav->type & pxd_real32 ?
- real32at(pav->value.array.data + (index << 2),
- (pav->type & pxd_big_endian) != 0) :
- (real)integer_elt(pav, index));
+ (pav->type & pxd_real32 ?
+ real32at(pav->value.array.data + (index << 2),
+ (pav->type & pxd_big_endian) != 0) :
+ (real)integer_elt(pav, index));
}
diff --git a/pxl/pxvalue.h b/pxl/pxvalue.h
index 3d5a6bbb1..15d826f8b 100644
--- a/pxl/pxvalue.h
+++ b/pxl/pxvalue.h
@@ -74,10 +74,10 @@ typedef struct {
const px_value_t *pv_ = (pv);\
if ( pv_->type & pxd_any_real )\
x1 = pv_->value.ra[0], y1 = pv_->value.ra[1],\
- x2 = pv_->value.ra[2], y2 = pv_->value.ra[3];\
+ x2 = pv_->value.ra[2], y2 = pv_->value.ra[3];\
else\
x1 = pv_->value.ia[0], y1 = pv_->value.ia[1],\
- x2 = pv_->value.ia[2], y2 = pv_->value.ia[3];\
+ x2 = pv_->value.ia[2], y2 = pv_->value.ia[3];\
} while ( 0 )
#define value_size(pv)\