From 94c3327ac812e61cd2ba27ede0ec7b0b80cd8bf5 Mon Sep 17 00:00:00 2001 From: picomeg <megordon5@gmail.com> Date: Tue, 26 Apr 2022 03:44:58 +0100 Subject: [PATCH] style and error checking improvements --- pdf.c | 58 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/pdf.c b/pdf.c index 6e9b60c..3307ace 100644 --- a/pdf.c +++ b/pdf.c @@ -1605,8 +1605,10 @@ act_tnumb(const HParseResult *p, void *u) double value; - if (p->ast->token_type == TT_SINT) value = (double)p->ast->sint; - else value = p->ast->dbl; + if (p->ast->token_type == TT_SINT) + value = (double)p->ast->sint; + else + value = H_CAST_DOUBLE(p->ast); return H_MAKE_DOUBLE(value); } @@ -5026,20 +5028,28 @@ void parse_pagenode ( double llx, lly, urx, ury; // typical but can be any diagonal HParsedToken * token; token = H_INDEX_TOKEN(item, 0); - if (token->token_type == TT_SINT) llx = (double)token->sint; - else llx = token->dbl; + if (token->token_type == TT_SINT) + llx = (double)token->sint; + else + llx = H_CAST_DOUBLE(token); token = H_INDEX_TOKEN(item, 1); - if (token->token_type == TT_SINT) lly = (double)token->sint; - else lly = token->dbl; + if (token->token_type == TT_SINT) + lly = (double)token->sint; + else + lly = H_CAST_DOUBLE(token); token = H_INDEX_TOKEN(item, 2); - if (token->token_type == TT_SINT) urx = (double)token->sint; - else urx = token->dbl; + if (token->token_type == TT_SINT) + urx = (double)token->sint; + else + urx = H_CAST_DOUBLE(token); token = H_INDEX_TOKEN(item, 3); - if (token->token_type == TT_SINT) ury = (double)token->sint; - else ury = token->dbl; + if (token->token_type == TT_SINT) + ury = (double)token->sint; + else + ury = H_CAST_DOUBLE(token); myNode->mediaBox.tx = fabs(llx - urx); - myNode->mediaBox.ty = fabs(lly - ury);; + myNode->mediaBox.ty = fabs(lly - ury); } } @@ -5266,19 +5276,27 @@ parse_pagetree( double llx, lly, urx, ury; // typical but can be any diagonal HParsedToken * token; token = H_INDEX_TOKEN(item, 0); - if (token->token_type == TT_SINT) llx = (double)token->sint; - else llx = token->dbl; + if (token->token_type == TT_SINT) + llx = (double)token->sint; + else + llx = H_CAST_DOUBLE(token); token = H_INDEX_TOKEN(item, 1); - if (token->token_type == TT_SINT) lly = (double)token->sint; - else lly = token->dbl; + if (token->token_type == TT_SINT) + lly = (double)token->sint; + else + lly = H_CAST_DOUBLE(token); token = H_INDEX_TOKEN(item, 2); - if (token->token_type == TT_SINT) urx = (double)token->sint; - else urx = token->dbl; + if (token->token_type == TT_SINT) + urx = (double)token->sint; + else + urx = H_CAST_DOUBLE(token); token = H_INDEX_TOKEN(item, 3); - if (token->token_type == TT_SINT) ury = (double)token->sint; - else ury = token->dbl; + if (token->token_type == TT_SINT) + ury = (double)token->sint; + else + ury = H_CAST_DOUBLE(token); myNode->mediaBox.tx = fabs(llx - urx); - myNode->mediaBox.ty = fabs(lly - ury);; + myNode->mediaBox.ty = fabs(lly - ury); } } -- GitLab