summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>2014-03-11 09:58:31 -0600
committerHenry Stiles <henry.stiles@artifex.com>2014-03-11 17:17:53 -0600
commitee30f349671e3a23d666615f1648eab4a5290b4c (patch)
treee5ffc98c89cf1df41e1a1eee725ec27cc975c361
parent4c2f426905b4bf300f6b412024d71cd2be6276de (diff)
downloadghostpdl-ee30f349671e3a23d666615f1648eab4a5290b4c.tar.gz
Abbreviated escape sequence improvement.
Abbreviated escape sequences were not handled properly with commands that hold arbitrary amounts of data, like raster and font related commands. PCL shorthand is rarely used in this circumstance but it is legal. Thanks to Hin-Tak for the discovery and analysis of this problem.
-rw-r--r--pcl/pcparse.c14
-rw-r--r--pcl/pcparse.h3
2 files changed, 11 insertions, 6 deletions
diff --git a/pcl/pcparse.c b/pcl/pcparse.c
index af405e5b5..60b1d8978 100644
--- a/pcl/pcparse.c
+++ b/pcl/pcparse.c
@@ -296,7 +296,6 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
while (p < rlimit) {
byte chr;
const pcl_command_definition_t *cdefn = NULL;
-
switch (pst->scan_type) {
case scanning_data:
{ /* Accumulate command data in a buffer. */
@@ -317,7 +316,10 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
pst->param_class,
pst->param_group,
pst->args.command);
- pst->scan_type = scanning_none;
+ if (pst->short_hand)
+ pst->scan_type = scanning_parameter;
+ else
+ pst->scan_type = scanning_none;
break;
}
case scanning_display:
@@ -426,11 +428,13 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
dmprintf1(pcs->memory, " %c\n", chr);
}
#endif
+ pst->short_hand = false;
if (chr >= min_escape_command + 32 &&
- chr <= max_escape_command + 32)
+ chr <= max_escape_command + 32) {
+ pst->short_hand = true;
chr -= 32;
- else if (chr >= min_escape_command &&
- chr <= max_escape_command)
+ } else if (chr >= min_escape_command &&
+ chr <= max_escape_command)
pst->scan_type = scanning_none;
else {
pst->scan_type = scanning_none;
diff --git a/pcl/pcparse.h b/pcl/pcparse.h
index 83a2798ca..99949b25f 100644
--- a/pcl/pcparse.h
+++ b/pcl/pcparse.h
@@ -76,6 +76,7 @@ struct pcl_parser_state_s
{
/* Internal state */
pcl_scan_type_t scan_type;
+ bool short_hand;
bool garbage_in_parameter;
pcl_args_t args;
double scale; /* for accumulating floating numbers */
@@ -86,7 +87,7 @@ struct pcl_parser_state_s
};
#define pcl_parser_init_inline(pst)\
- ((pst)->scan_type = scanning_none, (pst)->args.data = 0, (pst)->args.data_on_heap = false)
+ ((pst)->scan_type = scanning_none, (pst)->args.data = 0, (pst)->args.data_on_heap = false, (pst)->short_hand = false)
/* Define the prefix of a macro definition. */
typedef struct pcl_macro_s