summaryrefslogtreecommitdiff
path: root/xps
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-01-26 16:58:02 +0000
committerRobin Watts <robin.watts@artifex.com>2012-01-26 17:01:00 +0000
commitb6cc2a2539097d71ec200591788134703a2840a1 (patch)
tree82038d402318ce29c6d7d450e5effc297f390b32 /xps
parent8eb237bc17ea481f75f482288c854ca42b31466b (diff)
downloadghostpdl-b6cc2a2539097d71ec200591788134703a2840a1.tar.gz
XPS Whitespace handling fix
Update the xps point reading code to use strtod rather than atof; this returns us an updated string pointer, rather than relying on us second-guessing where it may end up. Change xps_get_point to return this updated pointer, and change some calls of this to avoid having to skip whitespace (and potentially getting it wrong) after the call. Spotted as part of the commit to take the latest XPS changes into MuPDF.
Diffstat (limited to 'xps')
-rw-r--r--xps/ghostxps.h2
-rw-r--r--xps/xpspath.c14
2 files changed, 6 insertions, 10 deletions
diff --git a/xps/ghostxps.h b/xps/ghostxps.h
index 230387d4b..a7807b81f 100644
--- a/xps/ghostxps.h
+++ b/xps/ghostxps.h
@@ -337,7 +337,7 @@ int xps_parse_brush(xps_context_t *ctx, char *base_uri, xps_resource_t *dict, xp
int xps_parse_element(xps_context_t *ctx, char *base_uri, xps_resource_t *dict, xps_item_t *node);
char * xps_get_real_params(char *s, int num, float *x);
-void xps_get_point(char *s_in, float *x, float *y);
+char * xps_get_point(char *s_in, float *x, float *y);
void xps_clip(xps_context_t *ctx);
void xps_fill(xps_context_t *ctx);
void xps_bounds_in_user_space(xps_context_t *ctx, gs_rect *user);
diff --git a/xps/xpspath.c b/xps/xpspath.c
index 66af973a6..e8069693e 100644
--- a/xps/xpspath.c
+++ b/xps/xpspath.c
@@ -25,10 +25,7 @@ xps_get_real_params(char *s, int num, float *x)
{
while (*s == 0x0d || *s == '\t' || *s == ' ' || *s == 0x0a)
s++;
- sscanf(s, "%g", &(x[k]));
- while (*s == '-' || *s == '+' || *s == '.' || *s == 'e' ||
- *s == 'E' || *s >= '0' && *s <= '9')
- s++;
+ x[k] = (float)strtod(s, &s);
while (*s == 0x0d || *s == '\t' || *s == ' ' || *s == 0x0a)
s++;
if (*s == ',')
@@ -41,7 +38,7 @@ xps_get_real_params(char *s, int num, float *x)
return NULL;
}
-void
+char *
xps_get_point(char *s_in, float *x, float *y)
{
char *s_out = s_in;
@@ -50,6 +47,7 @@ xps_get_point(char *s_in, float *x, float *y)
s_out = xps_get_real_params(s_out, 2, xy);
*x = xy[0];
*y = xy[1];
+ return s_out;
}
void
@@ -557,8 +555,7 @@ xps_parse_poly_quadratic_bezier_segment(xps_context_t *ctx, xps_item_t *root, in
while (*s != 0)
{
while (*s == ' ') s++;
- xps_get_point(s, &x[n], &y[n]);
- while (*s != ' ' && *s != 0) s++;
+ s = xps_get_point(s, &x[n], &y[n]);
n ++;
if (n == 2)
{
@@ -606,8 +603,7 @@ xps_parse_poly_bezier_segment(xps_context_t *ctx, xps_item_t *root, int stroking
while (*s != 0)
{
while (*s == ' ') s++;
- xps_get_point(s, &x[n], &y[n]);
- while (*s != ' ' && *s != 0) s++;
+ s = xps_get_point(s, &x[n], &y[n]);
n ++;
if (n == 3)
{