diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2011-11-06 10:59:41 +0000 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2012-03-15 11:54:07 +0000 |
commit | 3e9227fd53127d7bac9e8eb0a7ee2fa8427d9d73 (patch) | |
tree | fe0d6c38bb318853769612f2fd00b7343422d526 /gs/psi | |
parent | 18b29fefc0b3b72c260fffc3c16322e33405ee2d (diff) |
Bug 692470: remove sscanf() in CFF code
On Linux (at least) the locale affects the behaviour of sscanf(): certain
languages use a comma (",") for the decimal point, rather than a full stop
("."). Setting one of those locales (such as Spanish) causes sscanf() to fail
when parsing a number with a fractional component in the CFF interpreter.
Replace the sscanf() call in the CFF interpreter with a call to Ghostscript
PS interpreter's internal scan_number() function which is unaffected by locale.
No cluster differences.
Diffstat (limited to 'gs/psi')
-rw-r--r-- | gs/psi/zfont2.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/gs/psi/zfont2.c b/gs/psi/zfont2.c index df81dcf09..2ca983fce 100644 --- a/gs/psi/zfont2.c +++ b/gs/psi/zfont2.c @@ -29,6 +29,7 @@ #include "iname.h" /* for CFF parser */ #include "iddict.h" /* for CFF parser */ #include "store.h" /* for CFF parser */ +#include "iscannum.h" /* Private utilities */ static uint @@ -1463,7 +1464,7 @@ get_int(int *v, const cff_data_t *data, unsigned p, unsigned pe) } static int -get_float(float *v, const cff_data_t *data, unsigned p, unsigned pe) +get_float(ref *fnum, const cff_data_t *data, unsigned p, unsigned pe) { int code; unsigned int c, i; @@ -1499,16 +1500,23 @@ get_float(float *v, const cff_data_t *data, unsigned p, unsigned pe) *q++ = '-'; break; case 15: { /* end */ - int scanned; + int sign = 0; + char *eptr, *bptr = buf; - *q = 0; - sscanf(buf, "%f%n", v, &scanned); - if (scanned == q - buf) + if (buf[0] == '-'){ + sign = -1; + bptr = &(buf[1]); + } + + code = scan_number ((const byte *)bptr, (const byte *)q, sign, fnum, (const byte **)&eptr, 0); + if (code < 0) { + return(code); + } + else { return p - p0 + 1; - else - return_error(e_rangecheck); } break; + } } } p++; @@ -2244,13 +2252,12 @@ parse_dict(i_ctx_t *i_ctx_p, ref *topdict, font_offsets_t *offsets, case 22: case 23: case 24: case 25: case 26: case 27: /* reserved */ continue; case 30: { /* float operand */ - float f; - if (op_i >= MAXOP) return_error(e_limitcheck); - if ((code = get_float(&f, data, p, pe)) < 0) + + if ((code = get_float(&ops[op_i], data, p, pe)) < 0) return code; - make_real(&ops[op_i], f); + op_i++; p += code; } |