From e625edd598d9809a2dfc7fe990fcad90ad73e2f4 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Fri, 2 Jan 2009 16:50:56 +0000 Subject: improve messages git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@809 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/ppm/picttoppm.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'converter/ppm/picttoppm.c') diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c index a89c3086..04d8cc5f 100644 --- a/converter/ppm/picttoppm.c +++ b/converter/ppm/picttoppm.c @@ -764,6 +764,18 @@ load_fontdir(const char * const dirfile) { +static void +dumpRect(const char * const label, + struct Rect const rectangle) { + + pm_message("%s (%u,%u) (%u,%u)", + label, + rectangle.left, rectangle.top, + rectangle.right, rectangle.bottom); +} + + + static void read_rect(struct Rect * const r) { @@ -771,18 +783,15 @@ read_rect(struct Rect * const r) { r->left = read_word(); r->bottom = read_word(); r->right = read_word(); -} - + if (r->top < r->bottom || r->right < r->left) + dumpRect("Invalid rectangle", *r); -static void -dumpRect(const char * const label, - struct Rect const rectangle) { - - pm_message("%s (%u,%u) (%u,%u)", - label, - rectangle.left, rectangle.top, - rectangle.right, rectangle.bottom); + if (r->top < r->bottom) + pm_error("Invalid PICT: a rectangle has a top below its bottom"); + if (r->right < r->left) + pm_error("Invalid PICT: a rectangle has a right edge " + "left of its left edge"); } @@ -3942,14 +3951,14 @@ interpret_pict(FILE * const ofP) { picSize = read_word(); if (verbose) - pm_message("picture size = %d (0x%x)", picSize, picSize); + pm_message("picture size = %u (0x%x)", picSize, picSize); stage = "reading picture frame"; read_rect(&picFrame); if (verbose) { dumpRect("Picture frame:", picFrame); - pm_message("Picture size is %d x %d", + pm_message("Picture size is %u x %u", picFrame.right - picFrame.left, picFrame.bottom - picFrame.top); } -- cgit 1.4.1