From d03bc5c12d63cd1b014ffe6dcb23bb242b65e453 Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 18 Oct 2002 00:48:21 +0000 Subject: * tests/imgPhoto.test: * generic/tkImgPhoto.c (ImgPhotoConfigureMaster): fix arg handling for missing -format or -data options. [Bug #624974] --- ChangeLog | 4 ++++ generic/tkImgPhoto.c | 22 +++++++++++++++------- tests/imgPhoto.test | 11 ++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb1ae12..0c9871a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-10-17 Jeff Hobbs + * tests/imgPhoto.test: + * generic/tkImgPhoto.c (ImgPhotoConfigureMaster): fix arg handling + for missing -format or -data options. [Bug #624974] + * tests/text.test: properly return the number of * unix/tkUnixFont.c (ControlUtfProc): bytes consumed. [Bug #624732] diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index f470835..8379f1d 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -16,7 +16,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.35 2002/10/09 09:32:24 dkf Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.36 2002/10/18 00:48:22 hobbs Exp $ */ #include "tkInt.h" @@ -1841,16 +1841,24 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) args[j] = Tcl_GetStringFromObj(objv[i], &length); if ((length > 1) && (args[j][0] == '-')) { if ((args[j][1] == 'd') && - !strncmp(args[j],"-data", (size_t) length)) { - if (i < objc) { - data = objv[++i]; + !strncmp(args[j], "-data", (size_t) length)) { + if (++i < objc) { + data = objv[i]; j--; + } else { + Tcl_AppendResult(interp, + "value for \"-data\" missing", (char *) NULL); + return TCL_ERROR; } } else if ((args[j][1] == 'f') && - !strncmp(args[j],"-format", (size_t) length)) { - if (i < objc) { - format = objv[++i]; + !strncmp(args[j], "-format", (size_t) length)) { + if (++i < objc) { + format = objv[i]; j--; + } else { + Tcl_AppendResult(interp, + "value for \"-format\" missing", (char *) NULL); + return TCL_ERROR; } } } diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index 273c3cc..e2b4468 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -9,7 +9,7 @@ # # Author: Paul Mackerras (paulus@cs.anu.edu.au) # -# RCS: @(#) $Id: imgPhoto.test,v 1.14 2002/07/14 15:45:23 dgp Exp $ +# RCS: @(#) $Id: imgPhoto.test,v 1.15 2002/10/18 00:48:22 hobbs Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -78,6 +78,15 @@ test imgPhoto-1.7 {options for photo images} { test imgPhoto-1.8 {options for photo images} { list [catch {image create photo -blah blah} err] $err } {1 {unknown option "-blah"}} +test imgPhoto-1.9 {options for photo images - error case} { + list [catch {image create photo -format} err] $err +} {1 {value for "-format" missing}} +test imgPhoto-1.10 {options for photo images - error case} { + list [catch {image create photo -data} err] $err +} {1 {value for "-data" missing}} +test imgPhoto-1.11 {options for photo images - error case} { + list [catch {image create photo p1 -format} err] $err +} {1 {value for "-format" missing}} test imgPhoto-2.1 {ImgPhotoCreate procedure} { eval image delete [image names] -- cgit v0.12