"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "psi/zchar.c" between
ghostscript-9.26.tar.xz and ghostscript-9.27.tar.xz

About: Ghostscript is an interpreter and rendering engine for the PostScript language and for PDF (GPL release).

zchar.c  (ghostscript-9.26.tar.xz):zchar.c  (ghostscript-9.27.tar.xz)
/* Copyright (C) 2001-2018 Artifex Software, Inc. /* Copyright (C) 2001-2019 Artifex Software, Inc.
All Rights Reserved. All Rights Reserved.
This software is provided AS-IS with no warranty, either express or This software is provided AS-IS with no warranty, either express or
implied. implied.
This software is distributed under license and may not be copied, This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution. of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact Refer to licensing information at http://www.artifex.com or contact
skipping to change at line 57 skipping to change at line 57
static int op_show_cleanup(i_ctx_t *); static int op_show_cleanup(i_ctx_t *);
static int op_show_return_width(i_ctx_t *, uint, double *); static int op_show_return_width(i_ctx_t *, uint, double *);
static int zawidthshow(i_ctx_t *i_ctx_p); static int zawidthshow(i_ctx_t *i_ctx_p);
static int zwidthshow(i_ctx_t *i_ctx_p); static int zwidthshow(i_ctx_t *i_ctx_p);
/* <string> show - */ /* <string> show - */
static int static int
zshow(i_ctx_t *i_ctx_p) zshow(i_ctx_t *i_ctx_p)
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
int code = op_show_setup(i_ctx_p, op); int code = op_show_setup(i_ctx_p, op);
if (code != 0 || if (code != 0 ||
(code = gs_show_begin(igs, op->value.bytes, r_size(op), imemory_local, & penum)) < 0) (code = gs_show_begin(igs, op->value.bytes, r_size(op), imemory_local, & penum)) < 0)
return code; return code;
*(op_proc_t *)&penum->enum_client_data = zshow; *(op_proc_t *)&penum->enum_client_data = zshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_show)) < 0) { if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zshow");
return code; return code;
} }
return op_show_continue_pop(i_ctx_p, 1);
code = op_show_continue_pop(i_ctx_p, 1);
if (code < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zshow");
}
return code;
} }
/* <ax> <ay> <string> ashow - */ /* <ax> <ay> <string> ashow - */
static int static int
zashow(i_ctx_t *i_ctx_p) zashow(i_ctx_t *i_ctx_p)
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
double axy[2]; double axy[2];
int code = num_params(op - 1, 2, axy); int code = num_params(op - 1, 2, axy);
if (code < 0 || if (code < 0 ||
(code = op_show_setup(i_ctx_p, op)) != 0 || (code = op_show_setup(i_ctx_p, op)) != 0 ||
(code = gs_ashow_begin(igs, axy[0], axy[1], op->value.bytes, r_size(op), imemory_local, &penum)) < 0) (code = gs_ashow_begin(igs, axy[0], axy[1], op->value.bytes, r_size(op), imemory_local, &penum)) < 0)
return code; return code;
*(op_proc_t *)&penum->enum_client_data = zashow; *(op_proc_t *)&penum->enum_client_data = zashow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 3, finish_show)) < 0) { if ((code = op_show_finish_setup(i_ctx_p, penum, 3, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zashow");
return code; return code;
} }
return op_show_continue_pop(i_ctx_p, 3); code = op_show_continue_pop(i_ctx_p, 3);
if (code < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zashow");
}
return code;
} }
static int static int
widthshow_aux(i_ctx_t *i_ctx_p, bool single_byte_space) widthshow_aux(i_ctx_t *i_ctx_p, bool single_byte_space)
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
double cxy[2]; double cxy[2];
int code; int code;
if ((code = op_show_setup(i_ctx_p, op)) != 0 ) if ((code = op_show_setup(i_ctx_p, op)) != 0 )
return code; return code;
check_type(op[-1], t_integer); check_type(op[-1], t_integer);
if (gs_currentfont(igs)->FontType == ft_composite) { if (gs_currentfont(igs)->FontType == ft_composite) {
if ((gs_char) (op[-1].value.intval) != op[-1].value.intval) if ((gs_char) (op[-1].value.intval) != op[-1].value.intval)
return_error(gs_error_rangecheck); return_error(gs_error_rangecheck);
} else { } else {
if (op[-1].value.intval < 0 || op[-1].value.intval > 255) if (op[-1].value.intval < 0 || op[-1].value.intval > 255)
return_error(gs_error_rangecheck); /* per PLRM and CET 13-26 */ return_error(gs_error_rangecheck); /* per PLRM and CET 13-26 */
} }
if ((code = num_params(op - 2, 2, cxy)) < 0 ) if ((code = num_params(op - 2, 2, cxy)) < 0 )
return code; return code;
if ((code = gs_widthshow_begin(igs, cxy[0], cxy[1], if ((code = gs_widthshow_begin(igs, cxy[0], cxy[1],
(gs_char) op[-1].value.intval, (gs_char) op[-1].value.intval,
op->value.bytes, r_size(op), op->value.bytes, r_size(op),
imemory_local, &penum)) < 0) imemory_local, &penum)) < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
ifree_object(penum, "widthshow_aux");
esp = ep;
return code; return code;
}
*(op_proc_t *)&penum->enum_client_data = zwidthshow; *(op_proc_t *)&penum->enum_client_data = zwidthshow;
penum->single_byte_space = single_byte_space; penum->single_byte_space = single_byte_space;
if ((code = op_show_finish_setup(i_ctx_p, penum, 4, finish_show)) < 0) { if ((code = op_show_finish_setup(i_ctx_p, penum, 4, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "widthshow_aux");
return code; return code;
} }
return op_show_continue_pop(i_ctx_p, 4); code = op_show_continue_pop(i_ctx_p, 4);
if (code < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "widthshow_aux");
}
return code;
} }
/* <cx> <cy> <char> <string> widthshow - */ /* <cx> <cy> <char> <string> widthshow - */
static int static int
zwidthshow(i_ctx_t *i_ctx_p) zwidthshow(i_ctx_t *i_ctx_p)
{ {
return(widthshow_aux(i_ctx_p, false)); return(widthshow_aux(i_ctx_p, false));
} }
/* For PDF word spacing we need to identify strictly /* For PDF word spacing we need to identify strictly
skipping to change at line 159 skipping to change at line 219
/* <cx> <cy> <char> <string> .pdfwidthshow - */ /* <cx> <cy> <char> <string> .pdfwidthshow - */
static int static int
zpdfwidthshow(i_ctx_t *i_ctx_p) zpdfwidthshow(i_ctx_t *i_ctx_p)
{ {
return(widthshow_aux(i_ctx_p, true)); return(widthshow_aux(i_ctx_p, true));
} }
static int static int
awidthshow_aux(i_ctx_t *i_ctx_p, bool single_byte_space) awidthshow_aux(i_ctx_t *i_ctx_p, bool single_byte_space)
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
double cxy[2], axy[2]; double cxy[2], axy[2];
int code; int code;
if ((code = op_show_setup(i_ctx_p, op)) != 0 ) if ((code = op_show_setup(i_ctx_p, op)) != 0 )
return code; return code;
if ((code = num_params(op - 1, 2, axy)) < 0 ) if ((code = num_params(op - 1, 2, axy)) < 0 )
return code; return code;
check_type(op[-3], t_integer); check_type(op[-3], t_integer);
if (gs_currentfont(igs)->FontType == ft_composite) { if (gs_currentfont(igs)->FontType == ft_composite) {
if ((gs_char) (op[-3].value.intval) != op[-3].value.intval) if ((gs_char) (op[-3].value.intval) != op[-3].value.intval)
skipping to change at line 189 skipping to change at line 250
(gs_char) op[-3].value.intval, (gs_char) op[-3].value.intval,
axy[0], axy[1], axy[0], axy[1],
op->value.bytes, r_size(op), op->value.bytes, r_size(op),
imemory_local, &penum)) < 0) imemory_local, &penum)) < 0)
return code; return code;
*(op_proc_t *)&penum->enum_client_data = zawidthshow; *(op_proc_t *)&penum->enum_client_data = zawidthshow;
penum->single_byte_space = single_byte_space; penum->single_byte_space = single_byte_space;
if ((code = op_show_finish_setup(i_ctx_p, penum, 6, finish_show)) < 0) { if ((code = op_show_finish_setup(i_ctx_p, penum, 6, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "awidthshow_aux");
return code; return code;
} }
return op_show_continue_pop(i_ctx_p, 6); code = op_show_continue_pop(i_ctx_p, 6);
if (code < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "awidthshow_aux");
}
return code;
} }
/* <cx> <cy> <char> <ax> <ay> <string> awidthshow - */ /* <cx> <cy> <char> <ax> <ay> <string> awidthshow - */
static int static int
zawidthshow(i_ctx_t *i_ctx_p) zawidthshow(i_ctx_t *i_ctx_p)
{ {
return(awidthshow_aux(i_ctx_p, false)); return(awidthshow_aux(i_ctx_p, false));
} }
/* <cx> <cy> <char> <ax> <ay> <string> .pdfawidthshow - */ /* <cx> <cy> <char> <ax> <ay> <string> .pdfawidthshow - */
static int static int
zpdfawidthshow(i_ctx_t *i_ctx_p) zpdfawidthshow(i_ctx_t *i_ctx_p)
{ {
return(awidthshow_aux(i_ctx_p, true)); return(awidthshow_aux(i_ctx_p, true));
} }
/* <proc> <string> kshow - */ /* <proc> <string> kshow - */
static int static int
zkshow(i_ctx_t *i_ctx_p) zkshow(i_ctx_t *i_ctx_p)
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
int code; int code;
check_read_type(*op, t_string); check_read_type(*op, t_string);
check_proc(op[-1]); check_proc(op[-1]);
/* /*
* Per PLRM Section xx.x, kshow is illegal if the current font is a * Per PLRM Section xx.x, kshow is illegal if the current font is a
* composite font. The graphics library does not have this limitation, * composite font. The graphics library does not have this limitation,
* so we check for it here. * so we check for it here.
*/ */
if (gs_currentfont(igs)->FontType == ft_composite) if (gs_currentfont(igs)->FontType == ft_composite)
return_error(gs_error_invalidfont); return_error(gs_error_invalidfont);
if ((code = op_show_setup(i_ctx_p, op)) != 0 || if ((code = op_show_setup(i_ctx_p, op)) != 0 ||
(code = gs_kshow_begin(igs, op->value.bytes, r_size(op), (code = gs_kshow_begin(igs, op->value.bytes, r_size(op),
imemory_local, &penum)) < 0) imemory_local, &penum)) < 0)
return code; return code;
*(op_proc_t *)&penum->enum_client_data = zkshow; *(op_proc_t *)&penum->enum_client_data = zkshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) { if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zkshow");
return code; return code;
} }
sslot = op[-1]; /* save kerning proc */ sslot = op[-1]; /* save kerning proc */
return op_show_continue_pop(i_ctx_p, 2); code = op_show_continue_pop(i_ctx_p, 2);
if (code < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zkshow");
}
return code;
} }
/* Common finish procedure for all show operations. */ /* Common finish procedure for all show operations. */
/* Doesn't have to do anything. */ /* Doesn't have to do anything. */
static int static int
finish_show(i_ctx_t *i_ctx_p) finish_show(i_ctx_t *i_ctx_p)
{ {
return 0; return 0;
} }
/* Finishing procedure for stringwidth. */
/* Pushes the accumulated width. */
static int
finish_stringwidth(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gs_point width;
gs_text_total_width(senum, &width);
push(2);
make_real(op - 1, width.x);
make_real(op, width.y);
return 0;
}
/* <string> stringwidth <wx> <wy> */ /* <string> stringwidth <wx> <wy> */
static int static int
zstringwidth(i_ctx_t *i_ctx_p) zstringwidth(i_ctx_t *i_ctx_p)
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
int code = op_show_setup(i_ctx_p, op); int code = op_show_setup(i_ctx_p, op);
if (code != 0 || if (code != 0 ||
(code = gs_stringwidth_begin(igs, op->value.bytes, r_size(op), (code = gs_stringwidth_begin(igs, op->value.bytes, r_size(op),
imemory, &penum)) < 0) imemory, &penum)) < 0)
return code; return code;
*(op_proc_t *)&penum->enum_client_data = zstringwidth; *(op_proc_t *)&penum->enum_client_data = zstringwidth;
if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_stringwidth)) < 0 ) { if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_stringwidth)) < 0 ) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zstringwidth");
return code; return code;
} }
return op_show_continue_pop(i_ctx_p, 1); code = op_show_continue_pop(i_ctx_p, 1);
} if (code < 0) {
/* Finishing procedure for stringwidth. */ /* We must restore the exec stack pointer back to the point where we ent
/* Pushes the accumulated width. */ ered, in case
/* This is exported for .glyphwidth (in zcharx.c). */ * we 'retry' the operation (eg having increased the operand stack).
int * We must also free the enumerator if we created one.
finish_stringwidth(i_ctx_t *i_ctx_p) * Bug #700618.
{ */
os_ptr op = osp; esp = ep;
gs_point width; ifree_object(penum, "zstringwidth");
}
gs_text_total_width(senum, &width); return code;
push(2);
make_real(op - 1, width.x);
make_real(op, width.y);
return 0;
} }
/* Common code for charpath and .charboxpath. */ /* Common code for charpath and .charboxpath. */
static int static int
zchar_path(i_ctx_t *i_ctx_p, op_proc_t proc, zchar_path(i_ctx_t *i_ctx_p, op_proc_t proc,
int (*begin)(gs_gstate *, const byte *, uint, int (*begin)(gs_gstate *, const byte *, uint,
bool, gs_memory_t *, gs_text_enum_t **)) bool, gs_memory_t *, gs_text_enum_t **))
{ {
es_ptr ep = esp; /* Save in case of error */
os_ptr op = osp; os_ptr op = osp;
gs_text_enum_t *penum; gs_text_enum_t *penum = NULL;
int code; int code;
check_type(*op, t_boolean); check_type(*op, t_boolean);
code = op_show_setup(i_ctx_p, op - 1); code = op_show_setup(i_ctx_p, op - 1);
if (code != 0 || if (code != 0 ||
(code = begin(igs, op[-1].value.bytes, r_size(op - 1), (code = begin(igs, op[-1].value.bytes, r_size(op - 1),
op->value.boolval, imemory, &penum)) < 0) op->value.boolval, imemory, &penum)) < 0)
return code; return code;
*(op_proc_t *)&penum->enum_client_data = proc; *(op_proc_t *)&penum->enum_client_data = proc;
if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) { if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup"); /* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zchar_path");
return code; return code;
} }
return op_show_continue_pop(i_ctx_p, 2); code = op_show_continue_pop(i_ctx_p, 2);
if (code < 0) {
/* We must restore the exec stack pointer back to the point where we ent
ered, in case
* we 'retry' the operation (eg having increased the operand stack).
* We must also free the enumerator if we created one.
* Bug #700618.
*/
esp = ep;
ifree_object(penum, "zchar_path");
}
return code;
} }
/* <string> <outline_bool> charpath - */ /* <string> <outline_bool> charpath - */
static int static int
zcharpath(i_ctx_t *i_ctx_p) zcharpath(i_ctx_t *i_ctx_p)
{ {
return zchar_path(i_ctx_p, zcharpath, gs_charpath_begin); return zchar_path(i_ctx_p, zcharpath, gs_charpath_begin);
} }
/* <string> <box_bool> .charboxpath - */ /* <string> <box_bool> .charboxpath - */
static int static int
zcharboxpath(i_ctx_t *i_ctx_p) zcharboxpath(i_ctx_t *i_ctx_p)
 End of changes. 33 change blocks. 
39 lines changed or deleted 181 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)