diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2014-11-03 13:35:39 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2014-11-03 13:35:39 +0000 |
commit | 069de63df0794b833f5953c262c1f813e7a1b920 (patch) | |
tree | 62e249099b9984f04e07c302598c3ea128b54995 /Build/source/texk/dvipdfm-x/pdfparse.c | |
parent | eb8e65b9fe94f8a1f0bb616af32591eb9c79c30e (diff) |
texk/dvipdfm-x: Further fixes for PK font support (from S. Hirata)
git-svn-id: svn://tug.org/texlive/trunk@35496 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x/pdfparse.c')
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfparse.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/Build/source/texk/dvipdfm-x/pdfparse.c b/Build/source/texk/dvipdfm-x/pdfparse.c index 860ea1c0abc..ab874ff11f0 100644 --- a/Build/source/texk/dvipdfm-x/pdfparse.c +++ b/Build/source/texk/dvipdfm-x/pdfparse.c @@ -26,6 +26,8 @@ #include <ctype.h> #include <string.h> +/* pow() */ +#include <math.h> #include "system.h" #include "mem.h" @@ -227,32 +229,18 @@ parse_opt_ident (const char **start, const char *end) return NULL; } -#define DDIGITS_MAX 10 pdf_obj * parse_pdf_number (const char **pp, const char *endptr) { const char *p; - unsigned long ipart = 0, dpart = 0; - int nddigits = 0, sign = 1; - int has_dot = 0; - static double ipot[DDIGITS_MAX+1] = { - 1.0, - 0.1, - 0.01, - 0.001, - 0.0001, - 0.00001, - 0.000001, - 0.0000001, - 0.00000001, - 0.000000001, - 0.0000000001 - }; + double v = 0.0; + int nddigits = 0, sign = 1; + int has_dot = 0; p = *pp; skip_white(&p, endptr); if (p >= endptr || - (!isdigit((unsigned char)p[0]) && p[0] != '.' && + (!isdigit(p[0]) && p[0] != '.' && p[0] != '+' && p[0] != '-')) { WARN("Could not find a numeric object."); return NULL; @@ -277,21 +265,17 @@ parse_pdf_number (const char **pp, const char *endptr) while (p < endptr && !istokensep(p[0])) { if (p[0] == '.') { if (has_dot) { /* Two dots */ - WARN("Could not find a numeric object."); - return NULL; + WARN("Could not find a numeric object."); + return NULL; } else { - has_dot = 1; + has_dot = 1; } - } else if (isdigit((unsigned char)p[0])) { + } else if (isdigit(p[0])) { if (has_dot) { - if (nddigits == DDIGITS_MAX && pdf_obj_get_verbose() > 1) { - WARN("Number with more than %d fractional digits.", DDIGITS_MAX); - } else if (nddigits < DDIGITS_MAX) { - dpart = dpart * 10 + p[0] - '0'; - nddigits++; - } /* Ignore decimal digits more than DDIGITS_MAX */ + v += (p[0] - '0') / pow(10, nddigits + 1); + nddigits++; } else { - ipart = ipart * 10 + p[0] - '0'; + v = v * 10.0 + p[0] - '0'; } } else { WARN("Could not find a numeric object."); @@ -301,7 +285,7 @@ parse_pdf_number (const char **pp, const char *endptr) } *pp = p; - return pdf_new_number((double) sign * (((double ) ipart) + dpart * ipot[nddigits])); + return pdf_new_number(sign * v); } /* |