diff options
Diffstat (limited to 'source/svg')
-rw-r--r-- | source/svg/svg-color.c | 2 | ||||
-rw-r--r-- | source/svg/svg-imp.h | 6 | ||||
-rw-r--r-- | source/svg/svg-parse.c | 35 |
3 files changed, 9 insertions, 34 deletions
diff --git a/source/svg/svg-color.c b/source/svg/svg-color.c index 35e9392f..b554ff82 100644 --- a/source/svg/svg-color.c +++ b/source/svg/svg-color.c @@ -176,7 +176,7 @@ static int unhex(int chr) } void -svg_parse_color(fz_context *ctx, svg_document *doc, char *str, float *rgb) +svg_parse_color(fz_context *ctx, svg_document *doc, const char *str, float *rgb) { int i, l, m, r, cmp; diff --git a/source/svg/svg-imp.h b/source/svg/svg-imp.h index 614304b8..cb91f842 100644 --- a/source/svg/svg-imp.h +++ b/source/svg/svg-imp.h @@ -15,12 +15,12 @@ struct svg_document_s /* Parse basic data type units. */ const char *svg_lex_number(float *fp, const char *str); -float svg_parse_number(const char *str, float min,float max, float inherit); +float svg_parse_number(const char *str, float min, float max, float inherit); float svg_parse_length(const char *str, float percent, float font_size); float svg_parse_angle(const char *str); -void svg_parse_color(fz_context *ctx, svg_document *doc, char *str, float *rgb); -fz_matrix svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix transform); +void svg_parse_color(fz_context *ctx, svg_document *doc, const char *str, float *rgb); +fz_matrix svg_parse_transform(fz_context *ctx, svg_document *doc, const char *str, fz_matrix transform); int svg_is_whitespace_or_comma(int c); int svg_is_whitespace(int c); diff --git a/source/svg/svg-parse.c b/source/svg/svg-parse.c index c5b0a7db..9f0d3a6c 100644 --- a/source/svg/svg-parse.c +++ b/source/svg/svg-parse.c @@ -118,35 +118,23 @@ svg_parse_angle(const char *str) /* Coordinate transformations */ fz_matrix -svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix transform) +svg_parse_transform(fz_context *ctx, svg_document *doc, const char *str, fz_matrix transform) { char keyword[20]; int keywordlen; - char number[20]; - int numberlen; float args[6]; int nargs; - int first = 1; nargs = 0; keywordlen = 0; while (*str) { - while (svg_is_whitespace(*str)) + while (svg_is_whitespace_or_comma(*str)) str ++; if (*str == 0) break; - if (!first) - { - if (*str == ',') - str ++; - while (svg_is_whitespace(*str)) - str ++; - } - first = 0; - /* * Parse keyword and opening parenthesis. */ @@ -173,23 +161,10 @@ svg_parse_transform(fz_context *ctx, svg_document *doc, char *str, fz_matrix tra nargs = 0; while (*str && *str != ')' && nargs < 6) { - if (nargs > 0 && *str == ',') - str ++; - while (svg_is_whitespace(*str)) - str ++; - - numberlen = 0; - while (svg_is_digit(*str) && numberlen < sizeof(number) - 1) - number[numberlen++] = *str++; - number[numberlen] = 0; - - if (numberlen == 0) - fz_throw(ctx, FZ_ERROR_SYNTAX, "expected number in transform attribute"); - - args[nargs++] = fz_atof(number); - - while (svg_is_whitespace(*str)) + while (svg_is_whitespace_or_comma(*str)) str ++; + if (svg_is_digit(*str)) + str = svg_lex_number(&args[nargs++], str); } if (*str != ')') |